Added mcVersion column
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
@ -124,6 +124,14 @@ std::pair<int, bool> Mod::compare(const Resource& other, SortType type) const
|
||||
return { -1, type == SortType::LOADERS };
|
||||
break;
|
||||
}
|
||||
case SortType::MC_VERSIONS: {
|
||||
auto thisVersion = mcVersions().join(",");
|
||||
auto otherVersion = cast_other->mcVersions().join(",");
|
||||
auto compare_result = QString::compare(thisVersion, otherVersion, Qt::CaseInsensitive);
|
||||
if (compare_result != 0)
|
||||
return { compare_result, type == SortType::MC_VERSIONS };
|
||||
break;
|
||||
}
|
||||
}
|
||||
return { 0, false };
|
||||
}
|
||||
@ -261,6 +269,13 @@ auto Mod::loaders() const -> ModPlatform::ModLoaderTypes
|
||||
return {};
|
||||
}
|
||||
|
||||
auto Mod::mcVersions() const -> QStringList
|
||||
{
|
||||
if (metadata())
|
||||
return metadata()->mcVersions;
|
||||
return {};
|
||||
}
|
||||
|
||||
auto Mod::licenses() const -> const QList<ModLicense>&
|
||||
{
|
||||
return details().licenses;
|
||||
|
@ -73,6 +73,7 @@ class Mod : public Resource {
|
||||
auto metaurl() const -> QString;
|
||||
auto side() const -> Metadata::ModSide;
|
||||
auto loaders() const -> ModPlatform::ModLoaderTypes;
|
||||
auto mcVersions() const -> QStringList;
|
||||
|
||||
/** Get the intneral path to the mod's icon file*/
|
||||
QString iconPath() const { return m_local_details.icon_file; }
|
||||
|
@ -64,15 +64,16 @@
|
||||
ModFolderModel::ModFolderModel(const QString& dir, BaseInstance* instance, bool is_indexed, bool create_dir)
|
||||
: ResourceFolderModel(QDir(dir), instance, nullptr, create_dir), m_is_indexed(is_indexed)
|
||||
{
|
||||
m_column_names = QStringList({ "Enable", "Image", "Name", "Version", "Last Modified", "Provider", "Side", "Loaders" });
|
||||
m_column_names_translated = QStringList(
|
||||
{ tr("Enable"), tr("Image"), tr("Name"), tr("Version"), tr("Last Modified"), tr("Provider"), tr("Side"), tr("Loaders") });
|
||||
m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::NAME, SortType::VERSION,
|
||||
SortType::DATE, SortType::PROVIDER, SortType::SIDE, SortType::LOADERS };
|
||||
m_column_names =
|
||||
QStringList({ "Enable", "Image", "Name", "Version", "Last Modified", "Provider", "Side", "Loaders", "Miecraft Versions" });
|
||||
m_column_names_translated = QStringList({ tr("Enable"), tr("Image"), tr("Name"), tr("Version"), tr("Last Modified"), tr("Provider"),
|
||||
tr("Side"), tr("Loaders"), tr("Miecraft Versions") });
|
||||
m_column_sort_keys = { SortType::ENABLED, SortType::NAME, SortType::NAME, SortType::VERSION, SortType::DATE,
|
||||
SortType::PROVIDER, SortType::SIDE, SortType::LOADERS, SortType::MC_VERSIONS };
|
||||
m_column_resize_modes = { QHeaderView::ResizeToContents, QHeaderView::Interactive, QHeaderView::Stretch,
|
||||
QHeaderView::ResizeToContents, QHeaderView::ResizeToContents, QHeaderView::ResizeToContents,
|
||||
QHeaderView::ResizeToContents, QHeaderView::ResizeToContents };
|
||||
m_columnsHideable = { false, true, false, true, true, true, true, true };
|
||||
QHeaderView::ResizeToContents, QHeaderView::ResizeToContents, QHeaderView::ResizeToContents };
|
||||
m_columnsHideable = { false, true, false, true, true, true, true, true, true };
|
||||
}
|
||||
|
||||
QVariant ModFolderModel::data(const QModelIndex& index, int role) const
|
||||
@ -122,7 +123,10 @@ QVariant ModFolderModel::data(const QModelIndex& index, int role) const
|
||||
loaders << getModLoaderAsString(loader);
|
||||
}
|
||||
}
|
||||
return loaders.join(",");
|
||||
return loaders.join(", ");
|
||||
}
|
||||
case McVersionsColumn: {
|
||||
return at(row)->mcVersions().join(", ");
|
||||
}
|
||||
default:
|
||||
return QVariant();
|
||||
@ -175,6 +179,7 @@ QVariant ModFolderModel::headerData(int section, [[maybe_unused]] Qt::Orientatio
|
||||
case ImageColumn:
|
||||
case SideColumn:
|
||||
case LoadersColumn:
|
||||
case McVersionsColumn:
|
||||
return columnNames().at(section);
|
||||
default:
|
||||
return QVariant();
|
||||
@ -196,6 +201,8 @@ QVariant ModFolderModel::headerData(int section, [[maybe_unused]] Qt::Orientatio
|
||||
return tr("On what environment the mod is running.");
|
||||
case LoadersColumn:
|
||||
return tr("The mod loader.");
|
||||
case McVersionsColumn:
|
||||
return tr("The supported minecraft versions.");
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ class ModFolderModel : public ResourceFolderModel {
|
||||
ProviderColumn,
|
||||
SideColumn,
|
||||
LoadersColumn,
|
||||
McVersionsColumn,
|
||||
NUM_COLUMNS
|
||||
};
|
||||
enum ModStatusAction { Disable, Enable, Toggle };
|
||||
|
@ -15,7 +15,7 @@ enum class ResourceType {
|
||||
LITEMOD, //!< The resource is a litemod
|
||||
};
|
||||
|
||||
enum class SortType { NAME, DATE, VERSION, ENABLED, PACK_FORMAT, PROVIDER, SIDE, LOADERS };
|
||||
enum class SortType { NAME, DATE, VERSION, ENABLED, PACK_FORMAT, PROVIDER, SIDE, LOADERS, MC_VERSIONS };
|
||||
|
||||
enum class EnableAction { ENABLE, DISABLE, TOGGLE };
|
||||
|
||||
|
Reference in New Issue
Block a user