summaryrefslogtreecommitdiff
path: root/src/modlistsortproxy.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2014-05-13 21:20:44 +0200
committerTannin <devnull@localhost>2014-05-13 21:20:44 +0200
commit977b4075254ca79e68bbdec2e689eccb291fe701 (patch)
tree0afa2ad971bb786ca6acfa19944cd8381e925c8b /src/modlistsortproxy.cpp
parentf4b1aba61ae81b4151695798006b3a787e0de6de (diff)
- mod list context menu split into two menus (one for whole list, one for selected mods)
- added option to combine category filters using "or" - added context menu option for deselecting category filters - slightly changed ui on the category filters - added a sample plugin for cpp that can be built without building the rest of MO - simple installer can now be configured to run without any user interaction - extended interface for python plugins - iorganizer implementation moved out of the main window - nexus requests from plugins will now be identified in the user agent - bugfix: shortcuts created from MO used the wrong working directory - bugfix: deactivation of bsas didn't stick - bugfix: file hiding mechanism wasn't active - bugfix: executables linked on the toolbar couldn't be removed if the executable was removed first - bugfix: the endorsement-filter couldn't be combined with other filters - bugfix: python interface to repository bridge was broken
Diffstat (limited to 'src/modlistsortproxy.cpp')
-rw-r--r--src/modlistsortproxy.cpp66
1 files changed, 58 insertions, 8 deletions
diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp
index 49f37726..052e65b2 100644
--- a/src/modlistsortproxy.cpp
+++ b/src/modlistsortproxy.cpp
@@ -33,6 +33,7 @@ ModListSortProxy::ModListSortProxy(Profile* profile, QObject *parent)
, m_CategoryFilter()
, m_CurrentFilter()
, m_FilterActive(false)
+ , m_FilterMode(FILTER_AND)
{
m_EnabledColumns.set(ModList::COL_FLAGS);
m_EnabledColumns.set(ModList::COL_NAME);
@@ -224,13 +225,8 @@ bool ModListSortProxy::hasConflictFlag(const std::vector<ModInfo::EFlag> &flags)
}
-bool ModListSortProxy::filterMatchesMod(ModInfo::Ptr info, bool enabled) const
+bool ModListSortProxy::filterMatchesModAnd(ModInfo::Ptr info, bool enabled) const
{
- if (!m_CurrentFilter.isEmpty() &&
- !info->name().contains(m_CurrentFilter, Qt::CaseInsensitive)) {
- return false;
- }
-
for (auto iter = m_CategoryFilter.begin(); iter != m_CategoryFilter.end(); ++iter) {
switch (*iter) {
case CategoryFactory::CATEGORY_SPECIAL_CHECKED: {
@@ -250,17 +246,71 @@ bool ModListSortProxy::filterMatchesMod(ModInfo::Ptr info, bool enabled) const
} break;
case CategoryFactory::CATEGORY_SPECIAL_NOTENDORSED: {
ModInfo::EEndorsedState state = info->endorsedState();
- return (state == ModInfo::ENDORSED_FALSE) || (state == ModInfo::ENDORSED_NEVER);
+ if (state != ModInfo::ENDORSED_FALSE) return false;
} break;
default: {
if (!info->categorySet(*iter)) return false;
} break;
}
}
-
return true;
}
+bool ModListSortProxy::filterMatchesModOr(ModInfo::Ptr info, bool enabled) const
+{
+ for (auto iter = m_CategoryFilter.begin(); iter != m_CategoryFilter.end(); ++iter) {
+ switch (*iter) {
+ case CategoryFactory::CATEGORY_SPECIAL_CHECKED: {
+ if (enabled) return true;
+ } break;
+ case CategoryFactory::CATEGORY_SPECIAL_UNCHECKED: {
+ if (!enabled) return true;
+ } break;
+ case CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE: {
+ if (info->updateAvailable() || info->downgradeAvailable()) return true;
+ } break;
+ case CategoryFactory::CATEGORY_SPECIAL_NOCATEGORY: {
+ if (info->getCategories().size() == 0) return true;
+ } break;
+ case CategoryFactory::CATEGORY_SPECIAL_CONFLICT: {
+ if (hasConflictFlag(info->getFlags())) return true;
+ } break;
+ case CategoryFactory::CATEGORY_SPECIAL_NOTENDORSED: {
+ ModInfo::EEndorsedState state = info->endorsedState();
+ if ((state == ModInfo::ENDORSED_FALSE) && (state != ModInfo::ENDORSED_NEVER)) return true;
+ } break;
+ default: {
+ if (info->categorySet(*iter)) return true;
+ } break;
+ }
+ }
+ return false;
+}
+
+
+
+bool ModListSortProxy::filterMatchesMod(ModInfo::Ptr info, bool enabled) const
+{
+ if (!m_CurrentFilter.isEmpty() &&
+ !info->name().contains(m_CurrentFilter, Qt::CaseInsensitive)) {
+ return false;
+ }
+
+ if (m_FilterMode == FILTER_AND) {
+ return filterMatchesModAnd(info, enabled);
+ } else {
+ return (m_CategoryFilter.size() == 0) || filterMatchesModOr(info, enabled);
+ }
+}
+
+void ModListSortProxy::setFilterMode(ModListSortProxy::FilterMode mode)
+{
+ if (m_FilterMode != mode) {
+ m_FilterMode = mode;
+ this->invalidate();
+ }
+}
+
bool ModListSortProxy::filterAcceptsRow(int row, const QModelIndex &parent) const
{