Commit ebbebac2 authored by Peter Penz's avatar Peter Penz
Browse files

Fix issue that the sort proxy model does not work for QTreeView and...

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
parent 588a73db
......@@ -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)) {
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment