mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-29 13:58:51 +03:00
Use naturalSort in TorrentContentFilterModel.
This commit is contained in:
parent
18edf7a20c
commit
09abc9d8b7
2 changed files with 20 additions and 0 deletions
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue