1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Added preset list of mod types for mod list

This commit is contained in:
Ivan Savenko 2023-03-27 01:10:44 +03:00
parent efed2991f2
commit 1d1d31c4e8
4 changed files with 49 additions and 21 deletions

View File

@ -316,7 +316,6 @@ CModEntry CModList::getMod(QString modname) const
settings["active"] = false;
}
for(auto entry : repositories)
{
QVariant repoVal = getValue(entry, path);

View File

@ -12,19 +12,6 @@
#include <QIcon>
namespace ModFields
{
static const QString names[ModFields::COUNT] =
{
"name",
"",
"",
"modType",
"version",
};
}
namespace ModStatus
{
static const QString iconDelete = "icons:mod-delete.png";
@ -48,18 +35,59 @@ QString CModListModel::modIndexToName(const QModelIndex & index) const
return "";
}
QString CModListModel::modTypeName(QString modTypeID) const
{
static QMap<QString, QString> modTypes = {
{"Translation", tr("Translation")},
{"Town", tr("Town") },
{"Test", tr("Test") },
{"Templates", tr("Templates") },
{"Spells", tr("Spells") },
{"Music", tr("Music") },
{"Sounds", tr("Sounds") },
{"Skills", tr("Skills") },
{"Other", tr("Other") },
{"Objects", tr("Objects") },
{"Mechanical", tr("Mechanics") },
{"Mechanics", tr("Mechanics") },
{"Themes", tr("Interface") },
{"Interface", tr("Interface") },
{"Heroes", tr("Heroes") },
{"Graphic", tr("Graphical") },
{"Graphical", tr("Graphical") },
{"Expansion", tr("Expansion") },
{"Creatures", tr("Creatures") },
{"Artifacts", tr("Artifacts") },
{"AI", tr("AI") },
};
if (modTypes.contains(modTypeID))
return modTypes[modTypeID];
return tr("Other");
}
QVariant CModListModel::getValue(const CModEntry & mod, int field) const
{
switch(field)
{
case ModFields::STATUS_ENABLED:
return mod.getModStatus() & (ModStatus::ENABLED | ModStatus::INSTALLED);
case ModFields::STATUS_ENABLED:
return mod.getModStatus() & (ModStatus::ENABLED | ModStatus::INSTALLED);
case ModFields::STATUS_UPDATE:
return mod.getModStatus() & (ModStatus::UPDATEABLE | ModStatus::INSTALLED);
case ModFields::STATUS_UPDATE:
return mod.getModStatus() & (ModStatus::UPDATEABLE | ModStatus::INSTALLED);
default:
return mod.getValue(ModFields::names[field]);
case ModFields::NAME:
return mod.getValue("name");
case ModFields::VERSION:
return mod.getValue("version");
case ModFields::TYPE:
return modTypeName(mod.getValue("modType").toString());
default:
return QVariant();
}
}

View File

@ -48,6 +48,7 @@ class CModListModel : public QAbstractItemModel, public CModList
void endResetModel();
QString modIndexToName(const QModelIndex & index) const;
QString modTypeName(QString modTypeID) const;
QVariant getTextAlign(int field) const;
QVariant getValue(const CModEntry & mod, int field) const;

View File

@ -217,7 +217,7 @@ QStringList CModListView::getModNames(QStringList input)
{
QStringList result;
for (auto const & modID : input)
for(const auto & modID : input)
{
auto mod = modModel->getMod(modID);