Improvements to modlist export (#3512)

This commit is contained in:
Alexandru Ionut Tripon 2025-04-10 00:16:32 +03:00 committed by GitHub
commit a6f00330a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 19 additions and 0 deletions

View File

@ -138,6 +138,15 @@ auto Mod::name() const -> QString
return Resource::name();
}
auto Mod::mod_id() const -> QString
{
auto d_mod_id = details().mod_id;
if (!d_mod_id.isEmpty())
return d_mod_id;
return Resource::name();
}
auto Mod::version() const -> QString
{
return details().version;

View File

@ -61,6 +61,7 @@ class Mod : public Resource {
auto details() const -> const ModDetails&;
auto name() const -> QString override;
auto mod_id() const -> QString;
auto version() const -> QString;
auto homepage() const -> QString override;
auto description() const -> QString;

View File

@ -152,6 +152,9 @@ class Resource : public QObject {
[[nodiscard]] bool isMoreThanOneHardLink() const;
[[nodiscard]] auto mod_id() const -> QString { return m_mod_id; }
void setModId(const QString& modId) { m_mod_id = modId; }
protected:
/* The file corresponding to this resource. */
QFileInfo m_file_info;
@ -162,6 +165,7 @@ class Resource : public QObject {
QString m_internal_id;
/* Name as reported via the file name. In the absence of a better name, this is shown to the user. */
QString m_name;
QString m_mod_id;
/* The type of file we're dealing with. */
ResourceType m_type = ResourceType::UNKNOWN;

View File

@ -203,6 +203,7 @@ QString exportToModList(QList<Mod*> mods, QString lineTemplate)
for (auto mod : mods) {
auto meta = mod->metadata();
auto modName = mod->name();
auto modID = mod->mod_id();
auto url = mod->homepage();
auto ver = mod->version();
if (ver.isEmpty() && meta != nullptr)
@ -211,6 +212,7 @@ QString exportToModList(QList<Mod*> mods, QString lineTemplate)
auto filename = mod->fileinfo().fileName();
lines << QString(lineTemplate)
.replace("{name}", modName)
.replace("{mod_id}", modID)
.replace("{url}", url)
.replace("{version}", ver)
.replace("{authors}", authors)

View File

@ -79,6 +79,9 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>This text supports the following placeholders:&#10;{name} - Mod name&#10;{mod_id} - Mod ID&#10;{url} - Mod URL&#10;{version} - Mod version&#10;{authors} - Mod authors</string>
</property>
</widget>
</item>
</layout>