diff options
author | am <am@f440f766-f032-0410-8965-dc7d17de2ca0> | 2009-08-07 19:53:55 +0000 |
---|---|---|
committer | am <am@f440f766-f032-0410-8965-dc7d17de2ca0> | 2009-08-07 19:53:55 +0000 |
commit | 41802000a0bcbb44c3add7f218eceec101f52cc0 (patch) | |
tree | eb6e64d81cf9e3ab4a17a19031d5506ca7be405f /archiveproxy.cpp | |
parent | cbf3c617d366892cf6af9b5fdbc5286e47ca4b42 (diff) | |
download | SheMov-41802000a0bcbb44c3add7f218eceec101f52cc0.tar.gz SheMov-41802000a0bcbb44c3add7f218eceec101f52cc0.tar.bz2 SheMov-41802000a0bcbb44c3add7f218eceec101f52cc0.zip |
-fixed sorting in ArchiveProxy: had to introduce two new fields to MovieModel: partno and seriesno
-made changes to archiveviewiwdget.cpp and dialogs accordingly
git-svn-id: file:///var/svn/repos2/shemov/trunk@400 f440f766-f032-0410-8965-dc7d17de2ca0
Diffstat (limited to 'archiveproxy.cpp')
-rw-r--r-- | archiveproxy.cpp | 43 |
1 files changed, 13 insertions, 30 deletions
diff --git a/archiveproxy.cpp b/archiveproxy.cpp index 0249459..90374c6 100644 --- a/archiveproxy.cpp +++ b/archiveproxy.cpp @@ -9,8 +9,6 @@ #include <QRegExp> #include <QList> -#include <QDebug> - #include "archiveproxy.h" #include "moviemodel.h" @@ -74,35 +72,20 @@ bool ArchiveProxy::lessThan(const QModelIndex &left, const QModelIndex &right) c if(left.column() > 0){ return QSortFilterProxyModel::lessThan(left, right); } - QString l = left.data().toString(); - QString r = right.data().toString(); - QRegExp nos("(\\d+)"); - QList<int> lnos, rnos; - int pos = 0; - bool dummy; - while((pos = nos.indexIn(l, pos)) != -1){ - lnos << nos.cap(1).toInt(&dummy); - pos += nos.matchedLength(); - } - pos = 0; - while((pos = nos.indexIn(r, pos)) != -1){ - rnos << nos.cap(1).toInt(&dummy); - pos += nos.matchedLength(); - } - QRegExp baseRe("(.*)\\s+\\d+"); - baseRe.indexIn(l); - QString lbase = baseRe.cap(1); - baseRe.indexIn(r); - QString rbase = baseRe.cap(1); - if((lnos.size() == 1) && (rnos.size() == 1)){ - if(lbase == rbase){ - return (lnos.at(0) < rnos.at(0)); + QString lbase = left.data(MovieModel::TitleBaseRole).toString(); + QString rbase = right.data(MovieModel::TitleBaseRole).toString(); + if(lbase == rbase){ + int lseriesno = left.data(MovieModel::SeriesNoRole).toInt(); + int rseriesno = right.data(MovieModel::SeriesNoRole).toInt(); + if(lseriesno == rseriesno){ + int lpartno = left.data(MovieModel::PartNoRole).toInt(); + int rpartno = right.data(MovieModel::PartNoRole).toInt(); + return (lpartno < rpartno); + }else{ + return (lseriesno < rseriesno); } - } - if((lnos.size() == 2) && (rnos.size() == 2)){ - if(lbase == rbase){ - return (lnos.at(1) < rnos.at(1)); - } + }else{ + return (lbase < rbase); } return QSortFilterProxyModel::lessThan(left, right); } |