diff options
author | am <am@f440f766-f032-0410-8965-dc7d17de2ca0> | 2009-08-02 15:12:05 +0000 |
---|---|---|
committer | am <am@f440f766-f032-0410-8965-dc7d17de2ca0> | 2009-08-02 15:12:05 +0000 |
commit | 44a73ebcfc2ad65fe7301d49f7020f9f8dcd7762 (patch) | |
tree | 2549b471b5cb153b6f0e91fc0adbe15dd0ef3699 /archiveproxy.cpp | |
parent | 286d54a4705e56567a68cf6dabfa3ce64ac162d6 (diff) | |
download | SheMov-44a73ebcfc2ad65fe7301d49f7020f9f8dcd7762.tar.gz SheMov-44a73ebcfc2ad65fe7301d49f7020f9f8dcd7762.tar.bz2 SheMov-44a73ebcfc2ad65fe7301d49f7020f9f8dcd7762.zip |
-sorting of archive now takes movie number into account
git-svn-id: file:///var/svn/repos2/shemov/trunk@398 f440f766-f032-0410-8965-dc7d17de2ca0
Diffstat (limited to 'archiveproxy.cpp')
-rw-r--r-- | archiveproxy.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/archiveproxy.cpp b/archiveproxy.cpp index 6b1a9e7..0249459 100644 --- a/archiveproxy.cpp +++ b/archiveproxy.cpp @@ -7,6 +7,9 @@ #include <QStringList> #include <QRegExp> +#include <QList> + +#include <QDebug> #include "archiveproxy.h" #include "moviemodel.h" @@ -67,3 +70,40 @@ void ArchiveProxy::clearFilter(){ invalidate(); } +bool ArchiveProxy::lessThan(const QModelIndex &left, const QModelIndex &right) const{ + 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)); + } + } + if((lnos.size() == 2) && (rnos.size() == 2)){ + if(lbase == rbase){ + return (lnos.at(1) < rnos.at(1)); + } + } + return QSortFilterProxyModel::lessThan(left, right); +} + |