• R/O
  • HTTP
  • SSH
  • HTTPS

Katie: Commit

C++ toolkit derived from the Qt 4.8 framework


Commit MetaInfo

Revision668ccbb7c4b8f7768ba637791dc5309f87f48a2e (tree)
Time2022-12-21 03:57:33
AuthorIvailo Monev <xakepa10@gmai...>
CommiterIvailo Monev

Log Message

simplify emision of QFileSystemWatcher signals

the proxy signals are just redundant

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>

Change Summary

Incremental Difference

--- a/src/core/io/qfilesystemwatcher.cpp
+++ b/src/core/io/qfilesystemwatcher.cpp
@@ -35,47 +35,6 @@ QFileSystemWatcherPrivate::QFileSystemWatcherPrivate()
3535 {
3636 }
3737
38-
39-void QFileSystemWatcherPrivate::init()
40-{
41- Q_Q(const QFileSystemWatcher);
42- QObject::connect(watcher,
43- SIGNAL(fileChanged(QString,bool)),
44- q,
45- SLOT(_q_fileChanged(QString,bool)));
46- QObject::connect(watcher,
47- SIGNAL(directoryChanged(QString,bool)),
48- q,
49- SLOT(_q_directoryChanged(QString,bool)));
50-}
51-
52-
53-void QFileSystemWatcherPrivate::_q_fileChanged(const QString &path, bool removed)
54-{
55- Q_Q(QFileSystemWatcher);
56- if (!files.contains(path)) {
57- // the path was removed after a change was detected, but before we delivered the signal
58- return;
59- }
60- if (removed)
61- files.removeAll(path);
62- emit q->fileChanged(path);
63-}
64-
65-void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool removed)
66-{
67- Q_Q(QFileSystemWatcher);
68- if (!directories.contains(path)) {
69- // perhaps the path was removed after a change was detected, but before we delivered the signal
70- return;
71- }
72- if (removed)
73- directories.removeAll(path);
74- emit q->directoryChanged(path);
75-}
76-
77-
78-
7938 /*!
8039 \class QFileSystemWatcher
8140 \brief The QFileSystemWatcher class provides an interface for monitoring files and directories for modifications.
@@ -111,7 +70,15 @@ void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool re
11170 QFileSystemWatcher::QFileSystemWatcher(QObject *parent)
11271 : QObject(*new QFileSystemWatcherPrivate, parent)
11372 {
114- d_func()->init();
73+ Q_D(QFileSystemWatcher);
74+ connect(
75+ d->watcher, SIGNAL(fileChanged(QString)),
76+ this, SIGNAL(fileChanged(QString))
77+ );
78+ connect(
79+ d->watcher, SIGNAL(directoryChanged(QString)),
80+ this, SIGNAL(directoryChanged(QString))
81+ );
11582 }
11683
11784 /*!
@@ -121,7 +88,15 @@ QFileSystemWatcher::QFileSystemWatcher(QObject *parent)
12188 QFileSystemWatcher::QFileSystemWatcher(const QStringList &paths, QObject *parent)
12289 : QObject(*new QFileSystemWatcherPrivate, parent)
12390 {
124- d_func()->init();
91+ Q_D(QFileSystemWatcher);
92+ connect(
93+ d->watcher, SIGNAL(fileChanged(QString)),
94+ this, SIGNAL(fileChanged(QString))
95+ );
96+ connect(
97+ d->watcher, SIGNAL(directoryChanged(QString)),
98+ this, SIGNAL(directoryChanged(QString))
99+ );
125100 addPaths(paths);
126101 }
127102
--- a/src/core/io/qfilesystemwatcher.h
+++ b/src/core/io/qfilesystemwatcher.h
@@ -53,10 +53,6 @@ public:
5353 Q_SIGNALS:
5454 void fileChanged(const QString &path);
5555 void directoryChanged(const QString &path);
56-
57-private:
58- Q_PRIVATE_SLOT(d_func(), void _q_fileChanged(const QString &path, bool removed))
59- Q_PRIVATE_SLOT(d_func(), void _q_directoryChanged(const QString &path, bool removed))
6056 };
6157
6258 QT_END_NAMESPACE
--- a/src/core/io/qfilesystemwatcher_p.h
+++ b/src/core/io/qfilesystemwatcher_p.h
@@ -50,14 +50,9 @@ class QFileSystemWatcherPrivate : public QObjectPrivate
5050
5151 public:
5252 QFileSystemWatcherPrivate();
53- void init();
5453
5554 QFileSystemWatcherEngineUnix *watcher;
5655 QStringList files, directories;
57-
58- // private slots
59- void _q_fileChanged(const QString &path, bool removed);
60- void _q_directoryChanged(const QString &path, bool removed);
6156 };
6257
6358 QT_END_NAMESPACE
--- a/src/core/io/qfilesystemwatcher_unix.cpp
+++ b/src/core/io/qfilesystemwatcher_unix.cpp
@@ -34,7 +34,6 @@ QFileSystemWatcherEngineUnix::QFileSystemWatcherEngineUnix()
3434 : timer(this)
3535 {
3636 connect(&timer, SIGNAL(timeout()), this, SLOT(timeout()));
37- timer.start(PollingInterval);
3837 }
3938
4039 QStringList QFileSystemWatcherEngineUnix::addPaths(const QStringList &paths,
@@ -96,11 +95,10 @@ void QFileSystemWatcherEngineUnix::timeout()
9695 if (x.value() != fi) {
9796 if (!fi.exists()) {
9897 fit.remove();
99- emit fileChanged(path, true);
10098 } else {
10199 x.value() = fi;
102- emit fileChanged(path, false);
103100 }
101+ emit fileChanged(path);
104102 }
105103 }
106104 QMutableHashIterator<QString, QStatInfo> dit(directories);
@@ -113,11 +111,10 @@ void QFileSystemWatcherEngineUnix::timeout()
113111 if (!fi.dirEquals(x.value())) {
114112 if (!fi.exists()) {
115113 dit.remove();
116- emit directoryChanged(path, true);
117114 } else {
118115 x.value() = fi;
119- emit directoryChanged(path, false);
120116 }
117+ emit directoryChanged(path);
121118 }
122119 }
123120 }
--- a/src/core/io/qfilesystemwatcher_unix_p.h
+++ b/src/core/io/qfilesystemwatcher_unix_p.h
@@ -61,8 +61,8 @@ public:
6161 QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories);
6262
6363 Q_SIGNALS:
64- void fileChanged(const QString &path, bool removed);
65- void directoryChanged(const QString &path, bool removed);
64+ void fileChanged(const QString &path);
65+ void directoryChanged(const QString &path);
6666
6767 private Q_SLOTS:
6868 void timeout();
Show on old repository browser