[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/utils/dolphin/src
From: Peter Penz <peter.penz () gmx ! at>
Date: 2007-02-05 23:17:17
Message-ID: 1170717437.289736.23985.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 630674 by ppenz:
Only group the directories before items if the KDirModel::Name column is sorted. If \
the sorting is done e. g. by the date column, it is confusing when still directories \
are seperated from items.
M +19 -13 dolphinsortfilterproxymodel.cpp
M +1 -0 dolphinsortfilterproxymodel.h
--- trunk/playground/utils/dolphin/src/dolphinsortfilterproxymodel.cpp #630673:630674
@@ -39,7 +39,10 @@
DolphinSortFilterProxyModel::DolphinSortFilterProxyModel(QObject* parent) :
- QSortFilterProxyModel(parent)
+ QSortFilterProxyModel(parent),
+ m_sortColumn(0),
+ m_sorting(DolphinView::SortByName),
+ m_sortOrder(Qt::Ascending)
{
setDynamicSortFilter(true);
@@ -70,11 +73,12 @@
void DolphinSortFilterProxyModel::sort(int column, Qt::SortOrder sortOrder)
{
+ m_sortColumn = column;
m_sortOrder = sortOrder;
m_sorting = (column >= 0) && (column <= dolphinMapSize) ?
dirModelColumnToDolphinView[column] :
DolphinView::SortByName;
- QSortFilterProxyModel::sort(column,sortOrder);
+ QSortFilterProxyModel::sort(column, sortOrder);
}
bool DolphinSortFilterProxyModel::lessThan(const QModelIndex& left,
@@ -86,21 +90,23 @@
QVariant rightData = dirModel->data(right, sortRole());
if ((leftData.type() == QVariant::String) && (rightData.type() == \
QVariant::String)) {
- const QString leftStr = leftData.toString();
- const QString rightStr = rightData.toString();
-
- const bool leftIsDir = dirModel->itemForIndex(left)->isDir();
- const bool rightIsDir = dirModel->itemForIndex(right)->isDir();
-
// assure that directories are always sorted before files
- if (leftIsDir && !rightIsDir) {
- return true;
- }
+ // if the sorting is done by the 'Name' column
+ if (m_sortColumn == KDirModel::Name) {
+ const bool leftIsDir = dirModel->itemForIndex(left)->isDir();
+ const bool rightIsDir = dirModel->itemForIndex(right)->isDir();
+ if (leftIsDir && !rightIsDir) {
+ return true;
+ }
- if (!leftIsDir && rightIsDir) {
- return false;
+ if (!leftIsDir && rightIsDir) {
+ return false;
+ }
}
+ const QString leftStr = leftData.toString();
+ const QString rightStr = rightData.toString();
+
return sortCaseSensitivity() ? (naturalCompare(leftStr, rightStr) < 0) :
(naturalCompare(leftStr.toLower(), \
rightStr.toLower()) < 0); }
--- trunk/playground/utils/dolphin/src/dolphinsortfilterproxymodel.h #630673:630674
@@ -69,6 +69,7 @@
static int naturalCompare(const QString& a, const QString& b);
private:
+ int m_sortColumn;
DolphinView::Sorting m_sorting;
Qt::SortOrder m_sortOrder;
};
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic