mirror of
https://github.com/nextcloud/desktop.git
synced 2024-10-28 07:54:49 +03:00
FolderWatcher: Add flag to ignore hidden files (or not).
This commit is contained in:
parent
a4336092f6
commit
711ae1d347
2 changed files with 25 additions and 5 deletions
|
@ -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,11 +82,15 @@ bool FolderWatcher::pathIsIgnored( const QString& path )
|
|||
{
|
||||
if( path.isEmpty() ) 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!
|
||||
foreach (QString pattern, _ignores) {
|
||||
|
|
|
@ -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<QString> _lastPaths;
|
||||
bool _ignoreHidden;
|
||||
|
||||
friend class FolderWatcherPrivate;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue