diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/dialogs/qfilesystemmodel.cpp | 6 | ||||
-rw-r--r-- | src/gui/dialogs/qfilesystemmodel_p.h | 13 |
2 files changed, 17 insertions, 2 deletions
diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp index 66d9bb0..b9012c7 100644 --- a/src/gui/dialogs/qfilesystemmodel.cpp +++ b/src/gui/dialogs/qfilesystemmodel.cpp @@ -1104,6 +1104,8 @@ void QFileSystemModelPrivate::sortChildren(int column, const QModelIndex &parent qStableSort(values.begin(), values.end(), ms); // First update the new visible list indexNode->visibleChildren.clear(); + //No more dirty item we reset our internal dirty index + indexNode->dirtyChildrenIndex = -1; for (int i = 0; i < values.count(); ++i) { indexNode->visibleChildren.append(values.at(i).first->fileName); values.at(i).first->isVisible = true; @@ -1706,6 +1708,10 @@ void QFileSystemModelPrivate::addVisibleFiles(QFileSystemNode *parentNode, const if (!indexHidden) { q->beginInsertRows(parent, parentNode->visibleChildren.count() , parentNode->visibleChildren.count() + newFiles.count() - 1); } + + if (parentNode->dirtyChildrenIndex == -1) + parentNode->dirtyChildrenIndex = parentNode->visibleChildren.count(); + for (int i = 0; i < newFiles.count(); ++i) { parentNode->visibleChildren.append(newFiles.at(i)); parentNode->children[newFiles.at(i)]->isVisible = true; diff --git a/src/gui/dialogs/qfilesystemmodel_p.h b/src/gui/dialogs/qfilesystemmodel_p.h index 9734f1c..175159f 100644 --- a/src/gui/dialogs/qfilesystemmodel_p.h +++ b/src/gui/dialogs/qfilesystemmodel_p.h @@ -84,7 +84,7 @@ public: { public: QFileSystemNode(const QString &filename = QString(), QFileSystemNode *p = 0) - : fileName(filename), populatedChildren(false), isVisible(false), parent(p), info(0) {} + : fileName(filename), populatedChildren(false), isVisible(false), dirtyChildrenIndex(-1), parent(p), info(0) {} ~QFileSystemNode() { QHash<QString, QFileSystemNode*>::const_iterator i = children.constBegin(); while (i != children.constEnd()) { @@ -194,6 +194,7 @@ public: bool isVisible; QHash<QString,QFileSystemNode *> children; QList<QString> visibleChildren; + int dirtyChildrenIndex; QFileSystemNode *parent; @@ -237,7 +238,15 @@ public: void sortChildren(int column, const QModelIndex &parent); inline int translateVisibleLocation(QFileSystemNode *parent, int row) const { - return (sortOrder == Qt::AscendingOrder) ? row : parent->visibleChildren.count() - row - 1; + if (sortOrder == Qt::AscendingOrder) + return row; + if (parent->dirtyChildrenIndex == -1 || row < parent->dirtyChildrenIndex) + if (parent->dirtyChildrenIndex != -1) + return parent->dirtyChildrenIndex - row - 1; + else + return parent->visibleChildren.count() - row - 1; + else + return row; } inline static QString myComputer() { |