diff options
| author | Tannin <devnull@localhost> | 2015-01-03 15:58:52 +0100 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2015-01-03 15:58:52 +0100 |
| commit | a16e25380f088dc310fbed24d2dcef603357e99a (patch) | |
| tree | 40fc3b5254f2797eb20bfac1d54a22652d469fa2 /src/modlistsortproxy.cpp | |
| parent | 459816ab71ae6b350847cc93f1e03e49ecf75ade (diff) | |
| parent | f2f9e11fdd876821107cff0c1c5b9d8ecf66691f (diff) | |
Merge with branch1.2
Diffstat (limited to 'src/modlistsortproxy.cpp')
| -rw-r--r-- | src/modlistsortproxy.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp index 4e066eb8..9c30d0f0 100644 --- a/src/modlistsortproxy.cpp +++ b/src/modlistsortproxy.cpp @@ -54,7 +54,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);
}
@@ -65,6 +65,13 @@ void ModListSortProxy::setCategoryFilter(const std::vector<int> &categories) this->invalidate();
}
+void ModListSortProxy::setContentFilter(const std::vector<int> &content)
+{
+ m_ContentFilter = content;
+ updateFilterActive();
+ this->invalidate();
+}
+
Qt::ItemFlags ModListSortProxy::flags(const QModelIndex &modelIndex) const
{
Qt::ItemFlags flags = sourceModel()->flags(mapToSource(modelIndex));
@@ -74,7 +81,6 @@ Qt::ItemFlags ModListSortProxy::flags(const QModelIndex &modelIndex) const return flags;
}
-
void ModListSortProxy::enableAllVisible()
{
if (m_Profile == NULL) return;
@@ -128,6 +134,13 @@ bool ModListSortProxy::lessThan(const QModelIndex &left, if (leftMod->getFlags().size() != rightMod->getFlags().size())
lt = leftMod->getFlags().size() < rightMod->getFlags().size();
} break;
+ case ModList::COL_CONTENT: {
+ int lLen = leftMod->getContents().size();
+ int rLen = rightMod->getContents().size();
+ if (lLen != rLen) {
+ lt = lLen < rLen;
+ }
+ } break;
case ModList::COL_NAME: {
int comp = QString::compare(leftMod->name(), rightMod->name(), Qt::CaseInsensitive);
if (comp != 0)
@@ -228,6 +241,11 @@ bool ModListSortProxy::filterMatchesModAnd(ModInfo::Ptr info, bool enabled) cons } break;
}
}
+
+ foreach (int content, m_ContentFilter) {
+ if (!info->hasContent(static_cast<ModInfo::EContent>(content))) return false;
+ }
+
return true;
}
@@ -265,6 +283,11 @@ bool ModListSortProxy::filterMatchesModOr(ModInfo::Ptr info, bool enabled) const } break;
}
}
+
+ foreach (int content, m_ContentFilter) {
+ if (info->hasContent(static_cast<ModInfo::EContent>(content))) return true;
+ }
+
return false;
}
@@ -278,7 +301,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);
}
}
|
