From 1eed7cde3ccedc9d2640e8de35f12e8caca69cae Mon Sep 17 00:00:00 2001 From: sledgehammer999 Date: Tue, 9 Jul 2013 19:15:53 +0300 Subject: [PATCH] Use naturalSort in TorrentContentFilterModel. --- src/torrentcontentfiltermodel.cpp | 18 ++++++++++++++++++ src/torrentcontentfiltermodel.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/torrentcontentfiltermodel.cpp b/src/torrentcontentfiltermodel.cpp index aafb160fc..5e7b2d9c8 100644 --- a/src/torrentcontentfiltermodel.cpp +++ b/src/torrentcontentfiltermodel.cpp @@ -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 #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();