diff --git a/src/gui/folderwatcher.cpp b/src/gui/folderwatcher.cpp index 874203982..b76480f70 100644 --- a/src/gui/folderwatcher.cpp +++ b/src/gui/folderwatcher.cpp @@ -36,7 +36,8 @@ namespace OCC { FolderWatcher::FolderWatcher(const QString &root, QObject *parent) - : QObject(parent) + : QObject(parent), + _ignoreHidden(true) { _d.reset(new FolderWatcherPrivate(this, root)); @@ -46,6 +47,16 @@ FolderWatcher::FolderWatcher(const QString &root, QObject *parent) FolderWatcher::~FolderWatcher() { } +void FolderWatcher::setIgnoreHidden(bool ignore) +{ + _ignoreHidden = ignore; +} + +bool FolderWatcher::ignoreHidden() +{ + return _ignoreHidden; +} + void FolderWatcher::addIgnoreListFile( const QString& file ) { if( file.isEmpty() ) return; @@ -71,10 +82,14 @@ bool FolderWatcher::pathIsIgnored( const QString& path ) { if( path.isEmpty() ) return true; - QFileInfo fInfo(path); - if( fInfo.isHidden() ) { - qDebug() << "* Discarded as is hidden!" << fInfo.filePath(); - return true; + // if events caused by changes to hidden files should be ignored, a QFileInfo + // object will tell us if the file is hidden + if( _ignoreHidden ) { + QFileInfo fInfo(path); + if( fInfo.isHidden() ) { + qDebug() << "* Discarded as is hidden!" << fInfo.filePath(); + return true; + } } // TODO: Best use csync_excluded_no_ctx() here somehow! diff --git a/src/gui/folderwatcher.h b/src/gui/folderwatcher.h index 7a7a41dbc..b0f529940 100644 --- a/src/gui/folderwatcher.h +++ b/src/gui/folderwatcher.h @@ -77,6 +77,10 @@ public: /* Check if the path is ignored. */ bool pathIsIgnored( const QString& path ); + /* set if the folderwatcher ignores events of hidden files */ + void setIgnoreHidden(bool ignore); + bool ignoreHidden(); + signals: /** Emitted when one of the watched directories or one * of the contained files is changed. */ @@ -98,6 +102,7 @@ private: QStringList _ignores; QTime _timer; QSet _lastPaths; + bool _ignoreHidden; friend class FolderWatcherPrivate; };