KCoreAddons

kdirwatch.h
1 /*
2  This file is part of the KDE libraries
3 
4  SPDX-FileCopyrightText: 1998 Sven Radej <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-only
7 */
8 #ifndef _KDIRWATCH_H
9 #define _KDIRWATCH_H
10 
11 #include <QDateTime>
12 #include <QObject>
13 #include <QString>
14 
15 #include <kcoreaddons_export.h>
16 
17 class KDirWatchPrivate;
18 
56 class KCOREADDONS_EXPORT KDirWatch : public QObject
57 {
58  Q_OBJECT
59 
60 public:
61 
66  enum WatchMode {
67  WatchDirOnly = 0,
68  WatchFiles = 0x01,
69  WatchSubDirs = 0x02
70  };
74  Q_DECLARE_FLAGS(WatchModes, WatchMode)
75 
76 
83  explicit KDirWatch(QObject *parent = nullptr);
84 
90  ~KDirWatch();
91 
111  void addDir(const QString &path, WatchModes watchModes = WatchDirOnly);
112 
118  void addFile(const QString &file);
119 
125  QDateTime ctime(const QString &path) const;
126 
133  void removeDir(const QString &path);
134 
141  void removeFile(const QString &file);
142 
155  bool stopDirScan(const QString &path);
156 
170  bool restartDirScan(const QString &path);
171 
188  void startScan(bool notify = false, bool skippedToo = false);
189 
195  void stopScan();
196 
202  bool isStopped();
203 
209  bool contains(const QString &path) const;
210 
211  void deleteQFSWatcher(); // KF6 TODO: remove from public API
212 
217  static void statistics(); // TODO implement a QDebug operator for KDirWatch instead.
218 
219  enum Method { FAM, INotify, Stat, QFSWatch };
224  Method internalMethod() const;
225 
238  static KDirWatch *self();
244  static bool exists();
245 
246 public Q_SLOTS:
247 
252  void setCreated(const QString &path);
253 
258  void setDirty(const QString &path);
259 
264  void setDeleted(const QString &path);
265 
266 Q_SIGNALS:
267 
281  void dirty(const QString &path);
282 
288  void created(const QString &path);
289 
296  void deleted(const QString &path);
297 
298 private:
299  KDirWatchPrivate *d;
300 };
301 
302 Q_DECLARE_OPERATORS_FOR_FLAGS(KDirWatch::WatchModes)
303 
304 #endif
305 
WatchMode
Available watch modes for directory monitoring.
Definition: kdirwatch.h:66
Class for watching directory and file changes.
Definition: kdirwatch.h:56
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sun May 24 2020 23:08:49 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.