Let Descending order work

svn path=/trunk/KDE/kdebase/apps/; revision=677018
This commit is contained in:
Rafael Fernández López 2007-06-18 09:27:12 +00:00
parent d098f9641a
commit 4bf98b3386
4 changed files with 27 additions and 4 deletions

View file

@ -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)

View file

@ -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:

View file

@ -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
{

View file

@ -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