| Line | Source Code | Coverage | 
|---|
| 1 | /**************************************************************************** | - | 
| 2 | ** | - | 
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - | 
| 4 | ** Contact: http://www.qt-project.org/legal | - | 
| 5 | ** | - | 
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | 
| 7 | ** | - | 
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | 
| 9 | ** Commercial License Usage | - | 
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | 
| 11 | ** accordance with the commercial license agreement provided with the | - | 
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | 
| 13 | ** a written agreement between you and Digia.  For licensing terms and | - | 
| 14 | ** conditions see http://qt.digia.com/licensing.  For further information | - | 
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - | 
| 16 | ** | - | 
| 17 | ** GNU Lesser General Public License Usage | - | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | 
| 19 | ** General Public License version 2.1 as published by the Free Software | - | 
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - | 
| 21 | ** packaging of this file.  Please review the following information to | - | 
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - | 
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | 
| 24 | ** | - | 
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - | 
| 26 | ** rights.  These rights are described in the Digia Qt LGPL Exception | - | 
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | 
| 28 | ** | - | 
| 29 | ** GNU General Public License Usage | - | 
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - | 
| 31 | ** General Public License version 3.0 as published by the Free Software | - | 
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - | 
| 33 | ** packaging of this file.  Please review the following information to | - | 
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - | 
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - | 
| 36 | ** | - | 
| 37 | ** | - | 
| 38 | ** $QT_END_LICENSE$ | - | 
| 39 | ** | - | 
| 40 | ****************************************************************************/ | - | 
| 41 |  | - | 
| 42 | #include "qdirmodel.h" | - | 
| 43 |  | - | 
| 44 | #ifndef QT_NO_DIRMODEL | - | 
| 45 | #include <qstack.h> | - | 
| 46 | #include <qfile.h> | - | 
| 47 | #include <qfilesystemmodel.h> | - | 
| 48 | #include <qurl.h> | - | 
| 49 | #include <qmimedata.h> | - | 
| 50 | #include <qpair.h> | - | 
| 51 | #include <qvector.h> | - | 
| 52 | #include <qobject.h> | - | 
| 53 | #include <qdatetime.h> | - | 
| 54 | #include <qlocale.h> | - | 
| 55 | #include <qstyle.h> | - | 
| 56 | #include <qapplication.h> | - | 
| 57 | #include <private/qabstractitemmodel_p.h> | - | 
| 58 | #include <qdebug.h> | - | 
| 59 |  | - | 
| 60 | /*! | - | 
| 61 | \enum QDirModel::Roles | - | 
| 62 | \value FileIconRole | - | 
| 63 | \value FilePathRole | - | 
| 64 | \value FileNameRole | - | 
| 65 | */ | - | 
| 66 |  | - | 
| 67 | QT_BEGIN_NAMESPACE | - | 
| 68 |  | - | 
| 69 | class QDirModelPrivate : public QAbstractItemModelPrivate | - | 
| 70 | { | - | 
| 71 | Q_DECLARE_PUBLIC(QDirModel) | - | 
| 72 |  | - | 
| 73 | public: | - | 
| 74 | struct QDirNode | - | 
| 75 | { | - | 
| 76 | QDirNode() : parent(0), populated(false), stat(false) {} executed:  }Execution Count:10490 | 10490 | 
| 77 | ~QDirNode() { children.clear(); } executed:  }Execution Count:10522 | 10522 | 
| 78 | QDirNode *parent; | - | 
| 79 | QFileInfo info; | - | 
| 80 | QIcon icon; // cache the icon | - | 
| 81 | mutable QVector<QDirNode> children; | - | 
| 82 | mutable bool populated; // have we read the children | - | 
| 83 | mutable bool stat; | - | 
| 84 | }; | - | 
| 85 |  | - | 
| 86 | QDirModelPrivate() | - | 
| 87 | : resolveSymlinks(true), | - | 
| 88 | readOnly(true), | - | 
| 89 | lazyChildCount(false), | - | 
| 90 | allowAppendChild(true), | - | 
| 91 | iconProvider(&defaultProvider), | - | 
| 92 | shouldStat(true) // ### This is set to false by QFileDialog | - | 
| 93 | { } executed:  }Execution Count:82 | 82 | 
| 94 |  | - | 
| 95 | void init(); | - | 
| 96 | QDirNode *node(int row, QDirNode *parent) const; | - | 
| 97 | QVector<QDirNode> children(QDirNode *parent, bool stat) const; | - | 
| 98 |  | - | 
| 99 | void _q_refresh(); | - | 
| 100 |  | - | 
| 101 | void savePersistentIndexes(); | - | 
| 102 | void restorePersistentIndexes(); | - | 
| 103 |  | - | 
| 104 | QFileInfoList entryInfoList(const QString &path) const; | - | 
| 105 | QStringList entryList(const QString &path) const; | - | 
| 106 |  | - | 
| 107 | QString name(const QModelIndex &index) const; | - | 
| 108 | QString size(const QModelIndex &index) const; | - | 
| 109 | QString type(const QModelIndex &index) const; | - | 
| 110 | QString time(const QModelIndex &index) const; | - | 
| 111 |  | - | 
| 112 | void appendChild(QDirModelPrivate::QDirNode *parent, const QString &path) const; | - | 
| 113 | static QFileInfo resolvedInfo(QFileInfo info); | - | 
| 114 |  | - | 
| 115 | inline QDirNode *node(const QModelIndex &index) const; | - | 
| 116 | inline void populate(QDirNode *parent) const; | - | 
| 117 | inline void clear(QDirNode *parent) const; | - | 
| 118 |  | - | 
| 119 | void invalidate(); | - | 
| 120 |  | - | 
| 121 | mutable QDirNode root; | - | 
| 122 | bool resolveSymlinks; | - | 
| 123 | bool readOnly; | - | 
| 124 | bool lazyChildCount; | - | 
| 125 | bool allowAppendChild; | - | 
| 126 |  | - | 
| 127 | QDir::Filters filters; | - | 
| 128 | QDir::SortFlags sort; | - | 
| 129 | QStringList nameFilters; | - | 
| 130 |  | - | 
| 131 | QFileIconProvider *iconProvider; | - | 
| 132 | QFileIconProvider defaultProvider; | - | 
| 133 |  | - | 
| 134 | struct SavedPersistent { | - | 
| 135 | QString path; | - | 
| 136 | int column; | - | 
| 137 | QPersistentModelIndexData *data; | - | 
| 138 | QPersistentModelIndex index; | - | 
| 139 | }; | - | 
| 140 | QList<SavedPersistent> savedPersistent; | - | 
| 141 | QPersistentModelIndex toBeRefreshed; | - | 
| 142 |  | - | 
| 143 | bool shouldStat; // use the "carefull not to stat directories" mode | - | 
| 144 | }; | - | 
| 145 |  | - | 
| 146 | void qt_setDirModelShouldNotStat(QDirModelPrivate *modelPrivate) | - | 
| 147 | { | - | 
| 148 | modelPrivate->shouldStat = false; never executed (the execution status of this line is deduced):  modelPrivate->shouldStat = false; | - | 
| 149 | } | 0 | 
| 150 |  | - | 
| 151 | QDirModelPrivate::QDirNode *QDirModelPrivate::node(const QModelIndex &index) const | - | 
| 152 | { | - | 
| 153 | QDirModelPrivate::QDirNode *n = executed (the execution status of this line is deduced):  QDirModelPrivate::QDirNode *n = | - | 
| 154 | static_cast<QDirModelPrivate::QDirNode*>(index.internalPointer()); executed (the execution status of this line is deduced):  static_cast<QDirModelPrivate::QDirNode*>(index.internalPointer()); | - | 
| 155 | Q_ASSERT(n); executed (the execution status of this line is deduced):  qt_noop(); | - | 
| 156 | return n; executed:  return n;Execution Count:31153 | 31153 | 
| 157 | } | - | 
| 158 |  | - | 
| 159 | void QDirModelPrivate::populate(QDirNode *parent) const | - | 
| 160 | { | - | 
| 161 | Q_ASSERT(parent); executed (the execution status of this line is deduced):  qt_noop(); | - | 
| 162 | parent->children = children(parent, parent->stat); executed (the execution status of this line is deduced):  parent->children = children(parent, parent->stat); | - | 
| 163 | parent->populated = true; executed (the execution status of this line is deduced):  parent->populated = true; | - | 
| 164 | } executed:  }Execution Count:599 | 599 | 
| 165 |  | - | 
| 166 | void QDirModelPrivate::clear(QDirNode *parent) const | - | 
| 167 | { | - | 
| 168 | Q_ASSERT(parent); executed (the execution status of this line is deduced):  qt_noop(); | - | 
| 169 | parent->children.clear(); executed (the execution status of this line is deduced):  parent->children.clear(); | - | 
| 170 | parent->populated = false; executed (the execution status of this line is deduced):  parent->populated = false; | - | 
| 171 | } executed:  }Execution Count:108 | 108 | 
| 172 |  | - | 
| 173 | void QDirModelPrivate::invalidate() | - | 
| 174 | { | - | 
| 175 | QStack<const QDirNode*> nodes; never executed (the execution status of this line is deduced):  QStack<const QDirNode*> nodes; | - | 
| 176 | nodes.push(&root); never executed (the execution status of this line is deduced):  nodes.push(&root); | - | 
| 177 | while (!nodes.empty()) { never evaluated: !nodes.empty() | 0 | 
| 178 | const QDirNode *current = nodes.pop(); never executed (the execution status of this line is deduced):  const QDirNode *current = nodes.pop(); | - | 
| 179 | current->stat = false; never executed (the execution status of this line is deduced):  current->stat = false; | - | 
| 180 | const QVector<QDirNode> children = current->children; never executed (the execution status of this line is deduced):  const QVector<QDirNode> children = current->children; | - | 
| 181 | for (int i = 0; i < children.count(); ++i) never evaluated: i < children.count() | 0 | 
| 182 | nodes.push(&children.at(i)); never executed: nodes.push(&children.at(i)); | 0 | 
| 183 | } | 0 | 
| 184 | } | 0 | 
| 185 |  | - | 
| 186 | /*! | - | 
| 187 | \class QDirModel | - | 
| 188 | \obsolete | - | 
| 189 | \brief The QDirModel class provides a data model for the local filesystem. | - | 
| 190 |  | - | 
| 191 | \ingroup model-view | - | 
| 192 | \inmodule QtWidgets | - | 
| 193 |  | - | 
| 194 | The usage of QDirModel is not recommended anymore. The | - | 
| 195 | QFileSystemModel class is a more performant alternative. | - | 
| 196 |  | - | 
| 197 | This class provides access to the local filesystem, providing functions | - | 
| 198 | for renaming and removing files and directories, and for creating new | - | 
| 199 | directories. In the simplest case, it can be used with a suitable display | - | 
| 200 | widget as part of a browser or filer. | - | 
| 201 |  | - | 
| 202 | QDirModel keeps a cache with file information. The cache needs to be | - | 
| 203 | updated with refresh(). | - | 
| 204 |  | - | 
| 205 | QDirModel can be accessed using the standard interface provided by | - | 
| 206 | QAbstractItemModel, but it also provides some convenience functions | - | 
| 207 | that are specific to a directory model. The fileInfo() and isDir() | - | 
| 208 | functions provide information about the underlying files and directories | - | 
| 209 | related to items in the model. | - | 
| 210 |  | - | 
| 211 | Directories can be created and removed using mkdir(), rmdir(), and the | - | 
| 212 | model will be automatically updated to take the changes into account. | - | 
| 213 |  | - | 
| 214 | \note QDirModel requires an instance of a GUI application. | - | 
| 215 |  | - | 
| 216 | \sa nameFilters(), setFilter(), filter(), QListView, QTreeView, QFileSystemModel, | - | 
| 217 | {Dir View Example}, {Model Classes} | - | 
| 218 | */ | - | 
| 219 |  | - | 
| 220 | /*! | - | 
| 221 | Constructs a new directory model with the given \a parent. | - | 
| 222 | Only those files matching the \a nameFilters and the | - | 
| 223 | \a filters are included in the model. The sort order is given by the | - | 
| 224 | \a sort flags. | - | 
| 225 | */ | - | 
| 226 |  | - | 
| 227 | QDirModel::QDirModel(const QStringList &nameFilters, | - | 
| 228 | QDir::Filters filters, | - | 
| 229 | QDir::SortFlags sort, | - | 
| 230 | QObject *parent) | - | 
| 231 | : QAbstractItemModel(*new QDirModelPrivate, parent) | - | 
| 232 | { | - | 
| 233 | Q_D(QDirModel); never executed (the execution status of this line is deduced):  QDirModelPrivate * const d = d_func(); | - | 
| 234 | // we always start with QDir::drives() | - | 
| 235 | d->nameFilters = nameFilters.isEmpty() ? QStringList(QLatin1String("*")) : nameFilters; never evaluated: nameFilters.isEmpty() | 0 | 
| 236 | d->filters = filters; never executed (the execution status of this line is deduced):  d->filters = filters; | - | 
| 237 | d->sort = sort; never executed (the execution status of this line is deduced):  d->sort = sort; | - | 
| 238 | d->root.parent = 0; never executed (the execution status of this line is deduced):  d->root.parent = 0; | - | 
| 239 | d->root.info = QFileInfo(); never executed (the execution status of this line is deduced):  d->root.info = QFileInfo(); | - | 
| 240 | d->clear(&d->root); never executed (the execution status of this line is deduced):  d->clear(&d->root); | - | 
| 241 | } | 0 | 
| 242 |  | - | 
| 243 | /*! | - | 
| 244 | Constructs a directory model with the given \a parent. | - | 
| 245 | */ | - | 
| 246 |  | - | 
| 247 | QDirModel::QDirModel(QObject *parent) | - | 
| 248 | : QAbstractItemModel(*new QDirModelPrivate, parent) | - | 
| 249 | { | - | 
| 250 | Q_D(QDirModel); executed (the execution status of this line is deduced):  QDirModelPrivate * const d = d_func(); | - | 
| 251 | d->init(); executed (the execution status of this line is deduced):  d->init(); | - | 
| 252 | } executed:  }Execution Count:82 | 82 | 
| 253 |  | - | 
| 254 | /*! | - | 
| 255 | \internal | - | 
| 256 | */ | - | 
| 257 | QDirModel::QDirModel(QDirModelPrivate &dd, QObject *parent) | - | 
| 258 | : QAbstractItemModel(dd, parent) | - | 
| 259 | { | - | 
| 260 | Q_D(QDirModel); never executed (the execution status of this line is deduced):  QDirModelPrivate * const d = d_func(); | - | 
| 261 | d->init(); never executed (the execution status of this line is deduced):  d->init(); | - | 
| 262 | } | 0 | 
| 263 |  | - | 
| 264 | /*! | - | 
| 265 | Destroys this directory model. | - | 
| 266 | */ | - | 
| 267 |  | - | 
| 268 | QDirModel::~QDirModel() | - | 
| 269 | { | - | 
| 270 |  | - | 
| 271 | } | - | 
| 272 |  | - | 
| 273 | /*! | - | 
| 274 | Returns the model item index for the item in the \a parent with the | - | 
| 275 | given \a row and \a column. | - | 
| 276 |  | - | 
| 277 | */ | - | 
| 278 |  | - | 
| 279 | QModelIndex QDirModel::index(int row, int column, const QModelIndex &parent) const | - | 
| 280 | { | - | 
| 281 | Q_D(const QDirModel); executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 282 | // note that rowCount does lazy population | - | 
| 283 | if (column < 0 || column >= columnCount(parent) || row < 0 || parent.column() > 0) evaluated:  column < 0| yes Evaluation Count:4 | yes Evaluation Count:16799 | 
 evaluated:  column >= columnCount(parent)| yes Evaluation Count:1 | yes Evaluation Count:16798 | 
 evaluated:  row < 0| yes Evaluation Count:1 | yes Evaluation Count:16797 | 
 partially evaluated:  parent.column() > 0| no Evaluation Count:0 | yes Evaluation Count:16797 | 
 | 0-16799 | 
| 284 | return QModelIndex(); executed:  return QModelIndex();Execution Count:6 | 6 | 
| 285 | // make sure the list of children is up to date | - | 
| 286 | QDirModelPrivate::QDirNode *p = (d->indexValid(parent) ? d->node(parent) : &d->root); evaluated:  d->indexValid(parent)| yes Evaluation Count:16730 | yes Evaluation Count:67 | 
 | 67-16730 | 
| 287 | Q_ASSERT(p); executed (the execution status of this line is deduced):  qt_noop(); | - | 
| 288 | if (!p->populated) evaluated:  !p->populated| yes Evaluation Count:25 | yes Evaluation Count:16772 | 
 | 25-16772 | 
| 289 | d->populate(p); // populate without stat'ing executed:  d->populate(p);Execution Count:25 | 25 | 
| 290 | if (row >= p->children.count()) partially evaluated:  row >= p->children.count()| no Evaluation Count:0 | yes Evaluation Count:16797 | 
 | 0-16797 | 
| 291 | return QModelIndex(); never executed: return QModelIndex(); | 0 | 
| 292 | // now get the internal pointer for the index | - | 
| 293 | QDirModelPrivate::QDirNode *n = d->node(row, d->indexValid(parent) ? p : 0); executed (the execution status of this line is deduced):  QDirModelPrivate::QDirNode *n = d->node(row, d->indexValid(parent) ? p : 0); | - | 
| 294 | Q_ASSERT(n); executed (the execution status of this line is deduced):  qt_noop(); | - | 
| 295 |  | - | 
| 296 | return createIndex(row, column, n); executed:  return createIndex(row, column, n);Execution Count:16797 | 16797 | 
| 297 | } | - | 
| 298 |  | - | 
| 299 | /*! | - | 
| 300 | Return the parent of the given \a child model item. | - | 
| 301 | */ | - | 
| 302 |  | - | 
| 303 | QModelIndex QDirModel::parent(const QModelIndex &child) const | - | 
| 304 | { | - | 
| 305 | Q_D(const QDirModel); executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 306 |  | - | 
| 307 | if (!d->indexValid(child)) evaluated:  !d->indexValid(child)| yes Evaluation Count:4 | yes Evaluation Count:7347 | 
 | 4-7347 | 
| 308 | return QModelIndex(); executed:  return QModelIndex();Execution Count:4 | 4 | 
| 309 | QDirModelPrivate::QDirNode *node = d->node(child); executed (the execution status of this line is deduced):  QDirModelPrivate::QDirNode *node = d->node(child); | - | 
| 310 | QDirModelPrivate::QDirNode *par = (node ? node->parent : 0); partially evaluated:  node| yes Evaluation Count:7347 | no Evaluation Count:0 | 
 | 0-7347 | 
| 311 | if (par == 0) // parent is the root node evaluated:  par == 0| yes Evaluation Count:47 | yes Evaluation Count:7300 | 
 | 47-7300 | 
| 312 | return QModelIndex(); executed:  return QModelIndex();Execution Count:47 | 47 | 
| 313 |  | - | 
| 314 | // get the parent's row | - | 
| 315 | const QVector<QDirModelPrivate::QDirNode> children = executed (the execution status of this line is deduced):  const QVector<QDirModelPrivate::QDirNode> children = | - | 
| 316 | par->parent ? par->parent->children : d->root.children; evaluated:  par->parent| yes Evaluation Count:7001 | yes Evaluation Count:299 | 
 | 299-7001 | 
| 317 | Q_ASSERT(children.count() > 0); executed (the execution status of this line is deduced):  qt_noop(); | - | 
| 318 | int row = (par - &(children.at(0))); executed (the execution status of this line is deduced):  int row = (par - &(children.at(0))); | - | 
| 319 | Q_ASSERT(row >= 0); executed (the execution status of this line is deduced):  qt_noop(); | - | 
| 320 |  | - | 
| 321 | return createIndex(row, 0, par); executed:  return createIndex(row, 0, par);Execution Count:7300 | 7300 | 
| 322 | } | - | 
| 323 |  | - | 
| 324 | /*! | - | 
| 325 | Returns the number of rows in the \a parent model item. | - | 
| 326 |  | - | 
| 327 | */ | - | 
| 328 |  | - | 
| 329 | int QDirModel::rowCount(const QModelIndex &parent) const | - | 
| 330 | { | - | 
| 331 | Q_D(const QDirModel); executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 332 | if (parent.column() > 0) evaluated:  parent.column() > 0| yes Evaluation Count:1 | yes Evaluation Count:3193 | 
 | 1-3193 | 
| 333 | return 0; executed:  return 0;Execution Count:1 | 1 | 
| 334 |  | - | 
| 335 | if (!parent.isValid()) { evaluated:  !parent.isValid()| yes Evaluation Count:30 | yes Evaluation Count:3163 | 
 | 30-3163 | 
| 336 | if (!d->root.populated) // lazy population evaluated:  !d->root.populated| yes Evaluation Count:7 | yes Evaluation Count:23 | 
 | 7-23 | 
| 337 | d->populate(&d->root); executed:  d->populate(&d->root);Execution Count:7 | 7 | 
| 338 | return d->root.children.count(); executed:  return d->root.children.count();Execution Count:30 | 30 | 
| 339 | } | - | 
| 340 | if (parent.model() != this) partially evaluated:  parent.model() != this| no Evaluation Count:0 | yes Evaluation Count:3163 | 
 | 0-3163 | 
| 341 | return 0; never executed: return 0; | 0 | 
| 342 | QDirModelPrivate::QDirNode *p = d->node(parent); executed (the execution status of this line is deduced):  QDirModelPrivate::QDirNode *p = d->node(parent); | - | 
| 343 | if (p->info.isDir() && !p->populated) // lazy population partially evaluated:  p->info.isDir()| yes Evaluation Count:3163 | no Evaluation Count:0 | 
 evaluated:  !p->populated| yes Evaluation Count:170 | yes Evaluation Count:2993 | 
 | 0-3163 | 
| 344 | d->populate(p); executed:  d->populate(p);Execution Count:170 | 170 | 
| 345 | return p->children.count(); executed:  return p->children.count();Execution Count:3163 | 3163 | 
| 346 | } | - | 
| 347 |  | - | 
| 348 | /*! | - | 
| 349 | Returns the number of columns in the \a parent model item. | - | 
| 350 |  | - | 
| 351 | */ | - | 
| 352 |  | - | 
| 353 | int QDirModel::columnCount(const QModelIndex &parent) const | - | 
| 354 | { | - | 
| 355 | if (parent.column() > 0) partially evaluated:  parent.column() > 0| no Evaluation Count:0 | yes Evaluation Count:19796 | 
 | 0-19796 | 
| 356 | return 0; never executed: return 0; | 0 | 
| 357 | return 4; executed:  return 4;Execution Count:19796 | 19796 | 
| 358 | } | - | 
| 359 |  | - | 
| 360 | /*! | - | 
| 361 | Returns the data for the model item \a index with the given \a role. | - | 
| 362 | */ | - | 
| 363 | QVariant QDirModel::data(const QModelIndex &index, int role) const | - | 
| 364 | { | - | 
| 365 | Q_D(const QDirModel); executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 366 | if (!d->indexValid(index)) evaluated:  !d->indexValid(index)| yes Evaluation Count:258 | yes Evaluation Count:3117 | 
 | 258-3117 | 
| 367 | return QVariant(); executed:  return QVariant();Execution Count:258 | 258 | 
| 368 |  | - | 
| 369 | if (role == Qt::DisplayRole || role == Qt::EditRole) { evaluated:  role == Qt::DisplayRole| yes Evaluation Count:2458 | yes Evaluation Count:659 | 
 evaluated:  role == Qt::EditRole| yes Evaluation Count:164 | yes Evaluation Count:495 | 
 | 164-2458 | 
| 370 | switch (index.column()) { | - | 
| 371 | case 0: return d->name(index); executed:  return d->name(index);Execution Count:807 | 807 | 
| 372 | case 1: return d->size(index); executed:  return d->size(index);Execution Count:607 | 607 | 
| 373 | case 2: return d->type(index); executed:  return d->type(index);Execution Count:604 | 604 | 
| 374 | case 3: return d->time(index); executed:  return d->time(index);Execution Count:604 | 604 | 
| 375 | default: | - | 
| 376 | qWarning("data: invalid display value column %d", index.column()); never executed (the execution status of this line is deduced):  QMessageLogger("itemviews/qdirmodel.cpp", 376, __PRETTY_FUNCTION__).warning("data: invalid display value column %d", index.column()); | - | 
| 377 | return QVariant(); never executed: return QVariant(); | 0 | 
| 378 | } | - | 
| 379 | } | 0 | 
| 380 |  | - | 
| 381 | if (index.column() == 0) { evaluated:  index.column() == 0| yes Evaluation Count:161 | yes Evaluation Count:334 | 
 | 161-334 | 
| 382 | if (role == FileIconRole) evaluated:  role == FileIconRole| yes Evaluation Count:22 | yes Evaluation Count:139 | 
 | 22-139 | 
| 383 | return fileIcon(index); executed:  return fileIcon(index);Execution Count:22 | 22 | 
| 384 | if (role == FilePathRole) partially evaluated:  role == FilePathRole| no Evaluation Count:0 | yes Evaluation Count:139 | 
 | 0-139 | 
| 385 | return filePath(index); never executed: return filePath(index); | 0 | 
| 386 | if (role == FileNameRole) partially evaluated:  role == FileNameRole| no Evaluation Count:0 | yes Evaluation Count:139 | 
 | 0-139 | 
| 387 | return fileName(index); never executed: return fileName(index); | 0 | 
| 388 | } executed:  }Execution Count:139 | 139 | 
| 389 |  | - | 
| 390 | if (index.column() == 1 && Qt::TextAlignmentRole == role) { evaluated:  index.column() == 1| yes Evaluation Count:124 | yes Evaluation Count:349 | 
 evaluated:  Qt::TextAlignmentRole == role| yes Evaluation Count:18 | yes Evaluation Count:106 | 
 | 18-349 | 
| 391 | return Qt::AlignRight; executed:  return Qt::AlignRight;Execution Count:18 | 18 | 
| 392 | } | - | 
| 393 | return QVariant(); executed:  return QVariant();Execution Count:455 | 455 | 
| 394 | } | - | 
| 395 |  | - | 
| 396 | /*! | - | 
| 397 | Sets the data for the model item \a index with the given \a role to | - | 
| 398 | the data referenced by the \a value. Returns true if successful; | - | 
| 399 | otherwise returns false. | - | 
| 400 |  | - | 
| 401 | \sa Qt::ItemDataRole | - | 
| 402 | */ | - | 
| 403 |  | - | 
| 404 | bool QDirModel::setData(const QModelIndex &index, const QVariant &value, int role) | - | 
| 405 | { | - | 
| 406 | Q_D(QDirModel); executed (the execution status of this line is deduced):  QDirModelPrivate * const d = d_func(); | - | 
| 407 | if (!d->indexValid(index) || index.column() != 0 partially evaluated:  !d->indexValid(index)| yes Evaluation Count:3 | no Evaluation Count:0 | 
 never evaluated: index.column() != 0 | 0-3 | 
| 408 | || (flags(index) & Qt::ItemIsEditable) == 0 || role != Qt::EditRole) never evaluated: (flags(index) & Qt::ItemIsEditable) == 0 never evaluated: role != Qt::EditRole | 0 | 
| 409 | return false; executed:  return false;Execution Count:3 | 3 | 
| 410 |  | - | 
| 411 | QDirModelPrivate::QDirNode *node = d->node(index); never executed (the execution status of this line is deduced):  QDirModelPrivate::QDirNode *node = d->node(index); | - | 
| 412 | QDir dir = node->info.dir(); never executed (the execution status of this line is deduced):  QDir dir = node->info.dir(); | - | 
| 413 | QString name = value.toString(); never executed (the execution status of this line is deduced):  QString name = value.toString(); | - | 
| 414 | if (dir.rename(node->info.fileName(), name)) { never evaluated: dir.rename(node->info.fileName(), name) | 0 | 
| 415 | node->info = QFileInfo(dir, name); never executed (the execution status of this line is deduced):  node->info = QFileInfo(dir, name); | - | 
| 416 | QModelIndex sibling = index.sibling(index.row(), 3); never executed (the execution status of this line is deduced):  QModelIndex sibling = index.sibling(index.row(), 3); | - | 
| 417 | emit dataChanged(index, sibling); never executed (the execution status of this line is deduced):  dataChanged(index, sibling); | - | 
| 418 |  | - | 
| 419 | d->toBeRefreshed = index.parent(); never executed (the execution status of this line is deduced):  d->toBeRefreshed = index.parent(); | - | 
| 420 | QMetaObject::invokeMethod(this, "_q_refresh", Qt::QueuedConnection); never executed (the execution status of this line is deduced):  QMetaObject::invokeMethod(this, "_q_refresh", Qt::QueuedConnection); | - | 
| 421 |  | - | 
| 422 | return true; never executed: return true; | 0 | 
| 423 | } | - | 
| 424 |  | - | 
| 425 | return false; never executed: return false; | 0 | 
| 426 | } | - | 
| 427 |  | - | 
| 428 | /*! | - | 
| 429 | Returns the data stored under the given \a role for the specified \a section | - | 
| 430 | of the header with the given \a orientation. | - | 
| 431 | */ | - | 
| 432 |  | - | 
| 433 | QVariant QDirModel::headerData(int section, Qt::Orientation orientation, int role) const | - | 
| 434 | { | - | 
| 435 | if (orientation == Qt::Horizontal) { partially evaluated:  orientation == Qt::Horizontal| yes Evaluation Count:85 | no Evaluation Count:0 | 
 | 0-85 | 
| 436 | if (role != Qt::DisplayRole) evaluated:  role != Qt::DisplayRole| yes Evaluation Count:66 | yes Evaluation Count:19 | 
 | 19-66 | 
| 437 | return QVariant(); executed:  return QVariant();Execution Count:66 | 66 | 
| 438 | switch (section) { | - | 
| 439 | case 0: return tr("Name"); executed:  return tr("Name");Execution Count:11 | 11 | 
| 440 | case 1: return tr("Size"); executed:  return tr("Size");Execution Count:6 | 6 | 
| 441 | case 2: return executed:  return tr("Type", "All other platforms");Execution Count:1 | 1 | 
| 442 | #ifdef Q_OS_MAC executed:  return tr("Type", "All other platforms");Execution Count:1 | 1 | 
| 443 | tr("Kind", "Match OS X Finder"); executed:  return tr("Type", "All other platforms");Execution Count:1 | 1 | 
| 444 | #else executed:  return tr("Type", "All other platforms");Execution Count:1 | 1 | 
| 445 | tr("Type", "All other platforms"); executed:  return tr("Type", "All other platforms");Execution Count:1 | 1 | 
| 446 | #endif | - | 
| 447 | // Windows   - Type | - | 
| 448 | // OS X      - Kind | - | 
| 449 | // Konqueror - File Type | - | 
| 450 | // Nautilus  - Type | - | 
| 451 | case 3: return tr("Date Modified"); executed:  return tr("Date Modified");Execution Count:1 | 1 | 
| 452 | default: return QVariant(); never executed: return QVariant(); | 0 | 
| 453 | } | - | 
| 454 | } | 0 | 
| 455 | return QAbstractItemModel::headerData(section, orientation, role); never executed: return QAbstractItemModel::headerData(section, orientation, role); | 0 | 
| 456 | } | - | 
| 457 |  | - | 
| 458 | /*! | - | 
| 459 | Returns true if the \a parent model item has children; otherwise | - | 
| 460 | returns false. | - | 
| 461 | */ | - | 
| 462 |  | - | 
| 463 | bool QDirModel::hasChildren(const QModelIndex &parent) const | - | 
| 464 | { | - | 
| 465 | Q_D(const QDirModel); executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 466 | if (parent.column() > 0) evaluated:  parent.column() > 0| yes Evaluation Count:1767 | yes Evaluation Count:633 | 
 | 633-1767 | 
| 467 | return false; executed:  return false;Execution Count:1767 | 1767 | 
| 468 |  | - | 
| 469 | if (!parent.isValid()) // the invalid index is the "My Computer" item evaluated:  !parent.isValid()| yes Evaluation Count:7 | yes Evaluation Count:626 | 
 | 7-626 | 
| 470 | return true; // the drives executed:  return true;Execution Count:7 | 7 | 
| 471 | QDirModelPrivate::QDirNode *p = d->node(parent); executed (the execution status of this line is deduced):  QDirModelPrivate::QDirNode *p = d->node(parent); | - | 
| 472 | Q_ASSERT(p); executed (the execution status of this line is deduced):  qt_noop(); | - | 
| 473 |  | - | 
| 474 | if (d->lazyChildCount) // optimization that only checks for children if the node has been populated partially evaluated:  d->lazyChildCount| no Evaluation Count:0 | yes Evaluation Count:626 | 
 | 0-626 | 
| 475 | return p->info.isDir(); never executed: return p->info.isDir(); | 0 | 
| 476 | return p->info.isDir() && rowCount(parent) > 0; executed:  return p->info.isDir() && rowCount(parent) > 0;Execution Count:626 | 626 | 
| 477 | } | - | 
| 478 |  | - | 
| 479 | /*! | - | 
| 480 | Returns the item flags for the given \a index in the model. | - | 
| 481 |  | - | 
| 482 | \sa Qt::ItemFlags | - | 
| 483 | */ | - | 
| 484 | Qt::ItemFlags QDirModel::flags(const QModelIndex &index) const | - | 
| 485 | { | - | 
| 486 | Q_D(const QDirModel); executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 487 | Qt::ItemFlags flags = QAbstractItemModel::flags(index); executed (the execution status of this line is deduced):  Qt::ItemFlags flags = QAbstractItemModel::flags(index); | - | 
| 488 | if (!d->indexValid(index)) evaluated:  !d->indexValid(index)| yes Evaluation Count:1 | yes Evaluation Count:21 | 
 | 1-21 | 
| 489 | return flags; executed:  return flags;Execution Count:1 | 1 | 
| 490 | flags |= Qt::ItemIsDragEnabled; executed (the execution status of this line is deduced):  flags |= Qt::ItemIsDragEnabled; | - | 
| 491 | if (d->readOnly) partially evaluated:  d->readOnly| yes Evaluation Count:21 | no Evaluation Count:0 | 
 | 0-21 | 
| 492 | return flags; executed:  return flags;Execution Count:21 | 21 | 
| 493 | QDirModelPrivate::QDirNode *node = d->node(index); never executed (the execution status of this line is deduced):  QDirModelPrivate::QDirNode *node = d->node(index); | - | 
| 494 | if ((index.column() == 0) && node->info.isWritable()) { never evaluated: (index.column() == 0) never evaluated: node->info.isWritable() | 0 | 
| 495 | flags |= Qt::ItemIsEditable; never executed (the execution status of this line is deduced):  flags |= Qt::ItemIsEditable; | - | 
| 496 | if (fileInfo(index).isDir()) // is directory and is editable never evaluated: fileInfo(index).isDir() | 0 | 
| 497 | flags |= Qt::ItemIsDropEnabled; never executed: flags |= Qt::ItemIsDropEnabled; | 0 | 
| 498 | } | 0 | 
| 499 | return flags; never executed: return flags; | 0 | 
| 500 | } | - | 
| 501 |  | - | 
| 502 | /*! | - | 
| 503 | Sort the model items in the \a column using the \a order given. | - | 
| 504 | The order is a value defined in \l Qt::SortOrder. | - | 
| 505 | */ | - | 
| 506 |  | - | 
| 507 | void QDirModel::sort(int column, Qt::SortOrder order) | - | 
| 508 | { | - | 
| 509 | QDir::SortFlags sort = QDir::DirsFirst | QDir::IgnoreCase; executed (the execution status of this line is deduced):  QDir::SortFlags sort = QDir::DirsFirst | QDir::IgnoreCase; | - | 
| 510 | if (order == Qt::DescendingOrder) evaluated:  order == Qt::DescendingOrder| yes Evaluation Count:1 | yes Evaluation Count:12 | 
 | 1-12 | 
| 511 | sort |= QDir::Reversed; executed:  sort |= QDir::Reversed;Execution Count:1 | 1 | 
| 512 |  | - | 
| 513 | switch (column) { | - | 
| 514 | case 0: | - | 
| 515 | sort |= QDir::Name; executed (the execution status of this line is deduced):  sort |= QDir::Name; | - | 
| 516 | break; executed:  break;Execution Count:2 | 2 | 
| 517 | case 1: | - | 
| 518 | sort |= QDir::Size; executed (the execution status of this line is deduced):  sort |= QDir::Size; | - | 
| 519 | break; executed:  break;Execution Count:1 | 1 | 
| 520 | case 2: | - | 
| 521 | sort |= QDir::Type; executed (the execution status of this line is deduced):  sort |= QDir::Type; | - | 
| 522 | break; executed:  break;Execution Count:1 | 1 | 
| 523 | case 3: | - | 
| 524 | sort |= QDir::Time; executed (the execution status of this line is deduced):  sort |= QDir::Time; | - | 
| 525 | break; executed:  break;Execution Count:1 | 1 | 
| 526 | default: | - | 
| 527 | break; executed:  break;Execution Count:8 | 8 | 
| 528 | } | - | 
| 529 |  | - | 
| 530 | setSorting(sort); executed (the execution status of this line is deduced):  setSorting(sort); | - | 
| 531 | } executed:  }Execution Count:13 | 13 | 
| 532 |  | - | 
| 533 | /*! | - | 
| 534 | Returns a list of MIME types that can be used to describe a list of items | - | 
| 535 | in the model. | - | 
| 536 | */ | - | 
| 537 |  | - | 
| 538 | QStringList QDirModel::mimeTypes() const | - | 
| 539 | { | - | 
| 540 | return QStringList(QLatin1String("text/uri-list")); executed:  return QStringList(QLatin1String("text/uri-list"));Execution Count:1 | 1 | 
| 541 | } | - | 
| 542 |  | - | 
| 543 | /*! | - | 
| 544 | Returns an object that contains a serialized description of the specified | - | 
| 545 | \a indexes. The format used to describe the items corresponding to the | - | 
| 546 | indexes is obtained from the mimeTypes() function. | - | 
| 547 |  | - | 
| 548 | If the list of indexes is empty, 0 is returned rather than a serialized | - | 
| 549 | empty list. | - | 
| 550 | */ | - | 
| 551 |  | - | 
| 552 | QMimeData *QDirModel::mimeData(const QModelIndexList &indexes) const | - | 
| 553 | { | - | 
| 554 | QList<QUrl> urls; never executed (the execution status of this line is deduced):  QList<QUrl> urls; | - | 
| 555 | QList<QModelIndex>::const_iterator it = indexes.begin(); never executed (the execution status of this line is deduced):  QList<QModelIndex>::const_iterator it = indexes.begin(); | - | 
| 556 | for (; it != indexes.end(); ++it) never evaluated: it != indexes.end() | 0 | 
| 557 | if ((*it).column() == 0) never evaluated: (*it).column() == 0 | 0 | 
| 558 | urls << QUrl::fromLocalFile(filePath(*it)); never executed: urls << QUrl::fromLocalFile(filePath(*it)); | 0 | 
| 559 | QMimeData *data = new QMimeData(); never executed (the execution status of this line is deduced):  QMimeData *data = new QMimeData(); | - | 
| 560 | data->setUrls(urls); never executed (the execution status of this line is deduced):  data->setUrls(urls); | - | 
| 561 | return data; never executed: return data; | 0 | 
| 562 | } | - | 
| 563 |  | - | 
| 564 | /*! | - | 
| 565 | Handles the \a data supplied by a drag and drop operation that ended with | - | 
| 566 | the given \a action over the row in the model specified by the \a row and | - | 
| 567 | \a column and by the \a parent index. | - | 
| 568 |  | - | 
| 569 | Returns true if the drop was successful, and false otherwise. | - | 
| 570 |  | - | 
| 571 | \sa supportedDropActions() | - | 
| 572 | */ | - | 
| 573 |  | - | 
| 574 | bool QDirModel::dropMimeData(const QMimeData *data, Qt::DropAction action, | - | 
| 575 | int /* row */, int /* column */, const QModelIndex &parent) | - | 
| 576 | { | - | 
| 577 | Q_D(QDirModel); never executed (the execution status of this line is deduced):  QDirModelPrivate * const d = d_func(); | - | 
| 578 | if (!d->indexValid(parent) || isReadOnly()) never evaluated: !d->indexValid(parent) never evaluated: isReadOnly() | 0 | 
| 579 | return false; never executed: return false; | 0 | 
| 580 |  | - | 
| 581 | bool success = true; never executed (the execution status of this line is deduced):  bool success = true; | - | 
| 582 | QString to = filePath(parent) + QDir::separator(); never executed (the execution status of this line is deduced):  QString to = filePath(parent) + QDir::separator(); | - | 
| 583 | QModelIndex _parent = parent; never executed (the execution status of this line is deduced):  QModelIndex _parent = parent; | - | 
| 584 |  | - | 
| 585 | QList<QUrl> urls = data->urls(); never executed (the execution status of this line is deduced):  QList<QUrl> urls = data->urls(); | - | 
| 586 | QList<QUrl>::const_iterator it = urls.constBegin(); never executed (the execution status of this line is deduced):  QList<QUrl>::const_iterator it = urls.constBegin(); | - | 
| 587 |  | - | 
| 588 | switch (action) { | - | 
| 589 | case Qt::CopyAction: | - | 
| 590 | for (; it != urls.constEnd(); ++it) { never evaluated: it != urls.constEnd() | 0 | 
| 591 | QString path = (*it).toLocalFile(); never executed (the execution status of this line is deduced):  QString path = (*it).toLocalFile(); | - | 
| 592 | success = QFile::copy(path, to + QFileInfo(path).fileName()) && success; never evaluated: QFile::copy(path, to + QFileInfo(path).fileName()) never evaluated: success | 0 | 
| 593 | } | 0 | 
| 594 | break; | 0 | 
| 595 | case Qt::LinkAction: | - | 
| 596 | for (; it != urls.constEnd(); ++it) { never evaluated: it != urls.constEnd() | 0 | 
| 597 | QString path = (*it).toLocalFile(); never executed (the execution status of this line is deduced):  QString path = (*it).toLocalFile(); | - | 
| 598 | success = QFile::link(path, to + QFileInfo(path).fileName()) && success; never evaluated: QFile::link(path, to + QFileInfo(path).fileName()) never evaluated: success | 0 | 
| 599 | } | 0 | 
| 600 | break; | 0 | 
| 601 | case Qt::MoveAction: | - | 
| 602 | for (; it != urls.constEnd(); ++it) { never evaluated: it != urls.constEnd() | 0 | 
| 603 | QString path = (*it).toLocalFile(); never executed (the execution status of this line is deduced):  QString path = (*it).toLocalFile(); | - | 
| 604 | if (QFile::copy(path, to + QFileInfo(path).fileName()) never evaluated: QFile::copy(path, to + QFileInfo(path).fileName()) | 0 | 
| 605 | && QFile::remove(path)) { never evaluated: QFile::remove(path) | 0 | 
| 606 | QModelIndex idx=index(QFileInfo(path).path()); never executed (the execution status of this line is deduced):  QModelIndex idx=index(QFileInfo(path).path()); | - | 
| 607 | if (idx.isValid()) { never evaluated: idx.isValid() | 0 | 
| 608 | refresh(idx); never executed (the execution status of this line is deduced):  refresh(idx); | - | 
| 609 | //the previous call to refresh may invalidate the _parent. so recreate a new QModelIndex | - | 
| 610 | _parent = index(to); never executed (the execution status of this line is deduced):  _parent = index(to); | - | 
| 611 | } | 0 | 
| 612 | } else { | 0 | 
| 613 | success = false; never executed (the execution status of this line is deduced):  success = false; | - | 
| 614 | } | 0 | 
| 615 | } | - | 
| 616 | break; | 0 | 
| 617 | default: | - | 
| 618 | return false; never executed: return false; | 0 | 
| 619 | } | - | 
| 620 |  | - | 
| 621 | if (success) | 0 | 
| 622 | refresh(_parent); never executed: refresh(_parent); | 0 | 
| 623 |  | - | 
| 624 | return success; never executed: return success; | 0 | 
| 625 | } | - | 
| 626 |  | - | 
| 627 | /*! | - | 
| 628 | Returns the drop actions supported by this model. | - | 
| 629 |  | - | 
| 630 | \sa Qt::DropActions | - | 
| 631 | */ | - | 
| 632 |  | - | 
| 633 | Qt::DropActions QDirModel::supportedDropActions() const | - | 
| 634 | { | - | 
| 635 | return Qt::CopyAction | Qt::MoveAction; // FIXME: LinkAction is not supported yet executed:  return Qt::CopyAction | Qt::MoveAction;Execution Count:1 | 1 | 
| 636 | } | - | 
| 637 |  | - | 
| 638 | /*! | - | 
| 639 | Sets the \a provider of file icons for the directory model. | - | 
| 640 |  | - | 
| 641 | */ | - | 
| 642 |  | - | 
| 643 | void QDirModel::setIconProvider(QFileIconProvider *provider) | - | 
| 644 | { | - | 
| 645 | Q_D(QDirModel); executed (the execution status of this line is deduced):  QDirModelPrivate * const d = d_func(); | - | 
| 646 | d->iconProvider = provider; executed (the execution status of this line is deduced):  d->iconProvider = provider; | - | 
| 647 | } executed:  }Execution Count:2 | 2 | 
| 648 |  | - | 
| 649 | /*! | - | 
| 650 | Returns the file icon provider for this directory model. | - | 
| 651 | */ | - | 
| 652 |  | - | 
| 653 | QFileIconProvider *QDirModel::iconProvider() const | - | 
| 654 | { | - | 
| 655 | Q_D(const QDirModel); executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 656 | return d->iconProvider; executed:  return d->iconProvider;Execution Count:2 | 2 | 
| 657 | } | - | 
| 658 |  | - | 
| 659 | /*! | - | 
| 660 | Sets the name \a filters for the directory model. | - | 
| 661 | */ | - | 
| 662 |  | - | 
| 663 | void QDirModel::setNameFilters(const QStringList &filters) | - | 
| 664 | { | - | 
| 665 | Q_D(QDirModel); executed (the execution status of this line is deduced):  QDirModelPrivate * const d = d_func(); | - | 
| 666 | d->nameFilters = filters; executed (the execution status of this line is deduced):  d->nameFilters = filters; | - | 
| 667 | emit layoutAboutToBeChanged(); executed (the execution status of this line is deduced):  layoutAboutToBeChanged(); | - | 
| 668 | if (d->shouldStat) partially evaluated:  d->shouldStat| yes Evaluation Count:1 | no Evaluation Count:0 | 
 | 0-1 | 
| 669 | refresh(QModelIndex()); executed:  refresh(QModelIndex());Execution Count:1 | 1 | 
| 670 | else | - | 
| 671 | d->invalidate(); never executed: d->invalidate(); | 0 | 
| 672 | emit layoutChanged(); executed (the execution status of this line is deduced):  layoutChanged(); | - | 
| 673 | } executed:  }Execution Count:1 | 1 | 
| 674 |  | - | 
| 675 | /*! | - | 
| 676 | Returns a list of filters applied to the names in the model. | - | 
| 677 | */ | - | 
| 678 |  | - | 
| 679 | QStringList QDirModel::nameFilters() const | - | 
| 680 | { | - | 
| 681 | Q_D(const QDirModel); never executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 682 | return d->nameFilters; never executed: return d->nameFilters; | 0 | 
| 683 | } | - | 
| 684 |  | - | 
| 685 | /*! | - | 
| 686 | Sets the directory model's filter to that specified by \a filters. | - | 
| 687 |  | - | 
| 688 | Note that the filter you set should always include the QDir::AllDirs enum value, | - | 
| 689 | otherwise QDirModel won't be able to read the directory structure. | - | 
| 690 |  | - | 
| 691 | \sa QDir::Filters | - | 
| 692 | */ | - | 
| 693 |  | - | 
| 694 | void QDirModel::setFilter(QDir::Filters filters) | - | 
| 695 | { | - | 
| 696 | Q_D(QDirModel); executed (the execution status of this line is deduced):  QDirModelPrivate * const d = d_func(); | - | 
| 697 | d->filters = filters; executed (the execution status of this line is deduced):  d->filters = filters; | - | 
| 698 | emit layoutAboutToBeChanged(); executed (the execution status of this line is deduced):  layoutAboutToBeChanged(); | - | 
| 699 | if (d->shouldStat) partially evaluated:  d->shouldStat| yes Evaluation Count:3 | no Evaluation Count:0 | 
 | 0-3 | 
| 700 | refresh(QModelIndex()); executed:  refresh(QModelIndex());Execution Count:3 | 3 | 
| 701 | else | - | 
| 702 | d->invalidate(); never executed: d->invalidate(); | 0 | 
| 703 | emit layoutChanged(); executed (the execution status of this line is deduced):  layoutChanged(); | - | 
| 704 | } executed:  }Execution Count:3 | 3 | 
| 705 |  | - | 
| 706 | /*! | - | 
| 707 | Returns the filter specification for the directory model. | - | 
| 708 |  | - | 
| 709 | \sa QDir::Filters | - | 
| 710 | */ | - | 
| 711 |  | - | 
| 712 | QDir::Filters QDirModel::filter() const | - | 
| 713 | { | - | 
| 714 | Q_D(const QDirModel); executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 715 | return d->filters; executed:  return d->filters;Execution Count:2 | 2 | 
| 716 | } | - | 
| 717 |  | - | 
| 718 | /*! | - | 
| 719 | Sets the directory model's sorting order to that specified by \a sort. | - | 
| 720 |  | - | 
| 721 | \sa QDir::SortFlags | - | 
| 722 | */ | - | 
| 723 |  | - | 
| 724 | void QDirModel::setSorting(QDir::SortFlags sort) | - | 
| 725 | { | - | 
| 726 | Q_D(QDirModel); executed (the execution status of this line is deduced):  QDirModelPrivate * const d = d_func(); | - | 
| 727 | d->sort = sort; executed (the execution status of this line is deduced):  d->sort = sort; | - | 
| 728 | emit layoutAboutToBeChanged(); executed (the execution status of this line is deduced):  layoutAboutToBeChanged(); | - | 
| 729 | if (d->shouldStat) partially evaluated:  d->shouldStat| yes Evaluation Count:13 | no Evaluation Count:0 | 
 | 0-13 | 
| 730 | refresh(QModelIndex()); executed:  refresh(QModelIndex());Execution Count:13 | 13 | 
| 731 | else | - | 
| 732 | d->invalidate(); never executed: d->invalidate(); | 0 | 
| 733 | emit layoutChanged(); executed (the execution status of this line is deduced):  layoutChanged(); | - | 
| 734 | } executed:  }Execution Count:13 | 13 | 
| 735 |  | - | 
| 736 | /*! | - | 
| 737 | Returns the sorting method used for the directory model. | - | 
| 738 |  | - | 
| 739 | \sa QDir::SortFlags | - | 
| 740 | */ | - | 
| 741 |  | - | 
| 742 | QDir::SortFlags QDirModel::sorting() const | - | 
| 743 | { | - | 
| 744 | Q_D(const QDirModel); never executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 745 | return d->sort; never executed: return d->sort; | 0 | 
| 746 | } | - | 
| 747 |  | - | 
| 748 | /*! | - | 
| 749 | \property QDirModel::resolveSymlinks | - | 
| 750 | \brief Whether the directory model should resolve symbolic links | - | 
| 751 |  | - | 
| 752 | This is only relevant on operating systems that support symbolic | - | 
| 753 | links. | - | 
| 754 | */ | - | 
| 755 | void QDirModel::setResolveSymlinks(bool enable) | - | 
| 756 | { | - | 
| 757 | Q_D(QDirModel); executed (the execution status of this line is deduced):  QDirModelPrivate * const d = d_func(); | - | 
| 758 | d->resolveSymlinks = enable; executed (the execution status of this line is deduced):  d->resolveSymlinks = enable; | - | 
| 759 | } executed:  }Execution Count:4 | 4 | 
| 760 |  | - | 
| 761 | bool QDirModel::resolveSymlinks() const | - | 
| 762 | { | - | 
| 763 | Q_D(const QDirModel); executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 764 | return d->resolveSymlinks; executed:  return d->resolveSymlinks;Execution Count:2 | 2 | 
| 765 | } | - | 
| 766 |  | - | 
| 767 | /*! | - | 
| 768 | \property QDirModel::readOnly | - | 
| 769 | \brief Whether the directory model allows writing to the file system | - | 
| 770 |  | - | 
| 771 | If this property is set to false, the directory model will allow renaming, copying | - | 
| 772 | and deleting of files and directories. | - | 
| 773 |  | - | 
| 774 | This property is true by default | - | 
| 775 | */ | - | 
| 776 |  | - | 
| 777 | void QDirModel::setReadOnly(bool enable) | - | 
| 778 | { | - | 
| 779 | Q_D(QDirModel); executed (the execution status of this line is deduced):  QDirModelPrivate * const d = d_func(); | - | 
| 780 | d->readOnly = enable; executed (the execution status of this line is deduced):  d->readOnly = enable; | - | 
| 781 | } executed:  }Execution Count:65 | 65 | 
| 782 |  | - | 
| 783 | bool QDirModel::isReadOnly() const | - | 
| 784 | { | - | 
| 785 | Q_D(const QDirModel); executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 786 | return d->readOnly; executed:  return d->readOnly;Execution Count:16 | 16 | 
| 787 | } | - | 
| 788 |  | - | 
| 789 | /*! | - | 
| 790 | \property QDirModel::lazyChildCount | - | 
| 791 | \brief Whether the directory model optimizes the hasChildren function | - | 
| 792 | to only check if the item is a directory. | - | 
| 793 |  | - | 
| 794 | If this property is set to false, the directory model will make sure that a directory | - | 
| 795 | actually containes any files before reporting that it has children. | - | 
| 796 | Otherwise the directory model will report that an item has children if the item | - | 
| 797 | is a directory. | - | 
| 798 |  | - | 
| 799 | This property is false by default | - | 
| 800 | */ | - | 
| 801 |  | - | 
| 802 | void QDirModel::setLazyChildCount(bool enable) | - | 
| 803 | { | - | 
| 804 | Q_D(QDirModel); executed (the execution status of this line is deduced):  QDirModelPrivate * const d = d_func(); | - | 
| 805 | d->lazyChildCount = enable; executed (the execution status of this line is deduced):  d->lazyChildCount = enable; | - | 
| 806 | } executed:  }Execution Count:2 | 2 | 
| 807 |  | - | 
| 808 | bool QDirModel::lazyChildCount() const | - | 
| 809 | { | - | 
| 810 | Q_D(const QDirModel); executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 811 | return d->lazyChildCount; executed:  return d->lazyChildCount;Execution Count:2 | 2 | 
| 812 | } | - | 
| 813 |  | - | 
| 814 | /*! | - | 
| 815 | QDirModel caches file information. This function updates the | - | 
| 816 | cache. The \a parent parameter is the directory from which the | - | 
| 817 | model is updated; the default value will update the model from | - | 
| 818 | root directory of the file system (the entire model). | - | 
| 819 | */ | - | 
| 820 |  | - | 
| 821 | void QDirModel::refresh(const QModelIndex &parent) | - | 
| 822 | { | - | 
| 823 | Q_D(QDirModel); executed (the execution status of this line is deduced):  QDirModelPrivate * const d = d_func(); | - | 
| 824 |  | - | 
| 825 | QDirModelPrivate::QDirNode *n = d->indexValid(parent) ? d->node(parent) : &(d->root); evaluated:  d->indexValid(parent)| yes Evaluation Count:13 | yes Evaluation Count:17 | 
 | 13-17 | 
| 826 |  | - | 
| 827 | int rows = n->children.count(); executed (the execution status of this line is deduced):  int rows = n->children.count(); | - | 
| 828 | if (rows == 0) { evaluated:  rows == 0| yes Evaluation Count:4 | yes Evaluation Count:26 | 
 | 4-26 | 
| 829 | emit layoutAboutToBeChanged(); executed (the execution status of this line is deduced):  layoutAboutToBeChanged(); | - | 
| 830 | n->stat = true; // make sure that next time we read all the info executed (the execution status of this line is deduced):  n->stat = true; | - | 
| 831 | n->populated = false; executed (the execution status of this line is deduced):  n->populated = false; | - | 
| 832 | emit layoutChanged(); executed (the execution status of this line is deduced):  layoutChanged(); | - | 
| 833 | return; executed:  return;Execution Count:4 | 4 | 
| 834 | } | - | 
| 835 |  | - | 
| 836 | emit layoutAboutToBeChanged(); executed (the execution status of this line is deduced):  layoutAboutToBeChanged(); | - | 
| 837 | d->savePersistentIndexes(); executed (the execution status of this line is deduced):  d->savePersistentIndexes(); | - | 
| 838 | d->rowsAboutToBeRemoved(parent, 0, rows - 1); executed (the execution status of this line is deduced):  d->rowsAboutToBeRemoved(parent, 0, rows - 1); | - | 
| 839 | n->stat = true; // make sure that next time we read all the info executed (the execution status of this line is deduced):  n->stat = true; | - | 
| 840 | d->clear(n); executed (the execution status of this line is deduced):  d->clear(n); | - | 
| 841 | d->rowsRemoved(parent, 0, rows - 1); executed (the execution status of this line is deduced):  d->rowsRemoved(parent, 0, rows - 1); | - | 
| 842 | d->restorePersistentIndexes(); executed (the execution status of this line is deduced):  d->restorePersistentIndexes(); | - | 
| 843 | emit layoutChanged(); executed (the execution status of this line is deduced):  layoutChanged(); | - | 
| 844 | } executed:  }Execution Count:26 | 26 | 
| 845 |  | - | 
| 846 | /*! | - | 
| 847 | \overload | - | 
| 848 |  | - | 
| 849 | Returns the model item index for the given \a path. | - | 
| 850 | */ | - | 
| 851 |  | - | 
| 852 | QModelIndex QDirModel::index(const QString &path, int column) const | - | 
| 853 | { | - | 
| 854 | Q_D(const QDirModel); executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 855 |  | - | 
| 856 | if (path.isEmpty() || path == QCoreApplication::translate("QFileDialog", "My Computer")) evaluated:  path.isEmpty()| yes Evaluation Count:1 | yes Evaluation Count:57 | 
 partially evaluated:  path == QCoreApplication::translate("QFileDialog", "My Computer")| no Evaluation Count:0 | yes Evaluation Count:57 | 
 | 0-57 | 
| 857 | return QModelIndex(); executed:  return QModelIndex();Execution Count:1 | 1 | 
| 858 |  | - | 
| 859 | QString absolutePath = QDir(path).absolutePath(); executed (the execution status of this line is deduced):  QString absolutePath = QDir(path).absolutePath(); | - | 
| 860 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) | - | 
| 861 | absolutePath = absolutePath.toLower(); | - | 
| 862 | // On Windows, "filename......." and "filename" are equivalent | - | 
| 863 | if (absolutePath.endsWith(QLatin1Char('.'))) { | - | 
| 864 | int i; | - | 
| 865 | for (i = absolutePath.count() - 1; i >= 0; --i) { | - | 
| 866 | if (absolutePath.at(i) != QLatin1Char('.')) | - | 
| 867 | break; | - | 
| 868 | } | - | 
| 869 | absolutePath = absolutePath.left(i+1); | - | 
| 870 | } | - | 
| 871 | #endif | - | 
| 872 |  | - | 
| 873 | QStringList pathElements = absolutePath.split(QLatin1Char('/'), QString::SkipEmptyParts); executed (the execution status of this line is deduced):  QStringList pathElements = absolutePath.split(QLatin1Char('/'), QString::SkipEmptyParts); | - | 
| 874 | if ((pathElements.isEmpty() || !QFileInfo(path).exists()) partially evaluated:  pathElements.isEmpty()| no Evaluation Count:0 | yes Evaluation Count:57 | 
 evaluated:  !QFileInfo(path).exists()| yes Evaluation Count:4 | yes Evaluation Count:53 | 
 | 0-57 | 
| 875 | #if !defined(Q_OS_WIN) || defined(Q_OS_WINCE) executed (the execution status of this line is deduced):  | - | 
| 876 | && path != QLatin1String("/") partially evaluated:  path != QLatin1String("/")| yes Evaluation Count:4 | no Evaluation Count:0 | 
 | 0-4 | 
| 877 | #endif | - | 
| 878 | ) | - | 
| 879 | return QModelIndex(); executed:  return QModelIndex();Execution Count:4 | 4 | 
| 880 |  | - | 
| 881 | QModelIndex idx; // start with "My Computer" executed (the execution status of this line is deduced):  QModelIndex idx; | - | 
| 882 | if (!d->root.populated) // make sure the root is populated evaluated:  !d->root.populated| yes Evaluation Count:33 | yes Evaluation Count:20 | 
 | 20-33 | 
| 883 | d->populate(&d->root); executed:  d->populate(&d->root);Execution Count:33 | 33 | 
| 884 |  | - | 
| 885 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) | - | 
| 886 | if (absolutePath.startsWith(QLatin1String("//"))) { // UNC path | - | 
| 887 | QString host = pathElements.first(); | - | 
| 888 | int r = 0; | - | 
| 889 | for (; r < d->root.children.count(); ++r) | - | 
| 890 | if (d->root.children.at(r).info.fileName() == host) | - | 
| 891 | break; | - | 
| 892 | bool childAppended = false; | - | 
| 893 | if (r >= d->root.children.count() && d->allowAppendChild) { | - | 
| 894 | d->appendChild(&d->root, QLatin1String("//") + host); | - | 
| 895 | childAppended = true; | - | 
| 896 | } | - | 
| 897 | idx = index(r, 0, QModelIndex()); | - | 
| 898 | pathElements.pop_front(); | - | 
| 899 | if (childAppended) | - | 
| 900 | emit const_cast<QDirModel*>(this)->layoutChanged(); | - | 
| 901 | } else | - | 
| 902 | #endif | - | 
| 903 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) | - | 
| 904 | if (pathElements.at(0).endsWith(QLatin1Char(':'))) { | - | 
| 905 | pathElements[0] += QLatin1Char('/'); | - | 
| 906 | } | - | 
| 907 | #else | - | 
| 908 | // add the "/" item, since it is a valid path element on unix | - | 
| 909 | pathElements.prepend(QLatin1String("/")); executed (the execution status of this line is deduced):  pathElements.prepend(QLatin1String("/")); | - | 
| 910 | #endif | - | 
| 911 |  | - | 
| 912 | for (int i = 0; i < pathElements.count(); ++i) { evaluated:  i < pathElements.count()| yes Evaluation Count:635 | yes Evaluation Count:52 | 
 | 52-635 | 
| 913 | Q_ASSERT(!pathElements.at(i).isEmpty()); executed (the execution status of this line is deduced):  qt_noop(); | - | 
| 914 | QString element = pathElements.at(i); executed (the execution status of this line is deduced):  QString element = pathElements.at(i); | - | 
| 915 | QDirModelPrivate::QDirNode *parent = (idx.isValid() ? d->node(idx) : &d->root); evaluated:  idx.isValid()| yes Evaluation Count:582 | yes Evaluation Count:53 | 
 | 53-582 | 
| 916 |  | - | 
| 917 | Q_ASSERT(parent); executed (the execution status of this line is deduced):  qt_noop(); | - | 
| 918 | if (!parent->populated) evaluated:  !parent->populated| yes Evaluation Count:364 | yes Evaluation Count:271 | 
 | 271-364 | 
| 919 | d->populate(parent); executed:  d->populate(parent);Execution Count:364 | 364 | 
| 920 |  | - | 
| 921 | // search for the element in the child nodes first | - | 
| 922 | int row = -1; executed (the execution status of this line is deduced):  int row = -1; | - | 
| 923 | for (int j = parent->children.count() - 1; j >= 0; --j) { evaluated:  j >= 0| yes Evaluation Count:5091 | yes Evaluation Count:13 | 
 | 13-5091 | 
| 924 | const QFileInfo& fi = parent->children.at(j).info; executed (the execution status of this line is deduced):  const QFileInfo& fi = parent->children.at(j).info; | - | 
| 925 | QString childFileName; executed (the execution status of this line is deduced):  QString childFileName; | - | 
| 926 | childFileName = idx.isValid() ? fi.fileName() : fi.absoluteFilePath(); evaluated:  idx.isValid()| yes Evaluation Count:5038 | yes Evaluation Count:53 | 
 | 53-5038 | 
| 927 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) | - | 
| 928 | childFileName = childFileName.toLower(); | - | 
| 929 | #endif | - | 
| 930 | if (childFileName == element) { evaluated:  childFileName == element| yes Evaluation Count:622 | yes Evaluation Count:4469 | 
 | 622-4469 | 
| 931 | if (i == pathElements.count() - 1) evaluated:  i == pathElements.count() - 1| yes Evaluation Count:50 | yes Evaluation Count:572 | 
 | 50-572 | 
| 932 | parent->children[j].stat = true; executed:  parent->children[j].stat = true;Execution Count:50 | 50 | 
| 933 | row = j; executed (the execution status of this line is deduced):  row = j; | - | 
| 934 | break; executed:  break;Execution Count:622 | 622 | 
| 935 | } | - | 
| 936 | } executed:  }Execution Count:4469 | 4469 | 
| 937 |  | - | 
| 938 | // we couldn't find the path element, we create a new node since we _know_ that the path is valid | - | 
| 939 | if (row == -1) { evaluated:  row == -1| yes Evaluation Count:13 | yes Evaluation Count:622 | 
 | 13-622 | 
| 940 | #if defined(Q_OS_WINCE) | - | 
| 941 | QString newPath; | - | 
| 942 | if (parent->info.isRoot()) | - | 
| 943 | newPath = parent->info.absoluteFilePath() + element; | - | 
| 944 | else | - | 
| 945 | newPath = parent->info.absoluteFilePath() + QLatin1Char('/') + element; | - | 
| 946 | #else | - | 
| 947 | QString newPath = parent->info.absoluteFilePath() + QLatin1Char('/') + element; executed (the execution status of this line is deduced):  QString newPath = parent->info.absoluteFilePath() + QLatin1Char('/') + element; | - | 
| 948 | #endif | - | 
| 949 | if (!d->allowAppendChild || !QFileInfo(newPath).isDir()) partially evaluated:  !d->allowAppendChild| no Evaluation Count:0 | yes Evaluation Count:13 | 
 evaluated:  !QFileInfo(newPath).isDir()| yes Evaluation Count:1 | yes Evaluation Count:12 | 
 | 0-13 | 
| 950 | return QModelIndex(); executed:  return QModelIndex();Execution Count:1 | 1 | 
| 951 | d->appendChild(parent, newPath); executed (the execution status of this line is deduced):  d->appendChild(parent, newPath); | - | 
| 952 | row = parent->children.count() - 1; executed (the execution status of this line is deduced):  row = parent->children.count() - 1; | - | 
| 953 | if (i == pathElements.count() - 1) // always stat children of  the last element evaluated:  i == pathElements.count() - 1| yes Evaluation Count:2 | yes Evaluation Count:10 | 
 | 2-10 | 
| 954 | parent->children[row].stat = true; executed:  parent->children[row].stat = true;Execution Count:2 | 2 | 
| 955 | emit const_cast<QDirModel*>(this)->layoutChanged(); executed (the execution status of this line is deduced):  const_cast<QDirModel*>(this)->layoutChanged(); | - | 
| 956 | } executed:  }Execution Count:12 | 12 | 
| 957 |  | - | 
| 958 | Q_ASSERT(row >= 0); executed (the execution status of this line is deduced):  qt_noop(); | - | 
| 959 | idx = createIndex(row, 0, static_cast<void*>(&parent->children[row])); executed (the execution status of this line is deduced):  idx = createIndex(row, 0, static_cast<void*>(&parent->children[row])); | - | 
| 960 | Q_ASSERT(idx.isValid()); executed (the execution status of this line is deduced):  qt_noop(); | - | 
| 961 | } executed:  }Execution Count:634 | 634 | 
| 962 |  | - | 
| 963 | if (column != 0) evaluated:  column != 0| yes Evaluation Count:3 | yes Evaluation Count:49 | 
 | 3-49 | 
| 964 | return idx.sibling(idx.row(), column); executed:  return idx.sibling(idx.row(), column);Execution Count:3 | 3 | 
| 965 | return idx; executed:  return idx;Execution Count:49 | 49 | 
| 966 | } | - | 
| 967 |  | - | 
| 968 | /*! | - | 
| 969 | Returns true if the model item \a index represents a directory; | - | 
| 970 | otherwise returns false. | - | 
| 971 | */ | - | 
| 972 |  | - | 
| 973 | bool QDirModel::isDir(const QModelIndex &index) const | - | 
| 974 | { | - | 
| 975 | Q_D(const QDirModel); never executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 976 | Q_ASSERT(d->indexValid(index)); never executed (the execution status of this line is deduced):  qt_noop(); | - | 
| 977 | QDirModelPrivate::QDirNode *node = d->node(index); never executed (the execution status of this line is deduced):  QDirModelPrivate::QDirNode *node = d->node(index); | - | 
| 978 | return node->info.isDir(); never executed: return node->info.isDir(); | 0 | 
| 979 | } | - | 
| 980 |  | - | 
| 981 | /*! | - | 
| 982 | Create a directory with the \a name in the \a parent model item. | - | 
| 983 | */ | - | 
| 984 |  | - | 
| 985 | QModelIndex QDirModel::mkdir(const QModelIndex &parent, const QString &name) | - | 
| 986 | { | - | 
| 987 | Q_D(QDirModel); executed (the execution status of this line is deduced):  QDirModelPrivate * const d = d_func(); | - | 
| 988 | if (!d->indexValid(parent) || isReadOnly()) partially evaluated:  !d->indexValid(parent)| no Evaluation Count:0 | yes Evaluation Count:7 | 
 partially evaluated:  isReadOnly()| no Evaluation Count:0 | yes Evaluation Count:7 | 
 | 0-7 | 
| 989 | return QModelIndex(); never executed: return QModelIndex(); | 0 | 
| 990 |  | - | 
| 991 | QDirModelPrivate::QDirNode *p = d->node(parent); executed (the execution status of this line is deduced):  QDirModelPrivate::QDirNode *p = d->node(parent); | - | 
| 992 | QString path = p->info.absoluteFilePath(); executed (the execution status of this line is deduced):  QString path = p->info.absoluteFilePath(); | - | 
| 993 | // For the indexOf() method to work, the new directory has to be a direct child of | - | 
| 994 | // the parent directory. | - | 
| 995 |  | - | 
| 996 | QDir newDir(name); executed (the execution status of this line is deduced):  QDir newDir(name); | - | 
| 997 | QDir dir(path); executed (the execution status of this line is deduced):  QDir dir(path); | - | 
| 998 | if (newDir.isRelative()) partially evaluated:  newDir.isRelative()| yes Evaluation Count:7 | no Evaluation Count:0 | 
 | 0-7 | 
| 999 | newDir = QDir(path + QLatin1Char('/') + name); executed:  newDir = QDir(path + QLatin1Char('/') + name);Execution Count:7 | 7 | 
| 1000 | QString childName = newDir.dirName(); // Get the singular name of the directory executed (the execution status of this line is deduced):  QString childName = newDir.dirName(); | - | 
| 1001 | newDir.cdUp(); executed (the execution status of this line is deduced):  newDir.cdUp(); | - | 
| 1002 |  | - | 
| 1003 | if (newDir.absolutePath() != dir.absolutePath() || !dir.mkdir(name)) evaluated:  newDir.absolutePath() != dir.absolutePath()| yes Evaluation Count:2 | yes Evaluation Count:5 | 
 evaluated:  !dir.mkdir(name)| yes Evaluation Count:1 | yes Evaluation Count:4 | 
 | 1-5 | 
| 1004 | return QModelIndex(); // nothing happened executed:  return QModelIndex();Execution Count:3 | 3 | 
| 1005 |  | - | 
| 1006 | refresh(parent); executed (the execution status of this line is deduced):  refresh(parent); | - | 
| 1007 |  | - | 
| 1008 | QStringList entryList = d->entryList(path); executed (the execution status of this line is deduced):  QStringList entryList = d->entryList(path); | - | 
| 1009 | int r = entryList.indexOf(childName); executed (the execution status of this line is deduced):  int r = entryList.indexOf(childName); | - | 
| 1010 | QModelIndex i = index(r, 0, parent); // return an invalid index executed (the execution status of this line is deduced):  QModelIndex i = index(r, 0, parent); | - | 
| 1011 |  | - | 
| 1012 | return i; executed:  return i;Execution Count:4 | 4 | 
| 1013 | } | - | 
| 1014 |  | - | 
| 1015 | /*! | - | 
| 1016 | Removes the directory corresponding to the model item \a index in the | - | 
| 1017 | directory model and \b{deletes the corresponding directory from the | - | 
| 1018 | file system}, returning true if successful. If the directory cannot be | - | 
| 1019 | removed, false is returned. | - | 
| 1020 |  | - | 
| 1021 | \warning This function deletes directories from the file system; it does | - | 
| 1022 | \b{not} move them to a location where they can be recovered. | - | 
| 1023 |  | - | 
| 1024 | \sa remove() | - | 
| 1025 | */ | - | 
| 1026 |  | - | 
| 1027 | bool QDirModel::rmdir(const QModelIndex &index) | - | 
| 1028 | { | - | 
| 1029 | Q_D(QDirModel); executed (the execution status of this line is deduced):  QDirModelPrivate * const d = d_func(); | - | 
| 1030 | if (!d->indexValid(index) || isReadOnly()) evaluated:  !d->indexValid(index)| yes Evaluation Count:3 | yes Evaluation Count:4 | 
 partially evaluated:  isReadOnly()| no Evaluation Count:0 | yes Evaluation Count:4 | 
 | 0-4 | 
| 1031 | return false; executed:  return false;Execution Count:3 | 3 | 
| 1032 |  | - | 
| 1033 | QDirModelPrivate::QDirNode *n = d_func()->node(index); executed (the execution status of this line is deduced):  QDirModelPrivate::QDirNode *n = d_func()->node(index); | - | 
| 1034 | if (!n->info.isDir()) { partially evaluated:  !n->info.isDir()| no Evaluation Count:0 | yes Evaluation Count:4 | 
 | 0-4 | 
| 1035 | qWarning("rmdir: the node is not a directory"); never executed (the execution status of this line is deduced):  QMessageLogger("itemviews/qdirmodel.cpp", 1035, __PRETTY_FUNCTION__).warning("rmdir: the node is not a directory"); | - | 
| 1036 | return false; never executed: return false; | 0 | 
| 1037 | } | - | 
| 1038 |  | - | 
| 1039 | QModelIndex par = parent(index); executed (the execution status of this line is deduced):  QModelIndex par = parent(index); | - | 
| 1040 | QDirModelPrivate::QDirNode *p = d_func()->node(par); executed (the execution status of this line is deduced):  QDirModelPrivate::QDirNode *p = d_func()->node(par); | - | 
| 1041 | QDir dir = p->info.dir(); // parent dir executed (the execution status of this line is deduced):  QDir dir = p->info.dir(); | - | 
| 1042 | QString path = n->info.absoluteFilePath(); executed (the execution status of this line is deduced):  QString path = n->info.absoluteFilePath(); | - | 
| 1043 | if (!dir.rmdir(path)) partially evaluated:  !dir.rmdir(path)| no Evaluation Count:0 | yes Evaluation Count:4 | 
 | 0-4 | 
| 1044 | return false; never executed: return false; | 0 | 
| 1045 |  | - | 
| 1046 | refresh(par); executed (the execution status of this line is deduced):  refresh(par); | - | 
| 1047 |  | - | 
| 1048 | return true; executed:  return true;Execution Count:4 | 4 | 
| 1049 | } | - | 
| 1050 |  | - | 
| 1051 | /*! | - | 
| 1052 | Removes the model item \a index from the directory model and \b{deletes the | - | 
| 1053 | corresponding file from the file system}, returning true if successful. If the | - | 
| 1054 | item cannot be removed, false is returned. | - | 
| 1055 |  | - | 
| 1056 | \warning This function deletes files from the file system; it does \b{not} | - | 
| 1057 | move them to a location where they can be recovered. | - | 
| 1058 |  | - | 
| 1059 | \sa rmdir() | - | 
| 1060 | */ | - | 
| 1061 |  | - | 
| 1062 | bool QDirModel::remove(const QModelIndex &index) | - | 
| 1063 | { | - | 
| 1064 | Q_D(QDirModel); executed (the execution status of this line is deduced):  QDirModelPrivate * const d = d_func(); | - | 
| 1065 | if (!d->indexValid(index) || isReadOnly()) partially evaluated:  !d->indexValid(index)| no Evaluation Count:0 | yes Evaluation Count:5 | 
 partially evaluated:  isReadOnly()| no Evaluation Count:0 | yes Evaluation Count:5 | 
 | 0-5 | 
| 1066 | return false; never executed: return false; | 0 | 
| 1067 |  | - | 
| 1068 | QDirModelPrivate::QDirNode *n = d_func()->node(index); executed (the execution status of this line is deduced):  QDirModelPrivate::QDirNode *n = d_func()->node(index); | - | 
| 1069 | if (n->info.isDir()) partially evaluated:  n->info.isDir()| no Evaluation Count:0 | yes Evaluation Count:5 | 
 | 0-5 | 
| 1070 | return false; never executed: return false; | 0 | 
| 1071 |  | - | 
| 1072 | QModelIndex par = parent(index); executed (the execution status of this line is deduced):  QModelIndex par = parent(index); | - | 
| 1073 | QDirModelPrivate::QDirNode *p = d_func()->node(par); executed (the execution status of this line is deduced):  QDirModelPrivate::QDirNode *p = d_func()->node(par); | - | 
| 1074 | QDir dir = p->info.dir(); // parent dir executed (the execution status of this line is deduced):  QDir dir = p->info.dir(); | - | 
| 1075 | QString path = n->info.absoluteFilePath(); executed (the execution status of this line is deduced):  QString path = n->info.absoluteFilePath(); | - | 
| 1076 | if (!dir.remove(path)) partially evaluated:  !dir.remove(path)| no Evaluation Count:0 | yes Evaluation Count:5 | 
 | 0-5 | 
| 1077 | return false; never executed: return false; | 0 | 
| 1078 |  | - | 
| 1079 | refresh(par); executed (the execution status of this line is deduced):  refresh(par); | - | 
| 1080 |  | - | 
| 1081 | return true; executed:  return true;Execution Count:5 | 5 | 
| 1082 | } | - | 
| 1083 |  | - | 
| 1084 | /*! | - | 
| 1085 | Returns the path of the item stored in the model under the | - | 
| 1086 | \a index given. | - | 
| 1087 |  | - | 
| 1088 | */ | - | 
| 1089 |  | - | 
| 1090 | QString QDirModel::filePath(const QModelIndex &index) const | - | 
| 1091 | { | - | 
| 1092 | Q_D(const QDirModel); executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 1093 | if (d->indexValid(index)) { partially evaluated:  d->indexValid(index)| yes Evaluation Count:23 | no Evaluation Count:0 | 
 | 0-23 | 
| 1094 | QFileInfo fi = fileInfo(index); executed (the execution status of this line is deduced):  QFileInfo fi = fileInfo(index); | - | 
| 1095 | if (d->resolveSymlinks && fi.isSymLink()) evaluated:  d->resolveSymlinks| yes Evaluation Count:22 | yes Evaluation Count:1 | 
 evaluated:  fi.isSymLink()| yes Evaluation Count:1 | yes Evaluation Count:21 | 
 | 1-22 | 
| 1096 | fi = d->resolvedInfo(fi); executed:  fi = d->resolvedInfo(fi);Execution Count:1 | 1 | 
| 1097 | return QDir::cleanPath(fi.absoluteFilePath()); executed:  return QDir::cleanPath(fi.absoluteFilePath());Execution Count:23 | 23 | 
| 1098 | } | - | 
| 1099 | return QString(); // root path never executed: return QString(); | 0 | 
| 1100 | } | - | 
| 1101 |  | - | 
| 1102 | /*! | - | 
| 1103 | Returns the name of the item stored in the model under the | - | 
| 1104 | \a index given. | - | 
| 1105 |  | - | 
| 1106 | */ | - | 
| 1107 |  | - | 
| 1108 | QString QDirModel::fileName(const QModelIndex &index) const | - | 
| 1109 | { | - | 
| 1110 | Q_D(const QDirModel); executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 1111 | if (!d->indexValid(index)) partially evaluated:  !d->indexValid(index)| yes Evaluation Count:1 | no Evaluation Count:0 | 
 | 0-1 | 
| 1112 | return QString(); executed:  return QString();Execution Count:1 | 1 | 
| 1113 | QFileInfo info = fileInfo(index); never executed (the execution status of this line is deduced):  QFileInfo info = fileInfo(index); | - | 
| 1114 | if (info.isRoot()) never evaluated: info.isRoot() | 0 | 
| 1115 | return info.absoluteFilePath(); never executed: return info.absoluteFilePath(); | 0 | 
| 1116 | if (d->resolveSymlinks && info.isSymLink()) never evaluated: d->resolveSymlinks never evaluated: info.isSymLink() | 0 | 
| 1117 | info = d->resolvedInfo(info); never executed: info = d->resolvedInfo(info); | 0 | 
| 1118 | return info.fileName(); never executed: return info.fileName(); | 0 | 
| 1119 | } | - | 
| 1120 |  | - | 
| 1121 | /*! | - | 
| 1122 | Returns the icons for the item stored in the model under the given | - | 
| 1123 | \a index. | - | 
| 1124 | */ | - | 
| 1125 |  | - | 
| 1126 | QIcon QDirModel::fileIcon(const QModelIndex &index) const | - | 
| 1127 | { | - | 
| 1128 | Q_D(const QDirModel); executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 1129 | if (!d->indexValid(index)) partially evaluated:  !d->indexValid(index)| no Evaluation Count:0 | yes Evaluation Count:22 | 
 | 0-22 | 
| 1130 | return d->iconProvider->icon(QFileIconProvider::Computer); never executed: return d->iconProvider->icon(QFileIconProvider::Computer); | 0 | 
| 1131 | QDirModelPrivate::QDirNode *node = d->node(index); executed (the execution status of this line is deduced):  QDirModelPrivate::QDirNode *node = d->node(index); | - | 
| 1132 | if (node->icon.isNull()) evaluated:  node->icon.isNull()| yes Evaluation Count:16 | yes Evaluation Count:6 | 
 | 6-16 | 
| 1133 | node->icon = d->iconProvider->icon(node->info); executed:  node->icon = d->iconProvider->icon(node->info);Execution Count:16 | 16 | 
| 1134 | return node->icon; executed:  return node->icon;Execution Count:22 | 22 | 
| 1135 | } | - | 
| 1136 |  | - | 
| 1137 | /*! | - | 
| 1138 | Returns the file information for the specified model \a index. | - | 
| 1139 |  | - | 
| 1140 | \b{Note:} If the model index represents a symbolic link in the | - | 
| 1141 | underlying filing system, the file information returned will contain | - | 
| 1142 | information about the symbolic link itself, regardless of whether | - | 
| 1143 | resolveSymlinks is enabled or not. | - | 
| 1144 |  | - | 
| 1145 | \sa QFileInfo::symLinkTarget() | - | 
| 1146 | */ | - | 
| 1147 |  | - | 
| 1148 | QFileInfo QDirModel::fileInfo(const QModelIndex &index) const | - | 
| 1149 | { | - | 
| 1150 | Q_D(const QDirModel); executed (the execution status of this line is deduced):  const QDirModelPrivate * const d = d_func(); | - | 
| 1151 | Q_ASSERT(d->indexValid(index)); executed (the execution status of this line is deduced):  qt_noop(); | - | 
| 1152 |  | - | 
| 1153 | QDirModelPrivate::QDirNode *node = d->node(index); executed (the execution status of this line is deduced):  QDirModelPrivate::QDirNode *node = d->node(index); | - | 
| 1154 | return node->info; executed:  return node->info;Execution Count:23 | 23 | 
| 1155 | } | - | 
| 1156 |  | - | 
| 1157 | /*! | - | 
| 1158 | \fn QObject *QDirModel::parent() const | - | 
| 1159 | \internal | - | 
| 1160 | */ | - | 
| 1161 |  | - | 
| 1162 | /* | - | 
| 1163 | The root node is never seen outside the model. | - | 
| 1164 | */ | - | 
| 1165 |  | - | 
| 1166 | void QDirModelPrivate::init() | - | 
| 1167 | { | - | 
| 1168 | filters = QDir::AllEntries | QDir::NoDotAndDotDot; executed (the execution status of this line is deduced):  filters = QDir::AllEntries | QDir::NoDotAndDotDot; | - | 
| 1169 | sort = QDir::Name; executed (the execution status of this line is deduced):  sort = QDir::Name; | - | 
| 1170 | nameFilters << QLatin1String("*"); executed (the execution status of this line is deduced):  nameFilters << QLatin1String("*"); | - | 
| 1171 | root.parent = 0; executed (the execution status of this line is deduced):  root.parent = 0; | - | 
| 1172 | root.info = QFileInfo(); executed (the execution status of this line is deduced):  root.info = QFileInfo(); | - | 
| 1173 | clear(&root); executed (the execution status of this line is deduced):  clear(&root); | - | 
| 1174 | roleNames.insertMulti(QDirModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration executed (the execution status of this line is deduced):  roleNames.insertMulti(QDirModel::FileIconRole, QByteArray("fileIcon", sizeof("fileIcon") - 1)); | - | 
| 1175 | roleNames.insert(QDirModel::FilePathRole, QByteArrayLiteral("filePath")); executed (the execution status of this line is deduced):  roleNames.insert(QDirModel::FilePathRole, QByteArray("filePath", sizeof("filePath") - 1)); | - | 
| 1176 | roleNames.insert(QDirModel::FileNameRole, QByteArrayLiteral("fileName")); executed (the execution status of this line is deduced):  roleNames.insert(QDirModel::FileNameRole, QByteArray("fileName", sizeof("fileName") - 1)); | - | 
| 1177 | } executed:  }Execution Count:82 | 82 | 
| 1178 |  | - | 
| 1179 | QDirModelPrivate::QDirNode *QDirModelPrivate::node(int row, QDirNode *parent) const | - | 
| 1180 | { | - | 
| 1181 | if (row < 0) partially evaluated:  row < 0| no Evaluation Count:0 | yes Evaluation Count:16797 | 
 | 0-16797 | 
| 1182 | return 0; never executed: return 0; | 0 | 
| 1183 |  | - | 
| 1184 | bool isDir = !parent || parent->info.isDir(); evaluated:  !parent| yes Evaluation Count:67 | yes Evaluation Count:16730 | 
 partially evaluated:  parent->info.isDir()| yes Evaluation Count:16730 | no Evaluation Count:0 | 
 | 0-16730 | 
| 1185 | QDirNode *p = (parent ? parent : &root); evaluated:  parent| yes Evaluation Count:16730 | yes Evaluation Count:67 | 
 | 67-16730 | 
| 1186 | if (isDir && !p->populated) partially evaluated:  isDir| yes Evaluation Count:16797 | no Evaluation Count:0 | 
 partially evaluated:  !p->populated| no Evaluation Count:0 | yes Evaluation Count:16797 | 
 | 0-16797 | 
| 1187 | populate(p); // will also resolve symlinks never executed: populate(p); | 0 | 
| 1188 |  | - | 
| 1189 | if (row >= p->children.count()) { partially evaluated:  row >= p->children.count()| no Evaluation Count:0 | yes Evaluation Count:16797 | 
 | 0-16797 | 
| 1190 | qWarning("node: the row does not exist"); never executed (the execution status of this line is deduced):  QMessageLogger("itemviews/qdirmodel.cpp", 1190, __PRETTY_FUNCTION__).warning("node: the row does not exist"); | - | 
| 1191 | return 0; never executed: return 0; | 0 | 
| 1192 | } | - | 
| 1193 |  | - | 
| 1194 | return const_cast<QDirNode*>(&p->children.at(row)); executed:  return const_cast<QDirNode*>(&p->children.at(row));Execution Count:16797 | 16797 | 
| 1195 | } | - | 
| 1196 |  | - | 
| 1197 | QVector<QDirModelPrivate::QDirNode> QDirModelPrivate::children(QDirNode *parent, bool stat) const | - | 
| 1198 | { | - | 
| 1199 | Q_ASSERT(parent); executed (the execution status of this line is deduced):  qt_noop(); | - | 
| 1200 | QFileInfoList infoList; executed (the execution status of this line is deduced):  QFileInfoList infoList; | - | 
| 1201 | if (parent == &root) { evaluated:  parent == &root| yes Evaluation Count:43 | yes Evaluation Count:556 | 
 | 43-556 | 
| 1202 | parent = 0; executed (the execution status of this line is deduced):  parent = 0; | - | 
| 1203 | infoList = QDir::drives(); executed (the execution status of this line is deduced):  infoList = QDir::drives(); | - | 
| 1204 | } else if (parent->info.isDir()) { executed:  }Execution Count:43 partially evaluated:  parent->info.isDir()| yes Evaluation Count:556 | no Evaluation Count:0 | 
 | 0-556 | 
| 1205 | //resolve directory links only if requested. | - | 
| 1206 | if (parent->info.isSymLink() && resolveSymlinks) { evaluated:  parent->info.isSymLink()| yes Evaluation Count:2 | yes Evaluation Count:554 | 
 partially evaluated:  resolveSymlinks| yes Evaluation Count:2 | no Evaluation Count:0 | 
 | 0-554 | 
| 1207 | QString link = parent->info.symLinkTarget(); executed (the execution status of this line is deduced):  QString link = parent->info.symLinkTarget(); | - | 
| 1208 | if (link.size() > 1 && link.at(link.size() - 1) == QDir::separator()) partially evaluated:  link.size() > 1| yes Evaluation Count:2 | no Evaluation Count:0 | 
 partially evaluated:  link.at(link.size() - 1) == QDir::separator()| no Evaluation Count:0 | yes Evaluation Count:2 | 
 | 0-2 | 
| 1209 | link.chop(1); never executed: link.chop(1); | 0 | 
| 1210 | if (stat) partially evaluated:  stat| yes Evaluation Count:2 | no Evaluation Count:0 | 
 | 0-2 | 
| 1211 | infoList = entryInfoList(link); executed:  infoList = entryInfoList(link);Execution Count:2 | 2 | 
| 1212 | else | - | 
| 1213 | infoList = QDir(link).entryInfoList(nameFilters, QDir::AllEntries | QDir::System); never executed: infoList = QDir(link).entryInfoList(nameFilters, QDir::AllEntries | QDir::System); | 0 | 
| 1214 | } else { | - | 
| 1215 | if (stat) partially evaluated:  stat| yes Evaluation Count:554 | no Evaluation Count:0 | 
 | 0-554 | 
| 1216 | infoList = entryInfoList(parent->info.absoluteFilePath()); executed:  infoList = entryInfoList(parent->info.absoluteFilePath());Execution Count:554 | 554 | 
| 1217 | else | - | 
| 1218 | 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 | 
| 1219 | } | - | 
| 1220 | } | - | 
| 1221 |  | - | 
| 1222 | QVector<QDirNode> nodes(infoList.count()); executed (the execution status of this line is deduced):  QVector<QDirNode> nodes(infoList.count()); | - | 
| 1223 | for (int i = 0; i < infoList.count(); ++i) { evaluated:  i < infoList.count()| yes Evaluation Count:10396 | yes Evaluation Count:599 | 
 | 599-10396 | 
| 1224 | QDirNode &node = nodes[i]; executed (the execution status of this line is deduced):  QDirNode &node = nodes[i]; | - | 
| 1225 | node.parent = parent; executed (the execution status of this line is deduced):  node.parent = parent; | - | 
| 1226 | node.info = infoList.at(i); executed (the execution status of this line is deduced):  node.info = infoList.at(i); | - | 
| 1227 | node.populated = false; executed (the execution status of this line is deduced):  node.populated = false; | - | 
| 1228 | node.stat = shouldStat; executed (the execution status of this line is deduced):  node.stat = shouldStat; | - | 
| 1229 | } executed:  }Execution Count:10396 | 10396 | 
| 1230 |  | - | 
| 1231 | return nodes; executed:  return nodes;Execution Count:599 | 599 | 
| 1232 | } | - | 
| 1233 |  | - | 
| 1234 | void QDirModelPrivate::_q_refresh() | - | 
| 1235 | { | - | 
| 1236 | Q_Q(QDirModel); never executed (the execution status of this line is deduced):  QDirModel * const q = q_func(); | - | 
| 1237 | q->refresh(toBeRefreshed); never executed (the execution status of this line is deduced):  q->refresh(toBeRefreshed); | - | 
| 1238 | toBeRefreshed = QModelIndex(); never executed (the execution status of this line is deduced):  toBeRefreshed = QModelIndex(); | - | 
| 1239 | } | 0 | 
| 1240 |  | - | 
| 1241 | void QDirModelPrivate::savePersistentIndexes() | - | 
| 1242 | { | - | 
| 1243 | Q_Q(QDirModel); executed (the execution status of this line is deduced):  QDirModel * const q = q_func(); | - | 
| 1244 | savedPersistent.clear(); executed (the execution status of this line is deduced):  savedPersistent.clear(); | - | 
| 1245 | foreach (QPersistentModelIndexData *data, persistent.indexes) { executed (the execution status of this line is deduced):  for (QForeachContainer<__typeof__(persistent.indexes)> _container_(persistent.indexes); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QPersistentModelIndexData *data = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - | 
| 1246 | SavedPersistent saved; executed (the execution status of this line is deduced):  SavedPersistent saved; | - | 
| 1247 | QModelIndex index = data->index; executed (the execution status of this line is deduced):  QModelIndex index = data->index; | - | 
| 1248 | saved.path = q->filePath(index); executed (the execution status of this line is deduced):  saved.path = q->filePath(index); | - | 
| 1249 | saved.column = index.column(); executed (the execution status of this line is deduced):  saved.column = index.column(); | - | 
| 1250 | saved.data = data; executed (the execution status of this line is deduced):  saved.data = data; | - | 
| 1251 | saved.index = index; executed (the execution status of this line is deduced):  saved.index = index; | - | 
| 1252 | savedPersistent.append(saved); executed (the execution status of this line is deduced):  savedPersistent.append(saved); | - | 
| 1253 | } executed:  }Execution Count:21 | 21 | 
| 1254 | } executed:  }Execution Count:38 | 38 | 
| 1255 |  | - | 
| 1256 | void QDirModelPrivate::restorePersistentIndexes() | - | 
| 1257 | { | - | 
| 1258 | Q_Q(QDirModel); executed (the execution status of this line is deduced):  QDirModel * const q = q_func(); | - | 
| 1259 | bool allow = allowAppendChild; executed (the execution status of this line is deduced):  bool allow = allowAppendChild; | - | 
| 1260 | allowAppendChild = false; executed (the execution status of this line is deduced):  allowAppendChild = false; | - | 
| 1261 | for (int i = 0; i < savedPersistent.count(); ++i) { evaluated:  i < savedPersistent.count()| yes Evaluation Count:21 | yes Evaluation Count:38 | 
 | 21-38 | 
| 1262 | QPersistentModelIndexData *data = savedPersistent.at(i).data; executed (the execution status of this line is deduced):  QPersistentModelIndexData *data = savedPersistent.at(i).data; | - | 
| 1263 | QString path = savedPersistent.at(i).path; executed (the execution status of this line is deduced):  QString path = savedPersistent.at(i).path; | - | 
| 1264 | int column = savedPersistent.at(i).column; executed (the execution status of this line is deduced):  int column = savedPersistent.at(i).column; | - | 
| 1265 | QModelIndex idx = q->index(path, column); executed (the execution status of this line is deduced):  QModelIndex idx = q->index(path, column); | - | 
| 1266 | if (idx != data->index || data->model == 0) { evaluated:  idx != data->index| yes Evaluation Count:17 | yes Evaluation Count:4 | 
 evaluated:  data->model == 0| yes Evaluation Count:2 | yes Evaluation Count:2 | 
 | 2-17 | 
| 1267 | //data->model may be equal to 0 if the model is getting destroyed | - | 
| 1268 | persistent.indexes.remove(data->index); executed (the execution status of this line is deduced):  persistent.indexes.remove(data->index); | - | 
| 1269 | data->index = idx; executed (the execution status of this line is deduced):  data->index = idx; | - | 
| 1270 | data->model = q; executed (the execution status of this line is deduced):  data->model = q; | - | 
| 1271 | if (idx.isValid()) evaluated:  idx.isValid()| yes Evaluation Count:17 | yes Evaluation Count:2 | 
 | 2-17 | 
| 1272 | persistent.indexes.insert(idx, data); executed:  persistent.indexes.insert(idx, data);Execution Count:17 | 17 | 
| 1273 | } executed:  }Execution Count:19 | 19 | 
| 1274 | } executed:  }Execution Count:21 | 21 | 
| 1275 | savedPersistent.clear(); executed (the execution status of this line is deduced):  savedPersistent.clear(); | - | 
| 1276 | allowAppendChild = allow; executed (the execution status of this line is deduced):  allowAppendChild = allow; | - | 
| 1277 | } executed:  }Execution Count:38 | 38 | 
| 1278 |  | - | 
| 1279 | QFileInfoList QDirModelPrivate::entryInfoList(const QString &path) const | - | 
| 1280 | { | - | 
| 1281 | const QDir dir(path); executed (the execution status of this line is deduced):  const QDir dir(path); | - | 
| 1282 | return dir.entryInfoList(nameFilters, filters, sort); executed:  return dir.entryInfoList(nameFilters, filters, sort);Execution Count:556 | 556 | 
| 1283 | } | - | 
| 1284 |  | - | 
| 1285 | QStringList QDirModelPrivate::entryList(const QString &path) const | - | 
| 1286 | { | - | 
| 1287 | const QDir dir(path); executed (the execution status of this line is deduced):  const QDir dir(path); | - | 
| 1288 | return dir.entryList(nameFilters, filters, sort); executed:  return dir.entryList(nameFilters, filters, sort);Execution Count:4 | 4 | 
| 1289 | } | - | 
| 1290 |  | - | 
| 1291 | QString QDirModelPrivate::name(const QModelIndex &index) const | - | 
| 1292 | { | - | 
| 1293 | const QDirNode *n = node(index); executed (the execution status of this line is deduced):  const QDirNode *n = node(index); | - | 
| 1294 | const QFileInfo info = n->info; executed (the execution status of this line is deduced):  const QFileInfo info = n->info; | - | 
| 1295 | if (info.isRoot()) { evaluated:  info.isRoot()| yes Evaluation Count:20 | yes Evaluation Count:787 | 
 | 20-787 | 
| 1296 | QString name = info.absoluteFilePath(); executed (the execution status of this line is deduced):  QString name = info.absoluteFilePath(); | - | 
| 1297 | #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) | - | 
| 1298 | if (name.startsWith(QLatin1Char('/'))) // UNC host | - | 
| 1299 | return info.fileName(); | - | 
| 1300 | if (name.endsWith(QLatin1Char('/'))) | - | 
| 1301 | name.chop(1); | - | 
| 1302 | #endif | - | 
| 1303 | return name; executed:  return name;Execution Count:20 | 20 | 
| 1304 | } | - | 
| 1305 | return info.fileName(); executed:  return info.fileName();Execution Count:787 | 787 | 
| 1306 | } | - | 
| 1307 |  | - | 
| 1308 | QString QDirModelPrivate::size(const QModelIndex &index) const | - | 
| 1309 | { | - | 
| 1310 | const QDirNode *n = node(index); executed (the execution status of this line is deduced):  const QDirNode *n = node(index); | - | 
| 1311 | if (n->info.isDir()) { evaluated:  n->info.isDir()| yes Evaluation Count:155 | yes Evaluation Count:452 | 
 | 155-452 | 
| 1312 | #ifdef Q_OS_MAC | - | 
| 1313 | return QLatin1String("--"); | - | 
| 1314 | #else | - | 
| 1315 | return QLatin1String(""); executed:  return QLatin1String("");Execution Count:155 | 155 | 
| 1316 | #endif | - | 
| 1317 | // Windows   - "" | - | 
| 1318 | // OS X      - "--" | - | 
| 1319 | // Konqueror - "4 KB" | - | 
| 1320 | // Nautilus  - "9 items" (the number of children) | - | 
| 1321 | } | - | 
| 1322 |  | - | 
| 1323 | // According to the Si standard KB is 1000 bytes, KiB is 1024 | - | 
| 1324 | // but on windows sizes are calulated by dividing by 1024 so we do what they do. | - | 
| 1325 | const quint64 kb = 1024; executed (the execution status of this line is deduced):  const quint64 kb = 1024; | - | 
| 1326 | const quint64 mb = 1024 * kb; executed (the execution status of this line is deduced):  const quint64 mb = 1024 * kb; | - | 
| 1327 | const quint64 gb = 1024 * mb; executed (the execution status of this line is deduced):  const quint64 gb = 1024 * mb; | - | 
| 1328 | const quint64 tb = 1024 * gb; executed (the execution status of this line is deduced):  const quint64 tb = 1024 * gb; | - | 
| 1329 | quint64 bytes = n->info.size(); executed (the execution status of this line is deduced):  quint64 bytes = n->info.size(); | - | 
| 1330 | if (bytes >= tb) evaluated:  bytes >= tb| yes Evaluation Count:1 | yes Evaluation Count:451 | 
 | 1-451 | 
| 1331 | return QFileSystemModel::tr("%1 TB").arg(QLocale().toString(qreal(bytes) / tb, 'f', 3)); executed:  return QFileSystemModel::tr("%1 TB").arg(QLocale().toString(qreal(bytes) / tb, 'f', 3));Execution Count:1 | 1 | 
| 1332 | if (bytes >= gb) partially evaluated:  bytes >= gb| no Evaluation Count:0 | yes Evaluation Count:451 | 
 | 0-451 | 
| 1333 | return QFileSystemModel::tr("%1 GB").arg(QLocale().toString(qreal(bytes) / gb, 'f', 2)); never executed: return QFileSystemModel::tr("%1 GB").arg(QLocale().toString(qreal(bytes) / gb, 'f', 2)); | 0 | 
| 1334 | if (bytes >= mb) evaluated:  bytes >= mb| yes Evaluation Count:9 | yes Evaluation Count:442 | 
 | 9-442 | 
| 1335 | return QFileSystemModel::tr("%1 MB").arg(QLocale().toString(qreal(bytes) / mb, 'f', 1)); executed:  return QFileSystemModel::tr("%1 MB").arg(QLocale().toString(qreal(bytes) / mb, 'f', 1));Execution Count:9 | 9 | 
| 1336 | if (bytes >= kb) evaluated:  bytes >= kb| yes Evaluation Count:341 | yes Evaluation Count:101 | 
 | 101-341 | 
| 1337 | return QFileSystemModel::tr("%1 KB").arg(QLocale().toString(bytes / kb)); executed:  return QFileSystemModel::tr("%1 KB").arg(QLocale().toString(bytes / kb));Execution Count:341 | 341 | 
| 1338 | return QFileSystemModel::tr("%1 byte(s)").arg(QLocale().toString(bytes)); executed:  return QFileSystemModel::tr("%1 byte(s)").arg(QLocale().toString(bytes));Execution Count:101 | 101 | 
| 1339 | } | - | 
| 1340 |  | - | 
| 1341 | QString QDirModelPrivate::type(const QModelIndex &index) const | - | 
| 1342 | { | - | 
| 1343 | return iconProvider->type(node(index)->info); executed:  return iconProvider->type(node(index)->info);Execution Count:604 | 604 | 
| 1344 | } | - | 
| 1345 |  | - | 
| 1346 | QString QDirModelPrivate::time(const QModelIndex &index) const | - | 
| 1347 | { | - | 
| 1348 | #ifndef QT_NO_DATESTRING | - | 
| 1349 | return node(index)->info.lastModified().toString(Qt::LocalDate); executed:  return node(index)->info.lastModified().toString(Qt::LocalDate);Execution Count:604 | 604 | 
| 1350 | #else | - | 
| 1351 | Q_UNUSED(index); | - | 
| 1352 | return QString(); | - | 
| 1353 | #endif | - | 
| 1354 | } | - | 
| 1355 |  | - | 
| 1356 | void QDirModelPrivate::appendChild(QDirModelPrivate::QDirNode *parent, const QString &path) const | - | 
| 1357 | { | - | 
| 1358 | QDirModelPrivate::QDirNode node; executed (the execution status of this line is deduced):  QDirModelPrivate::QDirNode node; | - | 
| 1359 | node.populated = false; executed (the execution status of this line is deduced):  node.populated = false; | - | 
| 1360 | node.stat = shouldStat; executed (the execution status of this line is deduced):  node.stat = shouldStat; | - | 
| 1361 | node.parent = (parent == &root ? 0 : parent); partially evaluated:  parent == &root| no Evaluation Count:0 | yes Evaluation Count:12 | 
 | 0-12 | 
| 1362 | node.info = QFileInfo(path); executed (the execution status of this line is deduced):  node.info = QFileInfo(path); | - | 
| 1363 | node.info.setCaching(true); executed (the execution status of this line is deduced):  node.info.setCaching(true); | - | 
| 1364 |  | - | 
| 1365 | // The following append(node) may reallocate the vector, thus | - | 
| 1366 | // we need to update the pointers to the childnodes parent. | - | 
| 1367 | QDirModelPrivate *that = const_cast<QDirModelPrivate *>(this); executed (the execution status of this line is deduced):  QDirModelPrivate *that = const_cast<QDirModelPrivate *>(this); | - | 
| 1368 | that->savePersistentIndexes(); executed (the execution status of this line is deduced):  that->savePersistentIndexes(); | - | 
| 1369 | parent->children.append(node); executed (the execution status of this line is deduced):  parent->children.append(node); | - | 
| 1370 | for (int i = 0; i < parent->children.count(); ++i) { evaluated:  i < parent->children.count()| yes Evaluation Count:20 | yes Evaluation Count:12 | 
 | 12-20 | 
| 1371 | QDirNode *childNode = &parent->children[i]; executed (the execution status of this line is deduced):  QDirNode *childNode = &parent->children[i]; | - | 
| 1372 | for (int j = 0; j < childNode->children.count(); ++j) partially evaluated:  j < childNode->children.count()| no Evaluation Count:0 | yes Evaluation Count:20 | 
 | 0-20 | 
| 1373 | childNode->children[j].parent = childNode; never executed: childNode->children[j].parent = childNode; | 0 | 
| 1374 | } executed:  }Execution Count:20 | 20 | 
| 1375 | that->restorePersistentIndexes(); executed (the execution status of this line is deduced):  that->restorePersistentIndexes(); | - | 
| 1376 | } executed:  }Execution Count:12 | 12 | 
| 1377 |  | - | 
| 1378 | QFileInfo QDirModelPrivate::resolvedInfo(QFileInfo info) | - | 
| 1379 | { | - | 
| 1380 | #ifdef Q_OS_WIN | - | 
| 1381 | // On windows, we cannot create a shortcut to a shortcut. | - | 
| 1382 | return QFileInfo(info.symLinkTarget()); | - | 
| 1383 | #else | - | 
| 1384 | QStringList paths; executed (the execution status of this line is deduced):  QStringList paths; | - | 
| 1385 | do { | - | 
| 1386 | QFileInfo link(info.symLinkTarget()); executed (the execution status of this line is deduced):  QFileInfo link(info.symLinkTarget()); | - | 
| 1387 | if (link.isRelative()) partially evaluated:  link.isRelative()| no Evaluation Count:0 | yes Evaluation Count:1 | 
 | 0-1 | 
| 1388 | info.setFile(info.absolutePath(), link.filePath()); never executed: info.setFile(info.absolutePath(), link.filePath()); | 0 | 
| 1389 | else | - | 
| 1390 | info = link; executed:  info = link;Execution Count:1 | 1 | 
| 1391 | if (paths.contains(info.absoluteFilePath())) partially evaluated:  paths.contains(info.absoluteFilePath())| no Evaluation Count:0 | yes Evaluation Count:1 | 
 | 0-1 | 
| 1392 | return QFileInfo(); never executed: return QFileInfo(); | 0 | 
| 1393 | paths.append(info.absoluteFilePath()); executed (the execution status of this line is deduced):  paths.append(info.absoluteFilePath()); | - | 
| 1394 | } while (info.isSymLink()); executed:  }Execution Count:1 partially evaluated:  info.isSymLink()| no Evaluation Count:0 | yes Evaluation Count:1 | 
 | 0-1 | 
| 1395 | return info; executed:  return info;Execution Count:1 | 1 | 
| 1396 | #endif | - | 
| 1397 | } | - | 
| 1398 |  | - | 
| 1399 | QT_END_NAMESPACE | - | 
| 1400 |  | - | 
| 1401 | #include "moc_qdirmodel.cpp" | - | 
| 1402 |  | - | 
| 1403 | #endif // QT_NO_DIRMODEL | - | 
| 1404 |  | - | 
|  |  |  |