From 3a92ff96ba5068aff0417219eed8cf759b55b9f7 Mon Sep 17 00:00:00 2001 From: Mikaƫl Capelle Date: Sat, 2 Jan 2021 15:08:29 +0100 Subject: Remove setName and remove from mod interface. --- src/modlist.cpp | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/modlist.cpp') 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(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(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); -- cgit v1.3.1