aboutsummaryrefslogtreecommitdiff
path: root/CategorizedProxyModel.cpp
blob: efcf13c8c3ad68ab9c845179fcfc4add8568de24 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "CategorizedProxyModel.h"

#include "CategorizedView.h"

CategorizedProxyModel::CategorizedProxyModel(QObject *parent)
	: QSortFilterProxyModel(parent)
{
}
bool CategorizedProxyModel::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;
	}
}