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