ProxyModel::ProxyModel( ItemModel* s )
{
setSourceModel( mSource );
}
//
ItemModel* ProxyModel::source() const
{
return mSource;
}
//
bool ProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent) const
{
if (!mFilterOn)
return true;
index = sourceModel()->index(sourceRow, 0, sourceParent);
return index.data(Item::FilterRole).toBool();
}
//
void ProxyModel::setFilter(int on)
{
if (!on)
mFilterOn = false;
else
mFilterOn = true;
if (mFilterOn)
{
setSortRole(Item::SortRole);
sort(0);
filterChanged ();
}
else
{
clear();
//reset();
}
}
ProxyModel::ProxyModel( ItemModel* s )
: QSortFilterProxyModel(s), mSource( s ), mFilterOn(false)
{
setSourceModel( mSource );
}
//
ItemModel* ProxyModel::source() const
{
return mSource;
}
//
bool ProxyModel::filterAcceptsRow( int sourceRow, const QModelIndex& sourceParent) const
{
if (!mFilterOn)
return true;
QModelIndex index;
index = sourceModel()->index(sourceRow, 0, sourceParent);
return index.data(Item::FilterRole).toBool();
}
//
void ProxyModel::setFilter(int on)
{
if (!on)
mFilterOn = false;
else
mFilterOn = true;
if (mFilterOn)
{
setSortRole(Item::SortRole);
sort(0);
filterChanged ();
}
else
{
clear();
//reset();
}
}
To copy to clipboard, switch view to plain text mode
now problem:
when i appling filter (setFilter(true)) my source model get filter and sorting - it's ok
when i remove filter (setFilter(false)) my source model loose filter but not sorting
how to remove sorting from proxy model?
Bookmarks