Improvements to modlist export

Added .replace("{mod_id}", modID)

Signed-off-by: hanlie <48323966+HanlieChina@users.noreply.github.com>
This commit is contained in:
hanlie 2025-03-19 00:24:58 +08:00
parent d0b9073f60
commit 6bda537633
4 changed files with 16 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)