From 793dfb1637322c60bcbf32fdc5a9c23bb7ed5ec4 Mon Sep 17 00:00:00 2001 From: Tannin Date: Wed, 10 Jun 2015 22:09:32 +0200 Subject: added plugin interface to add/remove/list categories to/from/of mods --- src/modinfo.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/modinfo.cpp') diff --git a/src/modinfo.cpp b/src/modinfo.cpp index 3fa42da9..526ec62b 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -303,6 +303,40 @@ void ModInfo::setVersion(const VersionInfo &version) m_Version = version; } +void ModInfo::addCategory(const QString &categoryName) +{ + int id = CategoryFactory::instance().getCategoryID(categoryName); + if (id == -1) { + id = CategoryFactory::instance().addCategory(categoryName, std::vector(), 0); + } + setCategory(id, true); +} + +bool ModInfo::removeCategory(const QString &categoryName) +{ + int id = CategoryFactory::instance().getCategoryID(categoryName); + if (id == -1) { + return false; + } + if (!categorySet(id)) { + return false; + } + setCategory(id, false); + return true; +} + +QStringList ModInfo::categories() +{ + QStringList result; + + CategoryFactory &catFac = CategoryFactory::instance(); + for (int id : m_Categories) { + result.append(catFac.getCategoryName(catFac.getCategoryIndex(id))); + } + + return result; +} + bool ModInfo::hasFlag(ModInfo::EFlag flag) const { std::vector flags = getFlags(); -- cgit v1.3.1