]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix issue that the sort proxy model does not work for QTreeView and QColumnView ...
authorPeter Penz <peter.penz19@gmail.com>
Tue, 27 Mar 2007 20:18:43 +0000 (20:18 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Tue, 27 Mar 2007 20:18:43 +0000 (20:18 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=647264

src/dolphinsortfilterproxymodel.cpp
src/dolphinsortfilterproxymodel.h

index c2ae4039afaa7848c734aaa473ebb51ef6d65db0..9374a40ad5de57c12190d52ecdd4cdab00c45536 100644 (file)
@@ -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)) {
index 44b4ce918e27db9899db0a09b5b08bdf0ec0c760..2db8ee26730f92b9a034e22a6356e720ea05c141 100644 (file)
@@ -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