summaryrefslogtreecommitdiff
path: root/src/modlistsortproxy.cpp
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2013-04-12 15:31:47 +0200
committerTannin <devnull@localhost>2013-04-12 15:31:47 +0200
commit4fbfc9aa54ed4499f54eb7b3cd942337f6b49e58 (patch)
tree43008c44a7adf429abc45d5a81537a118fcf6fa7 /src/modlistsortproxy.cpp
parenta47d9717884953b18b4b29e596d3e5a7d766e56e (diff)
- multi-selection in category window
- profile loading is now slightly more forgiving
Diffstat (limited to 'src/modlistsortproxy.cpp')
-rw-r--r--src/modlistsortproxy.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp
index 071e0384..a61ba2de 100644
--- a/src/modlistsortproxy.cpp
+++ b/src/modlistsortproxy.cpp
@@ -29,7 +29,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
ModListSortProxy::ModListSortProxy(Profile* profile, QObject *parent)
: QSortFilterProxyModel(parent), m_Profile(profile),
- m_CategoryFilter(CategoryFactory::CATEGORY_NONE), m_CurrentFilter()
+ m_CategoryFilter(), m_CurrentFilter()
{
m_EnabledColumns.set(ModList::COL_FLAGS);
m_EnabledColumns.set(ModList::COL_NAME);
@@ -47,12 +47,12 @@ void ModListSortProxy::setProfile(Profile *profile)
void ModListSortProxy::updateFilterActive()
{
- emit filterActive((m_CategoryFilter != CategoryFactory::CATEGORY_NONE) || !m_CurrentFilter.isEmpty());
+ emit filterActive((m_CategoryFilter.size() > 0) || !m_CurrentFilter.isEmpty());
}
-void ModListSortProxy::setCategoryFilter(int category)
+void ModListSortProxy::setCategoryFilter(const std::vector<int> &categories)
{
- m_CategoryFilter = category;
+ m_CategoryFilter = categories;
updateFilterActive();
this->invalidate();
}
@@ -197,13 +197,30 @@ bool ModListSortProxy::filterMatches(ModInfo::Ptr info, bool enabled) const
return false;
}
- return ((m_CategoryFilter == CategoryFactory::CATEGORY_NONE) ||
- ((m_CategoryFilter < CategoryFactory::CATEGORY_SPECIAL_FIRST) && (info->categorySet(m_CategoryFilter))) ||
- ((m_CategoryFilter == CategoryFactory::CATEGORY_SPECIAL_CHECKED) && enabled) ||
- ((m_CategoryFilter == CategoryFactory::CATEGORY_SPECIAL_UNCHECKED) && !enabled) ||
- ((m_CategoryFilter == CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE) && info->updateAvailable()) ||
- ((m_CategoryFilter == CategoryFactory::CATEGORY_SPECIAL_NOCATEGORY) && (info->getCategories().size() == 0)) ||
- ((m_CategoryFilter == CategoryFactory::CATEGORY_SPECIAL_CONFLICT) && (hasConflictFlag(info->getFlags()))));
+ for (auto iter = m_CategoryFilter.begin(); iter != m_CategoryFilter.end(); ++iter) {
+ switch (*iter) {
+ case CategoryFactory::CATEGORY_SPECIAL_CHECKED: {
+ if (!enabled) return false;
+ } break;
+ case CategoryFactory::CATEGORY_SPECIAL_UNCHECKED: {
+ if (enabled) return false;
+ } break;
+ case CategoryFactory::CATEGORY_SPECIAL_UPDATEAVAILABLE: {
+ if (!info->updateAvailable()) return false;
+ } break;
+ case CategoryFactory::CATEGORY_SPECIAL_NOCATEGORY: {
+ if (info->getCategories().size() > 0) return false;
+ } break;
+ case CategoryFactory::CATEGORY_SPECIAL_CONFLICT: {
+ if (!hasConflictFlag(info->getFlags())) return false;
+ } break;
+ default: {
+ if (!info->categorySet(*iter)) return false;
+ } break;
+ }
+ }
+
+ return true;
}