summaryrefslogtreecommitdiff
path: root/src/modlistsortproxy.cpp
diff options
context:
space:
mode:
authorisanae <14251494+isanae@users.noreply.github.com>2020-05-28 23:42:53 -0400
committerGitHub <noreply@github.com>2020-05-28 23:42:53 -0400
commitda35955d6c15c4abc83ae8c0a4ea8195c0c0ac85 (patch)
treebeab5513b64e93c32d50f628321654623b603129 /src/modlistsortproxy.cpp
parent652d3ab054cd2bd94fe88dc42aa39798fc3b2c4a (diff)
parent0a5790b333883c7c4ef07bb44f0a411ce8ba79b5 (diff)
Merge pull request #1092 from Holt59/mod-data-content
Use ModDataContent feature from GamePlugin
Diffstat (limited to 'src/modlistsortproxy.cpp')
-rw-r--r--src/modlistsortproxy.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp
index 018b9760..ab6dd852 100644
--- a/src/modlistsortproxy.cpp
+++ b/src/modlistsortproxy.cpp
@@ -22,6 +22,8 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "profile.h"
#include "messagedialog.h"
#include "qtgroupingproxy.h"
+#include "organizercore.h"
+
#include <log.h>
#include <QMenu>
#include <QCheckBox>
@@ -33,8 +35,9 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
using namespace MOBase;
-ModListSortProxy::ModListSortProxy(Profile* profile, QObject *parent)
- : QSortFilterProxyModel(parent)
+ModListSortProxy::ModListSortProxy(Profile* profile, OrganizerCore * organizer)
+ : QSortFilterProxyModel(organizer)
+ , m_Organizer(organizer)
, m_Profile(profile)
, m_FilterActive(false)
, m_FilterMode(FilterAnd)
@@ -177,21 +180,16 @@ bool ModListSortProxy::lessThan(const QModelIndex &left,
}
} break;
case ModList::COL_CONTENT: {
- std::vector<ModInfo::EContent> lContent = leftMod->getContents();
- std::vector<ModInfo::EContent> rContent = rightMod->getContents();
- if (lContent.size() != rContent.size()) {
- lt = lContent.size() < rContent.size();
- }
-
- int lValue = 0;
- int rValue = 0;
- for (ModInfo::EContent content : lContent) {
- lValue += 2 << (unsigned int)content;
- }
- for (ModInfo::EContent content : rContent) {
- rValue += 2 << (unsigned int)content;
- }
-
+ const auto& lContents = leftMod->getContents();
+ const auto& rContents = rightMod->getContents();
+ unsigned int lValue = 0;
+ unsigned int rValue = 0;
+ m_Organizer->modDataContents().forEachContentIn(lContents, [&lValue](auto const& content) {
+ lValue += 2U << static_cast<unsigned int>(content.id());
+ });
+ m_Organizer->modDataContents().forEachContentIn(rContents, [&rValue](auto const& content) {
+ rValue += 2U << static_cast<unsigned int>(content.id());
+ });
lt = lValue < rValue;
} break;
case ModList::COL_NAME: {
@@ -449,7 +447,7 @@ bool ModListSortProxy::categoryMatchesMod(
bool ModListSortProxy::contentMatchesMod(ModInfo::Ptr info, bool enabled, int content) const
{
- return info->hasContent(static_cast<ModInfo::EContent>(content));
+ return info->hasContent(content);
}
bool ModListSortProxy::filterMatchesMod(ModInfo::Ptr info, bool enabled) const