diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-02 15:08:29 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-02 15:08:29 +0100 |
| commit | 3a92ff96ba5068aff0417219eed8cf759b55b9f7 (patch) | |
| tree | 156453698a6e772f051478ff117a3924493f3cc1 /src/modlist.cpp | |
| parent | 386cfc511a0d843851d78eeb2bce8d1da725d0d0 (diff) | |
Remove setName and remove from mod interface.
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); |
