Skip to content

Commit

Permalink
Add form and header versions to plugin list tool tips and plugin API …
Browse files Browse the repository at this point in the history
…and add more columns (#2200)
  • Loading branch information
JonathanFeenstra authored Jan 31, 2025
1 parent 9049e65 commit 6299be2
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 7 deletions.
72 changes: 66 additions & 6 deletions src/pluginlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ QString PluginList::getColumnName(int column)
return tr("Mod Index");
case COL_FLAGS:
return tr("Flags");
case COL_FORMVERSION:
return tr("Form Version");
case COL_HEADERVERSION:
return tr("Header Version");
case COL_AUTHOR:
return tr("Author");
case COL_DESCRIPTION:
return tr("Description");
default:
return tr("unknown");
}
Expand All @@ -114,6 +122,14 @@ QString PluginList::getColumnToolTip(int column)
"overwrites data from plugins with lower priority.");
case COL_MODINDEX:
return tr("Determines the formids of objects originating from this mods.");
case COL_FORMVERSION:
return tr("Form version of the plugin.");
case COL_HEADERVERSION:
return tr("Header version of the plugin.");
case COL_AUTHOR:
return tr("Author of the plugin.");
case COL_DESCRIPTION:
return tr("Description of the plugin.");
default:
return tr("unknown");
}
Expand Down Expand Up @@ -1100,6 +1116,26 @@ bool PluginList::hasNoRecords(const QString& name) const
}
}

int PluginList::formVersion(const QString& name) const
{
auto iter = m_ESPsByName.find(name);
if (iter == m_ESPsByName.end()) {
return -1;
} else {
return m_ESPs[iter->second].formVersion;
}
}

float PluginList::headerVersion(const QString& name) const
{
auto iter = m_ESPsByName.find(name);
if (iter == m_ESPsByName.end()) {
return -1;
} else {
return m_ESPs[iter->second].headerVersion;
}
}

QString PluginList::author(const QString& name) const
{
auto iter = m_ESPsByName.find(name);
Expand Down Expand Up @@ -1279,17 +1315,30 @@ QVariant PluginList::data(const QModelIndex& modelIndex, int role) const

QVariant PluginList::displayData(const QModelIndex& modelIndex) const
{
const int index = modelIndex.row();
const int index = modelIndex.row();
const auto& plugin = m_ESPs[index];

switch (modelIndex.column()) {
case COL_NAME:
return m_ESPs[index].name;
return plugin.name;

case COL_PRIORITY:
return QString::number(m_ESPs[index].priority);
return QString::number(plugin.priority);

case COL_MODINDEX:
return m_ESPs[index].index;
return plugin.index;

case COL_FORMVERSION:
return plugin.formVersion != 0 ? QString::number(plugin.formVersion) : QString();

case COL_HEADERVERSION:
return QString::number(plugin.headerVersion);

case COL_AUTHOR:
return plugin.author;

case COL_DESCRIPTION:
return plugin.description;

default:
return {};
Expand Down Expand Up @@ -1388,6 +1437,15 @@ QVariant PluginList::tooltipData(const QModelIndex& modelIndex) const
tr("This plugin can't be disabled (enforced by the game).") + "</i></b>";
}

if (esp.formVersion != 0) {
// Oblivion-style plugin headers don't have a form version
toolTip +=
"<br><b>" + tr("Form Version") + "</b>: " + QString::number(esp.formVersion);
}

toolTip +=
"<br><b>" + tr("Header Version") + "</b>: " + QString::number(esp.headerVersion);

if (!esp.author.isEmpty()) {
toolTip += "<br><b>" + tr("Author") + "</b>: " + TruncateString(esp.author);
}
Expand Down Expand Up @@ -1960,8 +2018,10 @@ PluginList::ESPInfo::ESPInfo(const QString& name, bool forceLoaded, bool forceEn
file.isBlueprint();
hasNoRecords = file.isDummy();

author = QString::fromLatin1(file.author().c_str());
description = QString::fromLatin1(file.description().c_str());
formVersion = file.formVersion();
headerVersion = file.headerVersion();
author = QString::fromLatin1(file.author().c_str());
description = QString::fromLatin1(file.description().c_str());

for (auto&& m : file.masters()) {
masters.insert(QString::fromStdString(m));
Expand Down
12 changes: 11 additions & 1 deletion src/pluginlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ class PluginList : public QAbstractItemModel
COL_FLAGS,
COL_PRIORITY,
COL_MODINDEX,
COL_FORMVERSION,
COL_HEADERVERSION,
COL_AUTHOR,
COL_DESCRIPTION,

COL_LASTCOLUMN = COL_MODINDEX
COL_LASTCOLUMN = COL_DESCRIPTION,
};

using PluginStates = MOBase::IPluginList::PluginStates;
Expand Down Expand Up @@ -210,6 +214,8 @@ class PluginList : public QAbstractItemModel

QString getName(int index) const { return m_ESPs.at(index).name; }
int getPriority(int index) const { return m_ESPs.at(index).priority; }
QString getAuthor(int index) const { return m_ESPs.at(index).author; }
QString getDescription(int index) const { return m_ESPs.at(index).description; }
QString getIndexPriority(int index) const;
bool isESPLocked(int index) const;
void lockESPIndex(int index, bool lock);
Expand Down Expand Up @@ -247,6 +253,8 @@ class PluginList : public QAbstractItemModel
bool isBlueprintFlagged(const QString& name) const;
bool hasNoRecords(const QString& name) const;

int formVersion(const QString& name) const;
float headerVersion(const QString& name) const;
QString author(const QString& name) const;
QString description(const QString& name) const;

Expand Down Expand Up @@ -345,6 +353,8 @@ public slots:
bool hasNoRecords;
bool modSelected;
bool isMasterOfSelectedPlugin;
int formVersion;
float headerVersion;
QString author;
QString description;
bool hasIni;
Expand Down
10 changes: 10 additions & 0 deletions src/pluginlistproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ bool PluginListProxy::hasNoRecords(const QString& name) const
return m_Proxied->hasNoRecords(name);
}

int PluginListProxy::formVersion(const QString& name) const
{
return m_Proxied->formVersion(name);
}

float PluginListProxy::headerVersion(const QString& name) const
{
return m_Proxied->headerVersion(name);
}

QString PluginListProxy::author(const QString& name) const
{
return m_Proxied->author(name);
Expand Down
2 changes: 2 additions & 0 deletions src/pluginlistproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class PluginListProxy : public MOBase::IPluginList
bool isBlueprintFlagged(const QString& name) const override;
bool hasNoRecords(const QString& name) const override;

int formVersion(const QString& name) const override;
float headerVersion(const QString& name) const override;
QString author(const QString& name) const override;
QString description(const QString& name) const override;

Expand Down
9 changes: 9 additions & 0 deletions src/pluginlistsortproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ bool PluginListSortProxy::lessThan(const QModelIndex& left,
QString rightVal = plugins->getIndexPriority(right.row());
return leftVal < rightVal;
} break;
case PluginList::COL_AUTHOR: {
return QString::compare(plugins->getAuthor(left.row()),
plugins->getAuthor(right.row()), Qt::CaseInsensitive) < 0;
} break;
case PluginList::COL_DESCRIPTION: {
return QString::compare(plugins->getDescription(left.row()),
plugins->getDescription(right.row()),
Qt::CaseInsensitive) < 0;
} break;
default: {
return plugins->getPriority(left.row()) < plugins->getPriority(right.row());
} break;
Expand Down

0 comments on commit 6299be2

Please sign in to comment.