summaryrefslogtreecommitdiff
path: root/src/modlist.cpp
diff options
context:
space:
mode:
authorMikaƫl Capelle <capelle.mikael@gmail.com>2020-10-26 21:39:25 +0100
committerGitHub <noreply@github.com>2020-10-26 21:39:25 +0100
commit57e67eeb392ea6d3d4af69ca40538147cc608e0f (patch)
tree69976cb8870e1bffda3d149627123e1ecf24c654 /src/modlist.cpp
parentd42399e419fa6b769e343b8cf77480b6ac172b0f (diff)
parent61308ae2a6ed1123d3043659e72e300dc5c68cca (diff)
Merge pull request #1269 from Holt59/imodlist-updates
IModList updates
Diffstat (limited to 'src/modlist.cpp')
-rw-r--r--src/modlist.cpp52
1 files changed, 50 insertions, 2 deletions
diff --git a/src/modlist.cpp b/src/modlist.cpp
index 2499bac0..f4c034dc 100644
--- a/src/modlist.cpp
+++ b/src/modlist.cpp
@@ -77,6 +77,8 @@ ModList::ModList(PluginContainer *pluginContainer, OrganizerCore *organizer)
ModList::~ModList()
{
+ m_ModInstalled.disconnect_all_slots();
+ m_ModRemoved.disconnect_all_slots();
m_ModStateChanged.disconnect_all_slots();
m_ModMoved.disconnect_all_slots();
}
@@ -929,6 +931,31 @@ QStringList ModList::allMods() const
return result;
}
+QStringList ModList::allModsByProfilePriority(MOBase::IProfile* profile) const
+{
+ Profile* mo2Profile = profile == nullptr ?
+ m_Organizer->currentProfile() : static_cast<Profile*>(profile);
+ return m_Organizer->modsSortedByProfilePriority(mo2Profile);
+}
+
+MOBase::IModInterface* ModList::getMod(const QString& name) const
+{
+ unsigned int index = ModInfo::getIndex(name);
+ return index == UINT_MAX ? nullptr : ModInfo::getByIndex(index).data();
+}
+
+bool ModList::removeMod(MOBase::IModInterface* mod)
+{
+ unsigned int index = ModInfo::getIndex(mod->name());
+ if (index == UINT_MAX) {
+ return mod->remove();
+ }
+ else {
+ return ModInfo::removeMod(index);
+ }
+ notifyModRemoved(mod->name());
+}
+
IModList::ModStates ModList::state(const QString &name) const
{
unsigned int modIndex = ModInfo::getIndex(name);
@@ -1001,10 +1028,29 @@ bool ModList::setPriority(const QString &name, int newPriority)
}
}
+bool ModList::onModInstalled(const std::function<void(MOBase::IModInterface*)>& func)
+{
+ return m_ModInstalled.connect(func).connected();
+}
+
+bool ModList::onModRemoved(const std::function<void(QString const&)>& func)
+{
+ return m_ModRemoved.connect(func).connected();
+}
+
bool ModList::onModStateChanged(const std::function<void(const std::map<QString, ModStates>&)>& func)
{
- auto conn = m_ModStateChanged.connect(func);
- return conn.connected();
+ return m_ModStateChanged.connect(func).connected();
+}
+
+void ModList::notifyModInstalled(MOBase::IModInterface* mod) const
+{
+ m_ModInstalled(mod);
+}
+
+void ModList::notifyModRemoved(QString const& modName) const
+{
+ m_ModRemoved(modName);
}
void ModList::notifyModStateChanged(QList<unsigned int> modIndices) const
@@ -1176,6 +1222,8 @@ void ModList::removeRowForce(int row, const QModelIndex &parent)
m_Profile->refreshModStatus(); // removes the mod from the status list
m_Profile->writeModlist(); // this ensures the modified list gets written back before new mods can be installed
+ notifyModRemoved(modInfo->name());
+
if (wasEnabled) {
emit removeOrigin(modInfo->name());
}