~nskaggs/ubuntu-filemanager-app/plugin-cmake-build

« back to all changes in this revision

Viewing changes to plugin/libnemofolderlistmodel/src/externalfswatcher.h

  • Committer: nskaggs
  • Date: 2014-03-26 14:25:39 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20140326142539-tym4ip9b0z83ox2r
revert to r143 to merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**************************************************************************
2
 
 *
3
 
 * Copyright 2013 Canonical Ltd.
4
 
 * Copyright 2013 Carlos J Mazieri <carlos.mazieri@gmail.com>
5
 
 *
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.
9
 
 *
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.
14
 
 *
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/>.
17
 
 *
18
 
 * File: externalfswatcher.h
19
 
 * Date: 9/14/2013
20
 
 */
21
 
 
22
 
#ifndef EXTERNALFSWATCHER_H
23
 
#define EXTERNALFSWATCHER_H
24
 
 
25
 
#include <QFileSystemWatcher>
26
 
 
27
 
#define DEFAULT_NOTICATION_PERIOD  500
28
 
 
29
 
 
30
 
/*!
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.
33
 
 *
34
 
 *  The current path \a m_setPath is set by using the slot \ref  setCurrentPath()
35
 
 *
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.
39
 
 *
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.
42
 
 */
43
 
class ExternalFSWatcher : public QFileSystemWatcher
44
 
{
45
 
    Q_OBJECT
46
 
public:
47
 
    explicit ExternalFSWatcher(QObject *parent = 0);
48
 
    int      getIntervalToNotifyChanges() const;
49
 
 
50
 
signals:
51
 
     void      pathModified();
52
 
 
53
 
     public slots:
54
 
     void      setCurrentPath(const QString& curPath);
55
 
     void      setIntervalToNotifyChanges(int ms);     
56
 
 
57
 
private slots:
58
 
     void      slotDirChanged(const QString&);
59
 
     void      slotFireChanges();
60
 
 
61
 
 private:
62
 
     QString   m_setPath;
63
 
     QString   m_changedPath;   
64
 
     unsigned  m_waitingEmitCounter;
65
 
     int       m_msWaitTime;
66
 
};
67
 
 
68
 
#endif // EXTERNALFSWATCHER_H