mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-12-27 03:14:49 +00:00
31 lines
659 B
C++
31 lines
659 B
C++
|
#include "EnabledItemFilter.h"
|
||
|
|
||
|
EnabledItemFilter::EnabledItemFilter(QObject* parent)
|
||
|
:QSortFilterProxyModel(parent)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
void EnabledItemFilter::setActive(bool active)
|
||
|
{
|
||
|
m_active = active;
|
||
|
invalidateFilter();
|
||
|
}
|
||
|
|
||
|
bool EnabledItemFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||
|
{
|
||
|
if(!m_active)
|
||
|
return true;
|
||
|
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
|
||
|
if(sourceModel()->flags(index) & Qt::ItemIsEnabled)
|
||
|
{
|
||
|
return true;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
bool EnabledItemFilter::lessThan(const QModelIndex& left, const QModelIndex& right) const
|
||
|
{
|
||
|
return QSortFilterProxyModel::lessThan(left, right);
|
||
|
}
|