Use naturalSort in TorrentContentFilterModel.

This commit is contained in:
sledgehammer999 2013-07-09 19:15:53 +03:00
parent 512516225b
commit 1eed7cde3c
2 changed files with 20 additions and 0 deletions

View file

@ -81,6 +81,24 @@ bool TorrentContentFilterModel::filterAcceptsRow(int source_row, const QModelInd
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
}
bool TorrentContentFilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) const {
if (sortColumn() == NAME) {
QVariant vL = sourceModel()->data(left);
QVariant vR = sourceModel()->data(right);
if (!(vL.isValid() && vR.isValid()))
return QSortFilterProxyModel::lessThan(left, right);
Q_ASSERT(vL.isValid());
Q_ASSERT(vR.isValid());
bool res = false;
if (misc::naturalSort(vL.toString(), vR.toString(), res))
return res;
return QSortFilterProxyModel::lessThan(left, right);
}
return QSortFilterProxyModel::lessThan(left, right);
}
void TorrentContentFilterModel::selectAll()
{
for (int i=0; i<rowCount(); ++i) {

View file

@ -33,6 +33,7 @@
#include <QSortFilterProxyModel>
#include "torrentcontentmodelitem.h"
#include "proplistdelegate.h"
class TorrentContentModel;
@ -53,6 +54,7 @@ signals:
protected:
virtual bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const;
virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
public slots:
void selectAll();