diff options
-rw-r--r-- | archiveview.cpp | 23 | ||||
-rw-r--r-- | archiveview.h | 1 |
2 files changed, 24 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 */ diff --git a/archiveview.h b/archiveview.h index a900ec2..e6f741d 100644 --- a/archiveview.h +++ b/archiveview.h @@ -136,6 +136,7 @@ class ArchiveProxy : public QSortFilterProxyModel { protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const; private: QRegExp mFilter; |