diff options
| author | Tannin <devnull@localhost> | 2015-06-10 22:09:32 +0200 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2015-06-10 22:09:32 +0200 |
| commit | 793dfb1637322c60bcbf32fdc5a9c23bb7ed5ec4 (patch) | |
| tree | 29fb382b16bc6987132701efd46691302ef8800d /src/modinfo.cpp | |
| parent | d25a81071c078585f14176283b89e1a6b0ad5795 (diff) | |
added plugin interface to add/remove/list categories to/from/of mods
Diffstat (limited to 'src/modinfo.cpp')
| -rw-r--r-- | src/modinfo.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
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<int>(), 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<EFlag> flags = getFlags(); |
