From: Peter Penz Date: Tue, 27 Mar 2007 20:18:43 +0000 (+0000) Subject: Fix issue that the sort proxy model does not work for QTreeView and QColumnView ... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/9e810e1856ce0d4fb15818142e03e354dbf1ee47?ds=inline 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 --- 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(sorting) >= 0 && static_cast(sorting) < dolphinMapSize); sort(dolphinViewToDirModelColumn[static_cast(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