summaryrefslogtreecommitdiffstats
path: root/depends/groupview/GroupedProxyModel.cpp
blob: 57d7ff5c7985fa1dab154c1449a02d5a0d281869 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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(GroupViewRoles::GroupRole).toString();
	const QString rightCategory = right.data(GroupViewRoles::GroupRole).toString();
	if (leftCategory == rightCategory)
	{
		return left.row() < right.row();
	}
	else
	{
		return leftCategory < rightCategory;
	}
}