qdirmodel.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/itemviews/qdirmodel.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6class QDirModelPrivate : public QAbstractItemModelPrivate-
7{-
8 inline QDirModel* q_func() { return static_cast<QDirModel *>(q_ptr); } inline const QDirModel* q_func() const { return static_cast<const QDirModel *>(q_ptr); } friend class QDirModel;-
9-
10public:-
11 struct QDirNode-
12 {-
13 QDirNode() : parent(0), populated(false), stat(false) {}
never executed: end of block
0
14 QDirNode *parent;-
15 QFileInfo info;-
16 QIcon icon;-
17 mutable QVector<QDirNode> children;-
18 mutable bool populated;-
19 mutable bool stat;-
20 };-
21-
22 QDirModelPrivate()-
23 : resolveSymlinks(true),-
24 readOnly(true),-
25 lazyChildCount(false),-
26 allowAppendChild(true),-
27 iconProvider(&defaultProvider),-
28 shouldStat(true)-
29 { }
never executed: end of block
0
30-
31 void init();-
32 QDirNode *node(int row, QDirNode *parent) const;-
33 QVector<QDirNode> children(QDirNode *parent, bool stat) const;-
34-
35 void _q_refresh();-
36-
37 void savePersistentIndexes();-
38 void restorePersistentIndexes();-
39-
40 QFileInfoList entryInfoList(const QString &path) const;-
41 QStringList entryList(const QString &path) const;-
42-
43 QString name(const QModelIndex &index) const;-
44 QString size(const QModelIndex &index) const;-
45 QString type(const QModelIndex &index) const;-
46 QString time(const QModelIndex &index) const;-
47-
48 void appendChild(QDirModelPrivate::QDirNode *parent, const QString &path) const;-
49 static QFileInfo resolvedInfo(QFileInfo info);-
50-
51 inline QDirNode *node(const QModelIndex &index) const;-
52 inline void populate(QDirNode *parent) const;-
53 inline void clear(QDirNode *parent) const;-
54-
55 void invalidate();-
56-
57 mutable QDirNode root;-
58 bool resolveSymlinks;-
59 bool readOnly;-
60 bool lazyChildCount;-
61 bool allowAppendChild;-
62-
63 QDir::Filters filters;-
64 QDir::SortFlags sort;-
65 QStringList nameFilters;-
66-
67 QFileIconProvider *iconProvider;-
68 QFileIconProvider defaultProvider;-
69-
70 struct SavedPersistent {-
71 QString path;-
72 int column;-
73 QPersistentModelIndexData *data;-
74 QPersistentModelIndex index;-
75 };-
76 QVector<SavedPersistent> savedPersistent;-
77 QPersistentModelIndex toBeRefreshed;-
78-
79 bool shouldStat;-
80};-
81template<> class QTypeInfo<QDirModelPrivate::SavedPersistent > { public: enum { isComplex = (((Q_MOVABLE_TYPE) & Q_PRIMITIVE_TYPE) == 0), isStatic = (((Q_MOVABLE_TYPE) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), isRelocatable = !isStatic || ((Q_MOVABLE_TYPE) & Q_RELOCATABLE_TYPE), isLarge = (sizeof(QDirModelPrivate::SavedPersistent)>sizeof(void*)), isPointer = false, isIntegral = QtPrivate::is_integral< QDirModelPrivate::SavedPersistent >::value, isDummy = (((Q_MOVABLE_TYPE) & Q_DUMMY_TYPE) != 0), sizeOf = sizeof(QDirModelPrivate::SavedPersistent) }; static inline const char *name() { return "QDirModelPrivate::SavedPersistent"; } };-
82-
83void qt_setDirModelShouldNotStat(QDirModelPrivate *modelPrivate)-
84{-
85 modelPrivate->shouldStat = false;-
86}
never executed: end of block
0
87-
88QDirModelPrivate::QDirNode *QDirModelPrivate::node(const QModelIndex &index) const-
89{-
90 QDirModelPrivate::QDirNode *n =-
91 static_cast<QDirModelPrivate::QDirNode*>(index.internalPointer());-
92 ((!(n)) ? qt_assert("n",__FILE__,155) : qt_noop());-
93 return
never executed: return n;
n;
never executed: return n;
0
94}-
95-
96void QDirModelPrivate::populate(QDirNode *parent) const-
97{-
98 ((!(parent)) ? qt_assert("parent",__FILE__,161) : qt_noop());-
99 parent->children = children(parent, parent->stat);-
100 parent->populated = true;-
101}
never executed: end of block
0
102-
103void QDirModelPrivate::clear(QDirNode *parent) const-
104{-
105 ((!(parent)) ? qt_assert("parent",__FILE__,168) : qt_noop());-
106 parent->children.clear();-
107 parent->populated = false;-
108}
never executed: end of block
0
109-
110void QDirModelPrivate::invalidate()-
111{-
112 std::stack<const QDirNode*, std::vector<const QDirNode*> > nodes;-
113 nodes.push(&root);-
114 while (!nodes.empty()
!nodes.empty()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
115 const QDirNode *current = nodes.top();-
116 nodes.pop();-
117 current->stat = false;-
118 const QVector<QDirNode> &children = current->children;-
119 for (const auto &child : children)-
120 nodes.push(&child);
never executed: nodes.push(&child);
0
121 }
never executed: end of block
0
122}
never executed: end of block
0
123QDirModel::QDirModel(const QStringList &nameFilters,-
124 QDir::Filters filters,-
125 QDir::SortFlags sort,-
126 QObject *parent)-
127 : QAbstractItemModel(*new QDirModelPrivate, parent)-
128{-
129 QDirModelPrivate * const d = d_func();-
130-
131 d->nameFilters = nameFilters.isEmpty()
nameFilters.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
? QStringList(QLatin1String("*")) : nameFilters;
0
132 d->filters = filters;-
133 d->sort = sort;-
134 d->root.parent = 0;-
135 d->root.info = QFileInfo();-
136 d->clear(&d->root);-
137}
never executed: end of block
0
138-
139-
140-
141-
142-
143QDirModel::QDirModel(QObject *parent)-
144 : QAbstractItemModel(*new QDirModelPrivate, parent)-
145{-
146 QDirModelPrivate * const d = d_func();-
147 d->init();-
148}
never executed: end of block
0
149-
150-
151-
152-
153QDirModel::QDirModel(QDirModelPrivate &dd, QObject *parent)-
154 : QAbstractItemModel(dd, parent)-
155{-
156 QDirModelPrivate * const d = d_func();-
157 d->init();-
158}
never executed: end of block
0
159-
160-
161-
162-
163-
164QDirModel::~QDirModel()-
165{-
166-
167}-
168-
169-
170-
171-
172-
173-
174-
175QModelIndex QDirModel::index(int row, int column, const QModelIndex &parent) const-
176{-
177 const QDirModelPrivate * const d = d_func();-
178-
179 if (column < 0
column < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| column >= columnCount(parent)
column >= columnCount(parent)Description
TRUEnever evaluated
FALSEnever evaluated
|| row < 0
row < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| parent.column() > 0
parent.column() > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
180 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
181-
182 QDirModelPrivate::QDirNode *p = (d->indexValid(parent)
d->indexValid(parent)Description
TRUEnever evaluated
FALSEnever evaluated
? d->node(parent) : &d->root);
0
183 ((!(p)) ? qt_assert("p",__FILE__,288) : qt_noop());-
184 if (!p->populated
!p->populatedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
185 d->populate(p);
never executed: d->populate(p);
0
186 if (row >= p->children.count()
row >= p->children.count()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
187 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
188-
189 QDirModelPrivate::QDirNode *n = d->node(row, d->indexValid(parent) ? p : 0);-
190 ((!(n)) ? qt_assert("n",__FILE__,295) : qt_noop());-
191-
192 return
never executed: return createIndex(row, column, n);
createIndex(row, column, n);
never executed: return createIndex(row, column, n);
0
193}-
194-
195-
196-
197-
198-
199QModelIndex QDirModel::parent(const QModelIndex &child) const-
200{-
201 const QDirModelPrivate * const d = d_func();-
202-
203 if (!d->indexValid(child)
!d->indexValid(child)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
204 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
205 QDirModelPrivate::QDirNode *node = d->node(child);-
206 QDirModelPrivate::QDirNode *par = (node
nodeDescription
TRUEnever evaluated
FALSEnever evaluated
? node->parent : 0);
0
207 if (par == 0
par == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
208 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
209-
210-
211 const QVector<QDirModelPrivate::QDirNode> children =-
212 par->parent
par->parentDescription
TRUEnever evaluated
FALSEnever evaluated
? par->parent->children : d->root.children;
0
213 ((!(children.count() > 0)) ? qt_assert("children.count() > 0",__FILE__,318) : qt_noop());-
214 int row = (par - &(children.at(0)));-
215 ((!(row >= 0)) ? qt_assert("row >= 0",__FILE__,320) : qt_noop());-
216-
217 return
never executed: return createIndex(row, 0, par);
createIndex(row, 0, par);
never executed: return createIndex(row, 0, par);
0
218}-
219-
220-
221-
222-
223-
224-
225int QDirModel::rowCount(const QModelIndex &parent) const-
226{-
227 const QDirModelPrivate * const d = d_func();-
228 if (parent.column() > 0
parent.column() > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
229 return
never executed: return 0;
0;
never executed: return 0;
0
230-
231 if (!parent.isValid()
!parent.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
232 if (!d->root.populated
!d->root.populatedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
233 d->populate(&d->root);
never executed: d->populate(&d->root);
0
234 return
never executed: return d->root.children.count();
d->root.children.count();
never executed: return d->root.children.count();
0
235 }-
236 if (parent.model() != this
parent.model() != thisDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
237 return
never executed: return 0;
0;
never executed: return 0;
0
238 QDirModelPrivate::QDirNode *p = d->node(parent);-
239 if (p->info.isDir()
p->info.isDir()Description
TRUEnever evaluated
FALSEnever evaluated
&& !p->populated
!p->populatedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
240 d->populate(p);
never executed: d->populate(p);
0
241 return
never executed: return p->children.count();
p->children.count();
never executed: return p->children.count();
0
242}-
243-
244-
245-
246-
247-
248-
249int QDirModel::columnCount(const QModelIndex &parent) const-
250{-
251 if (parent.column() > 0
parent.column() > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
252 return
never executed: return 0;
0;
never executed: return 0;
0
253 return
never executed: return 4;
4;
never executed: return 4;
0
254}-
255-
256-
257-
258-
259QVariant QDirModel::data(const QModelIndex &index, int role) const-
260{-
261 const QDirModelPrivate * const d = d_func();-
262 if (!d->indexValid(index)
!d->indexValid(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
263 return
never executed: return QVariant();
QVariant();
never executed: return QVariant();
0
264-
265 if (role == Qt::DisplayRole
role == Qt::DisplayRoleDescription
TRUEnever evaluated
FALSEnever evaluated
|| role == Qt::EditRole
role == Qt::EditRoleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
266 switch (index.column()) {-
267 case
never executed: case 0:
0:
never executed: case 0:
return
never executed: return d->name(index);
d->name(index);
never executed: return d->name(index);
0
268 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
269 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
270 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
271 default
never executed: default:
:
never executed: default:
0
272 QMessageLogger(__FILE__, 377, __PRETTY_FUNCTION__).warning("data: invalid display value column %d", index.column());-
273 return
never executed: return QVariant();
QVariant();
never executed: return QVariant();
0
274 }-
275 }-
276-
277 if (index.column() == 0
index.column() == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
278 if (role == FileIconRole
role == FileIconRoleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
279 return
never executed: return fileIcon(index);
fileIcon(index);
never executed: return fileIcon(index);
0
280 if (role == FilePathRole
role == FilePathRoleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
281 return
never executed: return filePath(index);
filePath(index);
never executed: return filePath(index);
0
282 if (role == FileNameRole
role == FileNameRoleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
283 return
never executed: return fileName(index);
fileName(index);
never executed: return fileName(index);
0
284 }
never executed: end of block
0
285-
286 if (index.column() == 1
index.column() == 1Description
TRUEnever evaluated
FALSEnever evaluated
&& Qt::TextAlignmentRole == role
Qt::TextAlignmentRole == roleDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
287 return
never executed: return Qt::AlignRight;
Qt::AlignRight;
never executed: return Qt::AlignRight;
0
288 }-
289 return
never executed: return QVariant();
QVariant();
never executed: return QVariant();
0
290}-
291bool QDirModel::setData(const QModelIndex &index, const QVariant &value, int role)-
292{-
293 QDirModelPrivate * const d = d_func();-
294 if (!d->indexValid(index)
!d->indexValid(index)Description
TRUEnever evaluated
FALSEnever evaluated
|| index.column() != 0
index.column() != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
295 || (
(flags(index) ...Editable) == 0Description
TRUEnever evaluated
FALSEnever evaluated
flags(index) & Qt::ItemIsEditable) == 0
(flags(index) ...Editable) == 0Description
TRUEnever evaluated
FALSEnever evaluated
|| role != Qt::EditRole
role != Qt::EditRoleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
296 return
never executed: return false;
false;
never executed: return false;
0
297-
298 QDirModelPrivate::QDirNode *node = d->node(index);-
299 QDir dir = node->info.dir();-
300 QString name = value.toString();-
301 if (dir.rename(node->info.fileName(), name)
dir.rename(nod...eName(), name)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
302 node->info = QFileInfo(dir, name);-
303 QModelIndex sibling = index.sibling(index.row(), 3);-
304 dataChanged(index, sibling);-
305-
306 d->toBeRefreshed = index.parent();-
307 QMetaObject::invokeMethod(this, "_q_refresh", Qt::QueuedConnection);-
308-
309 return
never executed: return true;
true;
never executed: return true;
0
310 }-
311-
312 return
never executed: return false;
false;
never executed: return false;
0
313}-
314-
315-
316-
317-
318-
319-
320QVariant QDirModel::headerData(int section, Qt::Orientation orientation, int role) const-
321{-
322 if (orientation == Qt::Horizontal
orientation == Qt::HorizontalDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
323 if (role != Qt::DisplayRole
role != Qt::DisplayRoleDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
324 return
never executed: return QVariant();
QVariant();
never executed: return QVariant();
0
325 switch (section) {-
326 case
never executed: case 0:
0:
never executed: case 0:
return
never executed: return tr("Name");
tr("Name");
never executed: return tr("Name");
0
327 case
never executed: case 1:
1:
never executed: case 1:
return
never executed: return tr("Size");
tr("Size");
never executed: return tr("Size");
0
328 case
never executed: case 2:
2:
never executed: case 2:
return
never executed: return tr("Type", "All other platforms");
0
3290
3300
3310
332 tr("Type", "All other platforms");
never executed: return tr("Type", "All other platforms");
0
333-
334-
335-
336-
337-
338 case
never executed: case 3:
3:
never executed: case 3:
return
never executed: return tr("Date Modified");
tr("Date Modified");
never executed: return tr("Date Modified");
0
339 default
never executed: default:
:
never executed: default:
return
never executed: return QVariant();
QVariant();
never executed: return QVariant();
0
340 }-
341 }-
342 return
never executed: return QAbstractItemModel::headerData(section, orientation, role);
QAbstractItemModel::headerData(section, orientation, role);
never executed: return QAbstractItemModel::headerData(section, orientation, role);
0
343}-
344-
345-
346-
347-
348-
349-
350bool QDirModel::hasChildren(const QModelIndex &parent) const-
351{-
352 const QDirModelPrivate * const d = d_func();-
353 if (parent.column() > 0
parent.column() > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
354 return
never executed: return false;
false;
never executed: return false;
0
355-
356 if (!parent.isValid()
!parent.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
357 return
never executed: return true;
true;
never executed: return true;
0
358 QDirModelPrivate::QDirNode *p = d->node(parent);-
359 ((!(p)) ? qt_assert("p",__FILE__,473) : qt_noop());-
360-
361 if (d->lazyChildCount
d->lazyChildCountDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
362 return
never executed: return p->info.isDir();
p->info.isDir();
never executed: return p->info.isDir();
0
363 return
never executed: return p->info.isDir() && rowCount(parent) > 0;
p->info.isDir() && rowCount(parent) > 0;
never executed: return p->info.isDir() && rowCount(parent) > 0;
0
364}-
365-
366-
367-
368-
369-
370-
371Qt::ItemFlags QDirModel::flags(const QModelIndex &index) const-
372{-
373 const QDirModelPrivate * const d = d_func();-
374 Qt::ItemFlags flags = QAbstractItemModel::flags(index);-
375 if (!d->indexValid(index)
!d->indexValid(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
376 return
never executed: return flags;
flags;
never executed: return flags;
0
377 flags |= Qt::ItemIsDragEnabled;-
378 if (d->readOnly
d->readOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
379 return
never executed: return flags;
flags;
never executed: return flags;
0
380 QDirModelPrivate::QDirNode *node = d->node(index);-
381 if ((
(index.column() == 0)Description
TRUEnever evaluated
FALSEnever evaluated
index.column() == 0)
(index.column() == 0)Description
TRUEnever evaluated
FALSEnever evaluated
&& node->info.isWritable()
node->info.isWritable()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
382 flags |= Qt::ItemIsEditable;-
383 if (fileInfo(index).isDir()
fileInfo(index).isDir()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
384 flags |= Qt::ItemIsDropEnabled;
never executed: flags |= Qt::ItemIsDropEnabled;
0
385 }
never executed: end of block
0
386 return
never executed: return flags;
flags;
never executed: return flags;
0
387}-
388-
389-
390-
391-
392-
393-
394void QDirModel::sort(int column, Qt::SortOrder order)-
395{-
396 QDir::SortFlags sort = QDir::DirsFirst | QDir::IgnoreCase;-
397 if (order == Qt::DescendingOrder
order == Qt::DescendingOrderDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
398 sort |= QDir::Reversed;
never executed: sort |= QDir::Reversed;
0
399-
400 switch (column) {-
401 case
never executed: case 0:
0:
never executed: case 0:
0
402 sort |= QDir::Name;-
403 break;
never executed: break;
0
404 case
never executed: case 1:
1:
never executed: case 1:
0
405 sort |= QDir::Size;-
406 break;
never executed: break;
0
407 case
never executed: case 2:
2:
never executed: case 2:
0
408 sort |= QDir::Type;-
409 break;
never executed: break;
0
410 case
never executed: case 3:
3:
never executed: case 3:
0
411 sort |= QDir::Time;-
412 break;
never executed: break;
0
413 default
never executed: default:
:
never executed: default:
0
414 break;
never executed: break;
0
415 }-
416-
417 setSorting(sort);-
418}
never executed: end of block
0
419-
420-
421-
422-
423-
424-
425QStringList QDirModel::mimeTypes() const-
426{-
427 return
never executed: return QStringList(QLatin1String("text/uri-list"));
QStringList(QLatin1String("text/uri-list"));
never executed: return QStringList(QLatin1String("text/uri-list"));
0
428}-
429QMimeData *QDirModel::mimeData(const QModelIndexList &indexes) const-
430{-
431 QList<QUrl> urls;-
432 QList<QModelIndex>::const_iterator it = indexes.begin();-
433 for (; it != indexes.end()
it != indexes.end()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it)
0
434 if ((*
(*it).column() == 0Description
TRUEnever evaluated
FALSEnever evaluated
it).column() == 0
(*it).column() == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
435 urls << QUrl::fromLocalFile(filePath(*it));
never executed: urls << QUrl::fromLocalFile(filePath(*it));
0
436 QMimeData *data = new QMimeData();-
437 data->setUrls(urls);-
438 return
never executed: return data;
data;
never executed: return data;
0
439}-
440bool QDirModel::dropMimeData(const QMimeData *data, Qt::DropAction action,-
441 int , int , const QModelIndex &parent)-
442{-
443 QDirModelPrivate * const d = d_func();-
444 if (!d->indexValid(parent)
!d->indexValid(parent)Description
TRUEnever evaluated
FALSEnever evaluated
|| isReadOnly()
isReadOnly()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
445 return
never executed: return false;
false;
never executed: return false;
0
446-
447 bool success = true;-
448 QString to = filePath(parent) + QDir::separator();-
449 QModelIndex _parent = parent;-
450-
451 QList<QUrl> urls = data->urls();-
452 QList<QUrl>::const_iterator it = urls.constBegin();-
453-
454 switch (action) {-
455 case
never executed: case Qt::CopyAction:
Qt::CopyAction:
never executed: case Qt::CopyAction:
0
456 for (; it != urls.constEnd()
it != urls.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
457 QString path = (*it).toLocalFile();-
458 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
459 }
never executed: end of block
0
460 break;
never executed: break;
0
461 case
never executed: case Qt::LinkAction:
Qt::LinkAction:
never executed: case Qt::LinkAction:
0
462 for (; it != urls.constEnd()
it != urls.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
463 QString path = (*it).toLocalFile();-
464 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
465 }
never executed: end of block
0
466 break;
never executed: break;
0
467 case
never executed: case Qt::MoveAction:
Qt::MoveAction:
never executed: case Qt::MoveAction:
0
468 for (; it != urls.constEnd()
it != urls.constEnd()Description
TRUEnever evaluated
FALSEnever evaluated
; ++it) {
0
469 QString path = (*it).toLocalFile();-
470 if (QFile::copy(path, to + QFileInfo(path).fileName())
QFile::copy(pa...h).fileName())Description
TRUEnever evaluated
FALSEnever evaluated
0
471 && QFile::remove(path)
QFile::remove(path)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
472 QModelIndex idx=index(QFileInfo(path).path());-
473 if (idx.isValid()
idx.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
474 refresh(idx);-
475-
476 _parent = index(to);-
477 }
never executed: end of block
0
478 }
never executed: end of block
else {
0
479 success = false;-
480 }
never executed: end of block
0
481 }-
482 break;
never executed: break;
0
483 default
never executed: default:
:
never executed: default:
0
484 return
never executed: return false;
false;
never executed: return false;
0
485 }-
486-
487 if (success
successDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
488 refresh(_parent);
never executed: refresh(_parent);
0
489-
490 return
never executed: return success;
success;
never executed: return success;
0
491}-
492-
493-
494-
495-
496-
497-
498-
499Qt::DropActions QDirModel::supportedDropActions() const-
500{-
501 return
never executed: return Qt::CopyAction | Qt::MoveAction;
Qt::CopyAction | Qt::MoveAction;
never executed: return Qt::CopyAction | Qt::MoveAction;
0
502}-
503-
504-
505-
506-
507-
508-
509void QDirModel::setIconProvider(QFileIconProvider *provider)-
510{-
511 QDirModelPrivate * const d = d_func();-
512 d->iconProvider = provider;-
513}
never executed: end of block
0
514-
515-
516-
517-
518-
519QFileIconProvider *QDirModel::iconProvider() const-
520{-
521 const QDirModelPrivate * const d = d_func();-
522 return
never executed: return d->iconProvider;
d->iconProvider;
never executed: return d->iconProvider;
0
523}-
524-
525-
526-
527-
528-
529void QDirModel::setNameFilters(const QStringList &filters)-
530{-
531 QDirModelPrivate * const d = d_func();-
532 d->nameFilters = filters;-
533 layoutAboutToBeChanged();-
534 if (d->shouldStat
d->shouldStatDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
535 refresh(QModelIndex());
never executed: refresh(QModelIndex());
0
536 else-
537 d->invalidate();
never executed: d->invalidate();
0
538 layoutChanged();-
539}
never executed: end of block
0
540-
541-
542-
543-
544-
545QStringList QDirModel::nameFilters() const-
546{-
547 const QDirModelPrivate * const d = d_func();-
548 return
never executed: return d->nameFilters;
d->nameFilters;
never executed: return d->nameFilters;
0
549}-
550void QDirModel::setFilter(QDir::Filters filters)-
551{-
552 QDirModelPrivate * const d = d_func();-
553 d->filters = filters;-
554 layoutAboutToBeChanged();-
555 if (d->shouldStat
d->shouldStatDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
556 refresh(QModelIndex());
never executed: refresh(QModelIndex());
0
557 else-
558 d->invalidate();
never executed: d->invalidate();
0
559 layoutChanged();-
560}
never executed: end of block
0
561-
562-
563-
564-
565-
566-
567-
568QDir::Filters QDirModel::filter() const-
569{-
570 const QDirModelPrivate * const d = d_func();-
571 return
never executed: return d->filters;
d->filters;
never executed: return d->filters;
0
572}-
573-
574-
575-
576-
577-
578-
579-
580void QDirModel::setSorting(QDir::SortFlags sort)-
581{-
582 QDirModelPrivate * const d = d_func();-
583 d->sort = sort;-
584 layoutAboutToBeChanged();-
585 if (d->shouldStat
d->shouldStatDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
586 refresh(QModelIndex());
never executed: refresh(QModelIndex());
0
587 else-
588 d->invalidate();
never executed: d->invalidate();
0
589 layoutChanged();-
590}
never executed: end of block
0
591-
592-
593-
594-
595-
596-
597-
598QDir::SortFlags QDirModel::sorting() const-
599{-
600 const QDirModelPrivate * const d = d_func();-
601 return
never executed: return d->sort;
d->sort;
never executed: return d->sort;
0
602}-
603void QDirModel::setResolveSymlinks(bool enable)-
604{-
605 QDirModelPrivate * const d = d_func();-
606 d->resolveSymlinks = enable;-
607}
never executed: end of block
0
608-
609bool QDirModel::resolveSymlinks() const-
610{-
611 const QDirModelPrivate * const d = d_func();-
612 return
never executed: return d->resolveSymlinks;
d->resolveSymlinks;
never executed: return d->resolveSymlinks;
0
613}-
614void QDirModel::setReadOnly(bool enable)-
615{-
616 QDirModelPrivate * const d = d_func();-
617 d->readOnly = enable;-
618}
never executed: end of block
0
619-
620bool QDirModel::isReadOnly() const-
621{-
622 const QDirModelPrivate * const d = d_func();-
623 return
never executed: return d->readOnly;
d->readOnly;
never executed: return d->readOnly;
0
624}-
625void QDirModel::setLazyChildCount(bool enable)-
626{-
627 QDirModelPrivate * const d = d_func();-
628 d->lazyChildCount = enable;-
629}
never executed: end of block
0
630-
631bool QDirModel::lazyChildCount() const-
632{-
633 const QDirModelPrivate * const d = d_func();-
634 return
never executed: return d->lazyChildCount;
d->lazyChildCount;
never executed: return d->lazyChildCount;
0
635}-
636void QDirModel::refresh(const QModelIndex &parent)-
637{-
638 QDirModelPrivate * const d = d_func();-
639-
640 QDirModelPrivate::QDirNode *n = d->indexValid(parent)
d->indexValid(parent)Description
TRUEnever evaluated
FALSEnever evaluated
? d->node(parent) : &(d->root);
0
641-
642 int rows = n->children.count();-
643 if (rows == 0
rows == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
644 layoutAboutToBeChanged();-
645 n->stat = true;-
646 n->populated = false;-
647 layoutChanged();-
648 return;
never executed: return;
0
649 }-
650-
651 layoutAboutToBeChanged();-
652 d->savePersistentIndexes();-
653 d->rowsAboutToBeRemoved(parent, 0, rows - 1);-
654 n->stat = true;-
655 d->clear(n);-
656 d->rowsRemoved(parent, 0, rows - 1);-
657 d->restorePersistentIndexes();-
658 layoutChanged();-
659}
never executed: end of block
0
660-
661-
662-
663-
664-
665-
666-
667QModelIndex QDirModel::index(const QString &path, int column) const-
668{-
669 const QDirModelPrivate * const d = d_func();-
670-
671 if (path.isEmpty()
path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| path == QCoreApplication::translate("QFileDialog", "My Computer")
path == QCoreA..."My Computer")Description
TRUEnever evaluated
FALSEnever evaluated
)
0
672 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
673-
674 QString absolutePath = QDir(path).absolutePath();-
675 QStringList pathElements = absolutePath.split(QLatin1Char('/'), QString::SkipEmptyParts);-
676 if ((pathElements.isEmpty()
pathElements.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| !QFileInfo::exists(path)
!QFileInfo::exists(path)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
677-
678 && path != QLatin1String("/")
path != QLatin1String("/")Description
TRUEnever evaluated
FALSEnever evaluated
0
679-
680 )-
681 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
682-
683 QModelIndex idx;-
684 if (!d->root.populated
!d->root.populatedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
685 d->populate(&d->root);
never executed: d->populate(&d->root);
0
686 pathElements.prepend(QLatin1String("/"));-
687-
688-
689 for (int i = 0; i < pathElements.count()
i < pathElements.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
690 ((!(!pathElements.at(i).isEmpty())) ? qt_assert("!pathElements.at(i).isEmpty()",__FILE__,914) : qt_noop());-
691 QString element = pathElements.at(i);-
692 QDirModelPrivate::QDirNode *parent = (idx.isValid()
idx.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
? d->node(idx) : &d->root);
0
693-
694 ((!(parent)) ? qt_assert("parent",__FILE__,918) : qt_noop());-
695 if (!parent->populated
!parent->populatedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
696 d->populate(parent);
never executed: d->populate(parent);
0
697-
698-
699 int row = -1;-
700 for (int j = parent->children.count() - 1; j >= 0
j >= 0Description
TRUEnever evaluated
FALSEnever evaluated
; --j) {
0
701 const QFileInfo& fi = parent->children.at(j).info;-
702 QString childFileName;-
703 childFileName = idx.isValid()
idx.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
? fi.fileName() : fi.absoluteFilePath();
0
704-
705-
706-
707 if (childFileName == element
childFileName == elementDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
708 if (i == pathElements.count() - 1
i == pathElements.count() - 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
709 parent->children[j].stat = true;
never executed: parent->children[j].stat = true;
0
710 row = j;-
711 break;
never executed: break;
0
712 }-
713 }
never executed: end of block
0
714-
715-
716 if (row == -1
row == -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
717-
718-
719-
720-
721-
722-
723-
724 QString newPath = parent->info.absoluteFilePath() + QLatin1Char('/') + element;-
725-
726 if (!d->allowAppendChild
!d->allowAppendChildDescription
TRUEnever evaluated
FALSEnever evaluated
|| !QFileInfo(newPath).isDir()
!QFileInfo(newPath).isDir()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
727 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
728 d->appendChild(parent, newPath);-
729 row = parent->children.count() - 1;-
730 if (i == pathElements.count() - 1
i == pathElements.count() - 1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
731 parent->children[row].stat = true;
never executed: parent->children[row].stat = true;
0
732 const_cast<QDirModel*>(this)->layoutChanged();-
733 }
never executed: end of block
0
734-
735 ((!(row >= 0)) ? qt_assert("row >= 0",__FILE__,959) : qt_noop());-
736 idx = createIndex(row, 0, static_cast<void*>(&parent->children[row]));-
737 ((!(idx.isValid())) ? qt_assert("idx.isValid()",__FILE__,961) : qt_noop());-
738 }
never executed: end of block
0
739-
740 if (column != 0
column != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
741 return
never executed: return idx.sibling(idx.row(), column);
idx.sibling(idx.row(), column);
never executed: return idx.sibling(idx.row(), column);
0
742 return
never executed: return idx;
idx;
never executed: return idx;
0
743}-
744-
745-
746-
747-
748-
749-
750bool QDirModel::isDir(const QModelIndex &index) const-
751{-
752 const QDirModelPrivate * const d = d_func();-
753 ((!(d->indexValid(index))) ? qt_assert("d->indexValid(index)",__FILE__,977) : qt_noop());-
754 QDirModelPrivate::QDirNode *node = d->node(index);-
755 return
never executed: return node->info.isDir();
node->info.isDir();
never executed: return node->info.isDir();
0
756}-
757-
758-
759-
760-
761-
762QModelIndex QDirModel::mkdir(const QModelIndex &parent, const QString &name)-
763{-
764 QDirModelPrivate * const d = d_func();-
765 if (!d->indexValid(parent)
!d->indexValid(parent)Description
TRUEnever evaluated
FALSEnever evaluated
|| isReadOnly()
isReadOnly()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
766 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
767-
768 QDirModelPrivate::QDirNode *p = d->node(parent);-
769 QString path = p->info.absoluteFilePath();-
770-
771-
772-
773 QDir newDir(name);-
774 QDir dir(path);-
775 if (newDir.isRelative()
newDir.isRelative()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
776 newDir = QDir(path + QLatin1Char('/') + name);
never executed: newDir = QDir(path + QLatin1Char('/') + name);
0
777 QString childName = newDir.dirName();-
778 newDir.cdUp();-
779-
780 if (newDir.absolutePath() != dir.absolutePath()
newDir.absolut...absolutePath()Description
TRUEnever evaluated
FALSEnever evaluated
|| !dir.mkdir(name)
!dir.mkdir(name)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
781 return
never executed: return QModelIndex();
QModelIndex();
never executed: return QModelIndex();
0
782-
783 refresh(parent);-
784-
785 QStringList entryList = d->entryList(path);-
786 int r = entryList.indexOf(childName);-
787 QModelIndex i = index(r, 0, parent);-
788-
789 return
never executed: return i;
i;
never executed: return i;
0
790}-
791bool QDirModel::rmdir(const QModelIndex &index)-
792{-
793 QDirModelPrivate * const d = d_func();-
794 if (!d->indexValid(index)
!d->indexValid(index)Description
TRUEnever evaluated
FALSEnever evaluated
|| isReadOnly()
isReadOnly()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
795 return
never executed: return false;
false;
never executed: return false;
0
796-
797 QDirModelPrivate::QDirNode *n = d_func()->node(index);-
798 if (__builtin_expect(!!(!n->info.isDir()), false)
__builtin_expe...Dir()), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
799 QMessageLogger(__FILE__, 1036, __PRETTY_FUNCTION__).warning("rmdir: the node is not a directory");-
800 return
never executed: return false;
false;
never executed: return false;
0
801 }-
802-
803 QModelIndex par = parent(index);-
804 QDirModelPrivate::QDirNode *p = d_func()->node(par);-
805 QDir dir = p->info.dir();-
806 QString path = n->info.absoluteFilePath();-
807 if (!dir.rmdir(path)
!dir.rmdir(path)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
808 return
never executed: return false;
false;
never executed: return false;
0
809-
810 refresh(par);-
811-
812 return
never executed: return true;
true;
never executed: return true;
0
813}-
814bool QDirModel::remove(const QModelIndex &index)-
815{-
816 QDirModelPrivate * const d = d_func();-
817 if (!d->indexValid(index)
!d->indexValid(index)Description
TRUEnever evaluated
FALSEnever evaluated
|| isReadOnly()
isReadOnly()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
818 return
never executed: return false;
false;
never executed: return false;
0
819-
820 QDirModelPrivate::QDirNode *n = d_func()->node(index);-
821 if (n->info.isDir()
n->info.isDir()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
822 return
never executed: return false;
false;
never executed: return false;
0
823-
824 QModelIndex par = parent(index);-
825 QDirModelPrivate::QDirNode *p = d_func()->node(par);-
826 QDir dir = p->info.dir();-
827 QString path = n->info.absoluteFilePath();-
828 if (!dir.remove(path)
!dir.remove(path)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
829 return
never executed: return false;
false;
never executed: return false;
0
830-
831 refresh(par);-
832-
833 return
never executed: return true;
true;
never executed: return true;
0
834}-
835-
836-
837-
838-
839-
840-
841-
842QString QDirModel::filePath(const QModelIndex &index) const-
843{-
844 const QDirModelPrivate * const d = d_func();-
845 if (d->indexValid(index)
d->indexValid(index)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
846 QFileInfo fi = fileInfo(index);-
847 if (d->resolveSymlinks
d->resolveSymlinksDescription
TRUEnever evaluated
FALSEnever evaluated
&& fi.isSymLink()
fi.isSymLink()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
848 fi = d->resolvedInfo(fi);
never executed: fi = d->resolvedInfo(fi);
0
849 return
never executed: return QDir::cleanPath(fi.absoluteFilePath());
QDir::cleanPath(fi.absoluteFilePath());
never executed: return QDir::cleanPath(fi.absoluteFilePath());
0
850 }-
851 return
never executed: return QString();
QString();
never executed: return QString();
0
852}-
853-
854-
855-
856-
857-
858-
859-
860QString QDirModel::fileName(const QModelIndex &index) const-
861{-
862 const QDirModelPrivate * const d = d_func();-
863 if (!d->indexValid(index)
!d->indexValid(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
864 return
never executed: return QString();
QString();
never executed: return QString();
0
865 QFileInfo info = fileInfo(index);-
866 if (info.isRoot()
info.isRoot()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
867 return
never executed: return info.absoluteFilePath();
info.absoluteFilePath();
never executed: return info.absoluteFilePath();
0
868 if (d->resolveSymlinks
d->resolveSymlinksDescription
TRUEnever evaluated
FALSEnever evaluated
&& info.isSymLink()
info.isSymLink()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
869 info = d->resolvedInfo(info);
never executed: info = d->resolvedInfo(info);
0
870 return
never executed: return info.fileName();
info.fileName();
never executed: return info.fileName();
0
871}-
872-
873-
874-
875-
876-
877-
878QIcon QDirModel::fileIcon(const QModelIndex &index) const-
879{-
880 const QDirModelPrivate * const d = d_func();-
881 if (!d->indexValid(index)
!d->indexValid(index)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
882 return
never executed: return d->iconProvider->icon(QFileIconProvider::Computer);
d->iconProvider->icon(QFileIconProvider::Computer);
never executed: return d->iconProvider->icon(QFileIconProvider::Computer);
0
883 QDirModelPrivate::QDirNode *node = d->node(index);-
884 if (node->icon.isNull()
node->icon.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
885 node->icon = d->iconProvider->icon(node->info);
never executed: node->icon = d->iconProvider->icon(node->info);
0
886 return
never executed: return node->icon;
node->icon;
never executed: return node->icon;
0
887}-
888QFileInfo QDirModel::fileInfo(const QModelIndex &index) const-
889{-
890 const QDirModelPrivate * const d = d_func();-
891 ((!(d->indexValid(index))) ? qt_assert("d->indexValid(index)",__FILE__,1152) : qt_noop());-
892-
893 QDirModelPrivate::QDirNode *node = d->node(index);-
894 return
never executed: return node->info;
node->info;
never executed: return node->info;
0
895}-
896-
897-
898-
899-
900-
901void QDirModelPrivate::init()-
902{-
903 filters = QDir::AllEntries | QDir::NoDotAndDotDot;-
904 sort = QDir::Name;-
905 nameFilters << QLatin1String("*");-
906 root.parent = 0;-
907 root.info = QFileInfo();-
908 clear(&root);-
909 roleNames.insertMulti(QDirModel::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
910 roleNames.insert(QDirModel::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
911 roleNames.insert(QDirModel::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
912}
never executed: end of block
0
913-
914QDirModelPrivate::QDirNode *QDirModelPrivate::node(int row, QDirNode *parent) const-
915{-
916 if (row < 0
row < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
917 return
never executed: return 0;
0;
never executed: return 0;
0
918-
919 bool isDir = !parent
!parentDescription
TRUEnever evaluated
FALSEnever evaluated
|| parent->info.isDir()
parent->info.isDir()Description
TRUEnever evaluated
FALSEnever evaluated
;
0
920 QDirNode *p = (parent
parentDescription
TRUEnever evaluated
FALSEnever evaluated
? parent : &root);
0
921 if (isDir
isDirDescription
TRUEnever evaluated
FALSEnever evaluated
&& !p->populated
!p->populatedDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
922 populate(p);
never executed: populate(p);
0
923-
924 if (__builtin_expect(!!(row >= p->children.count()), false)
__builtin_expe...unt()), false)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
925 QMessageLogger(__FILE__, 1186, __PRETTY_FUNCTION__).warning("node: the row does not exist");-
926 return
never executed: return 0;
0;
never executed: return 0;
0
927 }-
928-
929 return
never executed: return const_cast<QDirNode*>(&p->children.at(row));
const_cast<QDirNode*>(&p->children.at(row));
never executed: return const_cast<QDirNode*>(&p->children.at(row));
0
930}-
931-
932QVector<QDirModelPrivate::QDirNode> QDirModelPrivate::children(QDirNode *parent, bool stat) const-
933{-
934 ((!(parent)) ? qt_assert("parent",__FILE__,1195) : qt_noop());-
935 QFileInfoList infoList;-
936 if (parent == &root
parent == &rootDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
937 parent = 0;-
938 infoList = QDir::drives();-
939 }
never executed: end of block
else if (parent->info.isDir()
parent->info.isDir()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
940-
941 if (parent->info.isSymLink()
parent->info.isSymLink()Description
TRUEnever evaluated
FALSEnever evaluated
&& resolveSymlinks
resolveSymlinksDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
942 QString link = parent->info.symLinkTarget();-
943 if (link.size() > 1
link.size() > 1Description
TRUEnever evaluated
FALSEnever evaluated
&& link.at(link.size() - 1) == QDir::separator()
link.at(link.s...r::separator()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
944 link.chop(1);
never executed: link.chop(1);
0
945 if (stat
statDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
946 infoList = entryInfoList(link);
never executed: infoList = entryInfoList(link);
0
947 else-
948 infoList = QDir(link).entryInfoList(nameFilters, QDir::AllEntries | QDir::System);
never executed: infoList = QDir(link).entryInfoList(nameFilters, QDir::AllEntries | QDir::System);
0
949 } else {-
950 if (stat
statDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
951 infoList = entryInfoList(parent->info.absoluteFilePath());
never executed: infoList = entryInfoList(parent->info.absoluteFilePath());
0
952 else-
953 infoList = QDir(parent->info.absoluteFilePath()).entryInfoList(nameFilters, QDir::AllEntries | QDir::System);
never executed: infoList = QDir(parent->info.absoluteFilePath()).entryInfoList(nameFilters, QDir::AllEntries | QDir::System);
0
954 }-
955 }-
956-
957 QVector<QDirNode> nodes(infoList.count());-
958 for (int i = 0; i < infoList.count()
i < infoList.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
959 QDirNode &node = nodes[i];-
960 node.parent = parent;-
961 node.info = infoList.at(i);-
962 node.populated = false;-
963 node.stat = shouldStat;-
964 }
never executed: end of block
0
965-
966 return
never executed: return nodes;
nodes;
never executed: return nodes;
0
967}-
968-
969void QDirModelPrivate::_q_refresh()-
970{-
971 QDirModel * const q = q_func();-
972 q->refresh(toBeRefreshed);-
973 toBeRefreshed = QModelIndex();-
974}
never executed: end of block
0
975-
976void QDirModelPrivate::savePersistentIndexes()-
977{-
978 QDirModel * const q = q_func();-
979 savedPersistent.clear();-
980 savedPersistent.reserve(persistent.indexes.size());-
981 for (QForeachContainer<typename QtPrivate::remove_reference<decltype(persistent.indexes)>::type> _container_((persistent.indexes)); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (QPersistentModelIndexData *data = *_container_.i; _container_.control; _container_.control = 0) {-
982 QModelIndex index = data->index;-
983 SavedPersistent saved = {-
984 q->filePath(index),-
985 index.column(),-
986 data,-
987 index,-
988 };-
989 savedPersistent.push_back(std::move(saved));-
990 }
never executed: end of block
0
991}
never executed: end of block
0
992-
993void QDirModelPrivate::restorePersistentIndexes()-
994{-
995 QDirModel * const q = q_func();-
996 bool allow = allowAppendChild;-
997 allowAppendChild = false;-
998 for (const SavedPersistent &sp : qAsConst(savedPersistent)) {-
999 QPersistentModelIndexData *data = sp.data;-
1000 QModelIndex idx = q->index(sp.path, sp.column);-
1001 if (idx != data->index
idx != data->indexDescription
TRUEnever evaluated
FALSEnever evaluated
|| data->model == 0
data->model == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1002-
1003 persistent.indexes.remove(data->index);-
1004 data->index = idx;-
1005 data->model = q;-
1006 if (idx.isValid()
idx.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1007 persistent.indexes.insert(idx, data);
never executed: persistent.indexes.insert(idx, data);
0
1008 }
never executed: end of block
0
1009 }
never executed: end of block
0
1010 savedPersistent.clear();-
1011 allowAppendChild = allow;-
1012}
never executed: end of block
0
1013-
1014QFileInfoList QDirModelPrivate::entryInfoList(const QString &path) const-
1015{-
1016 const QDir dir(path);-
1017 return
never executed: return dir.entryInfoList(nameFilters, filters, sort);
dir.entryInfoList(nameFilters, filters, sort);
never executed: return dir.entryInfoList(nameFilters, filters, sort);
0
1018}-
1019-
1020QStringList QDirModelPrivate::entryList(const QString &path) const-
1021{-
1022 const QDir dir(path);-
1023 return
never executed: return dir.entryList(nameFilters, filters, sort);
dir.entryList(nameFilters, filters, sort);
never executed: return dir.entryList(nameFilters, filters, sort);
0
1024}-
1025-
1026QString QDirModelPrivate::name(const QModelIndex &index) const-
1027{-
1028 const QDirNode *n = node(index);-
1029 const QFileInfo info = n->info;-
1030 if (info.isRoot()
info.isRoot()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1031 QString name = info.absoluteFilePath();-
1032-
1033-
1034-
1035-
1036-
1037-
1038 return
never executed: return name;
name;
never executed: return name;
0
1039 }-
1040 return
never executed: return info.fileName();
info.fileName();
never executed: return info.fileName();
0
1041}-
1042-
1043QString QDirModelPrivate::size(const QModelIndex &index) const-
1044{-
1045 const QDirNode *n = node(index);-
1046 if (n->info.isDir()
n->info.isDir()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1047-
1048-
1049-
1050 return
never executed: return QLatin1String("");
QLatin1String("");
never executed: return QLatin1String("");
0
1051-
1052-
1053-
1054-
1055-
1056 }-
1057-
1058-
1059-
1060 const quint64 kb = 1024;-
1061 const quint64 mb = 1024 * kb;-
1062 const quint64 gb = 1024 * mb;-
1063 const quint64 tb = 1024 * gb;-
1064 quint64 bytes = n->info.size();-
1065 if (bytes >= tb
bytes >= tbDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1066 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
1067 if (bytes >= gb
bytes >= gbDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1068 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
1069 if (bytes >= mb
bytes >= mbDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1070 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
1071 if (bytes >= kb
bytes >= kbDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1072 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
1073 return
never executed: return QFileSystemModel::tr("%1 byte(s)").arg(QLocale().toString(bytes));
QFileSystemModel::tr("%1 byte(s)").arg(QLocale().toString(bytes));
never executed: return QFileSystemModel::tr("%1 byte(s)").arg(QLocale().toString(bytes));
0
1074}-
1075-
1076QString QDirModelPrivate::type(const QModelIndex &index) const-
1077{-
1078 return
never executed: return iconProvider->type(node(index)->info);
iconProvider->type(node(index)->info);
never executed: return iconProvider->type(node(index)->info);
0
1079}-
1080-
1081QString QDirModelPrivate::time(const QModelIndex &index) const-
1082{-
1083-
1084 return
never executed: return node(index)->info.lastModified().toString(Qt::LocalDate);
node(index)->info.lastModified().toString(Qt::LocalDate);
never executed: return node(index)->info.lastModified().toString(Qt::LocalDate);
0
1085-
1086-
1087-
1088-
1089}-
1090-
1091void QDirModelPrivate::appendChild(QDirModelPrivate::QDirNode *parent, const QString &path) const-
1092{-
1093 QDirModelPrivate::QDirNode node;-
1094 node.populated = false;-
1095 node.stat = shouldStat;-
1096 node.parent = (parent == &root
parent == &rootDescription
TRUEnever evaluated
FALSEnever evaluated
? 0 : parent);
0
1097 node.info = QFileInfo(path);-
1098 node.info.setCaching(true);-
1099-
1100-
1101-
1102 QDirModelPrivate *that = const_cast<QDirModelPrivate *>(this);-
1103 that->savePersistentIndexes();-
1104 parent->children.append(node);-
1105 for (int i = 0; i < parent->children.count()
i < parent->children.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i) {
0
1106 QDirNode *childNode = &parent->children[i];-
1107 for (int j = 0; j < childNode->children.count()
j < childNode-...ildren.count()Description
TRUEnever evaluated
FALSEnever evaluated
; ++j)
0
1108 childNode->children[j].parent = childNode;
never executed: childNode->children[j].parent = childNode;
0
1109 }
never executed: end of block
0
1110 that->restorePersistentIndexes();-
1111}
never executed: end of block
0
1112-
1113QFileInfo QDirModelPrivate::resolvedInfo(QFileInfo info)-
1114{-
1115-
1116-
1117-
1118-
1119 QStringList paths;-
1120 do {-
1121 QFileInfo link(info.symLinkTarget());-
1122 if (link.isRelative()
link.isRelative()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1123 info.setFile(info.absolutePath(), link.filePath());
never executed: info.setFile(info.absolutePath(), link.filePath());
0
1124 else-
1125 info = link;
never executed: info = link;
0
1126 if (paths.contains(info.absoluteFilePath())
paths.contains...uteFilePath())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1127 return
never executed: return QFileInfo();
QFileInfo();
never executed: return QFileInfo();
0
1128 paths.append(info.absoluteFilePath());-
1129 }
never executed: end of block
while (info.isSymLink()
info.isSymLink()Description
TRUEnever evaluated
FALSEnever evaluated
);
0
1130 return
never executed: return info;
info;
never executed: return info;
0
1131-
1132}-
1133-
1134-
1135-
Switch to Source codePreprocessed file

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