1
/**************************************************************************
3
* Copyright 2013 Canonical Ltd.
4
* Copyright 2013 Carlos J Mazieri <carlos.mazieri@gmail.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation; version 3.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Lesser General Public License for more details.
15
* You should have received a copy of the GNU Lesser General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
* File: externalfswatcher.h
22
#ifndef EXTERNALFSWATCHER_H
23
#define EXTERNALFSWATCHER_H
25
#include <QFileSystemWatcher>
27
#define DEFAULT_NOTICATION_PERIOD 500
31
* \brief The ExternalFSWatcher class notifies the owner when the File System when the current path \a m_setPath has changed
32
* emitting pathModified() signal.
34
* The current path \a m_setPath is set by using the slot \ref setCurrentPath()
36
* The idea of this class is to minimize notifications as the current path can change quickly.
37
* A notification will occur if it was requested for a path and this path is still the current at the moment
38
* of the notification.
40
* Once it detects a change it will wait \ref getIntervalToNotifyChanges() milliseconds to notify that change.
41
* At this moment it checks if no \ref setCurrentPath() has been called during this time and then notifies that change.
43
class ExternalFSWatcher : public QFileSystemWatcher
47
explicit ExternalFSWatcher(QObject *parent = 0);
48
int getIntervalToNotifyChanges() const;
54
void setCurrentPath(const QString& curPath);
55
void setIntervalToNotifyChanges(int ms);
58
void slotDirChanged(const QString&);
59
void slotFireChanges();
63
QString m_changedPath;
64
unsigned m_waitingEmitCounter;
68
#endif // EXTERNALFSWATCHER_H