dialogs/qfilesystemmodel.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qfilesystemmodel_p.h" -
43#include "qfilesystemmodel.h" -
44#include <qlocale.h> -
45#include <qmimedata.h> -
46#include <qurl.h> -
47#include <qdebug.h> -
48#include <qmessagebox.h> -
49#include <qapplication.h> -
50 -
51#include <algorithm> -
52 -
53#ifdef Q_OS_WIN -
54# include <QtCore/QVarLengthArray> -
55# include <qt_windows.h> -
56#endif -
57 -
58QT_BEGIN_NAMESPACE -
59 -
60#ifndef QT_NO_FILESYSTEMMODEL -
61 -
62/*! -
63 \enum QFileSystemModel::Roles -
64 \value FileIconRole -
65 \value FilePathRole -
66 \value FileNameRole -
67 \value FilePermissions -
68*/ -
69 -
70/*! -
71 \class QFileSystemModel -
72 \since 4.4 -
73 -
74 \brief The QFileSystemModel class provides a data model for the local filesystem. -
75 -
76 \ingroup model-view -
77 \inmodule QtWidgets -
78 -
79 This class provides access to the local filesystem, providing functions -
80 for renaming and removing files and directories, and for creating new -
81 directories. In the simplest case, it can be used with a suitable display -
82 widget as part of a browser or filter. -
83 -
84 QFileSystemModel can be accessed using the standard interface provided by -
85 QAbstractItemModel, but it also provides some convenience functions that are -
86 specific to a directory model. -
87 The fileInfo(), isDir(), name(), and path() functions provide information -
88 about the underlying files and directories related to items in the model. -
89 Directories can be created and removed using mkdir(), rmdir(). -
90 -
91 \note QFileSystemModel requires an instance of a GUI application. -
92 -
93 \section1 Example Usage -
94 -
95 A directory model that displays the contents of a default directory -
96 is usually constructed with a parent object: -
97 -
98 \snippet shareddirmodel/main.cpp 2 -
99 -
100 A tree view can be used to display the contents of the model -
101 -
102 \snippet shareddirmodel/main.cpp 4 -
103 -
104 and the contents of a particular directory can be displayed by -
105 setting the tree view's root index: -
106 -
107 \snippet shareddirmodel/main.cpp 7 -
108 -
109 The view's root index can be used to control how much of a -
110 hierarchical model is displayed. QDirModel provides a convenience -
111 function that returns a suitable model index for a path to a -
112 directory within the model. -
113 -
114 \section1 Caching and Performance -
115 -
116 QFileSystemModel will not fetch any files or directories until setRootPath() -
117 is called. This will prevent any unnecessary querying on the file system -
118 until that point such as listing the drives on Windows. -
119 -
120 Unlike QDirModel, QFileSystemModel uses a separate thread to populate -
121 itself so it will not cause the main thread to hang as the file system -
122 is being queried. Calls to rowCount() will return 0 until the model -
123 populates a directory. -
124 -
125 QFileSystemModel keeps a cache with file information. The cache is -
126 automatically kept up to date using the QFileSystemWatcher. -
127 -
128 \sa {Model Classes} -
129*/ -
130 -
131/*! -
132 \fn bool QFileSystemModel::rmdir(const QModelIndex &index) -
133 -
134 Removes the directory corresponding to the model item \a index in the -
135 file system model and \b{deletes the corresponding directory from the -
136 file system}, returning true if successful. If the directory cannot be -
137 removed, false is returned. -
138 -
139 \warning This function deletes directories from the file system; it does -
140 \b{not} move them to a location where they can be recovered. -
141 -
142 \sa remove() -
143*/ -
144 -
145/*! -
146 \fn QIcon QFileSystemModel::fileName(const QModelIndex &index) const -
147 -
148 Returns the file name for the item stored in the model under the given -
149 \a index. -
150*/ -
151 -
152/*! -
153 \fn QIcon QFileSystemModel::fileIcon(const QModelIndex &index) const -
154 -
155 Returns the icon for the item stored in the model under the given -
156 \a index. -
157*/ -
158 -
159/*! -
160 \fn QFileInfo QFileSystemModel::fileInfo(const QModelIndex &index) const -
161 -
162 Returns the QFileInfo for the item stored in the model under the given -
163 \a index. -
164*/ -
165 -
166/*! -
167 \fn void QFileSystemModel::rootPathChanged(const QString &newPath); -
168 -
169 This signal is emitted whenever the root path has been changed to a \a newPath. -
170*/ -
171 -
172/*! -
173 \fn void QFileSystemModel::fileRenamed(const QString &path, const QString &oldName, const QString &newName) -
174 -
175 This signal is emitted whenever a file with the \a oldName is successfully -
176 renamed to \a newName. The file is located in in the directory \a path. -
177*/ -
178 -
179/*! -
180 \since 4.7 -
181 \fn void QFileSystemModel::directoryLoaded(const QString &path) -
182 -
183 This signal is emitted when the gatherer thread has finished to load the \a path. -
184 -
185*/ -
186 -
187/*! -
188 \fn bool QFileSystemModel::remove(const QModelIndex &index) -
189 -
190 Removes the model item \a index from the file system model and \b{deletes the -
191 corresponding file from the file system}, returning true if successful. If the -
192 item cannot be removed, false is returned. -
193 -
194 \warning This function deletes files from the file system; it does \b{not} -
195 move them to a location where they can be recovered. -
196 -
197 \sa rmdir() -
198*/ -
199 -
200bool QFileSystemModel::remove(const QModelIndex &aindex) -
201{ -
202 //### TODO optim -
203 QString path = filePath(aindex);
never executed (the execution status of this line is deduced): QString path = filePath(aindex);
-
204 QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func());
never executed (the execution status of this line is deduced): QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func());
-
205 d->fileInfoGatherer.removePath(path);
never executed (the execution status of this line is deduced): d->fileInfoGatherer.removePath(path);
-
206 QDirIterator it(path,
never executed (the execution status of this line is deduced): QDirIterator it(path,
-
207 QDir::AllDirs | QDir:: Files | QDir::NoDotAndDotDot,
never executed (the execution status of this line is deduced): QDir::AllDirs | QDir:: Files | QDir::NoDotAndDotDot,
-
208 QDirIterator::Subdirectories);
never executed (the execution status of this line is deduced): QDirIterator::Subdirectories);
-
209 QStringList children;
never executed (the execution status of this line is deduced): QStringList children;
-
210 while (it.hasNext())
never evaluated: it.hasNext()
0
211 children.prepend(it.next());
never executed: children.prepend(it.next());
0
212 children.append(path);
never executed (the execution status of this line is deduced): children.append(path);
-
213 -
214 bool error = false;
never executed (the execution status of this line is deduced): bool error = false;
-
215 for (int i = 0; i < children.count(); ++i) {
never evaluated: i < children.count()
0
216 QFileInfo info(children.at(i));
never executed (the execution status of this line is deduced): QFileInfo info(children.at(i));
-
217 QModelIndex modelIndex = index(children.at(i));
never executed (the execution status of this line is deduced): QModelIndex modelIndex = index(children.at(i));
-
218 if (info.isDir()) {
never evaluated: info.isDir()
0
219 QDir dir;
never executed (the execution status of this line is deduced): QDir dir;
-
220 if (children.at(i) != path)
never evaluated: children.at(i) != path
0
221 error |= remove(modelIndex);
never executed: error |= remove(modelIndex);
0
222 error |= rmdir(modelIndex);
never executed (the execution status of this line is deduced): error |= rmdir(modelIndex);
-
223 } else {
never executed: }
0
224 error |= QFile::remove(filePath(modelIndex));
never executed (the execution status of this line is deduced): error |= QFile::remove(filePath(modelIndex));
-
225 }
never executed: }
0
226 } -
227 return error;
never executed: return error;
0
228} -
229 -
230/*! -
231 Constructs a file system model with the given \a parent. -
232*/ -
233QFileSystemModel::QFileSystemModel(QObject *parent) -
234 : QAbstractItemModel(*new QFileSystemModelPrivate, parent) -
235{ -
236 Q_D(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModelPrivate * const d = d_func();
-
237 d->init();
executed (the execution status of this line is deduced): d->init();
-
238}
executed: }
Execution Count:273
273
239 -
240/*! -
241 \internal -
242*/ -
243QFileSystemModel::QFileSystemModel(QFileSystemModelPrivate &dd, QObject *parent) -
244 : QAbstractItemModel(dd, parent) -
245{ -
246 Q_D(QFileSystemModel);
never executed (the execution status of this line is deduced): QFileSystemModelPrivate * const d = d_func();
-
247 d->init();
never executed (the execution status of this line is deduced): d->init();
-
248}
never executed: }
0
249 -
250/*! -
251 Destroys this file system model. -
252*/ -
253QFileSystemModel::~QFileSystemModel() -
254{ -
255} -
256 -
257/*! -
258 \reimp -
259*/ -
260QModelIndex QFileSystemModel::index(int row, int column, const QModelIndex &parent) const -
261{ -
262 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
263 if (row < 0 || column < 0 || row >= rowCount(parent) || column >= columnCount(parent))
partially evaluated: row < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:84100
partially evaluated: column < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:84100
partially evaluated: row >= rowCount(parent)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:84100
partially evaluated: column >= columnCount(parent)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:84100
0-84100
264 return QModelIndex();
never executed: return QModelIndex();
0
265 -
266 // get the parent node -
267 QFileSystemModelPrivate::QFileSystemNode *parentNode = (d->indexValid(parent) ? d->node(parent) :
evaluated: d->indexValid(parent)
TRUEFALSE
yes
Evaluation Count:82114
yes
Evaluation Count:1986
1986-82114
268 const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&d->root));
executed (the execution status of this line is deduced): const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&d->root));
-
269 Q_ASSERT(parentNode);
executed (the execution status of this line is deduced): qt_noop();
-
270 -
271 // now get the internal pointer for the index -
272 QString childName = parentNode->visibleChildren[d->translateVisibleLocation(parentNode, row)];
executed (the execution status of this line is deduced): QString childName = parentNode->visibleChildren[d->translateVisibleLocation(parentNode, row)];
-
273 const QFileSystemModelPrivate::QFileSystemNode *indexNode = parentNode->children.value(childName);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate::QFileSystemNode *indexNode = parentNode->children.value(childName);
-
274 Q_ASSERT(indexNode);
executed (the execution status of this line is deduced): qt_noop();
-
275 -
276 return createIndex(row, column, const_cast<QFileSystemModelPrivate::QFileSystemNode*>(indexNode));
executed: return createIndex(row, column, const_cast<QFileSystemModelPrivate::QFileSystemNode*>(indexNode));
Execution Count:84100
84100
277} -
278 -
279/*! -
280 \overload -
281 -
282 Returns the model item index for the given \a path and \a column. -
283*/ -
284QModelIndex QFileSystemModel::index(const QString &path, int column) const -
285{ -
286 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
287 QFileSystemModelPrivate::QFileSystemNode *node = d->node(path, false);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *node = d->node(path, false);
-
288 QModelIndex idx = d->index(node);
executed (the execution status of this line is deduced): QModelIndex idx = d->index(node);
-
289 if (idx.column() != column)
evaluated: idx.column() != column
TRUEFALSE
yes
Evaluation Count:1202
yes
Evaluation Count:4092
1202-4092
290 idx = idx.sibling(idx.row(), column);
executed: idx = idx.sibling(idx.row(), column);
Execution Count:1202
1202
291 return idx;
executed: return idx;
Execution Count:5294
5294
292} -
293 -
294/*! -
295 \internal -
296 -
297 Return the QFileSystemNode that goes to index. -
298 */ -
299QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QModelIndex &index) const -
300{ -
301 if (!index.isValid())
evaluated: !index.isValid()
TRUEFALSE
yes
Evaluation Count:7663
yes
Evaluation Count:354188
7663-354188
302 return const_cast<QFileSystemNode*>(&root);
executed: return const_cast<QFileSystemNode*>(&root);
Execution Count:7663
7663
303 QFileSystemModelPrivate::QFileSystemNode *indexNode = static_cast<QFileSystemModelPrivate::QFileSystemNode*>(index.internalPointer());
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *indexNode = static_cast<QFileSystemModelPrivate::QFileSystemNode*>(index.internalPointer());
-
304 Q_ASSERT(indexNode);
executed (the execution status of this line is deduced): qt_noop();
-
305 return indexNode;
executed: return indexNode;
Execution Count:354188
354188
306} -
307 -
308#ifdef Q_OS_WIN32 -
309static QString qt_GetLongPathName(const QString &strShortPath) -
310{ -
311 if (strShortPath.isEmpty() -
312 || strShortPath == QLatin1String(".") || strShortPath == QLatin1String("..")) -
313 return strShortPath; -
314 if (strShortPath.length() == 2 && strShortPath.endsWith(QLatin1Char(':'))) -
315 return strShortPath.toUpper(); -
316 const QString absPath = QDir(strShortPath).absolutePath(); -
317 if (absPath.startsWith(QLatin1String("//")) -
318 || absPath.startsWith(QLatin1String("\\\\"))) // unc -
319 return QDir::fromNativeSeparators(absPath); -
320 if (absPath.startsWith(QLatin1Char('/'))) -
321 return QString(); -
322 const QString inputString = QLatin1String("\\\\?\\") + QDir::toNativeSeparators(absPath); -
323 QVarLengthArray<TCHAR, MAX_PATH> buffer(MAX_PATH); -
324 DWORD result = ::GetLongPathName((wchar_t*)inputString.utf16(), -
325 buffer.data(), -
326 buffer.size()); -
327 if (result > DWORD(buffer.size())) { -
328 buffer.resize(result); -
329 result = ::GetLongPathName((wchar_t*)inputString.utf16(), -
330 buffer.data(), -
331 buffer.size()); -
332 } -
333 if (result > 4) { -
334 QString longPath = QString::fromWCharArray(buffer.data() + 4); // ignoring prefix -
335 longPath[0] = longPath.at(0).toUpper(); // capital drive letters -
336 return QDir::fromNativeSeparators(longPath); -
337 } else { -
338 return QDir::fromNativeSeparators(strShortPath); -
339 } -
340} -
341#endif -
342 -
343/*! -
344 \internal -
345 -
346 Given a path return the matching QFileSystemNode or &root if invalid -
347*/ -
348QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QString &path, bool fetch) const -
349{ -
350 Q_Q(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModel * const q = q_func();
-
351 Q_UNUSED(q);
executed (the execution status of this line is deduced): (void)q;;
-
352 if (path.isEmpty() || path == myComputer() || path.startsWith(QLatin1Char(':')))
evaluated: path.isEmpty()
TRUEFALSE
yes
Evaluation Count:1069
yes
Evaluation Count:4945
partially evaluated: path == myComputer()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4945
partially evaluated: path.startsWith(QLatin1Char(':'))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4945
0-4945
353 return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
executed: return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
Execution Count:1069
1069
354 -
355 // Construct the nodes up to the new root path if they need to be built -
356 QString absolutePath;
executed (the execution status of this line is deduced): QString absolutePath;
-
357#ifdef Q_OS_WIN32 -
358 QString longPath = qt_GetLongPathName(path); -
359#else -
360 QString longPath = path;
executed (the execution status of this line is deduced): QString longPath = path;
-
361#endif -
362 if (longPath == rootDir.path())
evaluated: longPath == rootDir.path()
TRUEFALSE
yes
Evaluation Count:2989
yes
Evaluation Count:1956
1956-2989
363 absolutePath = rootDir.absolutePath();
executed: absolutePath = rootDir.absolutePath();
Execution Count:2989
2989
364 else -
365 absolutePath = QDir(longPath).absolutePath();
executed: absolutePath = QDir(longPath).absolutePath();
Execution Count:1956
1956
366 -
367 // ### TODO can we use bool QAbstractFileEngine::caseSensitive() const? -
368 QStringList pathElements = absolutePath.split(QLatin1Char('/'), QString::SkipEmptyParts);
executed (the execution status of this line is deduced): QStringList pathElements = absolutePath.split(QLatin1Char('/'), QString::SkipEmptyParts);
-
369 if ((pathElements.isEmpty())
evaluated: (pathElements.isEmpty())
TRUEFALSE
yes
Evaluation Count:122
yes
Evaluation Count:4823
122-4823
370#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE)
executed (the execution status of this line is deduced):
-
371 && QDir::fromNativeSeparators(longPath) != QLatin1String("/")
evaluated: QDir::fromNativeSeparators(longPath) != QLatin1String("/")
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:116
6-116
372#endif -
373 ) -
374 return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
executed: return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
Execution Count:6
6
375 QModelIndex index = QModelIndex(); // start with "My Computer"
executed (the execution status of this line is deduced): QModelIndex index = QModelIndex();
-
376#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -
377 if (absolutePath.startsWith(QLatin1String("//"))) { // UNC path -
378 QString host = QLatin1String("\\\\") + pathElements.first(); -
379 if (absolutePath == QDir::fromNativeSeparators(host)) -
380 absolutePath.append(QLatin1Char('/')); -
381 if (longPath.endsWith(QLatin1Char('/')) && !absolutePath.endsWith(QLatin1Char('/'))) -
382 absolutePath.append(QLatin1Char('/')); -
383 int r = 0; -
384 QFileSystemModelPrivate::QFileSystemNode *rootNode = const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root); -
385 if (!root.children.contains(host.toLower())) { -
386 if (pathElements.count() == 1 && !absolutePath.endsWith(QLatin1Char('/'))) -
387 return rootNode; -
388 QFileInfo info(host); -
389 if (!info.exists()) -
390 return rootNode; -
391 QFileSystemModelPrivate *p = const_cast<QFileSystemModelPrivate*>(this); -
392 p->addNode(rootNode, host,info); -
393 p->addVisibleFiles(rootNode, QStringList(host)); -
394 } -
395 r = rootNode->visibleLocation(host); -
396 r = translateVisibleLocation(rootNode, r); -
397 index = q->index(r, 0, QModelIndex()); -
398 pathElements.pop_front(); -
399 } else -
400#endif -
401 -
402#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -
403 { -
404 if (!pathElements.at(0).contains(QLatin1String(":"))) { -
405 QString rootPath = QDir(longPath).rootPath(); -
406 pathElements.prepend(rootPath); -
407 } -
408 if (pathElements.at(0).endsWith(QLatin1Char('/'))) -
409 pathElements[0].chop(1); -
410 } -
411#else -
412 // add the "/" item, since it is a valid path element on Unix -
413 if (absolutePath[0] == QLatin1Char('/'))
partially evaluated: absolutePath[0] == QLatin1Char('/')
TRUEFALSE
yes
Evaluation Count:4939
no
Evaluation Count:0
0-4939
414 pathElements.prepend(QLatin1String("/"));
executed: pathElements.prepend(QLatin1String("/"));
Execution Count:4939
4939
415#endif -
416 -
417 QFileSystemModelPrivate::QFileSystemNode *parent = node(index);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *parent = node(index);
-
418 -
419 for (int i = 0; i < pathElements.count(); ++i) {
evaluated: i < pathElements.count()
TRUEFALSE
yes
Evaluation Count:27312
yes
Evaluation Count:4788
4788-27312
420 QString element = pathElements.at(i);
executed (the execution status of this line is deduced): QString element = pathElements.at(i);
-
421#ifdef Q_OS_WIN -
422 // On Windows, "filename......." and "filename" are equivalent Task #133928 -
423 while (element.endsWith(QLatin1Char('.'))) -
424 element.chop(1); -
425#endif -
426 bool alreadyExisted = parent->children.contains(element);
executed (the execution status of this line is deduced): bool alreadyExisted = parent->children.contains(element);
-
427 -
428 // we couldn't find the path element, we create a new node since we -
429 // _know_ that the path is valid -
430 if (alreadyExisted) {
evaluated: alreadyExisted
TRUEFALSE
yes
Evaluation Count:24804
yes
Evaluation Count:2508
2508-24804
431 if ((parent->children.count() == 0)
partially evaluated: (parent->children.count() == 0)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24804
0-24804
432 || (parent->caseSensitive()
evaluated: parent->caseSensitive()
TRUEFALSE
yes
Evaluation Count:20112
yes
Evaluation Count:4692
4692-20112
433 && parent->children.value(element)->fileName != element)
partially evaluated: parent->children.value(element)->fileName != element
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20112
0-20112
434 || (!parent->caseSensitive()
evaluated: !parent->caseSensitive()
TRUEFALSE
yes
Evaluation Count:4692
yes
Evaluation Count:20112
4692-20112
435 && parent->children.value(element)->fileName.toLower() != element.toLower()))
partially evaluated: parent->children.value(element)->fileName.toLower() != element.toLower()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4692
0-4692
436 alreadyExisted = false;
never executed: alreadyExisted = false;
0
437 }
executed: }
Execution Count:24804
24804
438 -
439 QFileSystemModelPrivate::QFileSystemNode *node;
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *node;
-
440 if (!alreadyExisted) {
evaluated: !alreadyExisted
TRUEFALSE
yes
Evaluation Count:2508
yes
Evaluation Count:24804
2508-24804
441 // Someone might call ::index("file://cookie/monster/doesn't/like/veggies"), -
442 // a path that doesn't exists, I.E. don't blindly create directories. -
443 QFileInfo info(absolutePath);
executed (the execution status of this line is deduced): QFileInfo info(absolutePath);
-
444 if (!info.exists())
evaluated: !info.exists()
TRUEFALSE
yes
Evaluation Count:83
yes
Evaluation Count:2425
83-2425
445 return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
executed: return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
Execution Count:83
83
446 QFileSystemModelPrivate *p = const_cast<QFileSystemModelPrivate*>(this);
executed (the execution status of this line is deduced): QFileSystemModelPrivate *p = const_cast<QFileSystemModelPrivate*>(this);
-
447 node = p->addNode(parent, element,info);
executed (the execution status of this line is deduced): node = p->addNode(parent, element,info);
-
448 node->populate(fileInfoGatherer.getInfo(info));
executed (the execution status of this line is deduced): node->populate(fileInfoGatherer.getInfo(info));
-
449 } else {
executed: }
Execution Count:2425
2425
450 node = parent->children.value(element);
executed (the execution status of this line is deduced): node = parent->children.value(element);
-
451 }
executed: }
Execution Count:24804
24804
452 -
453 Q_ASSERT(node);
executed (the execution status of this line is deduced): qt_noop();
-
454 if (!node->isVisible) {
evaluated: !node->isVisible
TRUEFALSE
yes
Evaluation Count:2493
yes
Evaluation Count:24736
2493-24736
455 // It has been filtered out -
456 if (alreadyExisted && node->hasInformation() && !fetch)
evaluated: alreadyExisted
TRUEFALSE
yes
Evaluation Count:68
yes
Evaluation Count:2425
partially evaluated: node->hasInformation()
TRUEFALSE
yes
Evaluation Count:68
no
Evaluation Count:0
partially evaluated: !fetch
TRUEFALSE
yes
Evaluation Count:68
no
Evaluation Count:0
0-2425
457 return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
executed: return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
Execution Count:68
68
458 -
459 QFileSystemModelPrivate *p = const_cast<QFileSystemModelPrivate*>(this);
executed (the execution status of this line is deduced): QFileSystemModelPrivate *p = const_cast<QFileSystemModelPrivate*>(this);
-
460 p->addVisibleFiles(parent, QStringList(element));
executed (the execution status of this line is deduced): p->addVisibleFiles(parent, QStringList(element));
-
461 if (!p->bypassFilters.contains(node))
partially evaluated: !p->bypassFilters.contains(node)
TRUEFALSE
yes
Evaluation Count:2425
no
Evaluation Count:0
0-2425
462 p->bypassFilters[node] = 1;
executed: p->bypassFilters[node] = 1;
Execution Count:2425
2425
463 QString dir = q->filePath(this->index(parent));
executed (the execution status of this line is deduced): QString dir = q->filePath(this->index(parent));
-
464 if (!node->hasInformation() && fetch) {
partially evaluated: !node->hasInformation()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2425
never evaluated: fetch
0-2425
465 Fetching f;
never executed (the execution status of this line is deduced): Fetching f;
-
466 f.dir = dir;
never executed (the execution status of this line is deduced): f.dir = dir;
-
467 f.file = element;
never executed (the execution status of this line is deduced): f.file = element;
-
468 f.node = node;
never executed (the execution status of this line is deduced): f.node = node;
-
469 p->toFetch.append(f);
never executed (the execution status of this line is deduced): p->toFetch.append(f);
-
470 p->fetchingTimer.start(0, const_cast<QFileSystemModel*>(q));
never executed (the execution status of this line is deduced): p->fetchingTimer.start(0, const_cast<QFileSystemModel*>(q));
-
471 }
never executed: }
0
472 }
executed: }
Execution Count:2425
2425
473 parent = node;
executed (the execution status of this line is deduced): parent = node;
-
474 }
executed: }
Execution Count:27161
27161
475 -
476 return parent;
executed: return parent;
Execution Count:4788
4788
477} -
478 -
479/*! -
480 \reimp -
481*/ -
482void QFileSystemModel::timerEvent(QTimerEvent *event) -
483{ -
484 Q_D(QFileSystemModel);
never executed (the execution status of this line is deduced): QFileSystemModelPrivate * const d = d_func();
-
485 if (event->timerId() == d->fetchingTimer.timerId()) {
never evaluated: event->timerId() == d->fetchingTimer.timerId()
0
486 d->fetchingTimer.stop();
never executed (the execution status of this line is deduced): d->fetchingTimer.stop();
-
487#ifndef QT_NO_FILESYSTEMWATCHER -
488 for (int i = 0; i < d->toFetch.count(); ++i) {
never evaluated: i < d->toFetch.count()
0
489 const QFileSystemModelPrivate::QFileSystemNode *node = d->toFetch.at(i).node;
never executed (the execution status of this line is deduced): const QFileSystemModelPrivate::QFileSystemNode *node = d->toFetch.at(i).node;
-
490 if (!node->hasInformation()) {
never evaluated: !node->hasInformation()
0
491 d->fileInfoGatherer.fetchExtendedInformation(d->toFetch.at(i).dir,
never executed (the execution status of this line is deduced): d->fileInfoGatherer.fetchExtendedInformation(d->toFetch.at(i).dir,
-
492 QStringList(d->toFetch.at(i).file));
never executed (the execution status of this line is deduced): QStringList(d->toFetch.at(i).file));
-
493 } else {
never executed: }
0
494 // qDebug() << "yah!, you saved a little gerbil soul"; -
495 }
never executed: }
0
496 } -
497#endif -
498 d->toFetch.clear();
never executed (the execution status of this line is deduced): d->toFetch.clear();
-
499 }
never executed: }
0
500}
never executed: }
0
501 -
502/*! -
503 Returns true if the model item \a index represents a directory; -
504 otherwise returns false. -
505*/ -
506bool QFileSystemModel::isDir(const QModelIndex &index) const -
507{ -
508 // This function is for public usage only because it could create a file info -
509 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
510 if (!index.isValid())
evaluated: !index.isValid()
TRUEFALSE
yes
Evaluation Count:298
yes
Evaluation Count:802
298-802
511 return true;
executed: return true;
Execution Count:298
298
512 QFileSystemModelPrivate::QFileSystemNode *n = d->node(index);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *n = d->node(index);
-
513 if (n->hasInformation())
partially evaluated: n->hasInformation()
TRUEFALSE
yes
Evaluation Count:802
no
Evaluation Count:0
0-802
514 return n->isDir();
executed: return n->isDir();
Execution Count:802
802
515 return fileInfo(index).isDir();
never executed: return fileInfo(index).isDir();
0
516} -
517 -
518/*! -
519 Returns the size in bytes of \a index. If the file does not exist, 0 is returned. -
520 */ -
521qint64 QFileSystemModel::size(const QModelIndex &index) const -
522{ -
523 Q_D(const QFileSystemModel);
never executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
524 if (!index.isValid())
never evaluated: !index.isValid()
0
525 return 0;
never executed: return 0;
0
526 return d->node(index)->size();
never executed: return d->node(index)->size();
0
527} -
528 -
529/*! -
530 Returns the type of file \a index such as "Directory" or "JPEG file". -
531 */ -
532QString QFileSystemModel::type(const QModelIndex &index) const -
533{ -
534 Q_D(const QFileSystemModel);
never executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
535 if (!index.isValid())
never evaluated: !index.isValid()
0
536 return QString();
never executed: return QString();
0
537 return d->node(index)->type();
never executed: return d->node(index)->type();
0
538} -
539 -
540/*! -
541 Returns the date and time when \a index was last modified. -
542 */ -
543QDateTime QFileSystemModel::lastModified(const QModelIndex &index) const -
544{ -
545 Q_D(const QFileSystemModel);
never executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
546 if (!index.isValid())
never evaluated: !index.isValid()
0
547 return QDateTime();
never executed: return QDateTime();
0
548 return d->node(index)->lastModified();
never executed: return d->node(index)->lastModified();
0
549} -
550 -
551/*! -
552 \reimp -
553*/ -
554QModelIndex QFileSystemModel::parent(const QModelIndex &index) const -
555{ -
556 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
557 if (!d->indexValid(index))
partially evaluated: !d->indexValid(index)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:36156
0-36156
558 return QModelIndex();
never executed: return QModelIndex();
0
559 -
560 QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(index);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(index);
-
561 Q_ASSERT(indexNode != 0);
executed (the execution status of this line is deduced): qt_noop();
-
562 QFileSystemModelPrivate::QFileSystemNode *parentNode = (indexNode ? indexNode->parent : 0);
partially evaluated: indexNode
TRUEFALSE
yes
Evaluation Count:36156
no
Evaluation Count:0
0-36156
563 if (parentNode == 0 || parentNode == &d->root)
partially evaluated: parentNode == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:36156
evaluated: parentNode == &d->root
TRUEFALSE
yes
Evaluation Count:5601
yes
Evaluation Count:30555
0-36156
564 return QModelIndex();
executed: return QModelIndex();
Execution Count:5601
5601
565 -
566 // get the parent's row -
567 QFileSystemModelPrivate::QFileSystemNode *grandParentNode = parentNode->parent;
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *grandParentNode = parentNode->parent;
-
568 Q_ASSERT(grandParentNode->children.contains(parentNode->fileName));
executed (the execution status of this line is deduced): qt_noop();
-
569 int visualRow = d->translateVisibleLocation(grandParentNode, grandParentNode->visibleLocation(grandParentNode->children.value(parentNode->fileName)->fileName));
executed (the execution status of this line is deduced): int visualRow = d->translateVisibleLocation(grandParentNode, grandParentNode->visibleLocation(grandParentNode->children.value(parentNode->fileName)->fileName));
-
570 if (visualRow == -1)
partially evaluated: visualRow == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30555
0-30555
571 return QModelIndex();
never executed: return QModelIndex();
0
572 return createIndex(visualRow, 0, parentNode);
executed: return createIndex(visualRow, 0, parentNode);
Execution Count:30555
30555
573} -
574 -
575/* -
576 \internal -
577 -
578 return the index for node -
579*/ -
580QModelIndex QFileSystemModelPrivate::index(const QFileSystemModelPrivate::QFileSystemNode *node) const -
581{ -
582 Q_Q(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModel * const q = q_func();
-
583 QFileSystemModelPrivate::QFileSystemNode *parentNode = (node ? node->parent : 0);
partially evaluated: node
TRUEFALSE
yes
Evaluation Count:11020
no
Evaluation Count:0
0-11020
584 if (node == &root || !parentNode)
evaluated: node == &root
TRUEFALSE
yes
Evaluation Count:1722
yes
Evaluation Count:9298
partially evaluated: !parentNode
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9298
0-9298
585 return QModelIndex();
executed: return QModelIndex();
Execution Count:1722
1722
586 -
587 // get the parent's row -
588 Q_ASSERT(node);
executed (the execution status of this line is deduced): qt_noop();
-
589 if (!node->isVisible)
partially evaluated: !node->isVisible
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9298
0-9298
590 return QModelIndex();
never executed: return QModelIndex();
0
591 -
592 int visualRow = translateVisibleLocation(parentNode, parentNode->visibleLocation(node->fileName));
executed (the execution status of this line is deduced): int visualRow = translateVisibleLocation(parentNode, parentNode->visibleLocation(node->fileName));
-
593 return q->createIndex(visualRow, 0, const_cast<QFileSystemNode*>(node));
executed: return q->createIndex(visualRow, 0, const_cast<QFileSystemNode*>(node));
Execution Count:9298
9298
594} -
595 -
596/*! -
597 \reimp -
598*/ -
599bool QFileSystemModel::hasChildren(const QModelIndex &parent) const -
600{ -
601 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
602 if (parent.column() > 0)
partially evaluated: parent.column() > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5109
0-5109
603 return false;
never executed: return false;
0
604 -
605 if (!parent.isValid()) // drives
evaluated: !parent.isValid()
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:5069
40-5069
606 return true;
executed: return true;
Execution Count:40
40
607 -
608 const QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(parent);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(parent);
-
609 Q_ASSERT(indexNode);
executed (the execution status of this line is deduced): qt_noop();
-
610 return (indexNode->isDir());
executed: return (indexNode->isDir());
Execution Count:5069
5069
611} -
612 -
613/*! -
614 \reimp -
615 */ -
616bool QFileSystemModel::canFetchMore(const QModelIndex &parent) const -
617{ -
618 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
619 const QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(parent);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(parent);
-
620 return (!indexNode->populatedChildren);
executed: return (!indexNode->populatedChildren);
Execution Count:3094
3094
621} -
622 -
623/*! -
624 \reimp -
625 */ -
626void QFileSystemModel::fetchMore(const QModelIndex &parent) -
627{ -
628 Q_D(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModelPrivate * const d = d_func();
-
629 if (!d->setRootPath)
evaluated: !d->setRootPath
TRUEFALSE
yes
Evaluation Count:2079
yes
Evaluation Count:414
414-2079
630 return;
executed: return;
Execution Count:2079
2079
631 QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(parent);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(parent);
-
632 if (indexNode->populatedChildren)
evaluated: indexNode->populatedChildren
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:412
2-412
633 return;
executed: return;
Execution Count:2
2
634 indexNode->populatedChildren = true;
executed (the execution status of this line is deduced): indexNode->populatedChildren = true;
-
635 d->fileInfoGatherer.list(filePath(parent));
executed (the execution status of this line is deduced): d->fileInfoGatherer.list(filePath(parent));
-
636}
executed: }
Execution Count:412
412
637 -
638/*! -
639 \reimp -
640*/ -
641int QFileSystemModel::rowCount(const QModelIndex &parent) const -
642{ -
643 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
644 if (parent.column() > 0)
partially evaluated: parent.column() > 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:105875
0-105875
645 return 0;
never executed: return 0;
0
646 -
647 if (!parent.isValid())
evaluated: !parent.isValid()
TRUEFALSE
yes
Evaluation Count:6710
yes
Evaluation Count:99165
6710-99165
648 return d->root.visibleChildren.count();
executed: return d->root.visibleChildren.count();
Execution Count:6710
6710
649 -
650 const QFileSystemModelPrivate::QFileSystemNode *parentNode = d->node(parent);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate::QFileSystemNode *parentNode = d->node(parent);
-
651 return parentNode->visibleChildren.count();
executed: return parentNode->visibleChildren.count();
Execution Count:99165
99165
652} -
653 -
654/*! -
655 \reimp -
656*/ -
657int QFileSystemModel::columnCount(const QModelIndex &parent) const -
658{ -
659 return (parent.column() > 0) ? 0 : 4;
executed: return (parent.column() > 0) ? 0 : 4;
Execution Count:95951
95951
660} -
661 -
662/*! -
663 Returns the data stored under the given \a role for the item "My Computer". -
664 -
665 \sa Qt::ItemDataRole -
666 */ -
667QVariant QFileSystemModel::myComputer(int role) const -
668{ -
669 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
670 switch (role) { -
671 case Qt::DisplayRole: -
672 return d->myComputer();
executed: return d->myComputer();
Execution Count:298
298
673 case Qt::DecorationRole: -
674 return d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Computer);
executed: return d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Computer);
Execution Count:298
298
675 } -
676 return QVariant();
never executed: return QVariant();
0
677} -
678 -
679/*! -
680 \reimp -
681*/ -
682QVariant QFileSystemModel::data(const QModelIndex &index, int role) const -
683{ -
684 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
685 if (!index.isValid() || index.model() != this)
evaluated: !index.isValid()
TRUEFALSE
yes
Evaluation Count:893
yes
Evaluation Count:255359
partially evaluated: index.model() != this
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:255359
0-255359
686 return QVariant();
executed: return QVariant();
Execution Count:893
893
687 -
688 switch (role) { -
689 case Qt::EditRole: -
690 case Qt::DisplayRole: -
691 switch (index.column()) { -
692 case 0: return d->displayName(index);
executed: return d->displayName(index);
Execution Count:31228
31228
693 case 1: return d->size(index);
executed: return d->size(index);
Execution Count:1040
1040
694 case 2: return d->type(index);
executed: return d->type(index);
Execution Count:1040
1040
695 case 3: return d->time(index);
executed: return d->time(index);
Execution Count:1037
1037
696 default: -
697 qWarning("data: invalid display value column %d", index.column());
never executed (the execution status of this line is deduced): QMessageLogger("dialogs/qfilesystemmodel.cpp", 697, __PRETTY_FUNCTION__).warning("data: invalid display value column %d", index.column());
-
698 break;
never executed: break;
0
699 } -
700 break;
never executed: break;
0
701 case FilePathRole: -
702 return filePath(index);
executed: return filePath(index);
Execution Count:2509
2509
703 case FileNameRole: -
704 return d->name(index);
executed: return d->name(index);
Execution Count:3717
3717
705 case Qt::DecorationRole: -
706 if (index.column() == 0) {
evaluated: index.column() == 0
TRUEFALSE
yes
Evaluation Count:31376
yes
Evaluation Count:3117
3117-31376
707 QIcon icon = d->icon(index);
executed (the execution status of this line is deduced): QIcon icon = d->icon(index);
-
708 if (icon.isNull()) {
partially evaluated: icon.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:31376
0-31376
709 if (d->node(index)->isDir())
never evaluated: d->node(index)->isDir()
0
710 icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Folder);
never executed: icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Folder);
0
711 else -
712 icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::File);
never executed: icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::File);
0
713 } -
714 return icon;
executed: return icon;
Execution Count:31376
31376
715 } -
716 break;
executed: break;
Execution Count:3117
3117
717 case Qt::TextAlignmentRole: -
718 if (index.column() == 1)
evaluated: index.column() == 1
TRUEFALSE
yes
Evaluation Count:1001
yes
Evaluation Count:27588
1001-27588
719 return Qt::AlignRight;
executed: return Qt::AlignRight;
Execution Count:1001
1001
720 break;
executed: break;
Execution Count:27588
27588
721 case FilePermissions: -
722 int p = permissions(index);
executed (the execution status of this line is deduced): int p = permissions(index);
-
723 return p;
executed: return p;
Execution Count:3
3
724 } -
725 -
726 return QVariant();
executed: return QVariant();
Execution Count:182408
182408
727} -
728 -
729/*! -
730 \internal -
731*/ -
732QString QFileSystemModelPrivate::size(const QModelIndex &index) const -
733{ -
734 if (!index.isValid())
partially evaluated: !index.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1040
0-1040
735 return QString();
never executed: return QString();
0
736 const QFileSystemNode *n = node(index);
executed (the execution status of this line is deduced): const QFileSystemNode *n = node(index);
-
737 if (n->isDir()) {
evaluated: n->isDir()
TRUEFALSE
yes
Evaluation Count:555
yes
Evaluation Count:485
485-555
738#ifdef Q_OS_MAC -
739 return QLatin1String("--"); -
740#else -
741 return QLatin1String("");
executed: return QLatin1String("");
Execution Count:555
555
742#endif -
743 // Windows - "" -
744 // OS X - "--" -
745 // Konqueror - "4 KB" -
746 // Nautilus - "9 items" (the number of children) -
747 } -
748 return size(n->size());
executed: return size(n->size());
Execution Count:485
485
749} -
750 -
751QString QFileSystemModelPrivate::size(qint64 bytes) -
752{ -
753 // According to the Si standard KB is 1000 bytes, KiB is 1024 -
754 // but on windows sizes are calculated by dividing by 1024 so we do what they do. -
755 const qint64 kb = 1024;
executed (the execution status of this line is deduced): const qint64 kb = 1024;
-
756 const qint64 mb = 1024 * kb;
executed (the execution status of this line is deduced): const qint64 mb = 1024 * kb;
-
757 const qint64 gb = 1024 * mb;
executed (the execution status of this line is deduced): const qint64 gb = 1024 * mb;
-
758 const qint64 tb = 1024 * gb;
executed (the execution status of this line is deduced): const qint64 tb = 1024 * gb;
-
759 if (bytes >= tb)
partially evaluated: bytes >= tb
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:485
0-485
760 return QFileSystemModel::tr("%1 TB").arg(QLocale().toString(qreal(bytes) / tb, 'f', 3));
never executed: return QFileSystemModel::tr("%1 TB").arg(QLocale().toString(qreal(bytes) / tb, 'f', 3));
0
761 if (bytes >= gb)
partially evaluated: bytes >= gb
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:485
0-485
762 return QFileSystemModel::tr("%1 GB").arg(QLocale().toString(qreal(bytes) / gb, 'f', 2));
never executed: return QFileSystemModel::tr("%1 GB").arg(QLocale().toString(qreal(bytes) / gb, 'f', 2));
0
763 if (bytes >= mb)
evaluated: bytes >= mb
TRUEFALSE
yes
Evaluation Count:65
yes
Evaluation Count:420
65-420
764 return QFileSystemModel::tr("%1 MB").arg(QLocale().toString(qreal(bytes) / mb, 'f', 1));
executed: return QFileSystemModel::tr("%1 MB").arg(QLocale().toString(qreal(bytes) / mb, 'f', 1));
Execution Count:65
65
765 if (bytes >= kb)
evaluated: bytes >= kb
TRUEFALSE
yes
Evaluation Count:303
yes
Evaluation Count:117
117-303
766 return QFileSystemModel::tr("%1 KB").arg(QLocale().toString(bytes / kb));
executed: return QFileSystemModel::tr("%1 KB").arg(QLocale().toString(bytes / kb));
Execution Count:303
303
767 return QFileSystemModel::tr("%1 bytes").arg(QLocale().toString(bytes));
executed: return QFileSystemModel::tr("%1 bytes").arg(QLocale().toString(bytes));
Execution Count:117
117
768} -
769 -
770/*! -
771 \internal -
772*/ -
773QString QFileSystemModelPrivate::time(const QModelIndex &index) const -
774{ -
775 if (!index.isValid())
partially evaluated: !index.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1037
0-1037
776 return QString();
never executed: return QString();
0
777#ifndef QT_NO_DATESTRING -
778 return node(index)->lastModified().toString(Qt::SystemLocaleDate);
executed: return node(index)->lastModified().toString(Qt::SystemLocaleDate);
Execution Count:1037
1037
779#else -
780 Q_UNUSED(index); -
781 return QString(); -
782#endif -
783} -
784 -
785/* -
786 \internal -
787*/ -
788QString QFileSystemModelPrivate::type(const QModelIndex &index) const -
789{ -
790 if (!index.isValid())
partially evaluated: !index.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1040
0-1040
791 return QString();
never executed: return QString();
0
792 return node(index)->type();
executed: return node(index)->type();
Execution Count:1040
1040
793} -
794 -
795/*! -
796 \internal -
797*/ -
798QString QFileSystemModelPrivate::name(const QModelIndex &index) const -
799{ -
800 if (!index.isValid())
partially evaluated: !index.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34945
0-34945
801 return QString();
never executed: return QString();
0
802 QFileSystemNode *dirNode = node(index);
executed (the execution status of this line is deduced): QFileSystemNode *dirNode = node(index);
-
803 if (dirNode->isSymLink() && fileInfoGatherer.resolveSymlinks()) {
evaluated: dirNode->isSymLink()
TRUEFALSE
yes
Evaluation Count:593
yes
Evaluation Count:34352
partially evaluated: fileInfoGatherer.resolveSymlinks()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:593
0-34352
804 QString fullPath = QDir::fromNativeSeparators(filePath(index));
never executed (the execution status of this line is deduced): QString fullPath = QDir::fromNativeSeparators(filePath(index));
-
805 if (resolvedSymLinks.contains(fullPath))
never evaluated: resolvedSymLinks.contains(fullPath)
0
806 return resolvedSymLinks[fullPath];
never executed: return resolvedSymLinks[fullPath];
0
807 }
never executed: }
0
808 return dirNode->fileName;
executed: return dirNode->fileName;
Execution Count:34945
34945
809} -
810 -
811/*! -
812 \internal -
813*/ -
814QString QFileSystemModelPrivate::displayName(const QModelIndex &index) const -
815{ -
816#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -
817 QFileSystemNode *dirNode = node(index); -
818 if (!dirNode->volumeName.isNull()) -
819 return dirNode->volumeName + QLatin1String(" (") + name(index) + QLatin1Char(')'); -
820#endif -
821 return name(index);
executed: return name(index);
Execution Count:31228
31228
822} -
823 -
824/*! -
825 \internal -
826*/ -
827QIcon QFileSystemModelPrivate::icon(const QModelIndex &index) const -
828{ -
829 if (!index.isValid())
partially evaluated: !index.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:31376
0-31376
830 return QIcon();
never executed: return QIcon();
0
831 return node(index)->icon();
executed: return node(index)->icon();
Execution Count:31376
31376
832} -
833 -
834/*! -
835 \reimp -
836*/ -
837bool QFileSystemModel::setData(const QModelIndex &idx, const QVariant &value, int role) -
838{ -
839 Q_D(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModelPrivate * const d = d_func();
-
840 if (!idx.isValid()
partially evaluated: !idx.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
841 || idx.column() != 0
partially evaluated: idx.column() != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
842 || role != Qt::EditRole
partially evaluated: role != Qt::EditRole
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
843 || (flags(idx) & Qt::ItemIsEditable) == 0) {
evaluated: (flags(idx) & Qt::ItemIsEditable) == 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
844 return false;
executed: return false;
Execution Count:1
1
845 } -
846 -
847 QString newName = value.toString();
executed (the execution status of this line is deduced): QString newName = value.toString();
-
848 QString oldName = idx.data().toString();
executed (the execution status of this line is deduced): QString oldName = idx.data().toString();
-
849 if (newName == idx.data().toString())
partially evaluated: newName == idx.data().toString()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
850 return true;
never executed: return true;
0
851 -
852 if (newName.isEmpty()
partially evaluated: newName.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
853 || newName.contains(QDir::separator())
partially evaluated: newName.contains(QDir::separator())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
854 || !QDir(filePath(parent(idx))).rename(oldName, newName)) {
partially evaluated: !QDir(filePath(parent(idx))).rename(oldName, newName)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
855#ifndef QT_NO_MESSAGEBOX -
856 QMessageBox::information(0, QFileSystemModel::tr("Invalid filename"),
never executed (the execution status of this line is deduced): QMessageBox::information(0, QFileSystemModel::tr("Invalid filename"),
-
857 QFileSystemModel::tr("<b>The name \"%1\" can not be used.</b><p>Try using another name, with fewer characters or no punctuations marks.")
never executed (the execution status of this line is deduced): QFileSystemModel::tr("<b>The name \"%1\" can not be used.</b><p>Try using another name, with fewer characters or no punctuations marks.")
-
858 .arg(newName),
never executed (the execution status of this line is deduced): .arg(newName),
-
859 QMessageBox::Ok);
never executed (the execution status of this line is deduced): QMessageBox::Ok);
-
860#endif // QT_NO_MESSAGEBOX -
861 return false;
never executed: return false;
0
862 } else { -
863 /* -
864 *After re-naming something we don't want the selection to change* -
865 - can't remove rows and later insert -
866 - can't quickly remove and insert -
867 - index pointer can't change because treeview doesn't use persistant index's -
868 -
869 - if this get any more complicated think of changing it to just -
870 use layoutChanged -
871 */ -
872 -
873 QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(idx);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(idx);
-
874 QFileSystemModelPrivate::QFileSystemNode *parentNode = indexNode->parent;
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *parentNode = indexNode->parent;
-
875 int visibleLocation = parentNode->visibleLocation(parentNode->children.value(indexNode->fileName)->fileName);
executed (the execution status of this line is deduced): int visibleLocation = parentNode->visibleLocation(parentNode->children.value(indexNode->fileName)->fileName);
-
876 -
877 d->addNode(parentNode, newName,indexNode->info->fileInfo());
executed (the execution status of this line is deduced): d->addNode(parentNode, newName,indexNode->info->fileInfo());
-
878 parentNode->visibleChildren.removeAt(visibleLocation);
executed (the execution status of this line is deduced): parentNode->visibleChildren.removeAt(visibleLocation);
-
879 QFileSystemModelPrivate::QFileSystemNode * oldValue = parentNode->children.value(oldName);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode * oldValue = parentNode->children.value(oldName);
-
880 parentNode->children[newName] = oldValue;
executed (the execution status of this line is deduced): parentNode->children[newName] = oldValue;
-
881 QFileInfo info(d->rootDir, newName);
executed (the execution status of this line is deduced): QFileInfo info(d->rootDir, newName);
-
882 oldValue->fileName = newName;
executed (the execution status of this line is deduced): oldValue->fileName = newName;
-
883 oldValue->parent = parentNode;
executed (the execution status of this line is deduced): oldValue->parent = parentNode;
-
884 oldValue->populate(d->fileInfoGatherer.getInfo(info));
executed (the execution status of this line is deduced): oldValue->populate(d->fileInfoGatherer.getInfo(info));
-
885 oldValue->isVisible = true;
executed (the execution status of this line is deduced): oldValue->isVisible = true;
-
886 -
887 parentNode->children.remove(oldName);
executed (the execution status of this line is deduced): parentNode->children.remove(oldName);
-
888 parentNode->visibleChildren.insert(visibleLocation, newName);
executed (the execution status of this line is deduced): parentNode->visibleChildren.insert(visibleLocation, newName);
-
889 -
890 d->delayedSort();
executed (the execution status of this line is deduced): d->delayedSort();
-
891 emit fileRenamed(filePath(idx.parent()), oldName, newName);
executed (the execution status of this line is deduced): fileRenamed(filePath(idx.parent()), oldName, newName);
-
892 }
executed: }
Execution Count:1
1
893 return true;
executed: return true;
Execution Count:1
1
894} -
895 -
896/*! -
897 \reimp -
898*/ -
899QVariant QFileSystemModel::headerData(int section, Qt::Orientation orientation, int role) const -
900{ -
901 switch (role) { -
902 case Qt::DecorationRole: -
903 if (section == 0) {
evaluated: section == 0
TRUEFALSE
yes
Evaluation Count:136
yes
Evaluation Count:305
136-305
904 // ### TODO oh man this is ugly and doesn't even work all the way! -
905 // it is still 2 pixels off -
906 QImage pixmap(16, 1, QImage::Format_Mono);
executed (the execution status of this line is deduced): QImage pixmap(16, 1, QImage::Format_Mono);
-
907 pixmap.fill(0);
executed (the execution status of this line is deduced): pixmap.fill(0);
-
908 pixmap.setAlphaChannel(pixmap.createAlphaMask());
executed (the execution status of this line is deduced): pixmap.setAlphaChannel(pixmap.createAlphaMask());
-
909 return pixmap;
executed: return pixmap;
Execution Count:136
136
910 } -
911 break;
executed: break;
Execution Count:305
305
912 case Qt::TextAlignmentRole: -
913 return Qt::AlignLeft;
executed: return Qt::AlignLeft;
Execution Count:123
123
914 } -
915 -
916 if (orientation != Qt::Horizontal || role != Qt::DisplayRole)
partially evaluated: orientation != Qt::Horizontal
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2348
evaluated: role != Qt::DisplayRole
TRUEFALSE
yes
Evaluation Count:1340
yes
Evaluation Count:1008
0-2348
917 return QAbstractItemModel::headerData(section, orientation, role);
executed: return QAbstractItemModel::headerData(section, orientation, role);
Execution Count:1340
1340
918 -
919 QString returnValue;
executed (the execution status of this line is deduced): QString returnValue;
-
920 switch (section) { -
921 case 0: returnValue = tr("Name");
executed (the execution status of this line is deduced): case 0: returnValue = tr("Name");
-
922 break;
executed: break;
Execution Count:136
136
923 case 1: returnValue = tr("Size");
executed (the execution status of this line is deduced): case 1: returnValue = tr("Size");
-
924 break;
executed: break;
Execution Count:293
293
925 case 2: returnValue =
executed (the execution status of this line is deduced): case 2: returnValue =
-
926#ifdef Q_OS_MAC
executed (the execution status of this line is deduced):
-
927 tr("Kind", "Match OS X Finder");
executed (the execution status of this line is deduced):
-
928#else
executed (the execution status of this line is deduced):
-
929 tr("Type", "All other platforms");
executed (the execution status of this line is deduced): tr("Type", "All other platforms");
-
930#endif -
931 break;
executed: break;
Execution Count:291
291
932 // Windows - Type -
933 // OS X - Kind -
934 // Konqueror - File Type -
935 // Nautilus - Type -
936 case 3: returnValue = tr("Date Modified");
executed (the execution status of this line is deduced): case 3: returnValue = tr("Date Modified");
-
937 break;
executed: break;
Execution Count:288
288
938 default: return QVariant();
never executed: return QVariant();
0
939 } -
940 return returnValue;
executed: return returnValue;
Execution Count:1008
1008
941} -
942 -
943/*! -
944 \reimp -
945*/ -
946Qt::ItemFlags QFileSystemModel::flags(const QModelIndex &index) const -
947{ -
948 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
949 Qt::ItemFlags flags = QAbstractItemModel::flags(index);
executed (the execution status of this line is deduced): Qt::ItemFlags flags = QAbstractItemModel::flags(index);
-
950 if (!index.isValid())
evaluated: !index.isValid()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:7030
1-7030
951 return flags;
executed: return flags;
Execution Count:1
1
952 -
953 QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(index);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(index);
-
954 if (d->nameFilterDisables && !d->passNameFilters(indexNode)) {
evaluated: d->nameFilterDisables
TRUEFALSE
yes
Evaluation Count:1455
yes
Evaluation Count:5575
partially evaluated: !d->passNameFilters(indexNode)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1455
0-5575
955 flags &= ~Qt::ItemIsEnabled;
never executed (the execution status of this line is deduced): flags &= ~Qt::ItemIsEnabled;
-
956 // ### TODO you shouldn't be able to set this as the current item, task 119433 -
957 return flags;
never executed: return flags;
0
958 } -
959 -
960 flags |= Qt::ItemIsDragEnabled;
executed (the execution status of this line is deduced): flags |= Qt::ItemIsDragEnabled;
-
961 if (d->readOnly)
evaluated: d->readOnly
TRUEFALSE
yes
Evaluation Count:1453
yes
Evaluation Count:5577
1453-5577
962 return flags;
executed: return flags;
Execution Count:1453
1453
963 if ((index.column() == 0) && indexNode->permissions() & QFile::WriteUser) {
evaluated: (index.column() == 0)
TRUEFALSE
yes
Evaluation Count:5249
yes
Evaluation Count:328
evaluated: indexNode->permissions() & QFile::WriteUser
TRUEFALSE
yes
Evaluation Count:3845
yes
Evaluation Count:1404
328-5249
964 flags |= Qt::ItemIsEditable;
executed (the execution status of this line is deduced): flags |= Qt::ItemIsEditable;
-
965 if (indexNode->isDir())
evaluated: indexNode->isDir()
TRUEFALSE
yes
Evaluation Count:3339
yes
Evaluation Count:506
506-3339
966 flags |= Qt::ItemIsDropEnabled;
executed: flags |= Qt::ItemIsDropEnabled;
Execution Count:3339
3339
967 }
executed: }
Execution Count:3845
3845
968 return flags;
executed: return flags;
Execution Count:5577
5577
969} -
970 -
971/*! -
972 \internal -
973*/ -
974void QFileSystemModelPrivate::_q_performDelayedSort() -
975{ -
976 Q_Q(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModel * const q = q_func();
-
977 q->sort(sortColumn, sortOrder);
executed (the execution status of this line is deduced): q->sort(sortColumn, sortOrder);
-
978}
executed: }
Execution Count:164
164
979 -
980static inline QChar getNextChar(const QString &s, int location) -
981{ -
982 return (location < s.length()) ? s.at(location) : QChar();
executed: return (location < s.length()) ? s.at(location) : QChar();
Execution Count:1960658
1960658
983} -
984 -
985/*! -
986 Natural number sort, skips spaces. -
987 -
988 Examples: -
989 1, 2, 10, 55, 100 -
990 01.jpg, 2.jpg, 10.jpg -
991 -
992 Note on the algorithm: -
993 Only as many characters as necessary are looked at and at most they all -
994 are looked at once. -
995 -
996 Slower then QString::compare() (of course) -
997 */ -
998int QFileSystemModelPrivate::naturalCompare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs) -
999{ -
1000 for (int l1 = 0, l2 = 0; l1 <= s1.count() && l2 <= s2.count(); ++l1, ++l2) {
evaluated: l1 <= s1.count()
TRUEFALSE
yes
Evaluation Count:929262
yes
Evaluation Count:2182
partially evaluated: l2 <= s2.count()
TRUEFALSE
yes
Evaluation Count:929262
no
Evaluation Count:0
0-929262
1001 // skip spaces, tabs and 0's -
1002 QChar c1 = getNextChar(s1, l1);
executed (the execution status of this line is deduced): QChar c1 = getNextChar(s1, l1);
-
1003 while (c1.isSpace())
partially evaluated: c1.isSpace()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:929262
0-929262
1004 c1 = getNextChar(s1, ++l1);
never executed: c1 = getNextChar(s1, ++l1);
0
1005 QChar c2 = getNextChar(s2, l2);
executed (the execution status of this line is deduced): QChar c2 = getNextChar(s2, l2);
-
1006 while (c2.isSpace())
partially evaluated: c2.isSpace()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:929262
0-929262
1007 c2 = getNextChar(s2, ++l2);
never executed: c2 = getNextChar(s2, ++l2);
0
1008 -
1009 if (c1.isDigit() && c2.isDigit()) {
evaluated: c1.isDigit()
TRUEFALSE
yes
Evaluation Count:52582
yes
Evaluation Count:876680
evaluated: c2.isDigit()
TRUEFALSE
yes
Evaluation Count:41301
yes
Evaluation Count:11281
11281-876680
1010 while (c1.digitValue() == 0)
evaluated: c1.digitValue() == 0
TRUEFALSE
yes
Evaluation Count:6536
yes
Evaluation Count:41301
6536-41301
1011 c1 = getNextChar(s1, ++l1);
executed: c1 = getNextChar(s1, ++l1);
Execution Count:6536
6536
1012 while (c2.digitValue() == 0)
evaluated: c2.digitValue() == 0
TRUEFALSE
yes
Evaluation Count:5798
yes
Evaluation Count:41301
5798-41301
1013 c2 = getNextChar(s2, ++l2);
executed: c2 = getNextChar(s2, ++l2);
Execution Count:5798
5798
1014 -
1015 int lookAheadLocation1 = l1;
executed (the execution status of this line is deduced): int lookAheadLocation1 = l1;
-
1016 int lookAheadLocation2 = l2;
executed (the execution status of this line is deduced): int lookAheadLocation2 = l2;
-
1017 int currentReturnValue = 0;
executed (the execution status of this line is deduced): int currentReturnValue = 0;
-
1018 // find the last digit, setting currentReturnValue as we go if it isn't equal -
1019 for ( -
1020 QChar lookAhead1 = c1, lookAhead2 = c2;
executed (the execution status of this line is deduced): QChar lookAhead1 = c1, lookAhead2 = c2;
-
1021 (lookAheadLocation1 <= s1.length() && lookAheadLocation2 <= s2.length());
partially evaluated: lookAheadLocation1 <= s1.length()
TRUEFALSE
yes
Evaluation Count:86201
no
Evaluation Count:0
partially evaluated: lookAheadLocation2 <= s2.length()
TRUEFALSE
yes
Evaluation Count:86201
no
Evaluation Count:0
0-86201
1022 lookAhead1 = getNextChar(s1, ++lookAheadLocation1),
executed (the execution status of this line is deduced): lookAhead1 = getNextChar(s1, ++lookAheadLocation1),
-
1023 lookAhead2 = getNextChar(s2, ++lookAheadLocation2)
executed (the execution status of this line is deduced): lookAhead2 = getNextChar(s2, ++lookAheadLocation2)
-
1024 ) { -
1025 bool is1ADigit = !lookAhead1.isNull() && lookAhead1.isDigit();
evaluated: !lookAhead1.isNull()
TRUEFALSE
yes
Evaluation Count:84943
yes
Evaluation Count:1258
evaluated: lookAhead1.isDigit()
TRUEFALSE
yes
Evaluation Count:47665
yes
Evaluation Count:37278
1258-84943
1026 bool is2ADigit = !lookAhead2.isNull() && lookAhead2.isDigit();
evaluated: !lookAhead2.isNull()
TRUEFALSE
yes
Evaluation Count:84944
yes
Evaluation Count:1257
evaluated: lookAhead2.isDigit()
TRUEFALSE
yes
Evaluation Count:49455
yes
Evaluation Count:35489
1257-84944
1027 if (!is1ADigit && !is2ADigit)
evaluated: !is1ADigit
TRUEFALSE
yes
Evaluation Count:38536
yes
Evaluation Count:47665
evaluated: !is2ADigit
TRUEFALSE
yes
Evaluation Count:33981
yes
Evaluation Count:4555
4555-47665
1028 break;
executed: break;
Execution Count:33981
33981
1029 if (!is1ADigit)
evaluated: !is1ADigit
TRUEFALSE
yes
Evaluation Count:4555
yes
Evaluation Count:47665
4555-47665
1030 return -1;
executed: return -1;
Execution Count:4555
4555
1031 if (!is2ADigit)
evaluated: !is2ADigit
TRUEFALSE
yes
Evaluation Count:2765
yes
Evaluation Count:44900
2765-44900
1032 return 1;
executed: return 1;
Execution Count:2765
2765
1033 if (currentReturnValue == 0) {
evaluated: currentReturnValue == 0
TRUEFALSE
yes
Evaluation Count:40398
yes
Evaluation Count:4502
4502-40398
1034 if (lookAhead1 < lookAhead2) {
evaluated: lookAhead1 < lookAhead2
TRUEFALSE
yes
Evaluation Count:8367
yes
Evaluation Count:32031
8367-32031
1035 currentReturnValue = -1;
executed (the execution status of this line is deduced): currentReturnValue = -1;
-
1036 } else if (lookAhead1 > lookAhead2) {
executed: }
Execution Count:8367
evaluated: lookAhead1 > lookAhead2
TRUEFALSE
yes
Evaluation Count:5404
yes
Evaluation Count:26627
5404-26627
1037 currentReturnValue = 1;
executed (the execution status of this line is deduced): currentReturnValue = 1;
-
1038 }
executed: }
Execution Count:5404
5404
1039 } -
1040 }
executed: }
Execution Count:44900
44900
1041 if (currentReturnValue != 0)
evaluated: currentReturnValue != 0
TRUEFALSE
yes
Evaluation Count:9797
yes
Evaluation Count:24184
9797-24184
1042 return currentReturnValue;
executed: return currentReturnValue;
Execution Count:9797
9797
1043 }
executed: }
Execution Count:24184
24184
1044 -
1045 if (cs == Qt::CaseInsensitive) {
partially evaluated: cs == Qt::CaseInsensitive
TRUEFALSE
yes
Evaluation Count:912145
no
Evaluation Count:0
0-912145
1046 if (!c1.isLower()) c1 = c1.toLower();
executed: c1 = c1.toLower();
Execution Count:121968
evaluated: !c1.isLower()
TRUEFALSE
yes
Evaluation Count:121968
yes
Evaluation Count:790177
121968-790177
1047 if (!c2.isLower()) c2 = c2.toLower();
executed: c2 = c2.toLower();
Execution Count:117351
evaluated: !c2.isLower()
TRUEFALSE
yes
Evaluation Count:117351
yes
Evaluation Count:794794
117351-794794
1048 }
executed: }
Execution Count:912145
912145
1049 int r = QString::localeAwareCompare(c1, c2);
executed (the execution status of this line is deduced): int r = QString::localeAwareCompare(c1, c2);
-
1050 if (r < 0)
evaluated: r < 0
TRUEFALSE
yes
Evaluation Count:123786
yes
Evaluation Count:788359
123786-788359
1051 return -1;
executed: return -1;
Execution Count:123786
123786
1052 if (r > 0)
evaluated: r > 0
TRUEFALSE
yes
Evaluation Count:74874
yes
Evaluation Count:713485
74874-713485
1053 return 1;
executed: return 1;
Execution Count:74874
74874
1054 }
executed: }
Execution Count:713485
713485
1055 // The two strings are the same (02 == 2) so fall back to the normal sort -
1056 return QString::compare(s1, s2, cs);
executed: return QString::compare(s1, s2, cs);
Execution Count:2182
2182
1057} -
1058 -
1059/* -
1060 \internal -
1061 Helper functor used by sort() -
1062*/ -
1063class QFileSystemModelSorter -
1064{ -
1065public: -
1066 inline QFileSystemModelSorter(int column) : sortColumn(column) {}
executed: }
Execution Count:152
152
1067 -
1068 bool compareNodes(const QFileSystemModelPrivate::QFileSystemNode *l, -
1069 const QFileSystemModelPrivate::QFileSystemNode *r) const -
1070 { -
1071 switch (sortColumn) { -
1072 case 0: { -
1073#ifndef Q_OS_MAC -
1074 // place directories before files -
1075 bool left = l->isDir();
executed (the execution status of this line is deduced): bool left = l->isDir();
-
1076 bool right = r->isDir();
executed (the execution status of this line is deduced): bool right = r->isDir();
-
1077 if (left ^ right)
evaluated: left ^ right
TRUEFALSE
yes
Evaluation Count:3656
yes
Evaluation Count:194311
3656-194311
1078 return left;
executed: return left;
Execution Count:3656
3656
1079#endif -
1080 return QFileSystemModelPrivate::naturalCompare(l->fileName,
executed: return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0;
Execution Count:194311
194311
1081 r->fileName, Qt::CaseInsensitive) < 0;
executed: return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0;
Execution Count:194311
194311
1082 } -
1083 case 1: -
1084 { -
1085 // Directories go first -
1086 bool left = l->isDir();
executed (the execution status of this line is deduced): bool left = l->isDir();
-
1087 bool right = r->isDir();
executed (the execution status of this line is deduced): bool right = r->isDir();
-
1088 if (left ^ right)
evaluated: left ^ right
TRUEFALSE
yes
Evaluation Count:587
yes
Evaluation Count:47695
587-47695
1089 return left;
executed: return left;
Execution Count:587
587
1090 -
1091 qint64 sizeDifference = l->size() - r->size();
executed (the execution status of this line is deduced): qint64 sizeDifference = l->size() - r->size();
-
1092 if (sizeDifference == 0)
evaluated: sizeDifference == 0
TRUEFALSE
yes
Evaluation Count:23634
yes
Evaluation Count:24061
23634-24061
1093 return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0;
executed: return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0;
Execution Count:23634
23634
1094 -
1095 return sizeDifference < 0;
executed: return sizeDifference < 0;
Execution Count:24061
24061
1096 } -
1097 case 2: -
1098 { -
1099 int compare = QString::localeAwareCompare(l->type(), r->type());
never executed (the execution status of this line is deduced): int compare = QString::localeAwareCompare(l->type(), r->type());
-
1100 if (compare == 0)
never evaluated: compare == 0
0
1101 return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0;
never executed: return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0;
0
1102 -
1103 return compare < 0;
never executed: return compare < 0;
0
1104 } -
1105 case 3: -
1106 { -
1107 if (l->lastModified() == r->lastModified())
evaluated: l->lastModified() == r->lastModified()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:29
14-29
1108 return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0;
executed: return QFileSystemModelPrivate::naturalCompare(l->fileName, r->fileName, Qt::CaseInsensitive) < 0;
Execution Count:14
14
1109 -
1110 return l->lastModified() < r->lastModified();
executed: return l->lastModified() < r->lastModified();
Execution Count:29
29
1111 } -
1112 } -
1113 Q_ASSERT(false);
never executed (the execution status of this line is deduced): qt_noop();
-
1114 return false;
never executed: return false;
0
1115 } -
1116 -
1117 bool operator()(const QPair<QFileSystemModelPrivate::QFileSystemNode*, int> &l, -
1118 const QPair<QFileSystemModelPrivate::QFileSystemNode*, int> &r) const -
1119 { -
1120 return compareNodes(l.first, r.first);
executed: return compareNodes(l.first, r.first);
Execution Count:246292
246292
1121 } -
1122 -
1123 -
1124private: -
1125 int sortColumn; -
1126}; -
1127 -
1128/* -
1129 \internal -
1130 -
1131 Sort all of the children of parent -
1132*/ -
1133void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent) -
1134{ -
1135 Q_Q(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModel * const q = q_func();
-
1136 QFileSystemModelPrivate::QFileSystemNode *indexNode = node(parent);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *indexNode = node(parent);
-
1137 if (indexNode->children.count() == 0)
evaluated: indexNode->children.count() == 0
TRUEFALSE
yes
Evaluation Count:10054
yes
Evaluation Count:152
152-10054
1138 return;
executed: return;
Execution Count:10054
10054
1139 -
1140 QList<QPair<QFileSystemModelPrivate::QFileSystemNode*, int> > values;
executed (the execution status of this line is deduced): QList<QPair<QFileSystemModelPrivate::QFileSystemNode*, int> > values;
-
1141 QHash<QString, QFileSystemNode *>::const_iterator iterator;
executed (the execution status of this line is deduced): QHash<QString, QFileSystemNode *>::const_iterator iterator;
-
1142 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
1143 for(iterator = indexNode->children.constBegin() ; iterator != indexNode->children.constEnd() ; ++iterator) {
evaluated: iterator != indexNode->children.constEnd()
TRUEFALSE
yes
Evaluation Count:20395
yes
Evaluation Count:152
152-20395
1144 if (filtersAcceptsNode(iterator.value())) {
evaluated: filtersAcceptsNode(iterator.value())
TRUEFALSE
yes
Evaluation Count:19756
yes
Evaluation Count:639
639-19756
1145 values.append(QPair<QFileSystemModelPrivate::QFileSystemNode*, int>((iterator.value()), i));
executed (the execution status of this line is deduced): values.append(QPair<QFileSystemModelPrivate::QFileSystemNode*, int>((iterator.value()), i));
-
1146 } else {
executed: }
Execution Count:19756
19756
1147 iterator.value()->isVisible = false;
executed (the execution status of this line is deduced): iterator.value()->isVisible = false;
-
1148 }
executed: }
Execution Count:639
639
1149 i++;
executed (the execution status of this line is deduced): i++;
-
1150 }
executed: }
Execution Count:20395
20395
1151 QFileSystemModelSorter ms(column);
executed (the execution status of this line is deduced): QFileSystemModelSorter ms(column);
-
1152 std::sort(values.begin(), values.end(), ms);
executed (the execution status of this line is deduced): std::sort(values.begin(), values.end(), ms);
-
1153 // First update the new visible list -
1154 indexNode->visibleChildren.clear();
executed (the execution status of this line is deduced): indexNode->visibleChildren.clear();
-
1155 //No more dirty item we reset our internal dirty index -
1156 indexNode->dirtyChildrenIndex = -1;
executed (the execution status of this line is deduced): indexNode->dirtyChildrenIndex = -1;
-
1157 for (int i = 0; i < values.count(); ++i) {
evaluated: i < values.count()
TRUEFALSE
yes
Evaluation Count:19756
yes
Evaluation Count:152
152-19756
1158 indexNode->visibleChildren.append(values.at(i).first->fileName);
executed (the execution status of this line is deduced): indexNode->visibleChildren.append(values.at(i).first->fileName);
-
1159 values.at(i).first->isVisible = true;
executed (the execution status of this line is deduced): values.at(i).first->isVisible = true;
-
1160 }
executed: }
Execution Count:19756
19756
1161 -
1162 if (!disableRecursiveSort) {
evaluated: !disableRecursiveSort
TRUEFALSE
yes
Evaluation Count:91
yes
Evaluation Count:61
61-91
1163 for (int i = 0; i < q->rowCount(parent); ++i) {
evaluated: i < q->rowCount(parent)
TRUEFALSE
yes
Evaluation Count:9742
yes
Evaluation Count:91
91-9742
1164 const QModelIndex childIndex = q->index(i, 0, parent);
executed (the execution status of this line is deduced): const QModelIndex childIndex = q->index(i, 0, parent);
-
1165 QFileSystemModelPrivate::QFileSystemNode *indexNode = node(childIndex);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *indexNode = node(childIndex);
-
1166 //Only do a recursive sort on visible nodes -
1167 if (indexNode->isVisible)
partially evaluated: indexNode->isVisible
TRUEFALSE
yes
Evaluation Count:9742
no
Evaluation Count:0
0-9742
1168 sortChildren(column, childIndex);
executed: sortChildren(column, childIndex);
Execution Count:9742
9742
1169 }
executed: }
Execution Count:9742
9742
1170 }
executed: }
Execution Count:91
91
1171}
executed: }
Execution Count:152
152
1172 -
1173/*! -
1174 \reimp -
1175*/ -
1176void QFileSystemModel::sort(int column, Qt::SortOrder order) -
1177{ -
1178 Q_D(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModelPrivate * const d = d_func();
-
1179 if (d->sortOrder == order && d->sortColumn == column && !d->forceSort)
evaluated: d->sortOrder == order
TRUEFALSE
yes
Evaluation Count:471
yes
Evaluation Count:15
evaluated: d->sortColumn == column
TRUEFALSE
yes
Evaluation Count:469
yes
Evaluation Count:2
evaluated: !d->forceSort
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:457
2-471
1180 return;
executed: return;
Execution Count:12
12
1181 -
1182 emit layoutAboutToBeChanged();
executed (the execution status of this line is deduced): layoutAboutToBeChanged();
-
1183 QModelIndexList oldList = persistentIndexList();
executed (the execution status of this line is deduced): QModelIndexList oldList = persistentIndexList();
-
1184 QList<QPair<QFileSystemModelPrivate::QFileSystemNode*, int> > oldNodes;
executed (the execution status of this line is deduced): QList<QPair<QFileSystemModelPrivate::QFileSystemNode*, int> > oldNodes;
-
1185 for (int i = 0; i < oldList.count(); ++i) {
evaluated: i < oldList.count()
TRUEFALSE
yes
Evaluation Count:192
yes
Evaluation Count:474
192-474
1186 QPair<QFileSystemModelPrivate::QFileSystemNode*, int> pair(d->node(oldList.at(i)), oldList.at(i).column());
executed (the execution status of this line is deduced): QPair<QFileSystemModelPrivate::QFileSystemNode*, int> pair(d->node(oldList.at(i)), oldList.at(i).column());
-
1187 oldNodes.append(pair);
executed (the execution status of this line is deduced): oldNodes.append(pair);
-
1188 }
executed: }
Execution Count:192
192
1189 -
1190 if (!(d->sortColumn == column && d->sortOrder != order && !d->forceSort)) {
evaluated: d->sortColumn == column
TRUEFALSE
yes
Evaluation Count:469
yes
Evaluation Count:5
evaluated: d->sortOrder != order
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:457
evaluated: !d->forceSort
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:2
2-469
1191 //we sort only from where we are, don't need to sort all the model -
1192 d->sortChildren(column, index(rootPath()));
executed (the execution status of this line is deduced): d->sortChildren(column, index(rootPath()));
-
1193 d->sortColumn = column;
executed (the execution status of this line is deduced): d->sortColumn = column;
-
1194 d->forceSort = false;
executed (the execution status of this line is deduced): d->forceSort = false;
-
1195 }
executed: }
Execution Count:464
464
1196 d->sortOrder = order;
executed (the execution status of this line is deduced): d->sortOrder = order;
-
1197 -
1198 QModelIndexList newList;
executed (the execution status of this line is deduced): QModelIndexList newList;
-
1199 for (int i = 0; i < oldNodes.count(); ++i) {
evaluated: i < oldNodes.count()
TRUEFALSE
yes
Evaluation Count:192
yes
Evaluation Count:474
192-474
1200 QModelIndex idx = d->index(oldNodes.at(i).first);
executed (the execution status of this line is deduced): QModelIndex idx = d->index(oldNodes.at(i).first);
-
1201 idx = idx.sibling(idx.row(), oldNodes.at(i).second);
executed (the execution status of this line is deduced): idx = idx.sibling(idx.row(), oldNodes.at(i).second);
-
1202 newList.append(idx);
executed (the execution status of this line is deduced): newList.append(idx);
-
1203 }
executed: }
Execution Count:192
192
1204 changePersistentIndexList(oldList, newList);
executed (the execution status of this line is deduced): changePersistentIndexList(oldList, newList);
-
1205 emit layoutChanged();
executed (the execution status of this line is deduced): layoutChanged();
-
1206}
executed: }
Execution Count:474
474
1207 -
1208/*! -
1209 Returns a list of MIME types that can be used to describe a list of items -
1210 in the model. -
1211*/ -
1212QStringList QFileSystemModel::mimeTypes() const -
1213{ -
1214 return QStringList(QLatin1String("text/uri-list"));
never executed: return QStringList(QLatin1String("text/uri-list"));
0
1215} -
1216 -
1217/*! -
1218 Returns an object that contains a serialized description of the specified -
1219 \a indexes. The format used to describe the items corresponding to the -
1220 indexes is obtained from the mimeTypes() function. -
1221 -
1222 If the list of indexes is empty, 0 is returned rather than a serialized -
1223 empty list. -
1224*/ -
1225QMimeData *QFileSystemModel::mimeData(const QModelIndexList &indexes) const -
1226{ -
1227 QList<QUrl> urls;
never executed (the execution status of this line is deduced): QList<QUrl> urls;
-
1228 QList<QModelIndex>::const_iterator it = indexes.begin();
never executed (the execution status of this line is deduced): QList<QModelIndex>::const_iterator it = indexes.begin();
-
1229 for (; it != indexes.end(); ++it)
never evaluated: it != indexes.end()
0
1230 if ((*it).column() == 0)
never evaluated: (*it).column() == 0
0
1231 urls << QUrl::fromLocalFile(filePath(*it));
never executed: urls << QUrl::fromLocalFile(filePath(*it));
0
1232 QMimeData *data = new QMimeData();
never executed (the execution status of this line is deduced): QMimeData *data = new QMimeData();
-
1233 data->setUrls(urls);
never executed (the execution status of this line is deduced): data->setUrls(urls);
-
1234 return data;
never executed: return data;
0
1235} -
1236 -
1237/*! -
1238 Handles the \a data supplied by a drag and drop operation that ended with -
1239 the given \a action over the row in the model specified by the \a row and -
1240 \a column and by the \a parent index. -
1241 -
1242 \sa supportedDropActions() -
1243*/ -
1244bool QFileSystemModel::dropMimeData(const QMimeData *data, Qt::DropAction action, -
1245 int row, int column, const QModelIndex &parent) -
1246{ -
1247 Q_UNUSED(row);
never executed (the execution status of this line is deduced): (void)row;;
-
1248 Q_UNUSED(column);
never executed (the execution status of this line is deduced): (void)column;;
-
1249 if (!parent.isValid() || isReadOnly())
never evaluated: !parent.isValid()
never evaluated: isReadOnly()
0
1250 return false;
never executed: return false;
0
1251 -
1252 bool success = true;
never executed (the execution status of this line is deduced): bool success = true;
-
1253 QString to = filePath(parent) + QDir::separator();
never executed (the execution status of this line is deduced): QString to = filePath(parent) + QDir::separator();
-
1254 -
1255 QList<QUrl> urls = data->urls();
never executed (the execution status of this line is deduced): QList<QUrl> urls = data->urls();
-
1256 QList<QUrl>::const_iterator it = urls.constBegin();
never executed (the execution status of this line is deduced): QList<QUrl>::const_iterator it = urls.constBegin();
-
1257 -
1258 switch (action) { -
1259 case Qt::CopyAction: -
1260 for (; it != urls.constEnd(); ++it) {
never evaluated: it != urls.constEnd()
0
1261 QString path = (*it).toLocalFile();
never executed (the execution status of this line is deduced): QString path = (*it).toLocalFile();
-
1262 success = QFile::copy(path, to + QFileInfo(path).fileName()) && success;
never evaluated: QFile::copy(path, to + QFileInfo(path).fileName())
never evaluated: success
0
1263 }
never executed: }
0
1264 break;
never executed: break;
0
1265 case Qt::LinkAction: -
1266 for (; it != urls.constEnd(); ++it) {
never evaluated: it != urls.constEnd()
0
1267 QString path = (*it).toLocalFile();
never executed (the execution status of this line is deduced): QString path = (*it).toLocalFile();
-
1268 success = QFile::link(path, to + QFileInfo(path).fileName()) && success;
never evaluated: QFile::link(path, to + QFileInfo(path).fileName())
never evaluated: success
0
1269 }
never executed: }
0
1270 break;
never executed: break;
0
1271 case Qt::MoveAction: -
1272 for (; it != urls.constEnd(); ++it) {
never evaluated: it != urls.constEnd()
0
1273 QString path = (*it).toLocalFile();
never executed (the execution status of this line is deduced): QString path = (*it).toLocalFile();
-
1274 success = QFile::rename(path, to + QFileInfo(path).fileName()) && success;
never evaluated: QFile::rename(path, to + QFileInfo(path).fileName())
never evaluated: success
0
1275 }
never executed: }
0
1276 break;
never executed: break;
0
1277 default: -
1278 return false;
never executed: return false;
0
1279 } -
1280 -
1281 return success;
never executed: return success;
0
1282} -
1283 -
1284/*! -
1285 \reimp -
1286*/ -
1287Qt::DropActions QFileSystemModel::supportedDropActions() const -
1288{ -
1289 return Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
never executed: return Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
0
1290} -
1291 -
1292/*! -
1293 Returns the path of the item stored in the model under the -
1294 \a index given. -
1295*/ -
1296QString QFileSystemModel::filePath(const QModelIndex &index) const -
1297{ -
1298 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
1299 QString fullPath = d->filePath(index);
executed (the execution status of this line is deduced): QString fullPath = d->filePath(index);
-
1300 QFileSystemModelPrivate::QFileSystemNode *dirNode = d->node(index);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *dirNode = d->node(index);
-
1301 if (dirNode->isSymLink() && d->fileInfoGatherer.resolveSymlinks()
partially evaluated: dirNode->isSymLink()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5364
never evaluated: d->fileInfoGatherer.resolveSymlinks()
0-5364
1302 && d->resolvedSymLinks.contains(fullPath)
never evaluated: d->resolvedSymLinks.contains(fullPath)
0
1303 && dirNode->isDir()) {
never evaluated: dirNode->isDir()
0
1304 QFileInfo resolvedInfo(fullPath);
never executed (the execution status of this line is deduced): QFileInfo resolvedInfo(fullPath);
-
1305 resolvedInfo = resolvedInfo.canonicalFilePath();
never executed (the execution status of this line is deduced): resolvedInfo = resolvedInfo.canonicalFilePath();
-
1306 if (resolvedInfo.exists())
never evaluated: resolvedInfo.exists()
0
1307 return resolvedInfo.filePath();
never executed: return resolvedInfo.filePath();
0
1308 }
never executed: }
0
1309 return fullPath;
executed: return fullPath;
Execution Count:5364
5364
1310} -
1311 -
1312QString QFileSystemModelPrivate::filePath(const QModelIndex &index) const -
1313{ -
1314 Q_Q(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModel * const q = q_func();
-
1315 Q_UNUSED(q);
executed (the execution status of this line is deduced): (void)q;;
-
1316 if (!index.isValid())
evaluated: !index.isValid()
TRUEFALSE
yes
Evaluation Count:344
yes
Evaluation Count:5020
344-5020
1317 return QString();
executed: return QString();
Execution Count:344
344
1318 Q_ASSERT(index.model() == q);
executed (the execution status of this line is deduced): qt_noop();
-
1319 -
1320 QStringList path;
executed (the execution status of this line is deduced): QStringList path;
-
1321 QModelIndex idx = index;
executed (the execution status of this line is deduced): QModelIndex idx = index;
-
1322 while (idx.isValid()) {
evaluated: idx.isValid()
TRUEFALSE
yes
Evaluation Count:27852
yes
Evaluation Count:5020
5020-27852
1323 QFileSystemModelPrivate::QFileSystemNode *dirNode = node(idx);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *dirNode = node(idx);
-
1324 if (dirNode)
partially evaluated: dirNode
TRUEFALSE
yes
Evaluation Count:27852
no
Evaluation Count:0
0-27852
1325 path.prepend(dirNode->fileName);
executed: path.prepend(dirNode->fileName);
Execution Count:27852
27852
1326 idx = idx.parent();
executed (the execution status of this line is deduced): idx = idx.parent();
-
1327 }
executed: }
Execution Count:27852
27852
1328 QString fullPath = QDir::fromNativeSeparators(path.join(QDir::separator()));
executed (the execution status of this line is deduced): QString fullPath = QDir::fromNativeSeparators(path.join(QDir::separator()));
-
1329#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE) -
1330 if ((fullPath.length() > 2) && fullPath[0] == QLatin1Char('/') && fullPath[1] == QLatin1Char('/'))
evaluated: (fullPath.length() > 2)
TRUEFALSE
yes
Evaluation Count:4597
yes
Evaluation Count:423
partially evaluated: fullPath[0] == QLatin1Char('/')
TRUEFALSE
yes
Evaluation Count:4597
no
Evaluation Count:0
partially evaluated: fullPath[1] == QLatin1Char('/')
TRUEFALSE
yes
Evaluation Count:4597
no
Evaluation Count:0
0-4597
1331 fullPath = fullPath.mid(1);
executed: fullPath = fullPath.mid(1);
Execution Count:4597
4597
1332#endif -
1333#if defined(Q_OS_WIN) -
1334 if (fullPath.length() == 2 && fullPath.endsWith(QLatin1Char(':'))) -
1335 fullPath.append(QLatin1Char('/')); -
1336#endif -
1337 return fullPath;
executed: return fullPath;
Execution Count:5020
5020
1338} -
1339 -
1340/*! -
1341 Create a directory with the \a name in the \a parent model index. -
1342*/ -
1343QModelIndex QFileSystemModel::mkdir(const QModelIndex &parent, const QString &name) -
1344{ -
1345 Q_D(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModelPrivate * const d = d_func();
-
1346 if (!parent.isValid())
partially evaluated: !parent.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1347 return parent;
never executed: return parent;
0
1348 -
1349 QDir dir(filePath(parent));
executed (the execution status of this line is deduced): QDir dir(filePath(parent));
-
1350 if (!dir.mkdir(name))
partially evaluated: !dir.mkdir(name)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
1351 return QModelIndex();
never executed: return QModelIndex();
0
1352 QFileSystemModelPrivate::QFileSystemNode *parentNode = d->node(parent);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *parentNode = d->node(parent);
-
1353 d->addNode(parentNode, name, QFileInfo());
executed (the execution status of this line is deduced): d->addNode(parentNode, name, QFileInfo());
-
1354 Q_ASSERT(parentNode->children.contains(name));
executed (the execution status of this line is deduced): qt_noop();
-
1355 QFileSystemModelPrivate::QFileSystemNode *node = parentNode->children[name];
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *node = parentNode->children[name];
-
1356 node->populate(d->fileInfoGatherer.getInfo(QFileInfo(dir.absolutePath() + QDir::separator() + name)));
executed (the execution status of this line is deduced): node->populate(d->fileInfoGatherer.getInfo(QFileInfo(dir.absolutePath() + QDir::separator() + name)));
-
1357 d->addVisibleFiles(parentNode, QStringList(name));
executed (the execution status of this line is deduced): d->addVisibleFiles(parentNode, QStringList(name));
-
1358 return d->index(node);
executed: return d->index(node);
Execution Count:3
3
1359} -
1360 -
1361/*! -
1362 Returns the complete OR-ed together combination of QFile::Permission for the \a index. -
1363 */ -
1364QFile::Permissions QFileSystemModel::permissions(const QModelIndex &index) const -
1365{ -
1366 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
1367 return d->node(index)->permissions();
executed: return d->node(index)->permissions();
Execution Count:9
9
1368} -
1369 -
1370/*! -
1371 Sets the directory that is being watched by the model to \a newPath by -
1372 installing a \l{QFileSystemWatcher}{file system watcher} on it. Any -
1373 changes to files and directories within this directory will be -
1374 reflected in the model. -
1375 -
1376 If the path is changed, the rootPathChanged() signal will be emitted. -
1377 -
1378 \note This function does not change the structure of the model or -
1379 modify the data available to views. In other words, the "root" of -
1380 the model is \e not changed to include only files and directories -
1381 within the directory specified by \a newPath in the file system. -
1382 */ -
1383QModelIndex QFileSystemModel::setRootPath(const QString &newPath) -
1384{ -
1385 Q_D(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModelPrivate * const d = d_func();
-
1386#ifdef Q_OS_WIN -
1387#ifdef Q_OS_WIN32 -
1388 QString longNewPath = qt_GetLongPathName(newPath); -
1389#else -
1390 QString longNewPath = QDir::fromNativeSeparators(newPath); -
1391#endif -
1392#else -
1393 QString longNewPath = newPath;
executed (the execution status of this line is deduced): QString longNewPath = newPath;
-
1394#endif -
1395 QDir newPathDir(longNewPath);
executed (the execution status of this line is deduced): QDir newPathDir(longNewPath);
-
1396 //we remove .. and . from the given path if exist -
1397 if (!newPath.isEmpty()) {
evaluated: !newPath.isEmpty()
TRUEFALSE
yes
Evaluation Count:298
yes
Evaluation Count:3
3-298
1398 longNewPath = QDir::cleanPath(longNewPath);
executed (the execution status of this line is deduced): longNewPath = QDir::cleanPath(longNewPath);
-
1399 newPathDir.setPath(longNewPath);
executed (the execution status of this line is deduced): newPathDir.setPath(longNewPath);
-
1400 }
executed: }
Execution Count:298
298
1401 -
1402 d->setRootPath = true;
executed (the execution status of this line is deduced): d->setRootPath = true;
-
1403 -
1404 //user don't ask for the root path ("") but the conversion failed -
1405 if (!newPath.isEmpty() && longNewPath.isEmpty())
evaluated: !newPath.isEmpty()
TRUEFALSE
yes
Evaluation Count:298
yes
Evaluation Count:3
partially evaluated: longNewPath.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:298
0-298
1406 return d->index(rootPath());
never executed: return d->index(rootPath());
0
1407 -
1408 if (d->rootDir.path() == longNewPath)
evaluated: d->rootDir.path() == longNewPath
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:300
1-300
1409 return d->index(rootPath());
executed: return d->index(rootPath());
Execution Count:1
1
1410 -
1411 bool showDrives = (longNewPath.isEmpty() || longNewPath == d->myComputer());
evaluated: longNewPath.isEmpty()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:297
partially evaluated: longNewPath == d->myComputer()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:297
0-297
1412 if (!showDrives && !newPathDir.exists())
evaluated: !showDrives
TRUEFALSE
yes
Evaluation Count:297
yes
Evaluation Count:3
evaluated: !newPathDir.exists()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:295
2-297
1413 return d->index(rootPath());
executed: return d->index(rootPath());
Execution Count:2
2
1414 -
1415 //We remove the watcher on the previous path -
1416 if (!rootPath().isEmpty() && rootPath() != QLatin1String(".")) {
partially evaluated: !rootPath().isEmpty()
TRUEFALSE
yes
Evaluation Count:298
no
Evaluation Count:0
evaluated: rootPath() != QLatin1String(".")
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:246
0-298
1417 //This remove the watcher for the old rootPath -
1418 d->fileInfoGatherer.removePath(rootPath());
executed (the execution status of this line is deduced): d->fileInfoGatherer.removePath(rootPath());
-
1419 //This line "marks" the node as dirty, so the next fetchMore -
1420 //call on the path will ask the gatherer to install a watcher again -
1421 //But it doesn't re-fetch everything -
1422 d->node(rootPath())->populatedChildren = false;
executed (the execution status of this line is deduced): d->node(rootPath())->populatedChildren = false;
-
1423 }
executed: }
Execution Count:52
52
1424 -
1425 // We have a new valid root path -
1426 d->rootDir = newPathDir;
executed (the execution status of this line is deduced): d->rootDir = newPathDir;
-
1427 QModelIndex newRootIndex;
executed (the execution status of this line is deduced): QModelIndex newRootIndex;
-
1428 if (showDrives) {
evaluated: showDrives
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:295
3-295
1429 // otherwise dir will become '.' -
1430 d->rootDir.setPath(QLatin1String(""));
executed (the execution status of this line is deduced): d->rootDir.setPath(QLatin1String(""));
-
1431 } else {
executed: }
Execution Count:3
3
1432 newRootIndex = d->index(newPathDir.path());
executed (the execution status of this line is deduced): newRootIndex = d->index(newPathDir.path());
-
1433 }
executed: }
Execution Count:295
295
1434 fetchMore(newRootIndex);
executed (the execution status of this line is deduced): fetchMore(newRootIndex);
-
1435 emit rootPathChanged(longNewPath);
executed (the execution status of this line is deduced): rootPathChanged(longNewPath);
-
1436 d->forceSort = true;
executed (the execution status of this line is deduced): d->forceSort = true;
-
1437 d->delayedSort();
executed (the execution status of this line is deduced): d->delayedSort();
-
1438 return newRootIndex;
executed: return newRootIndex;
Execution Count:298
298
1439} -
1440 -
1441/*! -
1442 The currently set root path -
1443 -
1444 \sa rootDirectory() -
1445*/ -
1446QString QFileSystemModel::rootPath() const -
1447{ -
1448 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
1449 return d->rootDir.path();
executed: return d->rootDir.path();
Execution Count:3182
3182
1450} -
1451 -
1452/*! -
1453 The currently set directory -
1454 -
1455 \sa rootPath() -
1456*/ -
1457QDir QFileSystemModel::rootDirectory() const -
1458{ -
1459 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
1460 QDir dir(d->rootDir);
executed (the execution status of this line is deduced): QDir dir(d->rootDir);
-
1461 dir.setNameFilters(nameFilters());
executed (the execution status of this line is deduced): dir.setNameFilters(nameFilters());
-
1462 dir.setFilter(filter());
executed (the execution status of this line is deduced): dir.setFilter(filter());
-
1463 return dir;
executed: return dir;
Execution Count:240
240
1464} -
1465 -
1466/*! -
1467 Sets the \a provider of file icons for the directory model. -
1468*/ -
1469void QFileSystemModel::setIconProvider(QFileIconProvider *provider) -
1470{ -
1471 Q_D(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModelPrivate * const d = d_func();
-
1472 d->fileInfoGatherer.setIconProvider(provider);
executed (the execution status of this line is deduced): d->fileInfoGatherer.setIconProvider(provider);
-
1473 d->root.updateIcon(provider, QString());
executed (the execution status of this line is deduced): d->root.updateIcon(provider, QString());
-
1474}
executed: }
Execution Count:4
4
1475 -
1476/*! -
1477 Returns the file icon provider for this directory model. -
1478*/ -
1479QFileIconProvider *QFileSystemModel::iconProvider() const -
1480{ -
1481 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
1482 return d->fileInfoGatherer.iconProvider();
executed: return d->fileInfoGatherer.iconProvider();
Execution Count:4
4
1483} -
1484 -
1485/*! -
1486 Sets the directory model's filter to that specified by \a filters. -
1487 -
1488 Note that the filter you set should always include the QDir::AllDirs enum value, -
1489 otherwise QFileSystemModel won't be able to read the directory structure. -
1490 -
1491 \sa QDir::Filters -
1492*/ -
1493void QFileSystemModel::setFilter(QDir::Filters filters) -
1494{ -
1495 Q_D(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModelPrivate * const d = d_func();
-
1496 if (d->filters == filters)
evaluated: d->filters == filters
TRUEFALSE
yes
Evaluation Count:211
yes
Evaluation Count:33
33-211
1497 return;
executed: return;
Execution Count:211
211
1498 d->filters = filters;
executed (the execution status of this line is deduced): d->filters = filters;
-
1499 // CaseSensitivity might have changed -
1500 setNameFilters(nameFilters());
executed (the execution status of this line is deduced): setNameFilters(nameFilters());
-
1501 d->forceSort = true;
executed (the execution status of this line is deduced): d->forceSort = true;
-
1502 d->delayedSort();
executed (the execution status of this line is deduced): d->delayedSort();
-
1503}
executed: }
Execution Count:33
33
1504 -
1505/*! -
1506 Returns the filter specified for the directory model. -
1507 -
1508 If a filter has not been set, the default filter is QDir::AllEntries | -
1509 QDir::NoDotAndDotDot | QDir::AllDirs. -
1510 -
1511 \sa QDir::Filters -
1512*/ -
1513QDir::Filters QFileSystemModel::filter() const -
1514{ -
1515 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
1516 return d->filters;
executed: return d->filters;
Execution Count:917
917
1517} -
1518 -
1519/*! -
1520 \property QFileSystemModel::resolveSymlinks -
1521 \brief Whether the directory model should resolve symbolic links -
1522 -
1523 This is only relevant on operating systems that support symbolic links. -
1524 -
1525 By default, this property is false. -
1526*/ -
1527void QFileSystemModel::setResolveSymlinks(bool enable) -
1528{ -
1529 Q_D(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModelPrivate * const d = d_func();
-
1530 d->fileInfoGatherer.setResolveSymlinks(enable);
executed (the execution status of this line is deduced): d->fileInfoGatherer.setResolveSymlinks(enable);
-
1531}
executed: }
Execution Count:2
2
1532 -
1533bool QFileSystemModel::resolveSymlinks() const -
1534{ -
1535 Q_D(const QFileSystemModel);
never executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
1536 return d->fileInfoGatherer.resolveSymlinks();
never executed: return d->fileInfoGatherer.resolveSymlinks();
0
1537} -
1538 -
1539/*! -
1540 \property QFileSystemModel::readOnly -
1541 \brief Whether the directory model allows writing to the file system -
1542 -
1543 If this property is set to false, the directory model will allow renaming, copying -
1544 and deleting of files and directories. -
1545 -
1546 This property is true by default -
1547*/ -
1548void QFileSystemModel::setReadOnly(bool enable) -
1549{ -
1550 Q_D(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModelPrivate * const d = d_func();
-
1551 d->readOnly = enable;
executed (the execution status of this line is deduced): d->readOnly = enable;
-
1552}
executed: }
Execution Count:200
200
1553 -
1554bool QFileSystemModel::isReadOnly() const -
1555{ -
1556 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
1557 return d->readOnly;
executed: return d->readOnly;
Execution Count:11
11
1558} -
1559 -
1560/*! -
1561 \property QFileSystemModel::nameFilterDisables -
1562 \brief Whether files that don't pass the name filter are hidden or disabled -
1563 -
1564 This property is true by default -
1565*/ -
1566void QFileSystemModel::setNameFilterDisables(bool enable) -
1567{ -
1568 Q_D(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModelPrivate * const d = d_func();
-
1569 if (d->nameFilterDisables == enable)
partially evaluated: d->nameFilterDisables == enable
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:206
0-206
1570 return;
never executed: return;
0
1571 d->nameFilterDisables = enable;
executed (the execution status of this line is deduced): d->nameFilterDisables = enable;
-
1572 d->forceSort = true;
executed (the execution status of this line is deduced): d->forceSort = true;
-
1573 d->delayedSort();
executed (the execution status of this line is deduced): d->delayedSort();
-
1574}
executed: }
Execution Count:206
206
1575 -
1576bool QFileSystemModel::nameFilterDisables() const -
1577{ -
1578 Q_D(const QFileSystemModel);
never executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
1579 return d->nameFilterDisables;
never executed: return d->nameFilterDisables;
0
1580} -
1581 -
1582/*! -
1583 Sets the name \a filters to apply against the existing files. -
1584*/ -
1585void QFileSystemModel::setNameFilters(const QStringList &filters) -
1586{ -
1587 // Prep the regexp's ahead of time -
1588#ifndef QT_NO_REGEXP -
1589 Q_D(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModelPrivate * const d = d_func();
-
1590 -
1591 if (!d->bypassFilters.isEmpty()) {
evaluated: !d->bypassFilters.isEmpty()
TRUEFALSE
yes
Evaluation Count:261
yes
Evaluation Count:3
3-261
1592 // update the bypass filter to only bypass the stuff that must be kept around -
1593 d->bypassFilters.clear();
executed (the execution status of this line is deduced): d->bypassFilters.clear();
-
1594 // We guarantee that rootPath will stick around -
1595 QPersistentModelIndex root(index(rootPath()));
executed (the execution status of this line is deduced): QPersistentModelIndex root(index(rootPath()));
-
1596 QModelIndexList persistantList = persistentIndexList();
executed (the execution status of this line is deduced): QModelIndexList persistantList = persistentIndexList();
-
1597 for (int i = 0; i < persistantList.count(); ++i) {
evaluated: i < persistantList.count()
TRUEFALSE
yes
Evaluation Count:261
yes
Evaluation Count:261
261
1598 QFileSystemModelPrivate::QFileSystemNode *node;
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *node;
-
1599 node = d->node(persistantList.at(i));
executed (the execution status of this line is deduced): node = d->node(persistantList.at(i));
-
1600 while (node) {
evaluated: node
TRUEFALSE
yes
Evaluation Count:2614
yes
Evaluation Count:261
261-2614
1601 if (d->bypassFilters.contains(node))
partially evaluated: d->bypassFilters.contains(node)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2614
0-2614
1602 break;
never executed: break;
0
1603 if (node->isDir())
partially evaluated: node->isDir()
TRUEFALSE
yes
Evaluation Count:2614
no
Evaluation Count:0
0-2614
1604 d->bypassFilters[node] = true;
executed: d->bypassFilters[node] = true;
Execution Count:2614
2614
1605 node = node->parent;
executed (the execution status of this line is deduced): node = node->parent;
-
1606 }
executed: }
Execution Count:2614
2614
1607 }
executed: }
Execution Count:261
261
1608 }
executed: }
Execution Count:261
261
1609 -
1610 d->nameFilters.clear();
executed (the execution status of this line is deduced): d->nameFilters.clear();
-
1611 const Qt::CaseSensitivity caseSensitive =
executed (the execution status of this line is deduced): const Qt::CaseSensitivity caseSensitive =
-
1612 (filter() & QDir::CaseSensitive) ? Qt::CaseSensitive : Qt::CaseInsensitive;
evaluated: (filter() & QDir::CaseSensitive)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:261
3-261
1613 for (int i = 0; i < filters.size(); ++i) {
evaluated: i < filters.size()
TRUEFALSE
yes
Evaluation Count:271
yes
Evaluation Count:264
264-271
1614 d->nameFilters << QRegExp(filters.at(i), caseSensitive, QRegExp::Wildcard);
executed (the execution status of this line is deduced): d->nameFilters << QRegExp(filters.at(i), caseSensitive, QRegExp::Wildcard);
-
1615 }
executed: }
Execution Count:271
271
1616 d->forceSort = true;
executed (the execution status of this line is deduced): d->forceSort = true;
-
1617 d->delayedSort();
executed (the execution status of this line is deduced): d->delayedSort();
-
1618#endif -
1619}
executed: }
Execution Count:264
264
1620 -
1621/*! -
1622 Returns a list of filters applied to the names in the model. -
1623*/ -
1624QStringList QFileSystemModel::nameFilters() const -
1625{ -
1626 Q_D(const QFileSystemModel);
executed (the execution status of this line is deduced): const QFileSystemModelPrivate * const d = d_func();
-
1627 QStringList filters;
executed (the execution status of this line is deduced): QStringList filters;
-
1628#ifndef QT_NO_REGEXP -
1629 for (int i = 0; i < d->nameFilters.size(); ++i) {
evaluated: i < d->nameFilters.size()
TRUEFALSE
yes
Evaluation Count:253
yes
Evaluation Count:274
253-274
1630 filters << d->nameFilters.at(i).pattern();
executed (the execution status of this line is deduced): filters << d->nameFilters.at(i).pattern();
-
1631 }
executed: }
Execution Count:253
253
1632#endif -
1633 return filters;
executed: return filters;
Execution Count:274
274
1634} -
1635 -
1636/*! -
1637 \reimp -
1638*/ -
1639bool QFileSystemModel::event(QEvent *event) -
1640{ -
1641 Q_D(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModelPrivate * const d = d_func();
-
1642 if (event->type() == QEvent::LanguageChange) {
partially evaluated: event->type() == QEvent::LanguageChange
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:698
0-698
1643 d->root.retranslateStrings(d->fileInfoGatherer.iconProvider(), QString());
never executed (the execution status of this line is deduced): d->root.retranslateStrings(d->fileInfoGatherer.iconProvider(), QString());
-
1644 return true;
never executed: return true;
0
1645 } -
1646 return QAbstractItemModel::event(event);
executed: return QAbstractItemModel::event(event);
Execution Count:698
698
1647} -
1648 -
1649bool QFileSystemModel::rmdir(const QModelIndex &aindex) -
1650{ -
1651 QString path = filePath(aindex);
never executed (the execution status of this line is deduced): QString path = filePath(aindex);
-
1652 QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func());
never executed (the execution status of this line is deduced): QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func());
-
1653 d->fileInfoGatherer.removePath(path);
never executed (the execution status of this line is deduced): d->fileInfoGatherer.removePath(path);
-
1654 return QDir().rmdir(path);
never executed: return QDir().rmdir(path);
0
1655} -
1656 -
1657/*! -
1658 \internal -
1659 -
1660 Performed quick listing and see if any files have been added or removed, -
1661 then fetch more information on visible files. -
1662 */ -
1663void QFileSystemModelPrivate::_q_directoryChanged(const QString &directory, const QStringList &files) -
1664{ -
1665 QFileSystemModelPrivate::QFileSystemNode *parentNode = node(directory, false);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *parentNode = node(directory, false);
-
1666 if (parentNode->children.count() == 0)
evaluated: parentNode->children.count() == 0
TRUEFALSE
yes
Evaluation Count:84
yes
Evaluation Count:80
80-84
1667 return;
executed: return;
Execution Count:84
84
1668 QStringList toRemove;
executed (the execution status of this line is deduced): QStringList toRemove;
-
1669 QStringList newFiles = files;
executed (the execution status of this line is deduced): QStringList newFiles = files;
-
1670 qSort(newFiles.begin(), newFiles.end());
executed (the execution status of this line is deduced): qSort(newFiles.begin(), newFiles.end());
-
1671 QHash<QString, QFileSystemNode*>::const_iterator i = parentNode->children.constBegin();
executed (the execution status of this line is deduced): QHash<QString, QFileSystemNode*>::const_iterator i = parentNode->children.constBegin();
-
1672 while (i != parentNode->children.constEnd()) {
evaluated: i != parentNode->children.constEnd()
TRUEFALSE
yes
Evaluation Count:5561
yes
Evaluation Count:80
80-5561
1673 QStringList::iterator iterator;
executed (the execution status of this line is deduced): QStringList::iterator iterator;
-
1674 iterator = qBinaryFind(newFiles.begin(), newFiles.end(),
executed (the execution status of this line is deduced): iterator = qBinaryFind(newFiles.begin(), newFiles.end(),
-
1675 i.value()->fileName);
executed (the execution status of this line is deduced): i.value()->fileName);
-
1676 if (iterator == newFiles.end()) {
evaluated: iterator == newFiles.end()
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:5527
34-5527
1677 toRemove.append(i.value()->fileName);
executed (the execution status of this line is deduced): toRemove.append(i.value()->fileName);
-
1678 }
executed: }
Execution Count:34
34
1679 ++i;
executed (the execution status of this line is deduced): ++i;
-
1680 }
executed: }
Execution Count:5561
5561
1681 for (int i = 0 ; i < toRemove.count() ; ++i )
evaluated: i < toRemove.count()
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:80
34-80
1682 removeNode(parentNode, toRemove[i]);
executed: removeNode(parentNode, toRemove[i]);
Execution Count:34
34
1683}
executed: }
Execution Count:80
80
1684 -
1685/*! -
1686 \internal -
1687 -
1688 Adds a new file to the children of parentNode -
1689 -
1690 *WARNING* this will change the count of children -
1691*/ -
1692QFileSystemModelPrivate::QFileSystemNode* QFileSystemModelPrivate::addNode(QFileSystemNode *parentNode, const QString &fileName, const QFileInfo& info) -
1693{ -
1694 // In the common case, itemLocation == count() so check there first -
1695 QFileSystemModelPrivate::QFileSystemNode *node = new QFileSystemModelPrivate::QFileSystemNode(fileName, parentNode);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *node = new QFileSystemModelPrivate::QFileSystemNode(fileName, parentNode);
-
1696#ifndef QT_NO_FILESYSTEMWATCHER -
1697 node->populate(info);
executed (the execution status of this line is deduced): node->populate(info);
-
1698#endif -
1699#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) -
1700 //The parentNode is "" so we are listing the drives -
1701 if (parentNode->fileName.isEmpty()) { -
1702 wchar_t name[MAX_PATH + 1]; -
1703 //GetVolumeInformation requires to add trailing backslash -
1704 const QString nodeName = fileName + QLatin1String("\\"); -
1705 BOOL success = ::GetVolumeInformation((wchar_t *)(nodeName.utf16()), -
1706 name, MAX_PATH + 1, NULL, 0, NULL, NULL, 0); -
1707 if (success && name[0]) -
1708 node->volumeName = QString::fromWCharArray(name); -
1709 } -
1710#endif -
1711 parentNode->children.insert(fileName, node);
executed (the execution status of this line is deduced): parentNode->children.insert(fileName, node);
-
1712 return node;
executed: return node;
Execution Count:24359
24359
1713} -
1714 -
1715/*! -
1716 \internal -
1717 -
1718 File at parentNode->children(itemLocation) has been removed, remove from the lists -
1719 and emit signals if necessary -
1720 -
1721 *WARNING* this will change the count of children and could change visibleChildren -
1722 */ -
1723void QFileSystemModelPrivate::removeNode(QFileSystemModelPrivate::QFileSystemNode *parentNode, const QString& name) -
1724{ -
1725 Q_Q(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModel * const q = q_func();
-
1726 QModelIndex parent = index(parentNode);
executed (the execution status of this line is deduced): QModelIndex parent = index(parentNode);
-
1727 bool indexHidden = isHiddenByFilter(parentNode, parent);
executed (the execution status of this line is deduced): bool indexHidden = isHiddenByFilter(parentNode, parent);
-
1728 -
1729 int vLocation = parentNode->visibleLocation(name);
executed (the execution status of this line is deduced): int vLocation = parentNode->visibleLocation(name);
-
1730 if (vLocation >= 0 && !indexHidden)
evaluated: vLocation >= 0
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:17
partially evaluated: !indexHidden
TRUEFALSE
yes
Evaluation Count:17
no
Evaluation Count:0
0-17
1731 q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation),
executed: q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation), translateVisibleLocation(parentNode, vLocation));
Execution Count:17
17
1732 translateVisibleLocation(parentNode, vLocation));
executed: q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation), translateVisibleLocation(parentNode, vLocation));
Execution Count:17
17
1733 QFileSystemNode * node = parentNode->children.take(name);
executed (the execution status of this line is deduced): QFileSystemNode * node = parentNode->children.take(name);
-
1734 delete node;
executed (the execution status of this line is deduced): delete node;
-
1735 // cleanup sort files after removing rather then re-sorting which is O(n) -
1736 if (vLocation >= 0)
evaluated: vLocation >= 0
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:17
17
1737 parentNode->visibleChildren.removeAt(vLocation);
executed: parentNode->visibleChildren.removeAt(vLocation);
Execution Count:17
17
1738 if (vLocation >= 0 && !indexHidden)
evaluated: vLocation >= 0
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:17
partially evaluated: !indexHidden
TRUEFALSE
yes
Evaluation Count:17
no
Evaluation Count:0
0-17
1739 q->endRemoveRows();
executed: q->endRemoveRows();
Execution Count:17
17
1740}
executed: }
Execution Count:34
34
1741 -
1742/* -
1743 \internal -
1744 Helper functor used by addVisibleFiles() -
1745*/ -
1746class QFileSystemModelVisibleFinder -
1747{ -
1748public: -
1749 inline QFileSystemModelVisibleFinder(QFileSystemModelPrivate::QFileSystemNode *node, QFileSystemModelSorter *sorter) : parentNode(node), sorter(sorter) {}
never executed: }
0
1750 -
1751 bool operator()(const QString &, QString r) const -
1752 { -
1753 return sorter->compareNodes(parentNode->children.value(name), parentNode->children.value(r));
never executed: return sorter->compareNodes(parentNode->children.value(name), parentNode->children.value(r));
0
1754 } -
1755 -
1756 QString name; -
1757private: -
1758 QFileSystemModelPrivate::QFileSystemNode *parentNode; -
1759 QFileSystemModelSorter *sorter; -
1760}; -
1761 -
1762/*! -
1763 \internal -
1764 -
1765 File at parentNode->children(itemLocation) was not visible before, but now should be -
1766 and emit signals if necessary. -
1767 -
1768 *WARNING* this will change the visible count -
1769 */ -
1770void QFileSystemModelPrivate::addVisibleFiles(QFileSystemNode *parentNode, const QStringList &newFiles) -
1771{ -
1772 Q_Q(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModel * const q = q_func();
-
1773 QModelIndex parent = index(parentNode);
executed (the execution status of this line is deduced): QModelIndex parent = index(parentNode);
-
1774 bool indexHidden = isHiddenByFilter(parentNode, parent);
executed (the execution status of this line is deduced): bool indexHidden = isHiddenByFilter(parentNode, parent);
-
1775 if (!indexHidden) {
partially evaluated: !indexHidden
TRUEFALSE
yes
Evaluation Count:2567
no
Evaluation Count:0
0-2567
1776 q->beginInsertRows(parent, parentNode->visibleChildren.count() , parentNode->visibleChildren.count() + newFiles.count() - 1);
executed (the execution status of this line is deduced): q->beginInsertRows(parent, parentNode->visibleChildren.count() , parentNode->visibleChildren.count() + newFiles.count() - 1);
-
1777 }
executed: }
Execution Count:2567
2567
1778 -
1779 if (parentNode->dirtyChildrenIndex == -1)
evaluated: parentNode->dirtyChildrenIndex == -1
TRUEFALSE
yes
Evaluation Count:2439
yes
Evaluation Count:128
128-2439
1780 parentNode->dirtyChildrenIndex = parentNode->visibleChildren.count();
executed: parentNode->dirtyChildrenIndex = parentNode->visibleChildren.count();
Execution Count:2439
2439
1781 -
1782 for (int i = 0; i < newFiles.count(); ++i) {
evaluated: i < newFiles.count()
TRUEFALSE
yes
Evaluation Count:23762
yes
Evaluation Count:2567
2567-23762
1783 parentNode->visibleChildren.append(newFiles.at(i));
executed (the execution status of this line is deduced): parentNode->visibleChildren.append(newFiles.at(i));
-
1784 parentNode->children[newFiles.at(i)]->isVisible = true;
executed (the execution status of this line is deduced): parentNode->children[newFiles.at(i)]->isVisible = true;
-
1785 }
executed: }
Execution Count:23762
23762
1786 if (!indexHidden)
partially evaluated: !indexHidden
TRUEFALSE
yes
Evaluation Count:2567
no
Evaluation Count:0
0-2567
1787 q->endInsertRows();
executed: q->endInsertRows();
Execution Count:2567
2567
1788}
executed: }
Execution Count:2567
2567
1789 -
1790/*! -
1791 \internal -
1792 -
1793 File was visible before, but now should NOT be -
1794 -
1795 *WARNING* this will change the visible count -
1796 */ -
1797void QFileSystemModelPrivate::removeVisibleFile(QFileSystemNode *parentNode, int vLocation) -
1798{ -
1799 Q_Q(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModel * const q = q_func();
-
1800 if (vLocation == -1)
partially evaluated: vLocation == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1801 return;
never executed: return;
0
1802 QModelIndex parent = index(parentNode);
executed (the execution status of this line is deduced): QModelIndex parent = index(parentNode);
-
1803 bool indexHidden = isHiddenByFilter(parentNode, parent);
executed (the execution status of this line is deduced): bool indexHidden = isHiddenByFilter(parentNode, parent);
-
1804 if (!indexHidden)
partially evaluated: !indexHidden
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1805 q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation),
executed: q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation), translateVisibleLocation(parentNode, vLocation));
Execution Count:1
1
1806 translateVisibleLocation(parentNode, vLocation));
executed: q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation), translateVisibleLocation(parentNode, vLocation));
Execution Count:1
1
1807 parentNode->children[parentNode->visibleChildren.at(vLocation)]->isVisible = false;
executed (the execution status of this line is deduced): parentNode->children[parentNode->visibleChildren.at(vLocation)]->isVisible = false;
-
1808 parentNode->visibleChildren.removeAt(vLocation);
executed (the execution status of this line is deduced): parentNode->visibleChildren.removeAt(vLocation);
-
1809 if (!indexHidden)
partially evaluated: !indexHidden
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
1810 q->endRemoveRows();
executed: q->endRemoveRows();
Execution Count:1
1
1811}
executed: }
Execution Count:1
1
1812 -
1813/*! -
1814 \internal -
1815 -
1816 The thread has received new information about files, -
1817 update and emit dataChanged if it has actually changed. -
1818 */ -
1819void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path, const QList<QPair<QString, QFileInfo> > &updates) -
1820{ -
1821 Q_Q(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModel * const q = q_func();
-
1822 QVector<QString> rowsToUpdate;
executed (the execution status of this line is deduced): QVector<QString> rowsToUpdate;
-
1823 QStringList newFiles;
executed (the execution status of this line is deduced): QStringList newFiles;
-
1824 QFileSystemModelPrivate::QFileSystemNode *parentNode = node(path, false);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode *parentNode = node(path, false);
-
1825 QModelIndex parentIndex = index(parentNode);
executed (the execution status of this line is deduced): QModelIndex parentIndex = index(parentNode);
-
1826 for (int i = 0; i < updates.count(); ++i) {
evaluated: i < updates.count()
TRUEFALSE
yes
Evaluation Count:25964
yes
Evaluation Count:206
206-25964
1827 QString fileName = updates.at(i).first;
executed (the execution status of this line is deduced): QString fileName = updates.at(i).first;
-
1828 Q_ASSERT(!fileName.isEmpty());
executed (the execution status of this line is deduced): qt_noop();
-
1829 QExtendedInformation info = fileInfoGatherer.getInfo(updates.at(i).second);
executed (the execution status of this line is deduced): QExtendedInformation info = fileInfoGatherer.getInfo(updates.at(i).second);
-
1830 bool previouslyHere = parentNode->children.contains(fileName);
executed (the execution status of this line is deduced): bool previouslyHere = parentNode->children.contains(fileName);
-
1831 if (!previouslyHere) {
evaluated: !previouslyHere
TRUEFALSE
yes
Evaluation Count:21930
yes
Evaluation Count:4034
4034-21930
1832 addNode(parentNode, fileName, info.fileInfo());
executed (the execution status of this line is deduced): addNode(parentNode, fileName, info.fileInfo());
-
1833 }
executed: }
Execution Count:21930
21930
1834 QFileSystemModelPrivate::QFileSystemNode * node = parentNode->children.value(fileName);
executed (the execution status of this line is deduced): QFileSystemModelPrivate::QFileSystemNode * node = parentNode->children.value(fileName);
-
1835 bool isCaseSensitive = parentNode->caseSensitive();
executed (the execution status of this line is deduced): bool isCaseSensitive = parentNode->caseSensitive();
-
1836 if (isCaseSensitive) {
evaluated: isCaseSensitive
TRUEFALSE
yes
Evaluation Count:25940
yes
Evaluation Count:24
24-25940
1837 if (node->fileName != fileName)
partially evaluated: node->fileName != fileName
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25940
0-25940
1838 continue;
never executed: continue;
0
1839 } else {
executed: }
Execution Count:25940
25940
1840 if (QString::compare(node->fileName,fileName,Qt::CaseInsensitive) != 0)
partially evaluated: QString::compare(node->fileName,fileName,Qt::CaseInsensitive) != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:24
0-24
1841 continue;
never executed: continue;
0
1842 }
executed: }
Execution Count:24
24
1843 if (isCaseSensitive) {
evaluated: isCaseSensitive
TRUEFALSE
yes
Evaluation Count:25940
yes
Evaluation Count:24
24-25940
1844 Q_ASSERT(node->fileName == fileName);
executed (the execution status of this line is deduced): qt_noop();
-
1845 } else {
executed: }
Execution Count:25940
25940
1846 node->fileName = fileName;
executed (the execution status of this line is deduced): node->fileName = fileName;
-
1847 }
executed: }
Execution Count:24
24
1848 -
1849 if (info.size() == -1 && !info.isSymLink()) {
partially evaluated: info.size() == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:25964
never evaluated: !info.isSymLink()
0-25964
1850 removeNode(parentNode, fileName);
never executed (the execution status of this line is deduced): removeNode(parentNode, fileName);
-
1851 continue;
never executed: continue;
0
1852 } -
1853 if (*node != info ) {
evaluated: *node != info
TRUEFALSE
yes
Evaluation Count:21965
yes
Evaluation Count:3999
3999-21965
1854 node->populate(info);
executed (the execution status of this line is deduced): node->populate(info);
-
1855 bypassFilters.remove(node);
executed (the execution status of this line is deduced): bypassFilters.remove(node);
-
1856 // brand new information. -
1857 if (filtersAcceptsNode(node)) {
evaluated: filtersAcceptsNode(node)
TRUEFALSE
yes
Evaluation Count:21368
yes
Evaluation Count:597
597-21368
1858 if (!node->isVisible) {
evaluated: !node->isVisible
TRUEFALSE
yes
Evaluation Count:21334
yes
Evaluation Count:34
34-21334
1859 newFiles.append(fileName);
executed (the execution status of this line is deduced): newFiles.append(fileName);
-
1860 } else {
executed: }
Execution Count:21334
21334
1861 rowsToUpdate.append(fileName);
executed (the execution status of this line is deduced): rowsToUpdate.append(fileName);
-
1862 }
executed: }
Execution Count:34
34
1863 } else { -
1864 if (node->isVisible) {
evaluated: node->isVisible
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:596
1-596
1865 int visibleLocation = parentNode->visibleLocation(fileName);
executed (the execution status of this line is deduced): int visibleLocation = parentNode->visibleLocation(fileName);
-
1866 removeVisibleFile(parentNode, visibleLocation);
executed (the execution status of this line is deduced): removeVisibleFile(parentNode, visibleLocation);
-
1867 } else {
executed: }
Execution Count:1
1
1868 // The file is not visible, don't do anything -
1869 }
executed: }
Execution Count:596
596
1870 } -
1871 } -
1872 }
executed: }
Execution Count:25964
25964
1873 -
1874 // bundle up all of the changed signals into as few as possible. -
1875 qSort(rowsToUpdate.begin(), rowsToUpdate.end());
executed (the execution status of this line is deduced): qSort(rowsToUpdate.begin(), rowsToUpdate.end());
-
1876 QString min;
executed (the execution status of this line is deduced): QString min;
-
1877 QString max;
executed (the execution status of this line is deduced): QString max;
-
1878 for (int i = 0; i < rowsToUpdate.count(); ++i) {
evaluated: i < rowsToUpdate.count()
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:206
34-206
1879 QString value = rowsToUpdate.at(i);
executed (the execution status of this line is deduced): QString value = rowsToUpdate.at(i);
-
1880 //##TODO is there a way to bundle signals with QString as the content of the list? -
1881 /*if (min.isEmpty()) { -
1882 min = value; -
1883 if (i != rowsToUpdate.count() - 1) -
1884 continue; -
1885 } -
1886 if (i != rowsToUpdate.count() - 1) { -
1887 if ((value == min + 1 && max.isEmpty()) || value == max + 1) { -
1888 max = value; -
1889 continue; -
1890 } -
1891 }*/ -
1892 max = value;
executed (the execution status of this line is deduced): max = value;
-
1893 min = value;
executed (the execution status of this line is deduced): min = value;
-
1894 int visibleMin = parentNode->visibleLocation(min);
executed (the execution status of this line is deduced): int visibleMin = parentNode->visibleLocation(min);
-
1895 int visibleMax = parentNode->visibleLocation(max);
executed (the execution status of this line is deduced): int visibleMax = parentNode->visibleLocation(max);
-
1896 if (visibleMin >= 0
partially evaluated: visibleMin >= 0
TRUEFALSE
yes
Evaluation Count:34
no
Evaluation Count:0
0-34
1897 && visibleMin < parentNode->visibleChildren.count()
partially evaluated: visibleMin < parentNode->visibleChildren.count()
TRUEFALSE
yes
Evaluation Count:34
no
Evaluation Count:0
0-34
1898 && parentNode->visibleChildren.at(visibleMin) == min
partially evaluated: parentNode->visibleChildren.at(visibleMin) == min
TRUEFALSE
yes
Evaluation Count:34
no
Evaluation Count:0
0-34
1899 && visibleMax >= 0) {
partially evaluated: visibleMax >= 0
TRUEFALSE
yes
Evaluation Count:34
no
Evaluation Count:0
0-34
1900 QModelIndex bottom = q->index(translateVisibleLocation(parentNode, visibleMin), 0, parentIndex);
executed (the execution status of this line is deduced): QModelIndex bottom = q->index(translateVisibleLocation(parentNode, visibleMin), 0, parentIndex);
-
1901 QModelIndex top = q->index(translateVisibleLocation(parentNode, visibleMax), 3, parentIndex);
executed (the execution status of this line is deduced): QModelIndex top = q->index(translateVisibleLocation(parentNode, visibleMax), 3, parentIndex);
-
1902 emit q->dataChanged(bottom, top);
executed (the execution status of this line is deduced): q->dataChanged(bottom, top);
-
1903 }
executed: }
Execution Count:34
34
1904 -
1905 /*min = QString(); -
1906 max = QString();*/ -
1907 }
executed: }
Execution Count:34
34
1908 -
1909 if (newFiles.count() > 0) {
evaluated: newFiles.count() > 0
TRUEFALSE
yes
Evaluation Count:139
yes
Evaluation Count:67
67-139
1910 addVisibleFiles(parentNode, newFiles);
executed (the execution status of this line is deduced): addVisibleFiles(parentNode, newFiles);
-
1911 }
executed: }
Execution Count:139
139
1912 -
1913 if (newFiles.count() > 0 || (sortColumn != 0 && rowsToUpdate.count() > 0)) {
evaluated: newFiles.count() > 0
TRUEFALSE
yes
Evaluation Count:139
yes
Evaluation Count:67
evaluated: sortColumn != 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:65
evaluated: rowsToUpdate.count() > 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1-139
1914 forceSort = true;
executed (the execution status of this line is deduced): forceSort = true;
-
1915 delayedSort();
executed (the execution status of this line is deduced): delayedSort();
-
1916 }
executed: }
Execution Count:140
140
1917}
executed: }
Execution Count:206
206
1918 -
1919/*! -
1920 \internal -
1921*/ -
1922void QFileSystemModelPrivate::_q_resolvedName(const QString &fileName, const QString &resolvedName) -
1923{ -
1924 resolvedSymLinks[fileName] = resolvedName;
never executed (the execution status of this line is deduced): resolvedSymLinks[fileName] = resolvedName;
-
1925}
never executed: }
0
1926 -
1927/*! -
1928 \internal -
1929*/ -
1930void QFileSystemModelPrivate::init() -
1931{ -
1932 Q_Q(QFileSystemModel);
executed (the execution status of this line is deduced): QFileSystemModel * const q = q_func();
-
1933 qRegisterMetaType<QList<QPair<QString,QFileInfo> > >();
executed (the execution status of this line is deduced): qRegisterMetaType<QList<QPair<QString,QFileInfo> > >();
-
1934 q->connect(&fileInfoGatherer, SIGNAL(newListOfFiles(QString,QStringList)),
executed (the execution status of this line is deduced): q->connect(&fileInfoGatherer, "2""newListOfFiles(QString,QStringList)",
-
1935 q, SLOT(_q_directoryChanged(QString,QStringList)));
executed (the execution status of this line is deduced): q, "1""_q_directoryChanged(QString,QStringList)");
-
1936 q->connect(&fileInfoGatherer, SIGNAL(updates(QString,QList<QPair<QString,QFileInfo> >)),
executed (the execution status of this line is deduced): q->connect(&fileInfoGatherer, "2""updates(QString,QList<QPair<QString,QFileInfo> >)",
-
1937 q, SLOT(_q_fileSystemChanged(QString,QList<QPair<QString,QFileInfo> >)));
executed (the execution status of this line is deduced): q, "1""_q_fileSystemChanged(QString,QList<QPair<QString,QFileInfo> >)");
-
1938 q->connect(&fileInfoGatherer, SIGNAL(nameResolved(QString,QString)),
executed (the execution status of this line is deduced): q->connect(&fileInfoGatherer, "2""nameResolved(QString,QString)",
-
1939 q, SLOT(_q_resolvedName(QString,QString)));
executed (the execution status of this line is deduced): q, "1""_q_resolvedName(QString,QString)");
-
1940 q->connect(&fileInfoGatherer, SIGNAL(directoryLoaded(QString)),
executed (the execution status of this line is deduced): q->connect(&fileInfoGatherer, "2""directoryLoaded(QString)",
-
1941 q, SIGNAL(directoryLoaded(QString)));
executed (the execution status of this line is deduced): q, "2""directoryLoaded(QString)");
-
1942 q->connect(&delayedSortTimer, SIGNAL(timeout()), q, SLOT(_q_performDelayedSort()), Qt::QueuedConnection);
executed (the execution status of this line is deduced): q->connect(&delayedSortTimer, "2""timeout()", q, "1""_q_performDelayedSort()", Qt::QueuedConnection);
-
1943 -
1944 roleNames.insertMulti(QFileSystemModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration
executed (the execution status of this line is deduced): roleNames.insertMulti(QFileSystemModel::FileIconRole, QByteArray("fileIcon", sizeof("fileIcon") - 1));
-
1945 roleNames.insert(QFileSystemModel::FilePathRole, QByteArrayLiteral("filePath"));
executed (the execution status of this line is deduced): roleNames.insert(QFileSystemModel::FilePathRole, QByteArray("filePath", sizeof("filePath") - 1));
-
1946 roleNames.insert(QFileSystemModel::FileNameRole, QByteArrayLiteral("fileName"));
executed (the execution status of this line is deduced): roleNames.insert(QFileSystemModel::FileNameRole, QByteArray("fileName", sizeof("fileName") - 1));
-
1947 roleNames.insert(QFileSystemModel::FilePermissions, QByteArrayLiteral("filePermissions"));
executed (the execution status of this line is deduced): roleNames.insert(QFileSystemModel::FilePermissions, QByteArray("filePermissions", sizeof("filePermissions") - 1));
-
1948}
executed: }
Execution Count:273
273
1949 -
1950/*! -
1951 \internal -
1952 -
1953 Returns false if node doesn't pass the filters otherwise true -
1954 -
1955 QDir::Modified is not supported -
1956 QDir::Drives is not supported -
1957*/ -
1958bool QFileSystemModelPrivate::filtersAcceptsNode(const QFileSystemNode *node) const -
1959{ -
1960 // always accept drives -
1961 if (node->parent == &root || bypassFilters.contains(node))
evaluated: node->parent == &root
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:42330
evaluated: bypassFilters.contains(node)
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:42311
19-42330
1962 return true;
executed: return true;
Execution Count:49
49
1963 -
1964 // If we don't know anything yet don't accept it -
1965 if (!node->hasInformation())
partially evaluated: !node->hasInformation()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:42311
0-42311
1966 return false;
never executed: return false;
0
1967 -
1968 const bool filterPermissions = ((filters & QDir::PermissionMask)
evaluated: (filters & QDir::PermissionMask)
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:42299
12-42299
1969 && (filters & QDir::PermissionMask) != QDir::PermissionMask);
partially evaluated: (filters & QDir::PermissionMask) != QDir::PermissionMask
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
1970 const bool hideDirs = !(filters & (QDir::Dirs | QDir::AllDirs));
executed (the execution status of this line is deduced): const bool hideDirs = !(filters & (QDir::Dirs | QDir::AllDirs));
-
1971 const bool hideFiles = !(filters & QDir::Files);
executed (the execution status of this line is deduced): const bool hideFiles = !(filters & QDir::Files);
-
1972 const bool hideReadable = !(!filterPermissions || (filters & QDir::Readable));
evaluated: !filterPermissions
TRUEFALSE
yes
Evaluation Count:42299
yes
Evaluation Count:12
partially evaluated: (filters & QDir::Readable)
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-42299
1973 const bool hideWritable = !(!filterPermissions || (filters & QDir::Writable));
evaluated: !filterPermissions
TRUEFALSE
yes
Evaluation Count:42299
yes
Evaluation Count:12
partially evaluated: (filters & QDir::Writable)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-42299
1974 const bool hideExecutable = !(!filterPermissions || (filters & QDir::Executable));
evaluated: !filterPermissions
TRUEFALSE
yes
Evaluation Count:42299
yes
Evaluation Count:12
partially evaluated: (filters & QDir::Executable)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-42299
1975 const bool hideHidden = !(filters & QDir::Hidden);
executed (the execution status of this line is deduced): const bool hideHidden = !(filters & QDir::Hidden);
-
1976 const bool hideSystem = !(filters & QDir::System);
executed (the execution status of this line is deduced): const bool hideSystem = !(filters & QDir::System);
-
1977 const bool hideSymlinks = (filters & QDir::NoSymLinks);
executed (the execution status of this line is deduced): const bool hideSymlinks = (filters & QDir::NoSymLinks);
-
1978 const bool hideDot = (filters & QDir::NoDot);
executed (the execution status of this line is deduced): const bool hideDot = (filters & QDir::NoDot);
-
1979 const bool hideDotDot = (filters & QDir::NoDotDot);
executed (the execution status of this line is deduced): const bool hideDotDot = (filters & QDir::NoDotDot);
-
1980 -
1981 // Note that we match the behavior of entryList and not QFileInfo on this. -
1982 bool isDot = (node->fileName == QLatin1String("."));
executed (the execution status of this line is deduced): bool isDot = (node->fileName == QLatin1String("."));
-
1983 bool isDotDot = (node->fileName == QLatin1String(".."));
executed (the execution status of this line is deduced): bool isDotDot = (node->fileName == QLatin1String(".."));
-
1984 if ( (hideHidden && !(isDot || isDotDot) && node->isHidden())
evaluated: hideHidden
TRUEFALSE
yes
Evaluation Count:34676
yes
Evaluation Count:7635
evaluated: isDot
TRUEFALSE
yes
Evaluation Count:214
yes
Evaluation Count:34462
evaluated: isDotDot
TRUEFALSE
yes
Evaluation Count:214
yes
Evaluation Count:34248
evaluated: node->isHidden()
TRUEFALSE
yes
Evaluation Count:709
yes
Evaluation Count:33539
214-34676
1985 || (hideSystem && node->isSystem())
evaluated: hideSystem
TRUEFALSE
yes
Evaluation Count:34059
yes
Evaluation Count:7543
evaluated: node->isSystem()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:34057
2-34059
1986 || (hideDirs && node->isDir())
evaluated: hideDirs
TRUEFALSE
yes
Evaluation Count:28
yes
Evaluation Count:41572
evaluated: node->isDir()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:17
11-41572
1987 || (hideFiles && node->isFile())
evaluated: hideFiles
TRUEFALSE
yes
Evaluation Count:97
yes
Evaluation Count:41492
evaluated: node->isFile()
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:60
37-41492
1988 || (hideSymlinks && node->isSymLink())
partially evaluated: hideSymlinks
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:41552
never evaluated: node->isSymLink()
0-41552
1989 || (hideReadable && node->isReadable())
partially evaluated: hideReadable
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:41552
never evaluated: node->isReadable()
0-41552
1990 || (hideWritable && node->isWritable())
evaluated: hideWritable
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:41546
evaluated: node->isWritable()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
2-41546
1991 || (hideExecutable && node->isExecutable())
evaluated: hideExecutable
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:41546
evaluated: node->isExecutable()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2-41546
1992 || (hideDot && isDot)
evaluated: hideDot
TRUEFALSE
yes
Evaluation Count:33955
yes
Evaluation Count:7593
evaluated: isDot
TRUEFALSE
yes
Evaluation Count:216
yes
Evaluation Count:33739
216-33955
1993 || (hideDotDot && isDotDot))
evaluated: hideDotDot
TRUEFALSE
yes
Evaluation Count:33743
yes
Evaluation Count:7589
evaluated: isDotDot
TRUEFALSE
yes
Evaluation Count:216
yes
Evaluation Count:33527
216-33743
1994 return false;
executed: return false;
Execution Count:1195
1195
1995 -
1996 return nameFilterDisables || passNameFilters(node);
executed: return nameFilterDisables || passNameFilters(node);
Execution Count:41116
41116
1997} -
1998 -
1999/* -
2000 \internal -
2001 -
2002 Returns true if node passes the name filters and should be visible. -
2003 */ -
2004bool QFileSystemModelPrivate::passNameFilters(const QFileSystemNode *node) const -
2005{ -
2006#ifndef QT_NO_REGEXP -
2007 if (nameFilters.isEmpty())
evaluated: nameFilters.isEmpty()
TRUEFALSE
yes
Evaluation Count:1518
yes
Evaluation Count:21792
1518-21792
2008 return true;
executed: return true;
Execution Count:1518
1518
2009 -
2010 // Check the name regularexpression filters -
2011 if (!(node->isDir() && (filters & QDir::AllDirs))) {
evaluated: node->isDir()
TRUEFALSE
yes
Evaluation Count:751
yes
Evaluation Count:21041
evaluated: (filters & QDir::AllDirs)
TRUEFALSE
yes
Evaluation Count:745
yes
Evaluation Count:6
6-21041
2012 for (int i = 0; i < nameFilters.size(); ++i) {
evaluated: i < nameFilters.size()
TRUEFALSE
yes
Evaluation Count:21065
yes
Evaluation Count:41
41-21065
2013 QRegExp copy = nameFilters.at(i);
executed (the execution status of this line is deduced): QRegExp copy = nameFilters.at(i);
-
2014 if (copy.exactMatch(node->fileName))
evaluated: copy.exactMatch(node->fileName)
TRUEFALSE
yes
Evaluation Count:21006
yes
Evaluation Count:59
59-21006
2015 return true;
executed: return true;
Execution Count:21006
21006
2016 }
executed: }
Execution Count:59
59
2017 return false;
executed: return false;
Execution Count:41
41
2018 } -
2019#endif -
2020 return true;
executed: return true;
Execution Count:745
745
2021} -
2022 -
2023QT_END_NAMESPACE -
2024 -
2025#include "moc_qfilesystemmodel.cpp" -
2026 -
2027#endif // QT_NO_FILESYSTEMMODEL -
2028 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial