diff options
author | Arno <am@disconnect.de> | 2014-07-10 02:45:31 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2014-07-10 02:45:31 +0200 |
commit | cee9b36534e3255aa65cf8607e81338406af81a2 (patch) | |
tree | 4823455946f7759d64e4bef1ce2f77ad3904f45a /archiveview.cpp | |
parent | 94ef66d78be46993c7d17ea62aef78cb6e7b1535 (diff) | |
download | SheMov-cee9b36534e3255aa65cf8607e81338406af81a2.tar.gz SheMov-cee9b36534e3255aa65cf8607e81338406af81a2.tar.bz2 SheMov-cee9b36534e3255aa65cf8607e81338406af81a2.zip |
Sort Movie archive list appropriately
Don't just sort alphabetically. Also regard the Series No. by extracting
it via a RegExp.
Diffstat (limited to 'archiveview.cpp')
-rw-r--r-- | archiveview.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/archiveview.cpp b/archiveview.cpp index 27285c2..2f4c77c 100644 --- a/archiveview.cpp +++ b/archiveview.cpp @@ -595,6 +595,29 @@ bool ArchiveProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourcePare return model->matchRecursive(nameIdx, mFilter); } +bool ArchiveProxy::lessThan(const QModelIndex &left, const QModelIndex &right) const{ + QString l = left.data().toString(); + QString r = right.data().toString(); + QRegExp nrRex("( \\d+$)"); + int lPos = nrRex.indexIn(l); + if(lPos != -1){ + int lNum = nrRex.cap(0).toInt(); + int rPos = nrRex.indexIn(r); + int rNum = -1; + if(rPos != -1){ + rNum = nrRex.cap(0).toInt(); + } + if(lNum > -1 && rNum > -1){ + QString lNoNum = l.mid(0, lPos); + QString rNoNum = r.mid(0, rPos); + if(lNoNum == rNoNum){ + return lNum < rNum; + } + } + } + return l < r; +} + ArchiveFilesProxy::ArchiveFilesProxy(QObject *parent) : QSortFilterProxyModel(parent) {} /* Mapping Editor Widget */ |