qfilesystemwatcher.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/io/qfilesystemwatcher.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15-
16-
17-
18-
19-
20QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject *parent)-
21{-
22-
23-
24-
25-
26-
27 return QInotifyFileSystemWatcherEngine::create(parent);-
28}-
29-
30QFileSystemWatcherPrivate::QFileSystemWatcherPrivate()-
31 : native(0), poller(0)-
32{-
33}-
34-
35void QFileSystemWatcherPrivate::init()-
36{-
37 QFileSystemWatcher * const q = q_func();-
38 native = createNativeEngine(q);-
39 if (native) {-
40 QObject::connect(native,-
41 qFlagLocation("2""fileChanged(QString,bool)" "\0" __FILE__ ":" "92""98"),-
42 q,-
43 qFlagLocation("1""_q_fileChanged(QString,bool)" "\0" __FILE__ ":" "94""100"));-
44 QObject::connect(native,-
45 qFlagLocation("2""directoryChanged(QString,bool)" "\0" __FILE__ ":" "96""102"),-
46 q,-
47 qFlagLocation("1""_q_directoryChanged(QString,bool)" "\0" __FILE__ ":" "98""104"));-
48 }-
49}-
50-
51void QFileSystemWatcherPrivate::initPollerEngine()-
52{-
53 if(poller)-
54 return;-
55-
56 QFileSystemWatcher * const q = q_func();-
57 poller = new QPollingFileSystemWatcherEngine(q);-
58 QObject::connect(poller,-
59 qFlagLocation("2""fileChanged(QString,bool)" "\0" __FILE__ ":" "110""116"),-
60 q,-
61 qFlagLocation("1""_q_fileChanged(QString,bool)" "\0" __FILE__ ":" "112""118"));-
62 QObject::connect(poller,-
63 qFlagLocation("2""directoryChanged(QString,bool)" "\0" __FILE__ ":" "114""120"),-
64 q,-
65 qFlagLocation("1""_q_directoryChanged(QString,bool)" "\0" __FILE__ ":" "116""122"));-
66}-
67-
68void QFileSystemWatcherPrivate::_q_fileChanged(const QString &path, bool removed)-
69{-
70 QFileSystemWatcher * const q = q_func();-
71 if (!files.contains(path)) {-
72-
73 return;-
74 }-
75 if (removed)-
76 files.removeAll(path);-
77 q->fileChanged(path, QFileSystemWatcher::QPrivateSignal());-
78}-
79-
80void QFileSystemWatcherPrivate::_q_directoryChanged(const QString &path, bool removed)-
81{-
82 QFileSystemWatcher * const q = q_func();-
83 if (!directories.contains(path)) {-
84-
85 return;-
86 }-
87 if (removed)-
88 directories.removeAll(path);-
89 q->directoryChanged(path, QFileSystemWatcher::QPrivateSignal());-
90}-
91QFileSystemWatcher::QFileSystemWatcher(QObject *parent)-
92 : QObject(*new QFileSystemWatcherPrivate, parent)-
93{-
94 d_func()->init();-
95}-
96-
97-
98-
99-
100-
101QFileSystemWatcher::QFileSystemWatcher(const QStringList &paths, QObject *parent)-
102 : QObject(*new QFileSystemWatcherPrivate, parent)-
103{-
104 d_func()->init();-
105 addPaths(paths);-
106}-
107-
108-
109-
110-
111QFileSystemWatcher::~QFileSystemWatcher()-
112{ }-
113bool QFileSystemWatcher::addPath(const QString &path)-
114{-
115 if (path.isEmpty()) {-
116 QMessageLogger(__FILE__, 248255, __PRETTY_FUNCTION__).warning("QFileSystemWatcher::addPath: path is empty");-
117 return true;-
118 }-
119-
120 QStringList paths = addPaths(QStringList(path));-
121 return paths.isEmpty();-
122}-
123QStringList QFileSystemWatcher::addPaths(const QStringList &paths)-
124{-
125 QFileSystemWatcherPrivate * const d = d_func();-
126-
127 QStringList p = paths;-
128 QMutableListIterator<QString> it(p);-
129-
130 while (it.hasNext()
it.hasNext()Description
TRUEevaluated 488 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
FALSEevaluated 487 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
) {
487-488
131 const QString &path = it.next();-
132 if (path.isEmpty()
path.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 487 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
)
1-487
133 it.remove();
executed 1 time by 1 test: it.remove();
Executed by:
  • tst_QFileSystemWatcher
1
134 }
executed 488 times by 8 tests: end of block
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
488
135-
136 if (p.isEmpty()
p.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 485 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
) {
2-485
137 QMessageLogger(__FILE__, 293300, __PRETTY_FUNCTION__).warning("QFileSystemWatcher::addPaths: list is empty");-
138 return
executed 2 times by 1 test: return QStringList();
Executed by:
  • tst_QFileSystemWatcher
QStringList();
executed 2 times by 1 test: return QStringList();
Executed by:
  • tst_QFileSystemWatcher
2
139 }-
140-
141 QFileSystemWatcherEngine *engine = 0;-
142-
143 const QString on = objectName();-
144-
145 if (!on.startsWith(QLatin1String("_qt_autotest_force_engine_"))
!on.startsWith...rce_engine_"))Description
TRUEevaluated 458 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
FALSEevaluated 27 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
) {
27-458
146-
147 if(d->native
d->nativeDescription
TRUEevaluated 458 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
FALSEnever evaluated
) {
0-458
148 engine = d->native;-
149 }
executed 458 times by 8 tests: end of block
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
else {
458
150 d_func()->initPollerEngine();-
151 engine = d->poller;-
152 }
never executed: end of block
0
153-
154 } else {-
155-
156 const QStringRef forceName = on.midRef(26);-
157 if(forceName == QLatin1String("poller")
forceName == Q...ring("poller")Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEevaluated 18 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
) {
9-18
158 QMessageLogger(__FILE__, 314321, __PRETTY_FUNCTION__).debug() << ("QFileSystemWatcher: skipping native engine, using only polling engine";);-
159 d_func()->initPollerEngine();-
160 engine = d->poller;-
161 }
executed 9 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
else if(forceName == QLatin1String("native")
forceName == Q...ring("native")Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • tst_QFileSystemWatcher
FALSEnever evaluated
) {
0-18
162 QMessageLogger(__FILE__, 318325, __PRETTY_FUNCTION__).debug() << ("QFileSystemWatcher: skipping polling engine, using only native engine";);-
163 engine = d->native;-
164 }
executed 18 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
18
165 }
executed 27 times by 1 test: end of block
Executed by:
  • tst_QFileSystemWatcher
27
166-
167 if(engine
engineDescription
TRUEevaluated 485 times by 8 tests
Evaluated by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
FALSEnever evaluated
)
0-485
168 p = engine->addPaths(p, &d->files, &d->directories);
executed 485 times by 8 tests: p = engine->addPaths(p, &d->files, &d->directories);
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
485
169-
170 return
executed 485 times by 8 tests: return p;
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
p;
executed 485 times by 8 tests: return p;
Executed by:
  • tst_QCompleter
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsProxyWidget
  • tst_QPrinter
  • tst_languageChange
485
171}-
172bool QFileSystemWatcher::removePath(const QString &path)-
173{-
174 if (path.isEmpty()) {-
175 QMessageLogger(__FILE__, 342349, __PRETTY_FUNCTION__).warning("QFileSystemWatcher::removePath: path is empty");-
176 return true;-
177 }-
178-
179 QStringList paths = removePaths(QStringList(path));-
180 return paths.isEmpty();-
181}-
182QStringList QFileSystemWatcher::removePaths(const QStringList &paths)-
183{-
184 QFileSystemWatcherPrivate * const d = d_func();-
185-
186 QStringList p = paths;-
187 QMutableListIterator<QString> it(p);-
188-
189 while (it.hasNext()) {-
190 const QString &path = it.next();-
191 if (path.isEmpty())-
192 it.remove();-
193 }-
194-
195 if (p.isEmpty()) {-
196 QMessageLogger(__FILE__, 375382, __PRETTY_FUNCTION__).warning("QFileSystemWatcher::removePaths: list is empty");-
197 return QStringList();-
198 }-
199-
200 if (d->native)-
201 p = d->native->removePaths(p, &d->files, &d->directories);-
202 if (d->poller)-
203 p = d->poller->removePaths(p, &d->files, &d->directories);-
204-
205 return p;-
206}-
207QStringList QFileSystemWatcher::directories() const-
208{-
209 const QFileSystemWatcherPrivate * const d = d_func();-
210 return d->directories;-
211}-
212-
213QStringList QFileSystemWatcher::files() const-
214{-
215 const QFileSystemWatcherPrivate * const d = d_func();-
216 return d->files;-
217}-
218-
219-
220-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9