qfilesystemmodel.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/dialogs/qfilesystemmodel.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3QFileInfo QFileSystemModel::fileInfo(const QModelIndex &index) const-
4{-
5 const QFileSystemModelPrivate * const d = d_func();-
6 return
never executed: return d->node(index)->fileInfo();
d->node(index)->fileInfo();
never executed: return d->node(index)->fileInfo();
0
7}-
8bool QFileSystemModel::remove(const QModelIndex &aindex)-
9{-
10 const QString path = filePath(aindex);-
11 const bool success = QFileInfo(path).isFile()
QFileInfo(path).isFile()Description
TRUEnever evaluated
FALSEnever evaluated
? QFile::remove(path) : QDir(path).removeRecursively();
0
12-
13 if (success
successDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
14 QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func());-
15 d->fileInfoGatherer.removePath(path);-
16 }
never executed: end of block
0
17-
18 return
never executed: return success;
success;
never executed: return success;
0
19}-
20-
21-
22-
23-
24QFileSystemModel::QFileSystemModel(QObject *parent)-
25 : QAbstractItemModel(*new QFileSystemModelPrivate, parent)-
26{-
27 QFileSystemModelPrivate * const d = d_func();-
28 d->init();-
29}
never executed: end of block
0
30-
31-
32-
33-
34QFileSystemModel::QFileSystemModel(QFileSystemModelPrivate &dd, QObject *parent)-
35 : QAbstractItemModel(dd, parent)-
36{-
37 QFileSystemModelPrivate * const d = d_func();-
38 d->init();-
39}
never executed: end of block
0
40-
41-
42-
43-
44QFileSystemModel::~QFileSystemModel()-
45{-
46}-
47-
48-
49-
50-
51QModelIndex QFileSystemModel::index(int row, int column, const QModelIndex &parent) const-
52{-
53 const QFileSystemModelPrivate * const d = d_func();-
54 if (row < 0
row < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| column < 0
column < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| row >= rowCount(parent)
row >= rowCount(parent)Description
TRUEnever evaluated
FALSEnever evaluated
|| column >= columnCount(parent)
column >= columnCount(parent)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
55 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
56-
57-
58 QFileSystemModelPrivate::QFileSystemNode *parentNode = (d->indexValid(parent)
d->indexValid(parent)Description
TRUEnever evaluated
FALSEnever evaluated
? d->node(parent) :
0
59 const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&d->root));-
60 ((!(parentNode)) ? qt_assert("parentNode",__FILE__,256) : qt_noop());-
61-
62-
63 const QString &childName = parentNode->visibleChildren.at(d->translateVisibleLocation(parentNode, row));-
64 const QFileSystemModelPrivate::QFileSystemNode *indexNode = parentNode->children.value(childName);-
65 ((!(indexNode)) ? qt_assert("indexNode",__FILE__,261) : qt_noop());-
66-
67 return
never executed: return createIndex(row, column, const_cast<QFileSystemModelPrivate::QFileSystemNode*>(indexNode));
createIndex(row, column, const_cast<QFileSystemModelPrivate::QFileSystemNode*>(indexNode));
never executed: return createIndex(row, column, const_cast<QFileSystemModelPrivate::QFileSystemNode*>(indexNode));
0
68}-
69-
70-
71-
72-
73QModelIndex QFileSystemModel::sibling(int row, int column, const QModelIndex &idx) const-
74{-
75 if (row == idx.row()
row == idx.row()Description
TRUEnever evaluated
FALSEnever evaluated
&& column < QFileSystemModelPrivate::NumColumns
column < QFile...te::NumColumnsDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
76-
77 return
never executed: return createIndex(row, column, idx.internalPointer());
createIndex(row, column, idx.internalPointer());
never executed: return createIndex(row, column, idx.internalPointer());
0
78 } else {-
79-
80-
81 return
never executed: return QAbstractItemModel::sibling(row, column, idx);
QAbstractItemModel::sibling(row, column, idx);
never executed: return QAbstractItemModel::sibling(row, column, idx);
0
82 }-
83}-
84-
85-
86-
87-
88-
89-
90QModelIndex QFileSystemModel::index(const QString &path, int column) const-
91{-
92 const QFileSystemModelPrivate * const d = d_func();-
93 QFileSystemModelPrivate::QFileSystemNode *node = d->node(path, false);-
94 return
never executed: return d->index(node, column);
d->index(node, column);
never executed: return d->index(node, column);
0
95}-
96-
97-
98-
99-
100-
101-
102QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QModelIndex &index) const-
103{-
104 if (!index.isValid()
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
105 return
never executed: return const_cast<QFileSystemNode*>(&root);
const_cast<QFileSystemNode*>(&root);
never executed: return const_cast<QFileSystemNode*>(&root);
0
106 QFileSystemModelPrivate::QFileSystemNode *indexNode = static_cast<QFileSystemModelPrivate::QFileSystemNode*>(index.internalPointer());-
107 ((!(indexNode)) ? qt_assert("indexNode",__FILE__,303) : qt_noop());-
108 return
never executed: return indexNode;
indexNode;
never executed: return indexNode;
0
109}-
110QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QString &path, bool fetch) const-
111{-
112 const QFileSystemModel * const q = q_func();-
113 (void)q;;-
114 if (path.isEmpty()
path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| path == myComputer()
path == myComputer()Description
TRUEnever evaluated
FALSEnever evaluated
|| path.startsWith(QLatin1Char(':'))
path.startsWit...tin1Char(':'))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
115 return
never executed: return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
never executed: return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
0
116-
117-
118 QString absolutePath;-
119-
120-
121-
122 QString longPath = path;-
123-
124 if (longPath == rootDir.path()
longPath == rootDir.path()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
125 absolutePath = rootDir.absolutePath();
never executed: absolutePath = rootDir.absolutePath();
0
126 else-
127 absolutePath = QDir(longPath).absolutePath();
never executed: absolutePath = QDir(longPath).absolutePath();
0
128-
129-
130 QStringList pathElements = absolutePath.split(QLatin1Char('/'), QString::SkipEmptyParts);-
131 if ((
(pathElements.isEmpty())Description
TRUEnever evaluated
FALSEnever evaluated
pathElements.isEmpty())
(pathElements.isEmpty())Description
TRUEnever evaluated
FALSEnever evaluated
0
132-
133 && QDir::fromNativeSeparators(longPath) != QLatin1String("/")
QDir::fromNati...in1String("/")Description
TRUEnever evaluated
FALSEnever evaluated
0
134-
135 )-
136 return
never executed: return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
never executed: return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
0
137 QModelIndex index = QModelIndex();-
138 QString elementPath;-
139 QChar separator = QLatin1Char('/');-
140 QString trailingSeparator;-
141 if (absolutePath[0] == QLatin1Char('/')
absolutePath[0...atin1Char('/')Description
TRUEnever evaluated
FALSEnever evaluated
)
0
142 pathElements.prepend(QLatin1String("/"));
never executed: pathElements.prepend(QLatin1String("/"));
0
143-
144-
145 QFileSystemModelPrivate::QFileSystemNode *parent = node(index);-
146-
147 for (int i = 0; i < pathElements.count()
i < pathElements.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
148 QString element = pathElements.at(i);-
149 if (i != 0
i != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
150 elementPath.append(separator);
never executed: elementPath.append(separator);
0
151 elementPath.append(element);-
152 if (i == pathElements.count() - 1
i == pathElements.count() - 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
153 elementPath.append(trailingSeparator);
never executed: elementPath.append(trailingSeparator);
0
154 bool alreadyExisted = parent->children.contains(element);-
155-
156-
157-
158 if (alreadyExisted
alreadyExistedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
159 if ((
(parent->child....count() == 0)Description
TRUEnever evaluated
FALSEnever evaluated
parent->children.count() == 0)
(parent->child....count() == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
160 || (parent->caseSensitive()
parent->caseSensitive()Description
TRUEnever evaluated
FALSEnever evaluated
0
161 && parent->children.value(element)->fileName != element
parent->childr...ame != elementDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
162 || (!parent->caseSensitive()
!parent->caseSensitive()Description
TRUEnever evaluated
FALSEnever evaluated
0
163 && parent->children.value(element)->fileName.toLower() != element.toLower()
parent->childr...ment.toLower()Description
TRUEnever evaluated
FALSEnever evaluated
))
0
164 alreadyExisted = false;
never executed: alreadyExisted = false;
0
165 }
never executed: end of block
0
166-
167 QFileSystemModelPrivate::QFileSystemNode *node;-
168 if (!alreadyExisted
!alreadyExistedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
169-
170-
171 QFileInfo info(elementPath);-
172 if (!info.exists()
!info.exists()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
173 return
never executed: return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
never executed: return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
0
174 QFileSystemModelPrivate *p = const_cast<QFileSystemModelPrivate*>(this);-
175 node = p->addNode(parent, element,info);-
176-
177 node->populate(fileInfoGatherer.getInfo(info));-
178-
179 }
never executed: end of block
else {
0
180 node = parent->children.value(element);-
181 }
never executed: end of block
0
182-
183 ((!(node)) ? qt_assert("node",__FILE__,472) : qt_noop());-
184 if (!node->isVisible
!node->isVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
185-
186 if (alreadyExisted
alreadyExistedDescription
TRUEnever evaluated
FALSEnever evaluated
&& node->hasInformation()
node->hasInformation()Description
TRUEnever evaluated
FALSEnever evaluated
&& !fetch
!fetchDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
187 return
never executed: return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
never executed: return const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
0
188-
189 QFileSystemModelPrivate *p = const_cast<QFileSystemModelPrivate*>(this);-
190 p->addVisibleFiles(parent, QStringList(element));-
191 if (!p->bypassFilters.contains(node)
!p->bypassFilt...contains(node)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
192 p->bypassFilters[node] = 1;
never executed: p->bypassFilters[node] = 1;
0
193 QString dir = q->filePath(this->index(parent));-
194 if (!node->hasInformation()
!node->hasInformation()Description
TRUEnever evaluated
FALSEnever evaluated
&& fetch
fetchDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
195 Fetching f = { std::move(dir), std::move(element), node };-
196 p->toFetch.append(std::move(f));-
197 p->fetchingTimer.start(0, const_cast<QFileSystemModel*>(q));-
198 }
never executed: end of block
0
199 }
never executed: end of block
0
200 parent = node;-
201 }
never executed: end of block
0
202-
203 return
never executed: return parent;
parent;
never executed: return parent;
0
204}-
205-
206-
207-
208-
209void QFileSystemModel::timerEvent(QTimerEvent *event)-
210{-
211 QFileSystemModelPrivate * const d = d_func();-
212 if (event->timerId() == d->fetchingTimer.timerId()
event->timerId...imer.timerId()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
213 d->fetchingTimer.stop();-
214-
215 for (int i = 0; i < d->toFetch.count()
i < d->toFetch.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
216 const QFileSystemModelPrivate::QFileSystemNode *node = d->toFetch.at(i).node;-
217 if (!node->hasInformation()
!node->hasInformation()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
218 d->fileInfoGatherer.fetchExtendedInformation(d->toFetch.at(i).dir,-
219 QStringList(d->toFetch.at(i).file));-
220 }
never executed: end of block
else {
0
221-
222 }
never executed: end of block
0
223 }-
224-
225 d->toFetch.clear();-
226 }
never executed: end of block
0
227}
never executed: end of block
0
228-
229-
230-
231-
232-
233bool QFileSystemModel::isDir(const QModelIndex &index) const-
234{-
235-
236 const QFileSystemModelPrivate * const d = d_func();-
237 if (!index.isValid()
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
238 return
never executed: return true;
true;
never executed: return true;
0
239 QFileSystemModelPrivate::QFileSystemNode *n = d->node(index);-
240 if (n->hasInformation()
n->hasInformation()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
241 return
never executed: return n->isDir();
n->isDir();
never executed: return n->isDir();
0
242 return
never executed: return fileInfo(index).isDir();
fileInfo(index).isDir();
never executed: return fileInfo(index).isDir();
0
243}-
244-
245-
246-
247-
248qint64 QFileSystemModel::size(const QModelIndex &index) const-
249{-
250 const QFileSystemModelPrivate * const d = d_func();-
251 if (!index.isValid()
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
252 return
never executed: return 0;
0;
never executed: return 0;
0
253 return
never executed: return d->node(index)->size();
d->node(index)->size();
never executed: return d->node(index)->size();
0
254}-
255-
256-
257-
258-
259QString QFileSystemModel::type(const QModelIndex &index) const-
260{-
261 const QFileSystemModelPrivate * const d = d_func();-
262 if (!index.isValid()
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
263 return
never executed: return QString();
QString();
never executed: return QString();
0
264 return
never executed: return d->node(index)->type();
d->node(index)->type();
never executed: return d->node(index)->type();
0
265}-
266-
267-
268-
269-
270QDateTime QFileSystemModel::lastModified(const QModelIndex &index) const-
271{-
272 const QFileSystemModelPrivate * const d = d_func();-
273 if (!index.isValid()
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
274 return
never executed: return QDateTime();
QDateTime();
never executed: return QDateTime();
0
275 return
never executed: return d->node(index)->lastModified();
d->node(index)->lastModified();
never executed: return d->node(index)->lastModified();
0
276}-
277-
278-
279-
280-
281QModelIndex QFileSystemModel::parent(const QModelIndex &index) const-
282{-
283 const QFileSystemModelPrivate * const d = d_func();-
284 if (!d->indexValid(index)
!d->indexValid(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
285 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
286-
287 QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(index);-
288 ((!(indexNode != 0)) ? qt_assert("indexNode != 0",__FILE__,577) : qt_noop());-
289 QFileSystemModelPrivate::QFileSystemNode *parentNode = indexNode->parent;-
290 if (parentNode == 0
parentNode == 0Description
TRUEnever evaluated
FALSEnever evaluated
|| parentNode == &d->root
parentNode == &d->rootDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
291 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
292-
293-
294 QFileSystemModelPrivate::QFileSystemNode *grandParentNode = parentNode->parent;-
295 ((!(grandParentNode->children.contains(parentNode->fileName))) ? qt_assert("grandParentNode->children.contains(parentNode->fileName)",__FILE__,584) : qt_noop());-
296 int visualRow = d->translateVisibleLocation(grandParentNode, grandParentNode->visibleLocation(grandParentNode->children.value(parentNode->fileName)->fileName));-
297 if (visualRow == -1
visualRow == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
298 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
299 return
never executed: return createIndex(visualRow, 0, parentNode);
createIndex(visualRow, 0, parentNode);
never executed: return createIndex(visualRow, 0, parentNode);
0
300}-
301-
302-
303-
304-
305-
306-
307QModelIndex QFileSystemModelPrivate::index(const QFileSystemModelPrivate::QFileSystemNode *node, int column) const-
308{-
309 const QFileSystemModel * const q = q_func();-
310 QFileSystemModelPrivate::QFileSystemNode *parentNode = (node
nodeDescription
TRUEnever evaluated
FALSEnever evaluated
? node->parent : 0);
0
311 if (node == &root
node == &rootDescription
TRUEnever evaluated
FALSEnever evaluated
|| !parentNode
!parentNodeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
312 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
313-
314-
315 ((!(node)) ? qt_assert("node",__FILE__,604) : qt_noop());-
316 if (!node->isVisible
!node->isVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
317 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
318-
319 int visualRow = translateVisibleLocation(parentNode, parentNode->visibleLocation(node->fileName));-
320 return
never executed: return q->createIndex(visualRow, column, const_cast<QFileSystemNode*>(node));
q->createIndex(visualRow, column, const_cast<QFileSystemNode*>(node));
never executed: return q->createIndex(visualRow, column, const_cast<QFileSystemNode*>(node));
0
321}-
322-
323-
324-
325-
326bool QFileSystemModel::hasChildren(const QModelIndex &parent) const-
327{-
328 const QFileSystemModelPrivate * const d = d_func();-
329 if (parent.column() > 0
parent.column() > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
330 return
never executed: return false;
false;
never executed: return false;
0
331-
332 if (!parent.isValid()
!parent.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
333 return
never executed: return true;
true;
never executed: return true;
0
334-
335 const QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(parent);-
336 ((!(indexNode)) ? qt_assert("indexNode",__FILE__,625) : qt_noop());-
337 return
never executed: return (indexNode->isDir());
(indexNode->isDir());
never executed: return (indexNode->isDir());
0
338}-
339-
340-
341-
342-
343bool QFileSystemModel::canFetchMore(const QModelIndex &parent) const-
344{-
345 const QFileSystemModelPrivate * const d = d_func();-
346 const QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(parent);-
347 return
never executed: return (!indexNode->populatedChildren);
(!indexNode->populatedChildren);
never executed: return (!indexNode->populatedChildren);
0
348}-
349-
350-
351-
352-
353void QFileSystemModel::fetchMore(const QModelIndex &parent)-
354{-
355 QFileSystemModelPrivate * const d = d_func();-
356 if (!d->setRootPath
!d->setRootPathDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
357 return;
never executed: return;
0
358 QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(parent);-
359 if (indexNode->populatedChildren
indexNode->populatedChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
360 return;
never executed: return;
0
361 indexNode->populatedChildren = true;-
362-
363 d->fileInfoGatherer.list(filePath(parent));-
364-
365}
never executed: end of block
0
366-
367-
368-
369-
370int QFileSystemModel::rowCount(const QModelIndex &parent) const-
371{-
372 const QFileSystemModelPrivate * const d = d_func();-
373 if (parent.column() > 0
parent.column() > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
374 return
never executed: return 0;
0;
never executed: return 0;
0
375-
376 if (!parent.isValid()
!parent.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
377 return
never executed: return d->root.visibleChildren.count();
d->root.visibleChildren.count();
never executed: return d->root.visibleChildren.count();
0
378-
379 const QFileSystemModelPrivate::QFileSystemNode *parentNode = d->node(parent);-
380 return
never executed: return parentNode->visibleChildren.count();
parentNode->visibleChildren.count();
never executed: return parentNode->visibleChildren.count();
0
381}-
382-
383-
384-
385-
386int QFileSystemModel::columnCount(const QModelIndex &parent) const-
387{-
388 return
never executed: return (parent.column() > 0) ? 0 : QFileSystemModelPrivate::NumColumns;
(parent.column() > 0) ? 0 : QFileSystemModelPrivate::NumColumns;
never executed: return (parent.column() > 0) ? 0 : QFileSystemModelPrivate::NumColumns;
0
389}-
390-
391-
392-
393-
394-
395-
396QVariant QFileSystemModel::myComputer(int role) const-
397{-
398-
399 const QFileSystemModelPrivate * const d = d_func();-
400-
401 switch (role) {-
402 case
never executed: case Qt::DisplayRole:
Qt::DisplayRole:
never executed: case Qt::DisplayRole:
0
403 return
never executed: return QFileSystemModelPrivate::myComputer();
QFileSystemModelPrivate::myComputer();
never executed: return QFileSystemModelPrivate::myComputer();
0
404-
405 case
never executed: case Qt::DecorationRole:
Qt::DecorationRole:
never executed: case Qt::DecorationRole:
0
406 return
never executed: return d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Computer);
d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Computer);
never executed: return d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Computer);
0
407-
408 }-
409 return
never executed: return QVariant();
QVariant();
never executed: return QVariant();
0
410}-
411-
412-
413-
414-
415QVariant QFileSystemModel::data(const QModelIndex &index, int role) const-
416{-
417 const QFileSystemModelPrivate * const d = d_func();-
418 if (!index.isValid()
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
|| index.model() != this
index.model() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
419 return
never executed: return QVariant();
QVariant();
never executed: return QVariant();
0
420-
421 switch (role) {-
422 case
never executed: case Qt::EditRole:
Qt::EditRole:
never executed: case Qt::EditRole:
0
423 case
never executed: case Qt::DisplayRole:
Qt::DisplayRole:
never executed: case Qt::DisplayRole:
0
424 switch (index.column()) {-
425 case
never executed: case 0:
0:
never executed: case 0:
return
never executed: return d->displayName(index);
d->displayName(index);
never executed: return d->displayName(index);
0
426 case
never executed: case 1:
1:
never executed: case 1:
return
never executed: return d->size(index);
d->size(index);
never executed: return d->size(index);
0
427 case
never executed: case 2:
2:
never executed: case 2:
return
never executed: return d->type(index);
d->type(index);
never executed: return d->type(index);
0
428 case
never executed: case 3:
3:
never executed: case 3:
return
never executed: return d->time(index);
d->time(index);
never executed: return d->time(index);
0
429 default
never executed: default:
:
never executed: default:
0
430 QMessageLogger(__FILE__, 719, __PRETTY_FUNCTION__).warning("data: invalid display value column %d", index.column());-
431 break;
never executed: break;
0
432 }-
433 break;
never executed: break;
0
434 case
never executed: case FilePathRole:
FilePathRole:
never executed: case FilePathRole:
0
435 return
never executed: return filePath(index);
filePath(index);
never executed: return filePath(index);
0
436 case
never executed: case FileNameRole:
FileNameRole:
never executed: case FileNameRole:
0
437 return
never executed: return d->name(index);
d->name(index);
never executed: return d->name(index);
0
438 case
never executed: case Qt::DecorationRole:
Qt::DecorationRole:
never executed: case Qt::DecorationRole:
0
439 if (index.column() == 0
index.column() == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
440 QIcon icon = d->icon(index);-
441-
442 if (icon.isNull()
icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
443 if (d->node(index)->isDir()
d->node(index)->isDir()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
444 icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Folder);
never executed: icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::Folder);
0
445 else-
446 icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::File);
never executed: icon = d->fileInfoGatherer.iconProvider()->icon(QFileIconProvider::File);
0
447 }-
448-
449 return
never executed: return icon;
icon;
never executed: return icon;
0
450 }-
451 break;
never executed: break;
0
452 case
never executed: case Qt::TextAlignmentRole:
Qt::TextAlignmentRole:
never executed: case Qt::TextAlignmentRole:
0
453 if (index.column() == 1
index.column() == 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
454 return
never executed: return Qt::AlignRight;
Qt::AlignRight;
never executed: return Qt::AlignRight;
0
455 break;
never executed: break;
0
456 case
never executed: case FilePermissions:
FilePermissions:
never executed: case FilePermissions:
0
457 int p = permissions(index);-
458 return
never executed: return p;
p;
never executed: return p;
0
459 }-
460-
461 return
never executed: return QVariant();
QVariant();
never executed: return QVariant();
0
462}-
463-
464-
465-
466-
467QString QFileSystemModelPrivate::size(const QModelIndex &index) const-
468{-
469 if (!index.isValid()
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
470 return
never executed: return QString();
QString();
never executed: return QString();
0
471 const QFileSystemNode *n = node(index);-
472 if (n->isDir()
n->isDir()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
473-
474-
475-
476 return
never executed: return QLatin1String("");
QLatin1String("");
never executed: return QLatin1String("");
0
477-
478-
479-
480-
481-
482 }-
483 return
never executed: return size(n->size());
size(n->size());
never executed: return size(n->size());
0
484}-
485-
486QString QFileSystemModelPrivate::size(qint64 bytes)-
487{-
488-
489-
490 const qint64 kb = 1024;-
491 const qint64 mb = 1024 * kb;-
492 const qint64 gb = 1024 * mb;-
493 const qint64 tb = 1024 * gb;-
494 if (bytes >= tb
bytes >= tbDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
495 return
never executed: return QFileSystemModel::tr("%1 TB").arg(QLocale().toString(qreal(bytes) / tb, 'f', 3));
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
496 if (bytes >= gb
bytes >= gbDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
497 return
never executed: return QFileSystemModel::tr("%1 GB").arg(QLocale().toString(qreal(bytes) / gb, 'f', 2));
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
498 if (bytes >= mb
bytes >= mbDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
499 return
never executed: return QFileSystemModel::tr("%1 MB").arg(QLocale().toString(qreal(bytes) / mb, 'f', 1));
QFileSystemModel::tr("%1 MB").arg(QLocale().toString(qreal(bytes) / mb, 'f', 1));
never executed: return QFileSystemModel::tr("%1 MB").arg(QLocale().toString(qreal(bytes) / mb, 'f', 1));
0
500 if (bytes >= kb
bytes >= kbDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
501 return
never executed: return QFileSystemModel::tr("%1 KB").arg(QLocale().toString(bytes / kb));
QFileSystemModel::tr("%1 KB").arg(QLocale().toString(bytes / kb));
never executed: return QFileSystemModel::tr("%1 KB").arg(QLocale().toString(bytes / kb));
0
502 return
never executed: return QFileSystemModel::tr("%1 bytes").arg(QLocale().toString(bytes));
QFileSystemModel::tr("%1 bytes").arg(QLocale().toString(bytes));
never executed: return QFileSystemModel::tr("%1 bytes").arg(QLocale().toString(bytes));
0
503}-
504-
505-
506-
507-
508QString QFileSystemModelPrivate::time(const QModelIndex &index) const-
509{-
510 if (!index.isValid()
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
511 return
never executed: return QString();
QString();
never executed: return QString();
0
512-
513 return
never executed: return node(index)->lastModified().toString(Qt::SystemLocaleDate);
node(index)->lastModified().toString(Qt::SystemLocaleDate);
never executed: return node(index)->lastModified().toString(Qt::SystemLocaleDate);
0
514-
515-
516-
517-
518}-
519-
520-
521-
522-
523QString QFileSystemModelPrivate::type(const QModelIndex &index) const-
524{-
525 if (!index.isValid()
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
526 return
never executed: return QString();
QString();
never executed: return QString();
0
527 return
never executed: return node(index)->type();
node(index)->type();
never executed: return node(index)->type();
0
528}-
529-
530-
531-
532-
533QString QFileSystemModelPrivate::name(const QModelIndex &index) const-
534{-
535 if (!index.isValid()
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
536 return
never executed: return QString();
QString();
never executed: return QString();
0
537 QFileSystemNode *dirNode = node(index);-
538 if (-
539-
540 fileInfoGatherer.resolveSymlinks()
fileInfoGather...olveSymlinks()Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
541-
542 !resolvedSymLinks.isEmpty()
!resolvedSymLinks.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& dirNode->isSymLink( true)
dirNode->isSymLink( true)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
543 QString fullPath = QDir::fromNativeSeparators(filePath(index));-
544 return
never executed: return resolvedSymLinks.value(fullPath, dirNode->fileName);
resolvedSymLinks.value(fullPath, dirNode->fileName);
never executed: return resolvedSymLinks.value(fullPath, dirNode->fileName);
0
545 }-
546 return
never executed: return dirNode->fileName;
dirNode->fileName;
never executed: return dirNode->fileName;
0
547}-
548-
549-
550-
551-
552QString QFileSystemModelPrivate::displayName(const QModelIndex &index) const-
553{-
554-
555-
556-
557-
558-
559 return
never executed: return name(index);
name(index);
never executed: return name(index);
0
560}-
561-
562-
563-
564-
565QIcon QFileSystemModelPrivate::icon(const QModelIndex &index) const-
566{-
567 if (!index.isValid()
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
568 return
never executed: return QIcon();
QIcon();
never executed: return QIcon();
0
569 return
never executed: return node(index)->icon();
node(index)->icon();
never executed: return node(index)->icon();
0
570}-
571-
572-
573-
574-
575bool QFileSystemModel::setData(const QModelIndex &idx, const QVariant &value, int role)-
576{-
577 QFileSystemModelPrivate * const d = d_func();-
578 if (!idx.isValid()
!idx.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
579 || idx.column() != 0
idx.column() != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
580 || role != Qt::EditRole
role != Qt::EditRoleDescription
TRUEnever evaluated
FALSEnever evaluated
0
581 || (
(flags(idx) & ...Editable) == 0Description
TRUEnever evaluated
FALSEnever evaluated
flags(idx) & Qt::ItemIsEditable) == 0
(flags(idx) & ...Editable) == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
582 return
never executed: return false;
false;
never executed: return false;
0
583 }-
584-
585 QString newName = value.toString();-
586 QString oldName = idx.data().toString();-
587 if (newName == idx.data().toString()
newName == idx...a().toString()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
588 return
never executed: return true;
true;
never executed: return true;
0
589-
590 const QString parentPath = filePath(parent(idx));-
591-
592 if (newName.isEmpty()
newName.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
593 || QDir::toNativeSeparators(newName).contains(QDir::separator())
QDir::toNative...::separator())Description
TRUEnever evaluated
FALSEnever evaluated
0
594 || !QDir(parentPath).rename(oldName, newName)
!QDir(parentPa...Name, newName)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
595-
596 QMessageBox::information(0, QFileSystemModel::tr("Invalid filename"),-
597 QFileSystemModel::tr("<b>The name \"%1\" can not be used.</b><p>Try using another name, with fewer characters or no punctuations marks.")-
598 .arg(newName),-
599 QMessageBox::Ok);-
600-
601 return
never executed: return false;
false;
never executed: return false;
0
602 } else {-
603 QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(idx);-
604 QFileSystemModelPrivate::QFileSystemNode *parentNode = indexNode->parent;-
605 int visibleLocation = parentNode->visibleLocation(parentNode->children.value(indexNode->fileName)->fileName);-
606-
607 parentNode->visibleChildren.removeAt(visibleLocation);-
608 QFileSystemModelPrivate::QFileSystemNode * oldValue = parentNode->children.value(oldName);-
609 parentNode->children[newName] = oldValue;-
610 oldValue->fileName = newName;-
611 oldValue->parent = parentNode;-
612-
613 oldValue->populate(d->fileInfoGatherer.getInfo(QFileInfo(parentPath, newName)));-
614-
615 oldValue->isVisible = true;-
616-
617 parentNode->children.remove(oldName);-
618 parentNode->visibleChildren.insert(visibleLocation, newName);-
619-
620 d->delayedSort();-
621 fileRenamed(parentPath, oldName, newName);-
622 }
never executed: end of block
0
623 return
never executed: return true;
true;
never executed: return true;
0
624}-
625-
626-
627-
628-
629QVariant QFileSystemModel::headerData(int section, Qt::Orientation orientation, int role) const-
630{-
631 switch (role) {-
632 case
never executed: case Qt::DecorationRole:
Qt::DecorationRole:
never executed: case Qt::DecorationRole:
0
633 if (section == 0
section == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
634-
635-
636 QImage pixmap(16, 1, QImage::Format_Mono);-
637 pixmap.fill(0);-
638 pixmap.setAlphaChannel(pixmap.createAlphaMask());-
639 return
never executed: return pixmap;
pixmap;
never executed: return pixmap;
0
640 }-
641 break;
never executed: break;
0
642 case
never executed: case Qt::TextAlignmentRole:
Qt::TextAlignmentRole:
never executed: case Qt::TextAlignmentRole:
0
643 return
never executed: return Qt::AlignLeft;
Qt::AlignLeft;
never executed: return Qt::AlignLeft;
0
644 }-
645-
646 if (orientation != Qt::Horizontal
orientation != Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
|| role != Qt::DisplayRole
role != Qt::DisplayRoleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
647 return
never executed: return QAbstractItemModel::headerData(section, orientation, role);
QAbstractItemModel::headerData(section, orientation, role);
never executed: return QAbstractItemModel::headerData(section, orientation, role);
0
648-
649 QString returnValue;-
650 switch (section) {-
651 case
never executed: case 0:
0:
never executed: case 0:
returnValue = tr("Name");
0
652 break;
never executed: break;
0
653 case
never executed: case 1:
1:
never executed: case 1:
returnValue = tr("Size");
0
654 break;
never executed: break;
0
655 case
never executed: case 2:
2:
never executed: case 2:
returnValue =
0
656-
657-
658-
659 tr("Type", "All other platforms");-
660-
661 break;
never executed: break;
0
662-
663-
664-
665-
666 case
never executed: case 3:
3:
never executed: case 3:
returnValue = tr("Date Modified");
0
667 break;
never executed: break;
0
668 default
never executed: default:
:
never executed: default:
return
never executed: return QVariant();
QVariant();
never executed: return QVariant();
0
669 }-
670 return
never executed: return returnValue;
returnValue;
never executed: return returnValue;
0
671}-
672-
673-
674-
675-
676Qt::ItemFlags QFileSystemModel::flags(const QModelIndex &index) const-
677{-
678 const QFileSystemModelPrivate * const d = d_func();-
679 Qt::ItemFlags flags = QAbstractItemModel::flags(index);-
680 if (!index.isValid()
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
681 return
never executed: return flags;
flags;
never executed: return flags;
0
682-
683 QFileSystemModelPrivate::QFileSystemNode *indexNode = d->node(index);-
684 if (d->nameFilterDisables
d->nameFilterDisablesDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->passNameFilters(indexNode)
!d->passNameFilters(indexNode)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
685 flags &= ~Qt::ItemIsEnabled;-
686-
687 return
never executed: return flags;
flags;
never executed: return flags;
0
688 }-
689-
690 flags |= Qt::ItemIsDragEnabled;-
691 if (d->readOnly
d->readOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
692 return
never executed: return flags;
flags;
never executed: return flags;
0
693 if ((
(index.column() == 0)Description
TRUEnever evaluated
FALSEnever evaluated
index.column() == 0)
(index.column() == 0)Description
TRUEnever evaluated
FALSEnever evaluated
&& indexNode->permissions() & QFile::WriteUser
indexNode->per...ile::WriteUserDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
694 flags |= Qt::ItemIsEditable;-
695 if (indexNode->isDir()
indexNode->isDir()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
696 flags |= Qt::ItemIsDropEnabled;
never executed: flags |= Qt::ItemIsDropEnabled;
0
697 else-
698 flags |= Qt::ItemNeverHasChildren;
never executed: flags |= Qt::ItemNeverHasChildren;
0
699 }-
700 return
never executed: return flags;
flags;
never executed: return flags;
0
701}-
702-
703-
704-
705-
706void QFileSystemModelPrivate::_q_performDelayedSort()-
707{-
708 QFileSystemModel * const q = q_func();-
709 q->sort(sortColumn, sortOrder);-
710}
never executed: end of block
0
711-
712-
713-
714-
715-
716-
717class QFileSystemModelSorter-
718{-
719public:-
720 inline QFileSystemModelSorter(int column) : sortColumn(column)-
721 {-
722 naturalCompare.setNumericMode(true);-
723 naturalCompare.setCaseSensitivity(Qt::CaseInsensitive);-
724 }
never executed: end of block
0
725-
726 bool compareNodes(const QFileSystemModelPrivate::QFileSystemNode *l,-
727 const QFileSystemModelPrivate::QFileSystemNode *r) const-
728 {-
729 switch (sortColumn) {-
730 case
never executed: case 0:
0:
never executed: case 0:
{
0
731-
732-
733 bool left = l->isDir();-
734 bool right = r->isDir();-
735 if (left ^ right
left ^ rightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
736 return
never executed: return left;
left;
never executed: return left;
0
737-
738 return
never executed: return naturalCompare.compare(l->fileName, r->fileName) < 0;
naturalCompare.compare(l->fileName, r->fileName) < 0;
never executed: return naturalCompare.compare(l->fileName, r->fileName) < 0;
0
739 }-
740 case
never executed: case 1:
1:
never executed: case 1:
0
741 {-
742-
743 bool left = l->isDir();-
744 bool right = r->isDir();-
745 if (left ^ right
left ^ rightDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
746 return
never executed: return left;
left;
never executed: return left;
0
747-
748 qint64 sizeDifference = l->size() - r->size();-
749 if (sizeDifference == 0
sizeDifference == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
750 return
never executed: return naturalCompare.compare(l->fileName, r->fileName) < 0;
naturalCompare.compare(l->fileName, r->fileName) < 0;
never executed: return naturalCompare.compare(l->fileName, r->fileName) < 0;
0
751-
752 return
never executed: return sizeDifference < 0;
sizeDifference < 0;
never executed: return sizeDifference < 0;
0
753 }-
754 case
never executed: case 2:
2:
never executed: case 2:
0
755 {-
756 int compare = naturalCompare.compare(l->type(), r->type());-
757 if (compare == 0
compare == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
758 return
never executed: return naturalCompare.compare(l->fileName, r->fileName) < 0;
naturalCompare.compare(l->fileName, r->fileName) < 0;
never executed: return naturalCompare.compare(l->fileName, r->fileName) < 0;
0
759-
760 return
never executed: return compare < 0;
compare < 0;
never executed: return compare < 0;
0
761 }-
762 case
never executed: case 3:
3:
never executed: case 3:
0
763 {-
764 if (l->lastModified() == r->lastModified()
l->lastModifie...lastModified()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
765 return
never executed: return naturalCompare.compare(l->fileName, r->fileName) < 0;
naturalCompare.compare(l->fileName, r->fileName) < 0;
never executed: return naturalCompare.compare(l->fileName, r->fileName) < 0;
0
766-
767 return
never executed: return l->lastModified() < r->lastModified();
l->lastModified() < r->lastModified();
never executed: return l->lastModified() < r->lastModified();
0
768 }-
769 }-
770 ((!(false)) ? qt_assert("false",__FILE__,1069) : qt_noop());-
771 return
never executed: return false;
false;
never executed: return false;
0
772 }-
773-
774 bool operator()(const QFileSystemModelPrivate::QFileSystemNode *l,-
775 const QFileSystemModelPrivate::QFileSystemNode *r) const-
776 {-
777 return
never executed: return compareNodes(l, r);
compareNodes(l, r);
never executed: return compareNodes(l, r);
0
778 }-
779-
780-
781private:-
782 QCollator naturalCompare;-
783 int sortColumn;-
784};-
785-
786-
787-
788-
789-
790-
791void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent)-
792{-
793 QFileSystemModel * const q = q_func();-
794 QFileSystemModelPrivate::QFileSystemNode *indexNode = node(parent);-
795 if (indexNode->children.count() == 0
indexNode->chi...n.count() == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
796 return;
never executed: return;
0
797-
798 QVector<QFileSystemModelPrivate::QFileSystemNode*> values;-
799 QHash<QString, QFileSystemNode *>::const_iterator iterator;-
800 for(iterator = indexNode->children.constBegin() ; iterator != indexNode->children.constEnd()
iterator != in...ren.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++iterator) {
0
801 if (filtersAcceptsNode(iterator.value())
filtersAccepts...rator.value())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
802 values.append(iterator.value());-
803 }
never executed: end of block
else {
0
804 iterator.value()->isVisible = false;-
805 }
never executed: end of block
0
806 }-
807 QFileSystemModelSorter ms(column);-
808 std::sort(values.begin(), values.end(), ms);-
809-
810 indexNode->visibleChildren.clear();-
811-
812 indexNode->dirtyChildrenIndex = -1;-
813 const int numValues = values.count();-
814 indexNode->visibleChildren.reserve(numValues);-
815 for (int i = 0; i < numValues
i < numValuesDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
816 indexNode->visibleChildren.append(values.at(i)->fileName);-
817 values.at(i)->isVisible = true;-
818 }
never executed: end of block
0
819-
820 if (!disableRecursiveSort
!disableRecursiveSortDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
821 for (int i = 0; i < q->rowCount(parent)
i < q->rowCount(parent)Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
822 const QModelIndex childIndex = q->index(i, 0, parent);-
823 QFileSystemModelPrivate::QFileSystemNode *indexNode = node(childIndex);-
824-
825 if (indexNode->isVisible
indexNode->isVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
826 sortChildren(column, childIndex);
never executed: sortChildren(column, childIndex);
0
827 }
never executed: end of block
0
828 }
never executed: end of block
0
829}
never executed: end of block
0
830-
831-
832-
833-
834void QFileSystemModel::sort(int column, Qt::SortOrder order)-
835{-
836 QFileSystemModelPrivate * const d = d_func();-
837 if (d->sortOrder == order
d->sortOrder == orderDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->sortColumn == column
d->sortColumn == columnDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->forceSort
!d->forceSortDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
838 return;
never executed: return;
0
839-
840 layoutAboutToBeChanged();-
841 QModelIndexList oldList = persistentIndexList();-
842 QVector<QPair<QFileSystemModelPrivate::QFileSystemNode*, int> > oldNodes;-
843 const int nodeCount = oldList.count();-
844 oldNodes.reserve(nodeCount);-
845 for (int i = 0; i < nodeCount
i < nodeCountDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
846 const QModelIndex &oldNode = oldList.at(i);-
847 QPair<QFileSystemModelPrivate::QFileSystemNode*, int> pair(d->node(oldNode), oldNode.column());-
848 oldNodes.append(pair);-
849 }
never executed: end of block
0
850-
851 if (!(d->sortColumn == column
d->sortColumn == columnDescription
TRUEnever evaluated
FALSEnever evaluated
&& d->sortOrder != order
d->sortOrder != orderDescription
TRUEnever evaluated
FALSEnever evaluated
&& !d->forceSort
!d->forceSortDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
852-
853 d->sortChildren(column, index(rootPath()));-
854 d->sortColumn = column;-
855 d->forceSort = false;-
856 }
never executed: end of block
0
857 d->sortOrder = order;-
858-
859 QModelIndexList newList;-
860 const int numOldNodes = oldNodes.size();-
861 newList.reserve(numOldNodes);-
862 for (int i = 0; i < numOldNodes
i < numOldNodesDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
863 const QPair<QFileSystemModelPrivate::QFileSystemNode*, int> &oldNode = oldNodes.at(i);-
864 newList.append(d->index(oldNode.first, oldNode.second));-
865 }
never executed: end of block
0
866 changePersistentIndexList(oldList, newList);-
867 layoutChanged();-
868}
never executed: end of block
0
869-
870-
871-
872-
873-
874QStringList QFileSystemModel::mimeTypes() const-
875{-
876 return
never executed: return QStringList(QLatin1String("text/uri-list"));
QStringList(QLatin1String("text/uri-list"));
never executed: return QStringList(QLatin1String("text/uri-list"));
0
877}-
878QMimeData *QFileSystemModel::mimeData(const QModelIndexList &indexes) const-
879{-
880 QList<QUrl> urls;-
881 QList<QModelIndex>::const_iterator it = indexes.begin();-
882 for (; it != indexes.end()
it != indexes.end()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it)
0
883 if ((*
(*it).column() == 0Description
TRUEnever evaluated
FALSEnever evaluated
it).column() == 0
(*it).column() == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
884 urls << QUrl::fromLocalFile(filePath(*it));
never executed: urls << QUrl::fromLocalFile(filePath(*it));
0
885 QMimeData *data = new QMimeData();-
886 data->setUrls(urls);-
887 return
never executed: return data;
data;
never executed: return data;
0
888}-
889bool QFileSystemModel::dropMimeData(const QMimeData *data, Qt::DropAction action,-
890 int row, int column, const QModelIndex &parent)-
891{-
892 (void)row;;-
893 (void)column;;-
894 if (!parent.isValid()
!parent.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
|| isReadOnly()
isReadOnly()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
895 return
never executed: return false;
false;
never executed: return false;
0
896-
897 bool success = true;-
898 QString to = filePath(parent) + QDir::separator();-
899-
900 QList<QUrl> urls = data->urls();-
901 QList<QUrl>::const_iterator it = urls.constBegin();-
902-
903 switch (action) {-
904 case
never executed: case Qt::CopyAction:
Qt::CopyAction:
never executed: case Qt::CopyAction:
0
905 for (; it != urls.constEnd()
it != urls.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
906 QString path = (*it).toLocalFile();-
907 success = QFile::copy(path, to + QFileInfo(path).fileName())
QFile::copy(pa...h).fileName())Description
TRUEnever evaluated
FALSEnever evaluated
&& success
successDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
908 }
never executed: end of block
0
909 break;
never executed: break;
0
910 case
never executed: case Qt::LinkAction:
Qt::LinkAction:
never executed: case Qt::LinkAction:
0
911 for (; it != urls.constEnd()
it != urls.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
912 QString path = (*it).toLocalFile();-
913 success = QFile::link(path, to + QFileInfo(path).fileName())
QFile::link(pa...h).fileName())Description
TRUEnever evaluated
FALSEnever evaluated
&& success
successDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
914 }
never executed: end of block
0
915 break;
never executed: break;
0
916 case
never executed: case Qt::MoveAction:
Qt::MoveAction:
never executed: case Qt::MoveAction:
0
917 for (; it != urls.constEnd()
it != urls.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
918 QString path = (*it).toLocalFile();-
919 success = QFile::rename(path, to + QFileInfo(path).fileName())
QFile::rename(...h).fileName())Description
TRUEnever evaluated
FALSEnever evaluated
&& success
successDescription
TRUEnever evaluated
FALSEnever evaluated
;
0
920 }
never executed: end of block
0
921 break;
never executed: break;
0
922 default
never executed: default:
:
never executed: default:
0
923 return
never executed: return false;
false;
never executed: return false;
0
924 }-
925-
926 return
never executed: return success;
success;
never executed: return success;
0
927}-
928-
929-
930-
931-
932Qt::DropActions QFileSystemModel::supportedDropActions() const-
933{-
934 return
never executed: return Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
never executed: return Qt::CopyAction | Qt::MoveAction | Qt::LinkAction;
0
935}-
936-
937-
938-
939-
940-
941QString QFileSystemModel::filePath(const QModelIndex &index) const-
942{-
943 const QFileSystemModelPrivate * const d = d_func();-
944 QString fullPath = d->filePath(index);-
945 QFileSystemModelPrivate::QFileSystemNode *dirNode = d->node(index);-
946 if (dirNode->isSymLink()
dirNode->isSymLink()Description
TRUEnever evaluated
FALSEnever evaluated
0
947-
948 && d->fileInfoGatherer.resolveSymlinks()
d->fileInfoGat...olveSymlinks()Description
TRUEnever evaluated
FALSEnever evaluated
0
949-
950 && d->resolvedSymLinks.contains(fullPath)
d->resolvedSym...ains(fullPath)Description
TRUEnever evaluated
FALSEnever evaluated
0
951 && dirNode->isDir()
dirNode->isDir()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
952 QFileInfo resolvedInfo(fullPath);-
953 resolvedInfo = resolvedInfo.canonicalFilePath();-
954 if (resolvedInfo.exists()
resolvedInfo.exists()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
955 return
never executed: return resolvedInfo.filePath();
resolvedInfo.filePath();
never executed: return resolvedInfo.filePath();
0
956 }
never executed: end of block
0
957 return
never executed: return fullPath;
fullPath;
never executed: return fullPath;
0
958}-
959-
960QString QFileSystemModelPrivate::filePath(const QModelIndex &index) const-
961{-
962 const QFileSystemModel * const q = q_func();-
963 (void)q;;-
964 if (!index.isValid()
!index.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
965 return
never executed: return QString();
QString();
never executed: return QString();
0
966 ((!(index.model() == q)) ? qt_assert("index.model() == q",__FILE__,1282) : qt_noop());-
967-
968 QStringList path;-
969 QModelIndex idx = index;-
970 while (idx.isValid()
idx.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
971 QFileSystemModelPrivate::QFileSystemNode *dirNode = node(idx);-
972 if (dirNode
dirNodeDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
973 path.prepend(dirNode->fileName);
never executed: path.prepend(dirNode->fileName);
0
974 idx = idx.parent();-
975 }
never executed: end of block
0
976 QString fullPath = QDir::fromNativeSeparators(path.join(QDir::separator()));-
977-
978 if ((
(fullPath.length() > 2)Description
TRUEnever evaluated
FALSEnever evaluated
fullPath.length() > 2)
(fullPath.length() > 2)Description
TRUEnever evaluated
FALSEnever evaluated
&& fullPath[0] == QLatin1Char('/')
fullPath[0] ==...atin1Char('/')Description
TRUEnever evaluated
FALSEnever evaluated
&& fullPath[1] == QLatin1Char('/')
fullPath[1] ==...atin1Char('/')Description
TRUEnever evaluated
FALSEnever evaluated
)
0
979 fullPath = fullPath.mid(1);
never executed: fullPath = fullPath.mid(1);
0
980-
981-
982-
983-
984-
985 return
never executed: return fullPath;
fullPath;
never executed: return fullPath;
0
986}-
987-
988-
989-
990-
991QModelIndex QFileSystemModel::mkdir(const QModelIndex &parent, const QString &name)-
992{-
993 QFileSystemModelPrivate * const d = d_func();-
994 if (!parent.isValid()
!parent.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
995 return
never executed: return parent;
parent;
never executed: return parent;
0
996-
997 QDir dir(filePath(parent));-
998 if (!dir.mkdir(name)
!dir.mkdir(name)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
999 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
1000 QFileSystemModelPrivate::QFileSystemNode *parentNode = d->node(parent);-
1001 d->addNode(parentNode, name, QFileInfo());-
1002 ((!(parentNode->children.contains(name))) ? qt_assert("parentNode->children.contains(name)",__FILE__,1318) : qt_noop());-
1003 QFileSystemModelPrivate::QFileSystemNode *node = parentNode->children[name];-
1004-
1005 node->populate(d->fileInfoGatherer.getInfo(QFileInfo(dir.absolutePath() + QDir::separator() + name)));-
1006-
1007 d->addVisibleFiles(parentNode, QStringList(name));-
1008 return
never executed: return d->index(node);
d->index(node);
never executed: return d->index(node);
0
1009}-
1010-
1011-
1012-
1013-
1014QFile::Permissions QFileSystemModel::permissions(const QModelIndex &index) const-
1015{-
1016 const QFileSystemModelPrivate * const d = d_func();-
1017 return
never executed: return d->node(index)->permissions();
d->node(index)->permissions();
never executed: return d->node(index)->permissions();
0
1018}-
1019QModelIndex QFileSystemModel::setRootPath(const QString &newPath)-
1020{-
1021 QFileSystemModelPrivate * const d = d_func();-
1022-
1023-
1024-
1025-
1026-
1027-
1028-
1029 QString longNewPath = newPath;-
1030-
1031 QDir newPathDir(longNewPath);-
1032-
1033 if (!newPath.isEmpty()
!newPath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1034 longNewPath = QDir::cleanPath(longNewPath);-
1035 newPathDir.setPath(longNewPath);-
1036 }
never executed: end of block
0
1037-
1038 d->setRootPath = true;-
1039-
1040-
1041 if (!newPath.isEmpty()
!newPath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& longNewPath.isEmpty()
longNewPath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1042 return
never executed: return d->index(rootPath());
d->index(rootPath());
never executed: return d->index(rootPath());
0
1043-
1044 if (d->rootDir.path() == longNewPath
d->rootDir.pat...== longNewPathDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1045 return
never executed: return d->index(rootPath());
d->index(rootPath());
never executed: return d->index(rootPath());
0
1046-
1047 bool showDrives = (longNewPath.isEmpty()
longNewPath.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| longNewPath == d->myComputer()
longNewPath == d->myComputer()Description
TRUEnever evaluated
FALSEnever evaluated
);
0
1048 if (!showDrives
!showDrivesDescription
TRUEnever evaluated
FALSEnever evaluated
&& !newPathDir.exists()
!newPathDir.exists()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1049 return
never executed: return d->index(rootPath());
d->index(rootPath());
never executed: return d->index(rootPath());
0
1050-
1051-
1052 if (!rootPath().isEmpty()
!rootPath().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& rootPath() != QLatin1String(".")
rootPath() != ...in1String(".")Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1053-
1054-
1055 d->fileInfoGatherer.removePath(rootPath());-
1056-
1057-
1058-
1059-
1060 d->node(rootPath())->populatedChildren = false;-
1061 }
never executed: end of block
0
1062-
1063-
1064 d->rootDir = newPathDir;-
1065 QModelIndex newRootIndex;-
1066 if (showDrives
showDrivesDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1067-
1068 d->rootDir.setPath(QLatin1String(""));-
1069 }
never executed: end of block
else {
0
1070 newRootIndex = d->index(newPathDir.path());-
1071 }
never executed: end of block
0
1072 fetchMore(newRootIndex);-
1073 rootPathChanged(longNewPath);-
1074 d->forceSort = true;-
1075 d->delayedSort();-
1076 return
never executed: return newRootIndex;
newRootIndex;
never executed: return newRootIndex;
0
1077}-
1078-
1079-
1080-
1081-
1082-
1083-
1084QString QFileSystemModel::rootPath() const-
1085{-
1086 const QFileSystemModelPrivate * const d = d_func();-
1087 return
never executed: return d->rootDir.path();
d->rootDir.path();
never executed: return d->rootDir.path();
0
1088}-
1089-
1090-
1091-
1092-
1093-
1094-
1095QDir QFileSystemModel::rootDirectory() const-
1096{-
1097 const QFileSystemModelPrivate * const d = d_func();-
1098 QDir dir(d->rootDir);-
1099 dir.setNameFilters(nameFilters());-
1100 dir.setFilter(filter());-
1101 return
never executed: return dir;
dir;
never executed: return dir;
0
1102}-
1103-
1104-
1105-
1106-
1107void QFileSystemModel::setIconProvider(QFileIconProvider *provider)-
1108{-
1109 QFileSystemModelPrivate * const d = d_func();-
1110-
1111 d->fileInfoGatherer.setIconProvider(provider);-
1112-
1113 d->root.updateIcon(provider, QString());-
1114}
never executed: end of block
0
1115-
1116-
1117-
1118-
1119QFileIconProvider *QFileSystemModel::iconProvider() const-
1120{-
1121-
1122 const QFileSystemModelPrivate * const d = d_func();-
1123 return
never executed: return d->fileInfoGatherer.iconProvider();
d->fileInfoGatherer.iconProvider();
never executed: return d->fileInfoGatherer.iconProvider();
0
1124-
1125-
1126-
1127}-
1128void QFileSystemModel::setFilter(QDir::Filters filters)-
1129{-
1130 QFileSystemModelPrivate * const d = d_func();-
1131 if (d->filters == filters
d->filters == filtersDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1132 return;
never executed: return;
0
1133 d->filters = filters;-
1134-
1135 setNameFilters(nameFilters());-
1136 d->forceSort = true;-
1137 d->delayedSort();-
1138}
never executed: end of block
0
1139QDir::Filters QFileSystemModel::filter() const-
1140{-
1141 const QFileSystemModelPrivate * const d = d_func();-
1142 return
never executed: return d->filters;
d->filters;
never executed: return d->filters;
0
1143}-
1144void QFileSystemModel::setResolveSymlinks(bool enable)-
1145{-
1146-
1147 QFileSystemModelPrivate * const d = d_func();-
1148 d->fileInfoGatherer.setResolveSymlinks(enable);-
1149-
1150-
1151-
1152}
never executed: end of block
0
1153-
1154bool QFileSystemModel::resolveSymlinks() const-
1155{-
1156-
1157 const QFileSystemModelPrivate * const d = d_func();-
1158 return
never executed: return d->fileInfoGatherer.resolveSymlinks();
d->fileInfoGatherer.resolveSymlinks();
never executed: return d->fileInfoGatherer.resolveSymlinks();
0
1159-
1160-
1161-
1162}-
1163void QFileSystemModel::setReadOnly(bool enable)-
1164{-
1165 QFileSystemModelPrivate * const d = d_func();-
1166 d->readOnly = enable;-
1167}
never executed: end of block
0
1168-
1169bool QFileSystemModel::isReadOnly() const-
1170{-
1171 const QFileSystemModelPrivate * const d = d_func();-
1172 return
never executed: return d->readOnly;
d->readOnly;
never executed: return d->readOnly;
0
1173}-
1174-
1175-
1176-
1177-
1178-
1179-
1180-
1181void QFileSystemModel::setNameFilterDisables(bool enable)-
1182{-
1183 QFileSystemModelPrivate * const d = d_func();-
1184 if (d->nameFilterDisables == enable
d->nameFilterD...bles == enableDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1185 return;
never executed: return;
0
1186 d->nameFilterDisables = enable;-
1187 d->forceSort = true;-
1188 d->delayedSort();-
1189}
never executed: end of block
0
1190-
1191bool QFileSystemModel::nameFilterDisables() const-
1192{-
1193 const QFileSystemModelPrivate * const d = d_func();-
1194 return
never executed: return d->nameFilterDisables;
d->nameFilterDisables;
never executed: return d->nameFilterDisables;
0
1195}-
1196-
1197-
1198-
1199-
1200void QFileSystemModel::setNameFilters(const QStringList &filters)-
1201{-
1202-
1203-
1204 QFileSystemModelPrivate * const d = d_func();-
1205-
1206 if (!d->bypassFilters.isEmpty()
!d->bypassFilters.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1207-
1208 d->bypassFilters.clear();-
1209-
1210 QPersistentModelIndex root(index(rootPath()));-
1211 const QModelIndexList persistentList = persistentIndexList();-
1212 for (const auto &persistentIndex : persistentList) {-
1213 QFileSystemModelPrivate::QFileSystemNode *node = d->node(persistentIndex);-
1214 while (node
nodeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1215 if (d->bypassFilters.contains(node)
d->bypassFilte...contains(node)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1216 break;
never executed: break;
0
1217 if (node->isDir()
node->isDir()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1218 d->bypassFilters[node] = true;
never executed: d->bypassFilters[node] = true;
0
1219 node = node->parent;-
1220 }
never executed: end of block
0
1221 }
never executed: end of block
0
1222 }
never executed: end of block
0
1223-
1224 d->nameFilters.clear();-
1225 const Qt::CaseSensitivity caseSensitive =-
1226 (
(filter() & QD...CaseSensitive)Description
TRUEnever evaluated
FALSEnever evaluated
filter() & QDir::CaseSensitive)
(filter() & QD...CaseSensitive)Description
TRUEnever evaluated
FALSEnever evaluated
? Qt::CaseSensitive : Qt::CaseInsensitive;
0
1227 for (const auto &filter : filters)-
1228 d->nameFilters << QRegExp(filter, caseSensitive, QRegExp::Wildcard);
never executed: d->nameFilters << QRegExp(filter, caseSensitive, QRegExp::Wildcard);
0
1229 d->forceSort = true;-
1230 d->delayedSort();-
1231-
1232}
never executed: end of block
0
1233-
1234-
1235-
1236-
1237QStringList QFileSystemModel::nameFilters() const-
1238{-
1239 const QFileSystemModelPrivate * const d = d_func();-
1240 QStringList filters;-
1241-
1242 const int numNameFilters = d->nameFilters.size();-
1243 filters.reserve(numNameFilters);-
1244 for (int i = 0; i < numNameFilters
i < numNameFiltersDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1245 filters << d->nameFilters.at(i).pattern();-
1246 }
never executed: end of block
0
1247-
1248 return
never executed: return filters;
filters;
never executed: return filters;
0
1249}-
1250-
1251-
1252-
1253-
1254bool QFileSystemModel::event(QEvent *event)-
1255{-
1256-
1257 QFileSystemModelPrivate * const d = d_func();-
1258 if (event->type() == QEvent::LanguageChange
event->type() ...LanguageChangeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1259 d->root.retranslateStrings(d->fileInfoGatherer.iconProvider(), QString());-
1260 return
never executed: return true;
true;
never executed: return true;
0
1261 }-
1262-
1263 return
never executed: return QAbstractItemModel::event(event);
QAbstractItemModel::event(event);
never executed: return QAbstractItemModel::event(event);
0
1264}-
1265-
1266bool QFileSystemModel::rmdir(const QModelIndex &aindex)-
1267{-
1268 QString path = filePath(aindex);-
1269 const bool success = QDir().rmdir(path);-
1270-
1271 if (success
successDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1272 QFileSystemModelPrivate * d = const_cast<QFileSystemModelPrivate*>(d_func());-
1273 d->fileInfoGatherer.removePath(path);-
1274 }
never executed: end of block
0
1275-
1276 return
never executed: return success;
success;
never executed: return success;
0
1277}-
1278-
1279-
1280-
1281-
1282-
1283-
1284-
1285void QFileSystemModelPrivate::_q_directoryChanged(const QString &directory, const QStringList &files)-
1286{-
1287 QFileSystemModelPrivate::QFileSystemNode *parentNode = node(directory, false);-
1288 if (parentNode->children.count() == 0
parentNode->ch...n.count() == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1289 return;
never executed: return;
0
1290 QStringList toRemove;-
1291 QStringList newFiles = files;-
1292 std::sort(newFiles.begin(), newFiles.end());-
1293 QHash<QString, QFileSystemNode*>::const_iterator i = parentNode->children.constBegin();-
1294 while (i != parentNode->children.constEnd()
i != parentNod...ren.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1295 QStringList::iterator iterator = std::lower_bound(newFiles.begin(), newFiles.end(), i.value()->fileName);-
1296 if ((
(iterator == newFiles.end())Description
TRUEnever evaluated
FALSEnever evaluated
iterator == newFiles.end())
(iterator == newFiles.end())Description
TRUEnever evaluated
FALSEnever evaluated
|| (
(i.value()->fi...e < *iterator)Description
TRUEnever evaluated
FALSEnever evaluated
i.value()->fileName < *iterator)
(i.value()->fi...e < *iterator)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1297 toRemove.append(i.value()->fileName);
never executed: toRemove.append(i.value()->fileName);
0
1298-
1299 ++i;-
1300 }
never executed: end of block
0
1301 for (int i = 0 ; i < toRemove.count()
i < toRemove.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i )
0
1302 removeNode(parentNode, toRemove[i]);
never executed: removeNode(parentNode, toRemove[i]);
0
1303}
never executed: end of block
0
1304QFileSystemModelPrivate::QFileSystemNode* QFileSystemModelPrivate::addNode(QFileSystemNode *parentNode, const QString &fileName, const QFileInfo& info)-
1305{-
1306-
1307 QFileSystemModelPrivate::QFileSystemNode *node = new QFileSystemModelPrivate::QFileSystemNode(fileName, parentNode);-
1308-
1309 node->populate(info);-
1310 parentNode->children.insert(fileName, node);-
1311 return
never executed: return node;
node;
never executed: return node;
0
1312}-
1313void QFileSystemModelPrivate::removeNode(QFileSystemModelPrivate::QFileSystemNode *parentNode, const QString& name)-
1314{-
1315 QFileSystemModel * const q = q_func();-
1316 QModelIndex parent = index(parentNode);-
1317 bool indexHidden = isHiddenByFilter(parentNode, parent);-
1318-
1319 int vLocation = parentNode->visibleLocation(name);-
1320 if (vLocation >= 0
vLocation >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& !indexHidden
!indexHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1321 q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation),
never executed: q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation), translateVisibleLocation(parentNode, vLocation));
0
1322 translateVisibleLocation(parentNode, vLocation));
never executed: q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation), translateVisibleLocation(parentNode, vLocation));
0
1323 QFileSystemNode * node = parentNode->children.take(name);-
1324 delete node;-
1325-
1326 if (vLocation >= 0
vLocation >= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1327 parentNode->visibleChildren.removeAt(vLocation);
never executed: parentNode->visibleChildren.removeAt(vLocation);
0
1328 if (vLocation >= 0
vLocation >= 0Description
TRUEnever evaluated
FALSEnever evaluated
&& !indexHidden
!indexHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1329 q->endRemoveRows();
never executed: q->endRemoveRows();
0
1330}
never executed: end of block
0
1331void QFileSystemModelPrivate::addVisibleFiles(QFileSystemNode *parentNode, const QStringList &newFiles)-
1332{-
1333 QFileSystemModel * const q = q_func();-
1334 QModelIndex parent = index(parentNode);-
1335 bool indexHidden = isHiddenByFilter(parentNode, parent);-
1336 if (!indexHidden
!indexHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1337 q->beginInsertRows(parent, parentNode->visibleChildren.count() , parentNode->visibleChildren.count() + newFiles.count() - 1);-
1338 }
never executed: end of block
0
1339-
1340 if (parentNode->dirtyChildrenIndex == -1
parentNode->di...renIndex == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1341 parentNode->dirtyChildrenIndex = parentNode->visibleChildren.count();
never executed: parentNode->dirtyChildrenIndex = parentNode->visibleChildren.count();
0
1342-
1343 for (const auto &newFile : newFiles) {-
1344 parentNode->visibleChildren.append(newFile);-
1345 parentNode->children.value(newFile)->isVisible = true;-
1346 }
never executed: end of block
0
1347 if (!indexHidden
!indexHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1348 q->endInsertRows();
never executed: q->endInsertRows();
0
1349}
never executed: end of block
0
1350void QFileSystemModelPrivate::removeVisibleFile(QFileSystemNode *parentNode, int vLocation)-
1351{-
1352 QFileSystemModel * const q = q_func();-
1353 if (vLocation == -1
vLocation == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1354 return;
never executed: return;
0
1355 QModelIndex parent = index(parentNode);-
1356 bool indexHidden = isHiddenByFilter(parentNode, parent);-
1357 if (!indexHidden
!indexHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1358 q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation),
never executed: q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation), translateVisibleLocation(parentNode, vLocation));
0
1359 translateVisibleLocation(parentNode, vLocation));
never executed: q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation), translateVisibleLocation(parentNode, vLocation));
0
1360 parentNode->children.value(parentNode->visibleChildren.at(vLocation))->isVisible = false;-
1361 parentNode->visibleChildren.removeAt(vLocation);-
1362 if (!indexHidden
!indexHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1363 q->endRemoveRows();
never executed: q->endRemoveRows();
0
1364}
never executed: end of block
0
1365-
1366-
1367-
1368-
1369-
1370-
1371-
1372void QFileSystemModelPrivate::_q_fileSystemChanged(const QString &path, const QVector<QPair<QString, QFileInfo> > &updates)-
1373{-
1374-
1375 QFileSystemModel * const q = q_func();-
1376 QVector<QString> rowsToUpdate;-
1377 QStringList newFiles;-
1378 QFileSystemModelPrivate::QFileSystemNode *parentNode = node(path, false);-
1379 QModelIndex parentIndex = index(parentNode);-
1380 for (const auto &update : updates) {-
1381 QString fileName = update.first;-
1382 ((!(!fileName.isEmpty())) ? qt_assert("!fileName.isEmpty()",__FILE__,1798) : qt_noop());-
1383 QExtendedInformation info = fileInfoGatherer.getInfo(update.second);-
1384 bool previouslyHere = parentNode->children.contains(fileName);-
1385 if (!previouslyHere
!previouslyHereDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1386 addNode(parentNode, fileName, info.fileInfo());-
1387 }
never executed: end of block
0
1388 QFileSystemModelPrivate::QFileSystemNode * node = parentNode->children.value(fileName);-
1389 bool isCaseSensitive = parentNode->caseSensitive();-
1390 if (isCaseSensitive
isCaseSensitiveDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1391 if (node->fileName != fileName
node->fileName != fileNameDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1392 continue;
never executed: continue;
0
1393 }
never executed: end of block
else {
0
1394 if (QString::compare(node->fileName,fileName,Qt::CaseInsensitive) != 0
QString::compa...ensitive) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1395 continue;
never executed: continue;
0
1396 }
never executed: end of block
0
1397 if (isCaseSensitive
isCaseSensitiveDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1398 ((!(node->fileName == fileName)) ? qt_assert("node->fileName == fileName",__FILE__,1814) : qt_noop());-
1399 }
never executed: end of block
else {
0
1400 node->fileName = fileName;-
1401 }
never executed: end of block
0
1402-
1403 if (*
*node != infoDescription
TRUEnever evaluated
FALSEnever evaluated
node != info
*node != infoDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1404 node->populate(info);-
1405 bypassFilters.remove(node);-
1406-
1407 if (filtersAcceptsNode(node)
filtersAcceptsNode(node)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1408 if (!node->isVisible
!node->isVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1409 newFiles.append(fileName);-
1410 }
never executed: end of block
else {
0
1411 rowsToUpdate.append(fileName);-
1412 }
never executed: end of block
0
1413 } else {-
1414 if (node->isVisible
node->isVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1415 int visibleLocation = parentNode->visibleLocation(fileName);-
1416 removeVisibleFile(parentNode, visibleLocation);-
1417 }
never executed: end of block
else {
0
1418-
1419 }
never executed: end of block
0
1420 }-
1421 }-
1422 }
never executed: end of block
0
1423-
1424-
1425 std::sort(rowsToUpdate.begin(), rowsToUpdate.end());-
1426 QString min;-
1427 QString max;-
1428 for (int i = 0; i < rowsToUpdate.count()
i < rowsToUpdate.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1429 QString value = rowsToUpdate.at(i);-
1430 max = value;-
1431 min = value;-
1432 int visibleMin = parentNode->visibleLocation(min);-
1433 int visibleMax = parentNode->visibleLocation(max);-
1434 if (visibleMin >= 0
visibleMin >= 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1435 && visibleMin < parentNode->visibleChildren.count()
visibleMin < p...ildren.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
1436 && parentNode->visibleChildren.at(visibleMin) == min
parentNode->vi...bleMin) == minDescription
TRUEnever evaluated
FALSEnever evaluated
0
1437 && visibleMax >= 0
visibleMax >= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1438 QModelIndex bottom = q->index(translateVisibleLocation(parentNode, visibleMin), 0, parentIndex);-
1439 QModelIndex top = q->index(translateVisibleLocation(parentNode, visibleMax), 3, parentIndex);-
1440 q->dataChanged(bottom, top);-
1441 }
never executed: end of block
0
1442-
1443-
1444-
1445 }
never executed: end of block
0
1446-
1447 if (newFiles.count() > 0
newFiles.count() > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1448 addVisibleFiles(parentNode, newFiles);-
1449 }
never executed: end of block
0
1450-
1451 if (newFiles.count() > 0
newFiles.count() > 0Description
TRUEnever evaluated
FALSEnever evaluated
|| (sortColumn != 0
sortColumn != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& rowsToUpdate.count() > 0
rowsToUpdate.count() > 0Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
1452 forceSort = true;-
1453 delayedSort();-
1454 }
never executed: end of block
0
1455-
1456-
1457-
1458-
1459}
never executed: end of block
0
1460-
1461-
1462-
1463-
1464void QFileSystemModelPrivate::_q_resolvedName(const QString &fileName, const QString &resolvedName)-
1465{-
1466 resolvedSymLinks[fileName] = resolvedName;-
1467}
never executed: end of block
0
1468-
1469-
1470-
1471-
1472void QFileSystemModelPrivate::init()-
1473{-
1474 QFileSystemModel * const q = q_func();-
1475 qRegisterMetaType<QVector<QPair<QString,QFileInfo> > >();-
1476-
1477 q->connect(&fileInfoGatherer, qFlagLocation("2""newListOfFiles(QString,QStringList)" "\0" __FILE__ ":" "1905"),-
1478 q, qFlagLocation("1""_q_directoryChanged(QString,QStringList)" "\0" __FILE__ ":" "1906"));-
1479 q->connect(&fileInfoGatherer, qFlagLocation("2""updates(QString,QVector<QPair<QString,QFileInfo> >)" "\0" __FILE__ ":" "1907"),-
1480 q, qFlagLocation("1""_q_fileSystemChanged(QString,QVector<QPair<QString,QFileInfo> >)" "\0" __FILE__ ":" "1908"));-
1481 q->connect(&fileInfoGatherer, qFlagLocation("2""nameResolved(QString,QString)" "\0" __FILE__ ":" "1909"),-
1482 q, qFlagLocation("1""_q_resolvedName(QString,QString)" "\0" __FILE__ ":" "1910"));-
1483 q->connect(&fileInfoGatherer, qFlagLocation("2""directoryLoaded(QString)" "\0" __FILE__ ":" "1911"),-
1484 q, qFlagLocation("2""directoryLoaded(QString)" "\0" __FILE__ ":" "1912"));-
1485-
1486 q->connect(&delayedSortTimer, qFlagLocation("2""timeout()" "\0" __FILE__ ":" "1914"), q, qFlagLocation("1""_q_performDelayedSort()" "\0" __FILE__ ":" "1914"), Qt::QueuedConnection);-
1487-
1488 roleNames.insertMulti(QFileSystemModel::FileIconRole, ([]() -> QByteArray { enum { Size = sizeof("fileIcon") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "fileIcon" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return
never executed: return ba;
ba;
never executed: return ba;
}()));
0
1489 roleNames.insert(QFileSystemModel::FilePathRole, ([]() -> QByteArray { enum { Size = sizeof("filePath") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "filePath" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return
never executed: return ba;
ba;
never executed: return ba;
}()));
0
1490 roleNames.insert(QFileSystemModel::FileNameRole, ([]() -> QByteArray { enum { Size = sizeof("fileName") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "fileName" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return
never executed: return ba;
ba;
never executed: return ba;
}()));
0
1491 roleNames.insert(QFileSystemModel::FilePermissions, ([]() -> QByteArray { enum { Size = sizeof("filePermissions") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "filePermissions" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return
never executed: return ba;
ba;
never executed: return ba;
}()));
0
1492}
never executed: end of block
0
1493bool QFileSystemModelPrivate::filtersAcceptsNode(const QFileSystemNode *node) const-
1494{-
1495-
1496 if (node->parent == &root
node->parent == &rootDescription
TRUEnever evaluated
FALSEnever evaluated
|| bypassFilters.contains(node)
bypassFilters.contains(node)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1497 return
never executed: return true;
true;
never executed: return true;
0
1498-
1499-
1500 if (!node->hasInformation()
!node->hasInformation()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1501 return
never executed: return false;
false;
never executed: return false;
0
1502-
1503 const bool filterPermissions = ((
(filters & QDi...ermissionMask)Description
TRUEnever evaluated
FALSEnever evaluated
filters & QDir::PermissionMask)
(filters & QDi...ermissionMask)Description
TRUEnever evaluated
FALSEnever evaluated
0
1504 && (
(filters & QDi...PermissionMaskDescription
TRUEnever evaluated
FALSEnever evaluated
filters & QDir::PermissionMask) != QDir::PermissionMask
(filters & QDi...PermissionMaskDescription
TRUEnever evaluated
FALSEnever evaluated
);
0
1505 const bool hideDirs = !(filters & (QDir::Dirs | QDir::AllDirs));-
1506 const bool hideFiles = !(filters & QDir::Files);-
1507 const bool hideReadable = !(!filterPermissions
!filterPermissionsDescription
TRUEnever evaluated
FALSEnever evaluated
|| (
(filters & QDir::Readable)Description
TRUEnever evaluated
FALSEnever evaluated
filters & QDir::Readable)
(filters & QDir::Readable)Description
TRUEnever evaluated
FALSEnever evaluated
);
0
1508 const bool hideWritable = !(!filterPermissions
!filterPermissionsDescription
TRUEnever evaluated
FALSEnever evaluated
|| (
(filters & QDir::Writable)Description
TRUEnever evaluated
FALSEnever evaluated
filters & QDir::Writable)
(filters & QDir::Writable)Description
TRUEnever evaluated
FALSEnever evaluated
);
0
1509 const bool hideExecutable = !(!filterPermissions
!filterPermissionsDescription
TRUEnever evaluated
FALSEnever evaluated
|| (
(filters & QDir::Executable)Description
TRUEnever evaluated
FALSEnever evaluated
filters & QDir::Executable)
(filters & QDir::Executable)Description
TRUEnever evaluated
FALSEnever evaluated
);
0
1510 const bool hideHidden = !(filters & QDir::Hidden);-
1511 const bool hideSystem = !(filters & QDir::System);-
1512 const bool hideSymlinks = (filters & QDir::NoSymLinks);-
1513 const bool hideDot = (filters & QDir::NoDot);-
1514 const bool hideDotDot = (filters & QDir::NoDotDot);-
1515-
1516-
1517 bool isDot = (node->fileName == QLatin1String("."));-
1518 bool isDotDot = (node->fileName == QLatin1String(".."));-
1519 if ( (hideHidden
hideHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
&& !(isDot
isDotDescription
TRUEnever evaluated
FALSEnever evaluated
|| isDotDot
isDotDotDescription
TRUEnever evaluated
FALSEnever evaluated
) && node->isHidden()
node->isHidden()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1520 || (hideSystem
hideSystemDescription
TRUEnever evaluated
FALSEnever evaluated
&& node->isSystem()
node->isSystem()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1521 || (hideDirs
hideDirsDescription
TRUEnever evaluated
FALSEnever evaluated
&& node->isDir()
node->isDir()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1522 || (hideFiles
hideFilesDescription
TRUEnever evaluated
FALSEnever evaluated
&& node->isFile()
node->isFile()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1523 || (hideSymlinks
hideSymlinksDescription
TRUEnever evaluated
FALSEnever evaluated
&& node->isSymLink()
node->isSymLink()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1524 || (hideReadable
hideReadableDescription
TRUEnever evaluated
FALSEnever evaluated
&& node->isReadable()
node->isReadable()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1525 || (hideWritable
hideWritableDescription
TRUEnever evaluated
FALSEnever evaluated
&& node->isWritable()
node->isWritable()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1526 || (hideExecutable
hideExecutableDescription
TRUEnever evaluated
FALSEnever evaluated
&& node->isExecutable()
node->isExecutable()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1527 || (hideDot
hideDotDescription
TRUEnever evaluated
FALSEnever evaluated
&& isDot
isDotDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1528 || (hideDotDot
hideDotDotDescription
TRUEnever evaluated
FALSEnever evaluated
&& isDotDot
isDotDotDescription
TRUEnever evaluated
FALSEnever evaluated
))
0
1529 return
never executed: return false;
false;
never executed: return false;
0
1530-
1531 return
never executed: return nameFilterDisables || passNameFilters(node);
nameFilterDisables || passNameFilters(node);
never executed: return nameFilterDisables || passNameFilters(node);
0
1532}-
1533-
1534-
1535-
1536-
1537-
1538-
1539bool QFileSystemModelPrivate::passNameFilters(const QFileSystemNode *node) const-
1540{-
1541-
1542 if (nameFilters.isEmpty()
nameFilters.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1543 return
never executed: return true;
true;
never executed: return true;
0
1544-
1545-
1546 if (!(node->isDir()
node->isDir()Description
TRUEnever evaluated
FALSEnever evaluated
&& (
(filters & QDir::AllDirs)Description
TRUEnever evaluated
FALSEnever evaluated
filters & QDir::AllDirs)
(filters & QDir::AllDirs)Description
TRUEnever evaluated
FALSEnever evaluated
)) {
0
1547 for (const auto &nameFilter : nameFilters) {-
1548 QRegExp copy = nameFilter;-
1549 if (copy.exactMatch(node->fileName)
copy.exactMatc...ode->fileName)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1550 return
never executed: return true;
true;
never executed: return true;
0
1551 }
never executed: end of block
0
1552 return
never executed: return false;
false;
never executed: return false;
0
1553 }-
1554-
1555 return
never executed: return true;
true;
never executed: return true;
0
1556}-
1557-
1558-
1559-
Switch to Source codePreprocessed file

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