mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-11-20 17:11:57 +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);
|
|
}
|