┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2007-03-27 20:18:43 +0000
committerPeter Penz <[email protected]>2007-03-27 20:18:43 +0000
commit9e810e1856ce0d4fb15818142e03e354dbf1ee47 (patch)
tree055ee65d3fe9f49f0e20c2d85a46196624299cec /src
parentcae12eb2211b9b3b8d478618c0fff652881938c6 (diff)
Fix issue that the sort proxy model does not work for QTreeView and QColumnView (duplicate entries occured). The fix is not perfect yet, but at least it allows to use the proxy model for the treeview sidebar and the column view.
svn path=/trunk/KDE/kdebase/apps/; revision=647264
Diffstat (limited to 'src')
-rw-r--r--src/dolphinsortfilterproxymodel.cpp15
-rw-r--r--src/dolphinsortfilterproxymodel.h6
2 files changed, 19 insertions, 2 deletions
diff --git a/src/dolphinsortfilterproxymodel.cpp b/src/dolphinsortfilterproxymodel.cpp
index c2ae4039a..9374a40ad 100644
--- a/src/dolphinsortfilterproxymodel.cpp
+++ b/src/dolphinsortfilterproxymodel.cpp
@@ -55,7 +55,6 @@ DolphinSortFilterProxyModel::DolphinSortFilterProxyModel(QObject* parent) :
// sort by the user visible string for now
setSortRole(Qt::DisplayRole);
setSortCaseSensitivity(Qt::CaseInsensitive);
- sort(KDirModel::Name, Qt::Ascending);
}
DolphinSortFilterProxyModel::~DolphinSortFilterProxyModel()
@@ -68,7 +67,7 @@ void DolphinSortFilterProxyModel::setSorting(DolphinView::Sorting sorting)
// KDirModel::ModelColumns. We will keep the sortOrder.
Q_ASSERT(static_cast<int>(sorting) >= 0 && static_cast<int>(sorting) < dolphinMapSize);
sort(dolphinViewToDirModelColumn[static_cast<int>(sorting)],
- m_sortOrder );
+ m_sortOrder);
}
void DolphinSortFilterProxyModel::setSortOrder(Qt::SortOrder sortOrder)
@@ -87,6 +86,18 @@ void DolphinSortFilterProxyModel::sort(int column, Qt::SortOrder sortOrder)
QSortFilterProxyModel::sort(column, sortOrder);
}
+bool DolphinSortFilterProxyModel::hasChildren(const QModelIndex& parent) const
+{
+ const QModelIndex sourceParent = mapToSource(parent);
+ return sourceModel()->hasChildren(sourceParent);
+}
+
+bool DolphinSortFilterProxyModel::canFetchMore(const QModelIndex& parent) const
+{
+ const QModelIndex sourceParent = mapToSource(parent);
+ return sourceModel()->canFetchMore(sourceParent);
+}
+
DolphinView::Sorting DolphinSortFilterProxyModel::sortingForColumn(int column)
{
if ((column >= 0) && (column < dolphinMapSize)) {
diff --git a/src/dolphinsortfilterproxymodel.h b/src/dolphinsortfilterproxymodel.h
index 44b4ce918..2db8ee267 100644
--- a/src/dolphinsortfilterproxymodel.h
+++ b/src/dolphinsortfilterproxymodel.h
@@ -62,6 +62,12 @@ public:
virtual void sort(int column,
Qt::SortOrder order = Qt::AscendingOrder);
+ /** Reimplemented from QAbstractItemModel. Returns true for directories. */
+ virtual bool hasChildren(const QModelIndex& parent = QModelIndex()) const;
+
+ /** Reimplemented from QAbstractItemModel. Returns true for empty directories. */
+ virtual bool canFetchMore(const QModelIndex& parent) const;
+
/**
* Helper method to get the DolphinView::Sorting type for a given
* column \a column. If the column is smaller 0 or greater than the