From 05c0ddf167054d1c7befe7440ff60718c98a8207 Mon Sep 17 00:00:00 2001 From: Arno Date: Mon, 7 Apr 2014 13:22:44 +0200 Subject: Fix sorting of SeriesParts Arrange Seriespartsname different so the default implementation of QSortfilterProxyModel can handle the sorting. --- archivemodel.cpp | 11 ++++++----- archiveview.cpp | 18 ------------------ archiveview.h | 1 - 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/archivemodel.cpp b/archivemodel.cpp index 0e29c37..b845812 100644 --- a/archivemodel.cpp +++ b/archivemodel.cpp @@ -80,11 +80,12 @@ QVariant ArchiveModel::data(const QModelIndex &index, int role) const{ }else if(nodeType == SeriesPartNode){ retval = item->data(Name).toString(); QString subtitle = item->data(Subtitle).toString(); - if(part > 0){ - retval = QString("%1 %2").arg(retval).arg(QString::number(part)); - } - if(!subtitle.isEmpty()){ - retval = QString("%1 - %2").arg(retval).arg(subtitle); + if(!subtitle.isEmpty() && (part > 0)){ + retval = QString("%1 - %2 - %3").arg(item->data(Name).toString()).arg(subtitle).arg(QString::number(part)); + }else if(part > 0){ + retval = QString("%1 %2").arg(item->data(Name).toString()).arg(QString::number(part)); + }else if(!subtitle.isEmpty()){ + retval = QString("%1 - %2").arg(item->data(Name).toString()).arg(subtitle); } } return retval; diff --git a/archiveview.cpp b/archiveview.cpp index 1e272f5..6a83685 100644 --- a/archiveview.cpp +++ b/archiveview.cpp @@ -458,24 +458,6 @@ bool ArchiveProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourcePare return model->matchRecursive(nameIdx, mFilter); } -bool ArchiveProxy::lessThan(const QModelIndex &left, const QModelIndex &right) const{ - int lNodeType = left.data(ArchiveModel::TypeRole).toInt(); - int rNodeType = right.data(ArchiveModel::TypeRole).toInt(); - if((lNodeType == ArchiveModel::SeriesPartNode) && (rNodeType == ArchiveModel::SeriesPartNode)){ - int lPartNo = left.data(ArchiveModel::SeriesPartRole).toInt(); - int rPartNo = right.data(ArchiveModel::SeriesPartRole).toInt(); - if((lPartNo > 0) && (rPartNo > 0)){ - return (lPartNo < rPartNo); - } - QString lSubtitle = left.data(ArchiveModel::SubtitleRole).toString(); - QString rSubtitle = right.data(ArchiveModel::SubtitleRole).toString(); - if(!lSubtitle.isEmpty() && !rSubtitle.isEmpty()){ - return (lSubtitle < rSubtitle); - } - } - return QSortFilterProxyModel::lessThan(left, right); -} - ArchiveFilesProxy::ArchiveFilesProxy(QObject *parent) : QSortFilterProxyModel(parent) {} /* Mapping Editor Widget */ diff --git a/archiveview.h b/archiveview.h index 4b1308c..2366fb5 100644 --- a/archiveview.h +++ b/archiveview.h @@ -117,7 +117,6 @@ class ArchiveProxy : public QSortFilterProxyModel { protected: bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; - bool lessThan(const QModelIndex &left, const QModelIndex &right) const; private: QRegExp mFilter; -- cgit v1.2.3-70-g09d2