From 4b1e6683d258412dd6e02c55618ff158c749ab4a Mon Sep 17 00:00:00 2001 From: Tannin Date: Mon, 18 Aug 2014 23:00:25 +0200 Subject: - can now filter by mod content - all files/directories that require write access can now be placed in AppData instead of the MO directory --- src/modlistsortproxy.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/modlistsortproxy.cpp') diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp index ecd1755d..da5d99d5 100644 --- a/src/modlistsortproxy.cpp +++ b/src/modlistsortproxy.cpp @@ -51,7 +51,7 @@ void ModListSortProxy::setProfile(Profile *profile) void ModListSortProxy::updateFilterActive() { - m_FilterActive = (m_CategoryFilter.size() > 0) || !m_CurrentFilter.isEmpty(); + m_FilterActive = (m_CategoryFilter.size() > 0) || (m_ContentFilter.size() > 0) || !m_CurrentFilter.isEmpty(); emit filterActive(m_FilterActive); } @@ -62,6 +62,13 @@ void ModListSortProxy::setCategoryFilter(const std::vector &categories) this->invalidate(); } +void ModListSortProxy::setContentFilter(const std::vector &content) +{ + m_ContentFilter = content; + updateFilterActive(); + this->invalidate(); +} + Qt::ItemFlags ModListSortProxy::flags(const QModelIndex &modelIndex) const { Qt::ItemFlags flags = sourceModel()->flags(mapToSource(modelIndex)); @@ -262,6 +269,11 @@ bool ModListSortProxy::filterMatchesModAnd(ModInfo::Ptr info, bool enabled) cons } break; } } + + foreach (int content, m_ContentFilter) { + if (!info->hasContent(static_cast(content))) return false; + } + return true; } @@ -299,6 +311,11 @@ bool ModListSortProxy::filterMatchesModOr(ModInfo::Ptr info, bool enabled) const } break; } } + + foreach (int content, m_ContentFilter) { + if (info->hasContent(static_cast(content))) return true; + } + return false; } @@ -312,7 +329,7 @@ bool ModListSortProxy::filterMatchesMod(ModInfo::Ptr info, bool enabled) const if (m_FilterMode == FILTER_AND) { return filterMatchesModAnd(info, enabled); } else { - return (m_CategoryFilter.size() == 0) || filterMatchesModOr(info, enabled); + return filterMatchesModOr(info, enabled); } } -- cgit v1.3.1