mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
generic: misc cleanups
This commit is contained in:
parent
b451b9602e
commit
361cc4b219
5 changed files with 35 additions and 48 deletions
|
@ -27,7 +27,6 @@
|
||||||
#include <kstandarddirs.h>
|
#include <kstandarddirs.h>
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
#include <klocale.h>
|
#include <klocale.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <QtCore/QHash>
|
#include <QtCore/QHash>
|
||||||
|
|
||||||
KBuildMimeTypeFactory::KBuildMimeTypeFactory() :
|
KBuildMimeTypeFactory::KBuildMimeTypeFactory() :
|
||||||
|
@ -52,7 +51,7 @@ KBuildMimeTypeFactory::~KBuildMimeTypeFactory()
|
||||||
|
|
||||||
KMimeTypeFactory::MimeTypeEntry::Ptr KBuildMimeTypeFactory::findMimeTypeEntryByName(const QString &_name, KMimeType::FindByNameOption options)
|
KMimeTypeFactory::MimeTypeEntry::Ptr KBuildMimeTypeFactory::findMimeTypeEntryByName(const QString &_name, KMimeType::FindByNameOption options)
|
||||||
{
|
{
|
||||||
assert (KSycoca::self()->isBuilding());
|
Q_ASSERT (KSycoca::self()->isBuilding());
|
||||||
|
|
||||||
QString name = _name;
|
QString name = _name;
|
||||||
if (options & KMimeType::ResolveAliases) {
|
if (options & KMimeType::ResolveAliases) {
|
||||||
|
@ -66,7 +65,7 @@ KMimeTypeFactory::MimeTypeEntry::Ptr KBuildMimeTypeFactory::findMimeTypeEntryByN
|
||||||
|
|
||||||
KSycocaEntry::List KBuildMimeTypeFactory::allEntries() const
|
KSycocaEntry::List KBuildMimeTypeFactory::allEntries() const
|
||||||
{
|
{
|
||||||
assert (KSycoca::self()->isBuilding());
|
Q_ASSERT (KSycoca::self()->isBuilding());
|
||||||
KSycocaEntry::List lst;
|
KSycocaEntry::List lst;
|
||||||
KSycocaEntryDict::Iterator itmime = m_entryDict->begin();
|
KSycocaEntryDict::Iterator itmime = m_entryDict->begin();
|
||||||
const KSycocaEntryDict::Iterator endmime = m_entryDict->end();
|
const KSycocaEntryDict::Iterator endmime = m_entryDict->end();
|
||||||
|
|
|
@ -109,7 +109,9 @@ KBuildServiceTypeFactory::saveHeader(QDataStream &str)
|
||||||
{
|
{
|
||||||
KSycocaFactory::saveHeader(str);
|
KSycocaFactory::saveHeader(str);
|
||||||
str << (qint32) m_propertyTypeDict.count();
|
str << (qint32) m_propertyTypeDict.count();
|
||||||
for (QMap<QString, int>::ConstIterator it = m_propertyTypeDict.constBegin(); it != m_propertyTypeDict.constEnd(); ++it) {
|
QMapIterator<QString, int> it(m_propertyTypeDict);
|
||||||
|
while(it.hasNext()) {
|
||||||
|
it.next();
|
||||||
str << it.key() << (qint32)it.value();
|
str << it.key() << (qint32)it.value();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,9 +138,9 @@ KBuildServiceTypeFactory::addEntry(const KSycocaEntry::Ptr& newEntry)
|
||||||
|
|
||||||
KServiceType::Ptr serviceType = KServiceType::Ptr::staticCast( newEntry );
|
KServiceType::Ptr serviceType = KServiceType::Ptr::staticCast( newEntry );
|
||||||
|
|
||||||
const QMap<QString,QVariant::Type>& pd = serviceType->propertyDefs();
|
QMapIterator<QString, QVariant::Type> pit(serviceType->propertyDefs());
|
||||||
QMap<QString,QVariant::Type>::ConstIterator pit = pd.begin();
|
while(pit.hasNext()) {
|
||||||
for( ; pit != pd.end(); ++pit ) {
|
pit.next();
|
||||||
const QString property = pit.key();
|
const QString property = pit.key();
|
||||||
QMap<QString, int>::iterator dictit = m_propertyTypeDict.find(property);
|
QMap<QString, int>::iterator dictit = m_propertyTypeDict.find(property);
|
||||||
if (dictit == m_propertyTypeDict.end())
|
if (dictit == m_propertyTypeDict.end())
|
||||||
|
|
|
@ -230,12 +230,10 @@ bool KBuildSycoca::build()
|
||||||
g_ctimeInfo = new KCTimeInfo(); // This is a build factory too, don't delete!!
|
g_ctimeInfo = new KCTimeInfo(); // This is a build factory too, don't delete!!
|
||||||
bool uptodate = true;
|
bool uptodate = true;
|
||||||
// For all resources
|
// For all resources
|
||||||
for( QStringList::ConstIterator it1 = allResources.constBegin();
|
foreach(const QString it1, allResources)
|
||||||
it1 != allResources.constEnd();
|
|
||||||
++it1 )
|
|
||||||
{
|
{
|
||||||
g_changed = false;
|
g_changed = false;
|
||||||
g_resource = (*it1).toLatin1();
|
g_resource = it1.toLatin1();
|
||||||
|
|
||||||
QStringList relFiles;
|
QStringList relFiles;
|
||||||
|
|
||||||
|
@ -266,16 +264,14 @@ bool KBuildSycoca::build()
|
||||||
++it2 )
|
++it2 )
|
||||||
{
|
{
|
||||||
KSycocaResource res = (*it2);
|
KSycocaResource res = (*it2);
|
||||||
if (res.resource != (*it1)) continue;
|
if (res.resource != it1) continue;
|
||||||
|
|
||||||
// For each file in the resource
|
// For each file in the resource
|
||||||
for( QStringList::ConstIterator it3 = relFiles.constBegin();
|
foreach(const QString it3, relFiles)
|
||||||
it3 != relFiles.constEnd();
|
|
||||||
++it3 )
|
|
||||||
{
|
{
|
||||||
// Check if file matches filter
|
// Check if file matches filter
|
||||||
if ((*it3).endsWith(res.extension))
|
if (it3.endsWith(res.extension))
|
||||||
createEntry(*it3, true);
|
createEntry(it3, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -577,18 +573,16 @@ bool KBuildSycoca::checkDirTimestamps( const QString& dirname, const QDateTime&
|
||||||
// means that there's no need to rebuild ksycoca
|
// means that there's no need to rebuild ksycoca
|
||||||
bool KBuildSycoca::checkTimestamps( quint32 timestamp, const QStringList &dirs )
|
bool KBuildSycoca::checkTimestamps( quint32 timestamp, const QStringList &dirs )
|
||||||
{
|
{
|
||||||
kDebug( 7021 ) << "checking file timestamps";
|
kDebug( 7021 ) << "checking file timestamps";
|
||||||
QDateTime stamp;
|
QDateTime stamp;
|
||||||
stamp.setTime_t( timestamp );
|
stamp.setTime_t( timestamp );
|
||||||
for( QStringList::ConstIterator it = dirs.begin();
|
foreach(const QString it, dirs)
|
||||||
it != dirs.end();
|
{
|
||||||
++it )
|
if( !checkDirTimestamps( it, stamp, true ))
|
||||||
{
|
|
||||||
if( !checkDirTimestamps( *it, stamp, true ))
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
kDebug( 7021 ) << "timestamps check ok";
|
kDebug( 7021 ) << "timestamps check ok";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList KBuildSycoca::existingResourceDirs()
|
QStringList KBuildSycoca::existingResourceDirs()
|
||||||
|
|
|
@ -51,23 +51,21 @@ void KCTimeDict::dump() const
|
||||||
|
|
||||||
QStringList KCTimeDict::resourceList() const
|
QStringList KCTimeDict::resourceList() const
|
||||||
{
|
{
|
||||||
QSet<QString> resources;
|
QStringList resources;
|
||||||
Hash::const_iterator it = m_hash.constBegin();
|
QHashIterator<QString,quint32> it(m_hash);
|
||||||
const Hash::const_iterator end = m_hash.constEnd();
|
while (it.hasNext()) {
|
||||||
for ( ; it != end; ++it ) {
|
it.next();
|
||||||
const QString key = it.key();
|
const QString key = it.key();
|
||||||
const QString res = key.left(key.indexOf('|'));
|
resources << key.left(key.indexOf('|'));
|
||||||
resources.insert(res);
|
|
||||||
}
|
}
|
||||||
return resources.toList();
|
return resources;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KCTimeDict::load(QDataStream &str)
|
void KCTimeDict::load(QDataStream &str)
|
||||||
{
|
{
|
||||||
QString key;
|
QString key;
|
||||||
quint32 ctime;
|
quint32 ctime;
|
||||||
while(true)
|
while (true) {
|
||||||
{
|
|
||||||
KSycocaEntry::read(str, key);
|
KSycocaEntry::read(str, key);
|
||||||
str >> ctime;
|
str >> ctime;
|
||||||
if (key.isEmpty()) break;
|
if (key.isEmpty()) break;
|
||||||
|
@ -77,10 +75,10 @@ void KCTimeDict::load(QDataStream &str)
|
||||||
|
|
||||||
void KCTimeDict::save(QDataStream &str) const
|
void KCTimeDict::save(QDataStream &str) const
|
||||||
{
|
{
|
||||||
Hash::const_iterator it = m_hash.constBegin();
|
QHashIterator<QString,quint32> it(m_hash);
|
||||||
const Hash::const_iterator end = m_hash.constEnd();
|
while (it.hasNext()) {
|
||||||
for ( ; it != end; ++it ) {
|
it.next();
|
||||||
str << it.key() << it.value();
|
str << it.key() << it.value();
|
||||||
}
|
}
|
||||||
str << QString() << (quint32) 0;
|
str << QString() << (quint32) 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,12 +72,6 @@ static bool bCheckSycoca;
|
||||||
static bool bCheckUpdates;
|
static bool bCheckUpdates;
|
||||||
static bool bCheckHostname;
|
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)
|
static void runBuildSycoca(QObject *callBackObj=0, const char *callBackSlot=0, const char *callBackErrorSlot=0)
|
||||||
{
|
{
|
||||||
const QString exe = KStandardDirs::findExe(KBUILDSYCOCA_EXENAME);
|
const QString exe = KStandardDirs::findExe(KBUILDSYCOCA_EXENAME);
|
||||||
|
@ -128,7 +122,7 @@ Kded::Kded()
|
||||||
session.registerObject("/kbuildsycoca", this);
|
session.registerObject("/kbuildsycoca", this);
|
||||||
session.registerObject("/kded", this);
|
session.registerObject("/kded", this);
|
||||||
|
|
||||||
qDBusAddSpyHook(messageFilter);
|
Q_DBUS_EXPORT(messageFilter);
|
||||||
|
|
||||||
m_pTimer = new QTimer(this);
|
m_pTimer = new QTimer(this);
|
||||||
m_pTimer->setSingleShot( true );
|
m_pTimer->setSingleShot( true );
|
||||||
|
|
Loading…
Add table
Reference in a new issue