|
|
@@ -320,6 +320,31 @@ bool CModFilterModel::filterAcceptsRow(int source_row, const QModelIndex & sourc
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+bool CModFilterModel::lessThan(const QModelIndex & source_left, const QModelIndex & source_right) const
|
|
|
+{
|
|
|
+ if(source_left.column() != ModFields::STATUS_ENABLED)
|
|
|
+ return QSortFilterProxyModel::lessThan(source_left, source_right);
|
|
|
+
|
|
|
+ const auto leftMod = base->model->getMod(base->modIndexToName(source_left));
|
|
|
+ const auto rightMod = base->model->getMod(base->modIndexToName(source_right));
|
|
|
+
|
|
|
+ const auto isLeftEnabled = base->model->isModEnabled(leftMod.getID());
|
|
|
+ const auto isRightEnabled = base->model->isModEnabled(rightMod.getID());
|
|
|
+ if(!isLeftEnabled && isRightEnabled)
|
|
|
+ return true;
|
|
|
+ if(isLeftEnabled && !isRightEnabled)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ const auto isLeftInstalled = leftMod.isInstalled();
|
|
|
+ const auto isRightInstalled = rightMod.isInstalled();
|
|
|
+ if(!isLeftInstalled && isRightInstalled)
|
|
|
+ return true;
|
|
|
+ if(isLeftInstalled && !isRightInstalled)
|
|
|
+ return false;
|
|
|
+
|
|
|
+ return QSortFilterProxyModel::lessThan(source_left.siblingAtColumn(ModFields::NAME), source_right.siblingAtColumn(ModFields::NAME));
|
|
|
+}
|
|
|
+
|
|
|
CModFilterModel::CModFilterModel(ModStateItemModel * model, QObject * parent)
|
|
|
: QSortFilterProxyModel(parent), base(model), filterMask(ModFilterMask::ALL)
|
|
|
{
|