static bool checkSearchPathTimestamps( const QStringList &paths, const QStringList ×tamps ) { QStringList currentTimestamps; bool changed = false; QStringList::ConstIterator t = timestamps.constBegin(); for( QStringList::ConstIterator it = paths.constBegin(); it != paths.constEnd(); ++it, ++t ) { QDateTime current = lastChanged( *it ); // store non-existent directory as "N" string rather than empty string, KConfig // has a bug with storing a list of empty items if( *t == "N" ? !current.isNull() : current != QDateTime::fromString( *t, Qt::ISODate )) changed = true; currentTimestamps.append( current.isNull() ? "N" : current.toString( Qt::ISODate )); } if( changed ) { KConfig config("kcmnspluginrc"); KConfigGroup cg(&config, "Misc"); cg.writeEntry( "lastSearchPaths", paths ); cg.writeEntry( "lastSearchTimestamps", currentTimestamps ); return true; } return false; }
static QDateTime lastChanged( const QString &dir ) { QDateTime t = QFileInfo( dir ).lastModified(); if( t.isNull()) return t; const QStringList subdirs = QDir( dir ).entryList(); for( QStringList::ConstIterator it = subdirs.constBegin(); it != subdirs.constEnd(); ++it ) { if( *it == "." || *it == ".." ) continue; QDateTime t2 = lastChanged( *it ); if( !t2.isNull() && t2 > t ) t = t2; } return t; }
DataRange::DataRange(QWidget *parent) : QWidget(parent) { setupUi(this); connect(_countFromEnd, SIGNAL(toggled(bool)), this, SLOT(countFromEndChanged())); connect(_readToEnd, SIGNAL(toggled(bool)), this, SLOT(readToEndChanged())); connect(_doSkip, SIGNAL(toggled(bool)), this, SLOT(doSkipChanged())); connect(_start, SIGNAL(textEdited(QString)), this, SLOT(startChanged())); connect(_range, SIGNAL(textEdited(QString)), this, SLOT(rangeChanged())); connect(_last, SIGNAL(textEdited(QString)), this, SLOT(lastChanged())); connect(_skip, SIGNAL(valueChanged(int)), this, SIGNAL(modified())); connect(_doFilter, SIGNAL(toggled(bool)), this, SIGNAL(modified())); connect(_countFromEnd, SIGNAL(toggled(bool)), this, SIGNAL(modified())); connect(_readToEnd, SIGNAL(toggled(bool)), this, SIGNAL(modified())); connect(_doSkip, SIGNAL(toggled(bool)), this, SIGNAL(modified())); connect(_startUnits, SIGNAL(currentIndexChanged(int)), this, SLOT(unitsChanged())); connect(_rangeUnits, SIGNAL(currentIndexChanged(int)), this, SLOT(unitsChanged())); _controlField0 = Range; _controlField1 = Start; }