2013-12-24 10:47:30 +00:00
|
|
|
#include "CategorizedProxyModel.h"
|
|
|
|
|
|
|
|
#include "CategorizedView.h"
|
|
|
|
|
|
|
|
CategorizedProxyModel::CategorizedProxyModel(QObject *parent)
|
|
|
|
: QSortFilterProxyModel(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
bool CategorizedProxyModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
|
|
|
|
{
|
2013-12-26 20:16:03 +00:00
|
|
|
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;
|
|
|
|
}
|
2013-12-24 10:47:30 +00:00
|
|
|
}
|