summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2020-12-29 12:42:13 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-02 15:38:16 +0100
commit25d852f07564883f5a225eb0e00e883cae30cbd2 (patch)
tree69ed03b68ed7d9b48fbe47869dbd2ff99ac9679e /src
parent9ea4e6bb097591e80bf9a975eac888cf618319bf (diff)
Fix filtering for separators.
Diffstat (limited to 'src')
-rw-r--r--src/modlistsortproxy.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp
index 422fa044..daa1478d 100644
--- a/src/modlistsortproxy.cpp
+++ b/src/modlistsortproxy.cpp
@@ -592,23 +592,39 @@ void ModListSortProxy::setOptions(
}
}
-bool ModListSortProxy::filterAcceptsRow(int row, const QModelIndex &parent) const
+bool ModListSortProxy::filterAcceptsRow(int source_row, const QModelIndex &parent) const
{
if (m_Profile == nullptr) {
return false;
}
- if (row >= static_cast<int>(m_Profile->numMods())) {
- log::warn("invalid row index: {}", row);
+ if (source_row >= static_cast<int>(m_Profile->numMods())) {
+ log::warn("invalid row index: {}", source_row);
return false;
}
- QModelIndex idx = sourceModel()->index(row, 0, parent);
+ QModelIndex idx = sourceModel()->index(source_row, 0, parent);
if (!idx.isValid()) {
log::debug("invalid mod index");
return false;
}
+
+ unsigned int index = ULONG_MAX;
+ {
+ bool ok = false;
+ index = idx.data(ModList::IndexRole).toInt(&ok);
+ if (!ok) {
+ index = ULONG_MAX;
+ }
+ }
+
if (sourceModel()->hasChildren(idx)) {
+ // we need to check the separator itself first
+ if (index < ModInfo::getNumMods() && ModInfo::getByIndex(index)->isSeparator()) {
+ if (filterMatchesMod(ModInfo::getByIndex(index), false)) {
+ return true;
+ }
+ }
for (int i = 0; i < sourceModel()->rowCount(idx); ++i) {
if (filterAcceptsRow(i, idx)) {
return true;
@@ -617,8 +633,7 @@ bool ModListSortProxy::filterAcceptsRow(int row, const QModelIndex &parent) cons
return false;
} else {
- bool modEnabled = idx.sibling(row, 0).data(Qt::CheckStateRole).toInt() == Qt::Checked;
- unsigned int index = idx.data(Qt::UserRole + 1).toInt();
+ bool modEnabled = idx.sibling(source_row, 0).data(Qt::CheckStateRole).toInt() == Qt::Checked;
return filterMatchesMod(ModInfo::getByIndex(index), modEnabled);
}
}