Browse Source

Use naturalSort in TorrentContentFilterModel.

adaptive-webui-19844
sledgehammer999 12 years ago
parent
commit
09abc9d8b7
  1. 18
      src/torrentcontentfiltermodel.cpp
  2. 2
      src/torrentcontentfiltermodel.h

18
src/torrentcontentfiltermodel.cpp

@ -81,6 +81,24 @@ bool TorrentContentFilterModel::filterAcceptsRow(int source_row, const QModelInd @@ -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) {

2
src/torrentcontentfiltermodel.h

@ -33,6 +33,7 @@ @@ -33,6 +33,7 @@
#include <QSortFilterProxyModel>
#include "torrentcontentmodelitem.h"
#include "proplistdelegate.h"
class TorrentContentModel;
@ -53,6 +54,7 @@ signals: @@ -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();

Loading…
Cancel
Save