2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-03-29 15:54:14 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-03-29 15:54:14 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-03-29 15:54:14 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:58:39 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2010-03-29 15:54:14 +02:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-03-29 15:54:14 +02:00
|
|
|
|
2013-03-15 12:35:25 +01:00
|
|
|
#ifndef FILESYSTEMWATCHER_H
|
|
|
|
|
#define FILESYSTEMWATCHER_H
|
2010-03-29 15:54:14 +02:00
|
|
|
|
2011-04-15 15:55:11 +02:00
|
|
|
#include "utils_global.h"
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QObject>
|
2010-03-29 15:54:14 +02:00
|
|
|
|
2011-04-15 15:55:11 +02:00
|
|
|
namespace Utils {
|
|
|
|
|
class FileSystemWatcherPrivate;
|
2010-03-29 15:54:14 +02:00
|
|
|
|
2011-04-15 15:55:11 +02:00
|
|
|
// Documentation inside.
|
|
|
|
|
class QTCREATOR_UTILS_EXPORT FileSystemWatcher : public QObject
|
2010-03-29 15:54:14 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2011-07-13 18:02:35 +02:00
|
|
|
|
2010-03-29 15:54:14 +02:00
|
|
|
public:
|
2011-04-15 15:55:11 +02:00
|
|
|
enum WatchMode
|
|
|
|
|
{
|
|
|
|
|
WatchModifiedDate,
|
|
|
|
|
WatchAllChanges
|
|
|
|
|
};
|
|
|
|
|
|
2010-03-29 15:54:14 +02:00
|
|
|
explicit FileSystemWatcher(QObject *parent = 0);
|
2011-04-15 15:55:11 +02:00
|
|
|
explicit FileSystemWatcher(int id, QObject *parent = 0);
|
2010-03-29 15:54:14 +02:00
|
|
|
virtual ~FileSystemWatcher();
|
|
|
|
|
|
2011-04-15 15:55:11 +02:00
|
|
|
void addFile(const QString &file, WatchMode wm);
|
|
|
|
|
void addFiles(const QStringList &files, WatchMode wm);
|
2010-03-29 15:54:14 +02:00
|
|
|
|
|
|
|
|
void removeFile(const QString &file);
|
|
|
|
|
void removeFiles(const QStringList &files);
|
|
|
|
|
|
2011-04-15 15:55:11 +02:00
|
|
|
bool watchesFile(const QString &file) const;
|
2010-03-29 15:54:14 +02:00
|
|
|
QStringList files() const;
|
|
|
|
|
|
2011-04-15 15:55:11 +02:00
|
|
|
void addDirectory(const QString &file, WatchMode wm);
|
|
|
|
|
void addDirectories(const QStringList &files, WatchMode wm);
|
2010-03-29 15:54:14 +02:00
|
|
|
|
|
|
|
|
void removeDirectory(const QString &file);
|
|
|
|
|
void removeDirectories(const QStringList &files);
|
|
|
|
|
|
2011-04-15 15:55:11 +02:00
|
|
|
bool watchesDirectory(const QString &file) const;
|
2010-03-29 15:54:14 +02:00
|
|
|
QStringList directories() const;
|
|
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void slotFileChanged(const QString &path);
|
|
|
|
|
void slotDirectoryChanged(const QString &path);
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void fileChanged(const QString &path);
|
|
|
|
|
void directoryChanged(const QString &path);
|
|
|
|
|
|
|
|
|
|
private:
|
2011-04-15 15:55:11 +02:00
|
|
|
void init();
|
2010-03-29 15:54:14 +02:00
|
|
|
|
2011-09-16 15:00:41 +02:00
|
|
|
FileSystemWatcherPrivate *d;
|
2010-03-29 15:54:14 +02:00
|
|
|
};
|
|
|
|
|
|
2011-04-15 15:55:11 +02:00
|
|
|
} // namespace Utils
|
2010-03-29 15:54:14 +02:00
|
|
|
|
2013-03-15 12:35:25 +01:00
|
|
|
#endif // FILESYSTEMWATCHER_H
|