diff options
Diffstat (limited to 'GroupedProxyModel.cpp')
-rw-r--r-- | GroupedProxyModel.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/GroupedProxyModel.cpp b/GroupedProxyModel.cpp new file mode 100644 index 00000000..ab00a412 --- /dev/null +++ b/GroupedProxyModel.cpp @@ -0,0 +1,21 @@ +#include "GroupedProxyModel.h" + +#include "GroupView.h" + +GroupedProxyModel::GroupedProxyModel(QObject *parent) : QSortFilterProxyModel(parent) +{ +} + +bool GroupedProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const +{ + const QString leftCategory = left.data(CategorizedViewRoles::CategoryRole).toString(); + const QString rightCategory = right.data(CategorizedViewRoles::CategoryRole).toString(); + if (leftCategory == rightCategory) + { + return left.row() < right.row(); + } + else + { + return leftCategory < rightCategory; + } +} |