Commit 993e6b92 authored by Rafael Fernández López's avatar Rafael Fernández López
Browse files

Let Descending order work

svn path=/trunk/KDE/kdebase/apps/; revision=677018
parent 389d5f5c
......@@ -89,7 +89,7 @@ void DolphinSortFilterProxyModel::sort(int column, Qt::SortOrder sortOrder)
dirModelColumnToDolphinView[column] :
DolphinView::SortByName;
setSortRole(m_sorting);
QSortFilterProxyModel::sort(column, sortOrder);
KSortFilterProxyModel::sort(column, sortOrder);
}
bool DolphinSortFilterProxyModel::hasChildren(const QModelIndex& parent) const
......@@ -249,7 +249,7 @@ bool DolphinSortFilterProxyModel::lessThan(const QModelIndex& left,
}
int DolphinSortFilterProxyModel::naturalCompare(const QString& a,
const QString& b)
const QString& b)
{
// This method chops the input a and b into pieces of
// digits and non-digits (a1.05 becomes a | 1 | . | 05)
......
......@@ -55,10 +55,14 @@ public:
{
if (purpose == GeneralPurpose)
{
return proxyModel->lessThanGeneralPurpose(left, right);
return proxyModel->sortOrder() == Qt::AscendingOrder ?
proxyModel->lessThanGeneralPurpose(left, right) :
!proxyModel->lessThanGeneralPurpose(left, right);
}
return proxyModel->lessThanCategoryPurpose(left, right);
return proxyModel->sortOrder() == Qt::AscendingOrder ?
proxyModel->lessThanCategoryPurpose(left, right) :
!proxyModel->lessThanCategoryPurpose(left, right);
}
private:
......
......@@ -29,6 +29,18 @@ KSortFilterProxyModel::~KSortFilterProxyModel()
{
}
void KSortFilterProxyModel::sort(int column, Qt::SortOrder order)
{
QSortFilterProxyModel::sort(column, order);
m_sortOrder = order;
}
Qt::SortOrder KSortFilterProxyModel::sortOrder() const
{
return m_sortOrder;
}
bool KSortFilterProxyModel::lessThanCategoryPurpose(const QModelIndex &left,
const QModelIndex &right) const
{
......
......@@ -32,11 +32,18 @@ public:
KSortFilterProxyModel(QObject *parent = 0);
~KSortFilterProxyModel();
virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
Qt::SortOrder sortOrder() const;
virtual bool lessThanGeneralPurpose(const QModelIndex &left,
const QModelIndex &right) const = 0;
virtual bool lessThanCategoryPurpose(const QModelIndex &left,
const QModelIndex &right) const;
private:
Qt::SortOrder m_sortOrder;
};
#endif
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