From cf1bbdd13e0db8856df672c367d3ec1610f6c556 Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Mon, 25 May 2020 19:53:21 +0200 Subject: Switch to using the ModDataContent feature from the game plugin. --- src/modinfo.h | 40 ++++++++++------------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) (limited to 'src/modinfo.h') diff --git a/src/modinfo.h b/src/modinfo.h index 29e6124d..c5b1cfca 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -87,24 +87,6 @@ public: FLAG_TRACKED, }; - enum EContent { - CONTENT_PLUGIN, - CONTENT_TEXTURE, - CONTENT_MESH, - CONTENT_BSA, - CONTENT_INTERFACE, - CONTENT_SOUND, - CONTENT_SCRIPT, - CONTENT_SKSE, - CONTENT_SKSEFILES, - CONTENT_SKYPROC, - CONTENT_MCM, - CONTENT_INI, - CONTENT_MODGROUP - }; - - static const int NUM_CONTENT_TYPES = CONTENT_MODGROUP + 1; - enum EHighlight { HIGHLIGHT_NONE = 0, HIGHLIGHT_INVALID = 1, @@ -248,13 +230,6 @@ public: // static bool isRegularName(const QString& name); - /** - * @brief retieve a name for one of the CONTENT_ enums - * @param contentType the content value - * @return a display string - */ - static QString getContentTypeName(int contentType); - virtual bool isRegular() const { return false; } virtual bool isEmpty() const { return false; } @@ -546,7 +521,10 @@ public: /** * @return a list of content types contained in a mod */ - virtual std::vector getContents() const { return std::vector(); } + virtual const std::vector& getContents() const { + static std::vector dummy; + return dummy; + } /** * @brief test if the specified flag is set for this mod @@ -563,11 +541,13 @@ public: bool hasAnyOfTheseFlags(std::vector flags) const; /** - * @brief test if the mods contains the specified content - * @param content the content to test - * @return true if the content is there, false otherwise + * @brief Test if the mod contains the specified content. + * + * @param content ID of the content to test. + * + * @return true if the content is there, false otherwise. */ - bool hasContent(ModInfo::EContent content) const; + virtual bool hasContent(int content) const = 0; /** * @return an indicator if and how this mod should be highlighted by the UI -- cgit v1.3.1 From 70f1e8bdf63e0471d0ccde41926383536f247dcb Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Wed, 27 May 2020 14:58:32 +0200 Subject: Make ModInfo::getContents() pure virtual. --- src/modinfo.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/modinfo.h') diff --git a/src/modinfo.h b/src/modinfo.h index c5b1cfca..5f2d7ba7 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -521,10 +521,7 @@ public: /** * @return a list of content types contained in a mod */ - virtual const std::vector& getContents() const { - static std::vector dummy; - return dummy; - } + virtual const std::vector& getContents() const = 0; /** * @brief test if the specified flag is set for this mod -- cgit v1.3.1 From 700c5fb16c1c4e39fd757998e95ead4a25ecc6da Mon Sep 17 00:00:00 2001 From: Mikaël Capelle Date: Wed, 27 May 2020 22:45:42 +0200 Subject: Store contents as a set instead of a vector. --- src/modinfo.h | 2 +- src/modinforegular.cpp | 5 +++-- src/modinforegular.h | 2 +- src/modinfowithconflictinfo.cpp | 2 +- src/modinfowithconflictinfo.h | 7 ++++--- src/modlist.cpp | 11 ++++------- src/modlist.h | 6 +++--- 7 files changed, 17 insertions(+), 18 deletions(-) (limited to 'src/modinfo.h') diff --git a/src/modinfo.h b/src/modinfo.h index 5f2d7ba7..a6c8ea65 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -521,7 +521,7 @@ public: /** * @return a list of content types contained in a mod */ - virtual const std::vector& getContents() const = 0; + virtual const std::set& getContents() const = 0; /** * @brief test if the specified flag is set for this mod diff --git a/src/modinforegular.cpp b/src/modinforegular.cpp index 8ad7ffe5..8ef8e007 100644 --- a/src/modinforegular.cpp +++ b/src/modinforegular.cpp @@ -653,12 +653,13 @@ std::vector ModInfoRegular::getFlags() const } -std::vector ModInfoRegular::doGetContents() const +std::set ModInfoRegular::doGetContents() const { ModDataContent* contentFeature = m_GamePlugin->feature(); if (contentFeature) { - return contentFeature->getContentsFor(contentFileTree()); + auto result = contentFeature->getContentsFor(contentFileTree()); + return std::set(std::begin(result), std::end(result)); } return {}; diff --git a/src/modinforegular.h b/src/modinforegular.h index b09dcd98..7e70631e 100644 --- a/src/modinforegular.h +++ b/src/modinforegular.h @@ -416,7 +416,7 @@ private slots: protected: - virtual std::vector doGetContents() const override; + virtual std::set doGetContents() const override; ModInfoRegular(PluginContainer *pluginContainer, const MOBase::IPluginGame *game, const QDir &path, MOShared::DirectoryEntry **directoryStructure); diff --git a/src/modinfowithconflictinfo.cpp b/src/modinfowithconflictinfo.cpp index 14b341d2..227ee12e 100644 --- a/src/modinfowithconflictinfo.cpp +++ b/src/modinfowithconflictinfo.cpp @@ -331,7 +331,7 @@ bool ModInfoWithConflictInfo::isValid() const { return m_Valid.value(); } -const std::vector& ModInfoWithConflictInfo::getContents() const { +const std::set& ModInfoWithConflictInfo::getContents() const { return m_Contents.value(); } diff --git a/src/modinfowithconflictinfo.h b/src/modinfowithconflictinfo.h index b66a7444..7109b83d 100644 --- a/src/modinfowithconflictinfo.h +++ b/src/modinfowithconflictinfo.h @@ -6,6 +6,7 @@ #include "thread_utils.h" #include "modinfo.h" +#include #include class ModInfoWithConflictInfo : public ModInfo @@ -24,7 +25,7 @@ public: /** * @return a list of content types contained in a mod */ - virtual const std::vector& getContents() const override; + virtual const std::set& getContents() const override; /** * @brief Test if the mod contains the specified content. @@ -75,7 +76,7 @@ protected: * * @return the contents for this mod. **/ - virtual std::vector doGetContents() const { return {}; } + virtual std::set doGetContents() const { return {}; } /** * @brief Retrieve a file tree corresponding to the underlying disk content @@ -146,7 +147,7 @@ private: MOShared::MemoizedLocked> m_FileTree; MOShared::MemoizedLocked m_Valid; - MOShared::MemoizedLocked> m_Contents; + MOShared::MemoizedLocked> m_Contents; MOShared::DirectoryEntry **m_DirectoryStructure; diff --git a/src/modlist.cpp b/src/modlist.cpp index 7fa63b54..614588db 100644 --- a/src/modlist.cpp +++ b/src/modlist.cpp @@ -178,13 +178,12 @@ QString ModList::getConflictFlagText(ModInfo::EConflictFlag flag, ModInfo::Ptr m } -QVariantList ModList::contentsToIcons(const std::vector &contents) const +QVariantList ModList::contentsToIcons(const std::set &contents) const { QVariantList result; - std::set contentsSet(contents.begin(), contents.end()); for (auto &content: m_Organizer->modDataContents()) { if (!content.isOnlyForFilter()) { - if (contentsSet.find(content.id()) != contentsSet.end()) { + if (contents.find(content.id()) != contents.end()) { result.append(content.icon()); } else { @@ -195,13 +194,11 @@ QVariantList ModList::contentsToIcons(const std::vector &contents) const return result; } -QString ModList::contentsToToolTip(const std::vector &contents) const +QString ModList::contentsToToolTip(const std::set &contents) const { QString result(""); - - std::set contentsSet(contents.begin(), contents.end()); for (auto& content : m_Organizer->modDataContents()) { - if (!content.isOnlyForFilter() && contentsSet.find(content.id()) != contentsSet.end()) { + if (!content.isOnlyForFilter() && contents.find(content.id()) != contents.end()) { result.append(QString("" "") .arg(content.icon()).arg(content.name())); diff --git a/src/modlist.h b/src/modlist.h index 4e2e86d2..8c29300d 100644 --- a/src/modlist.h +++ b/src/modlist.h @@ -79,7 +79,7 @@ public: * @brief constructor * @todo ensure this view works without a profile set, otherwise there are intransparent dependencies on the initialisation order **/ - ModList(PluginContainer *pluginContainer, OrganizerCore *parent = nullptr); + ModList(PluginContainer *pluginContainer, OrganizerCore *parent); ~ModList(); @@ -285,9 +285,9 @@ private: QString getColumnToolTip(int column) const; - QVariantList contentsToIcons(const std::vector &contentIds) const; + QVariantList contentsToIcons(const std::set &contentIds) const; - QString contentsToToolTip(const std::vector &contentsIds) const; + QString contentsToToolTip(const std::set &contentsIds) const; ModList::EColumn getEnabledColumn(int index) const; -- cgit v1.3.1
%2