summaryrefslogtreecommitdiff
path: root/src/modlist.cpp
diff options
context:
space:
mode:
authorMikaƫl Capelle <capelle.mikael@gmail.com>2021-01-02 15:25:40 +0100
committerGitHub <noreply@github.com>2021-01-02 15:25:40 +0100
commit71055e373de639d9654361084f39d81211d08819 (patch)
tree156453698a6e772f051478ff117a3924493f3cc1 /src/modlist.cpp
parent386cfc511a0d843851d78eeb2bce8d1da725d0d0 (diff)
parent3a92ff96ba5068aff0417219eed8cf759b55b9f7 (diff)
Merge pull request #1340 from Holt59/update-imodinterface
Remove setName and remove from mod interface.
Diffstat (limited to 'src/modlist.cpp')
-rw-r--r--src/modlist.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/modlist.cpp b/src/modlist.cpp
index 237f65fa..c8056140 100644
--- a/src/modlist.cpp
+++ b/src/modlist.cpp
@@ -940,7 +940,12 @@ bool ModList::removeMod(MOBase::IModInterface* mod)
{
unsigned int index = ModInfo::getIndex(mod->name());
if (index == UINT_MAX) {
- return mod->remove();
+ if (auto* p = dynamic_cast<ModInfo*>(mod)) {
+ return p->remove();
+ }
+ else {
+ return false;
+ }
}
else {
return ModInfo::removeMod(index);
@@ -948,6 +953,28 @@ bool ModList::removeMod(MOBase::IModInterface* mod)
notifyModRemoved(mod->name());
}
+MOBase::IModInterface* ModList::renameMod(MOBase::IModInterface* mod, const QString& name)
+{
+ unsigned int index = ModInfo::getIndex(mod->name());
+ if (index == UINT_MAX) {
+ if (auto* p = dynamic_cast<ModInfo*>(mod)) {
+ p->setName(name);
+ return p;
+ }
+ else {
+ return nullptr;
+ }
+ }
+ else {
+ if (renameMod(index, name)) {
+ return ModInfo::getByName(name).get();
+ }
+ else {
+ return nullptr;
+ }
+ }
+}
+
IModList::ModStates ModList::state(const QString &name) const
{
unsigned int modIndex = ModInfo::getIndex(name);