From 94519a441cf1ea77f1422c44a7ef8ec15171ad04 Mon Sep 17 00:00:00 2001 From: Jason McDonald Date: Wed, 11 Apr 2012 22:52:21 +1000 Subject: Address Qt 5 to-do comments related to QFileSystemModel. - QFileSystemModel::rmdir() and QFileSystemModel::remove() changed to non-const -- they don't change the object, but they do change the file system, and the Qt way is to be non-const if having side-effects on external entities. - The comment on incompatibility between entryList and QFileInfo will not be fixed as doing so is likely to break existing code. - The comment on removing the internal resolvedSymLinks variable has been removed, as the variable is still used. Task-number: QTBUG-25088 Change-Id: I20456e4d116076403d9c4d4692ee05c178a1ed17 Reviewed-by: Lars Knoll --- src/widgets/dialogs/qfilesystemmodel.cpp | 11 +++++------ src/widgets/dialogs/qfilesystemmodel.h | 4 ++-- src/widgets/dialogs/qfilesystemmodel_p.h | 1 - 3 files changed, 7 insertions(+), 9 deletions(-) (limited to 'src/widgets/dialogs') diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 809024ae6d..a7ae4b366b 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -129,7 +129,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn bool QFileSystemModel::rmdir(const QModelIndex &index) const + \fn bool QFileSystemModel::rmdir(const QModelIndex &index) Removes the directory corresponding to the model item \a index in the file system model and \b{deletes the corresponding directory from the @@ -185,7 +185,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn bool QFileSystemModel::remove(const QModelIndex &index) const + \fn bool QFileSystemModel::remove(const QModelIndex &index) Removes the model item \a index from the file system model and \b{deletes the corresponding file from the file system}, returning true if successful. If the @@ -197,7 +197,7 @@ QT_BEGIN_NAMESPACE \sa rmdir() */ -bool QFileSystemModel::remove(const QModelIndex &aindex) const +bool QFileSystemModel::remove(const QModelIndex &aindex) { //### TODO optim QString path = filePath(aindex); @@ -1653,7 +1653,7 @@ bool QFileSystemModel::event(QEvent *event) return QAbstractItemModel::event(event); } -bool QFileSystemModel::rmdir(const QModelIndex &aindex) const +bool QFileSystemModel::rmdir(const QModelIndex &aindex) { QString path = filePath(aindex); QFileSystemModelPrivate * d = const_cast(d_func()); @@ -1985,8 +1985,7 @@ bool QFileSystemModelPrivate::filtersAcceptsNode(const QFileSystemNode *node) co const bool hideDot = (filters & QDir::NoDot); const bool hideDotDot = (filters & QDir::NoDotDot); - // Note that we match the behavior of entryList and not QFileInfo on this and this - // incompatibility won't be fixed until Qt 5 at least + // Note that we match the behavior of entryList and not QFileInfo on this. bool isDot = (node->fileName == QLatin1String(".")); bool isDotDot = (node->fileName == QLatin1String("..")); if ( (hideHidden && !(isDot || isDotDot) && node->isHidden()) diff --git a/src/widgets/dialogs/qfilesystemmodel.h b/src/widgets/dialogs/qfilesystemmodel.h index 5a9139266d..875044e785 100644 --- a/src/widgets/dialogs/qfilesystemmodel.h +++ b/src/widgets/dialogs/qfilesystemmodel.h @@ -138,12 +138,12 @@ public: QDateTime lastModified(const QModelIndex &index) const; QModelIndex mkdir(const QModelIndex &parent, const QString &name); - bool rmdir(const QModelIndex &index) const; // ### Qt5: should not be const + bool rmdir(const QModelIndex &index); inline QString fileName(const QModelIndex &index) const; inline QIcon fileIcon(const QModelIndex &index) const; QFile::Permissions permissions(const QModelIndex &index) const; inline QFileInfo fileInfo(const QModelIndex &index) const; - bool remove(const QModelIndex &index) const; + bool remove(const QModelIndex &index); protected: QFileSystemModel(QFileSystemModelPrivate &, QObject *parent = 0); diff --git a/src/widgets/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h index 0e982140b5..3a02b91b09 100644 --- a/src/widgets/dialogs/qfilesystemmodel_p.h +++ b/src/widgets/dialogs/qfilesystemmodel_p.h @@ -315,7 +315,6 @@ public: #ifndef QT_NO_REGEXP QList nameFilters; #endif - // ### Qt 5: resolvedSymLinks goes away QHash resolvedSymLinks; QFileSystemNode root; -- cgit v1.2.3