From 361cc4b219770084ef014c87d0d0fb143bac8ef6 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Wed, 23 Sep 2015 02:45:53 +0000 Subject: [PATCH] generic: misc cleanups --- kded/kbuildmimetypefactory.cpp | 5 ++--- kded/kbuildservicetypefactory.cpp | 10 +++++---- kded/kbuildsycoca.cpp | 36 +++++++++++++------------------ kded/kctimefactory.cpp | 24 ++++++++++----------- kded/kded.cpp | 8 +------ 5 files changed, 35 insertions(+), 48 deletions(-) diff --git a/kded/kbuildmimetypefactory.cpp b/kded/kbuildmimetypefactory.cpp index 4cace570..7eaba0ea 100644 --- a/kded/kbuildmimetypefactory.cpp +++ b/kded/kbuildmimetypefactory.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include KBuildMimeTypeFactory::KBuildMimeTypeFactory() : @@ -52,7 +51,7 @@ KBuildMimeTypeFactory::~KBuildMimeTypeFactory() KMimeTypeFactory::MimeTypeEntry::Ptr KBuildMimeTypeFactory::findMimeTypeEntryByName(const QString &_name, KMimeType::FindByNameOption options) { - assert (KSycoca::self()->isBuilding()); + Q_ASSERT (KSycoca::self()->isBuilding()); QString name = _name; if (options & KMimeType::ResolveAliases) { @@ -66,7 +65,7 @@ KMimeTypeFactory::MimeTypeEntry::Ptr KBuildMimeTypeFactory::findMimeTypeEntryByN KSycocaEntry::List KBuildMimeTypeFactory::allEntries() const { - assert (KSycoca::self()->isBuilding()); + Q_ASSERT (KSycoca::self()->isBuilding()); KSycocaEntry::List lst; KSycocaEntryDict::Iterator itmime = m_entryDict->begin(); const KSycocaEntryDict::Iterator endmime = m_entryDict->end(); diff --git a/kded/kbuildservicetypefactory.cpp b/kded/kbuildservicetypefactory.cpp index 2a5afa83..f9c8b1ba 100644 --- a/kded/kbuildservicetypefactory.cpp +++ b/kded/kbuildservicetypefactory.cpp @@ -109,7 +109,9 @@ KBuildServiceTypeFactory::saveHeader(QDataStream &str) { KSycocaFactory::saveHeader(str); str << (qint32) m_propertyTypeDict.count(); - for (QMap::ConstIterator it = m_propertyTypeDict.constBegin(); it != m_propertyTypeDict.constEnd(); ++it) { + QMapIterator it(m_propertyTypeDict); + while(it.hasNext()) { + it.next(); str << it.key() << (qint32)it.value(); } } @@ -136,9 +138,9 @@ KBuildServiceTypeFactory::addEntry(const KSycocaEntry::Ptr& newEntry) KServiceType::Ptr serviceType = KServiceType::Ptr::staticCast( newEntry ); - const QMap& pd = serviceType->propertyDefs(); - QMap::ConstIterator pit = pd.begin(); - for( ; pit != pd.end(); ++pit ) { + QMapIterator pit(serviceType->propertyDefs()); + while(pit.hasNext()) { + pit.next(); const QString property = pit.key(); QMap::iterator dictit = m_propertyTypeDict.find(property); if (dictit == m_propertyTypeDict.end()) diff --git a/kded/kbuildsycoca.cpp b/kded/kbuildsycoca.cpp index 8260743e..65ac47e2 100644 --- a/kded/kbuildsycoca.cpp +++ b/kded/kbuildsycoca.cpp @@ -230,12 +230,10 @@ bool KBuildSycoca::build() g_ctimeInfo = new KCTimeInfo(); // This is a build factory too, don't delete!! bool uptodate = true; // For all resources - for( QStringList::ConstIterator it1 = allResources.constBegin(); - it1 != allResources.constEnd(); - ++it1 ) + foreach(const QString it1, allResources) { g_changed = false; - g_resource = (*it1).toLatin1(); + g_resource = it1.toLatin1(); QStringList relFiles; @@ -266,16 +264,14 @@ bool KBuildSycoca::build() ++it2 ) { KSycocaResource res = (*it2); - if (res.resource != (*it1)) continue; + if (res.resource != it1) continue; // For each file in the resource - for( QStringList::ConstIterator it3 = relFiles.constBegin(); - it3 != relFiles.constEnd(); - ++it3 ) + foreach(const QString it3, relFiles) { // Check if file matches filter - if ((*it3).endsWith(res.extension)) - createEntry(*it3, true); + if (it3.endsWith(res.extension)) + createEntry(it3, true); } } } @@ -577,18 +573,16 @@ bool KBuildSycoca::checkDirTimestamps( const QString& dirname, const QDateTime& // means that there's no need to rebuild ksycoca bool KBuildSycoca::checkTimestamps( quint32 timestamp, const QStringList &dirs ) { - kDebug( 7021 ) << "checking file timestamps"; - QDateTime stamp; - stamp.setTime_t( timestamp ); - for( QStringList::ConstIterator it = dirs.begin(); - it != dirs.end(); - ++it ) - { - if( !checkDirTimestamps( *it, stamp, true )) + kDebug( 7021 ) << "checking file timestamps"; + QDateTime stamp; + stamp.setTime_t( timestamp ); + foreach(const QString it, dirs) + { + if( !checkDirTimestamps( it, stamp, true )) return false; - } - kDebug( 7021 ) << "timestamps check ok"; - return true; + } + kDebug( 7021 ) << "timestamps check ok"; + return true; } QStringList KBuildSycoca::existingResourceDirs() diff --git a/kded/kctimefactory.cpp b/kded/kctimefactory.cpp index 0103c461..da9289b8 100644 --- a/kded/kctimefactory.cpp +++ b/kded/kctimefactory.cpp @@ -51,23 +51,21 @@ void KCTimeDict::dump() const QStringList KCTimeDict::resourceList() const { - QSet resources; - Hash::const_iterator it = m_hash.constBegin(); - const Hash::const_iterator end = m_hash.constEnd(); - for ( ; it != end; ++it ) { + QStringList resources; + QHashIterator it(m_hash); + while (it.hasNext()) { + it.next(); const QString key = it.key(); - const QString res = key.left(key.indexOf('|')); - resources.insert(res); + resources << key.left(key.indexOf('|')); } - return resources.toList(); + return resources; } void KCTimeDict::load(QDataStream &str) { QString key; quint32 ctime; - while(true) - { + while (true) { KSycocaEntry::read(str, key); str >> ctime; if (key.isEmpty()) break; @@ -77,10 +75,10 @@ void KCTimeDict::load(QDataStream &str) void KCTimeDict::save(QDataStream &str) const { - Hash::const_iterator it = m_hash.constBegin(); - const Hash::const_iterator end = m_hash.constEnd(); - for ( ; it != end; ++it ) { - str << it.key() << it.value(); + QHashIterator it(m_hash); + while (it.hasNext()) { + it.next(); + str << it.key() << it.value(); } str << QString() << (quint32) 0; } diff --git a/kded/kded.cpp b/kded/kded.cpp index 1ef76fd5..9ceb47c3 100644 --- a/kded/kded.cpp +++ b/kded/kded.cpp @@ -72,12 +72,6 @@ static bool bCheckSycoca; static bool bCheckUpdates; static bool bCheckHostname; -#ifdef Q_DBUS_EXPORT -extern Q_DBUS_EXPORT void qDBusAddSpyHook(void (*)(const QDBusMessage&)); -#else -extern QDBUS_EXPORT void qDBusAddSpyHook(void (*)(const QDBusMessage&)); -#endif - static void runBuildSycoca(QObject *callBackObj=0, const char *callBackSlot=0, const char *callBackErrorSlot=0) { const QString exe = KStandardDirs::findExe(KBUILDSYCOCA_EXENAME); @@ -128,7 +122,7 @@ Kded::Kded() session.registerObject("/kbuildsycoca", this); session.registerObject("/kded", this); - qDBusAddSpyHook(messageFilter); + Q_DBUS_EXPORT(messageFilter); m_pTimer = new QTimer(this); m_pTimer->setSingleShot( true );