diff options
Diffstat (limited to 'src/modlist.cpp')
| -rw-r--r-- | src/modlist.cpp | 29 |
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); |
