summaryrefslogtreecommitdiffstats
path: root/CategorizedProxyModel.cpp
blob: e4a7563a240a70ef7a77652d3320a749b4c25cf4 (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(CategorizedView::CategoryRole).toString();
	const QString rightCategory = right.data(CategorizedView::CategoryRole).toString();
	if (leftCategory == rightCategory)
	{
		return left.row() < right.row();
	}
	else
	{
		return leftCategory < rightCategory;
	}
}