diff options
Diffstat (limited to 'src/widgets/itemviews/qdirmodel.cpp')
-rw-r--r-- | src/widgets/itemviews/qdirmodel.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index 13a1bbd8eb..0d387d7def 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -39,6 +39,8 @@ #include "qdirmodel.h" +#if QT_DEPRECATED_SINCE(5, 15) + #include <qfile.h> #include <qfilesystemmodel.h> #include <qurl.h> @@ -73,7 +75,7 @@ class QDirModelPrivate : public QAbstractItemModelPrivate public: struct QDirNode { - QDirNode() : parent(0), populated(false), stat(false) {} + QDirNode() : parent(nullptr), populated(false), stat(false) {} QDirNode *parent; QFileInfo info; QIcon icon; // cache the icon @@ -236,7 +238,7 @@ QDirModel::QDirModel(const QStringList &nameFilters, d->nameFilters = nameFilters.isEmpty() ? QStringList(QLatin1String("*")) : nameFilters; d->filters = filters; d->sort = sort; - d->root.parent = 0; + d->root.parent = nullptr; d->root.info = QFileInfo(); d->clear(&d->root); } @@ -291,7 +293,7 @@ QModelIndex QDirModel::index(int row, int column, const QModelIndex &parent) con if (row >= p->children.count()) return QModelIndex(); // now get the internal pointer for the index - QDirModelPrivate::QDirNode *n = d->node(row, d->indexValid(parent) ? p : 0); + QDirModelPrivate::QDirNode *n = d->node(row, d->indexValid(parent) ? p : nullptr); Q_ASSERT(n); return createIndex(row, column, n); @@ -308,8 +310,8 @@ QModelIndex QDirModel::parent(const QModelIndex &child) const if (!d->indexValid(child)) return QModelIndex(); QDirModelPrivate::QDirNode *node = d->node(child); - QDirModelPrivate::QDirNode *par = (node ? node->parent : 0); - if (par == 0) // parent is the root node + QDirModelPrivate::QDirNode *par = (node ? node->parent : nullptr); + if (par == nullptr) // parent is the root node return QModelIndex(); // get the parent's row @@ -1157,10 +1159,10 @@ void QDirModelPrivate::init() filters = QDir::AllEntries | QDir::NoDotAndDotDot; sort = QDir::Name; nameFilters << QLatin1String("*"); - root.parent = 0; + root.parent = nullptr; root.info = QFileInfo(); clear(&root); - roleNames.insertMulti(QDirModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration + roleNames.insert(QDirModel::FileIconRole, QByteArrayLiteral("fileIcon")); // == Qt::decoration roleNames.insert(QDirModel::FilePathRole, QByteArrayLiteral("filePath")); roleNames.insert(QDirModel::FileNameRole, QByteArrayLiteral("fileName")); } @@ -1168,7 +1170,7 @@ void QDirModelPrivate::init() QDirModelPrivate::QDirNode *QDirModelPrivate::node(int row, QDirNode *parent) const { if (row < 0) - return 0; + return nullptr; bool isDir = !parent || parent->info.isDir(); QDirNode *p = (parent ? parent : &root); @@ -1177,7 +1179,7 @@ QDirModelPrivate::QDirNode *QDirModelPrivate::node(int row, QDirNode *parent) co if (Q_UNLIKELY(row >= p->children.count())) { qWarning("node: the row does not exist"); - return 0; + return nullptr; } return const_cast<QDirNode*>(&p->children.at(row)); @@ -1188,7 +1190,7 @@ QVector<QDirModelPrivate::QDirNode> QDirModelPrivate::children(QDirNode *parent, Q_ASSERT(parent); QFileInfoList infoList; if (parent == &root) { - parent = 0; + parent = nullptr; infoList = QDir::drives(); } else if (parent->info.isDir()) { //resolve directory links only if requested. @@ -1331,7 +1333,7 @@ void QDirModelPrivate::appendChild(QDirModelPrivate::QDirNode *parent, const QSt QDirModelPrivate::QDirNode node; node.populated = false; node.stat = shouldStat; - node.parent = (parent == &root ? 0 : parent); + node.parent = (parent == &root ? nullptr : parent); node.info = QFileInfo(path); node.info.setCaching(true); @@ -1372,3 +1374,5 @@ QFileInfo QDirModelPrivate::resolvedInfo(QFileInfo info) QT_END_NAMESPACE #include "moc_qdirmodel.cpp" + +#endif // QT_DEPRECATED_SINCE(5, 15) |