Skip to content

Commit 6299be2

Browse files
Add form and header versions to plugin list tool tips and plugin API and add more columns (#2200)
1 parent 9049e65 commit 6299be2

File tree

5 files changed

+98
-7
lines changed

5 files changed

+98
-7
lines changed

src/pluginlist.cpp

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ QString PluginList::getColumnName(int column)
9696
return tr("Mod Index");
9797
case COL_FLAGS:
9898
return tr("Flags");
99+
case COL_FORMVERSION:
100+
return tr("Form Version");
101+
case COL_HEADERVERSION:
102+
return tr("Header Version");
103+
case COL_AUTHOR:
104+
return tr("Author");
105+
case COL_DESCRIPTION:
106+
return tr("Description");
99107
default:
100108
return tr("unknown");
101109
}
@@ -114,6 +122,14 @@ QString PluginList::getColumnToolTip(int column)
114122
"overwrites data from plugins with lower priority.");
115123
case COL_MODINDEX:
116124
return tr("Determines the formids of objects originating from this mods.");
125+
case COL_FORMVERSION:
126+
return tr("Form version of the plugin.");
127+
case COL_HEADERVERSION:
128+
return tr("Header version of the plugin.");
129+
case COL_AUTHOR:
130+
return tr("Author of the plugin.");
131+
case COL_DESCRIPTION:
132+
return tr("Description of the plugin.");
117133
default:
118134
return tr("unknown");
119135
}
@@ -1100,6 +1116,26 @@ bool PluginList::hasNoRecords(const QString& name) const
11001116
}
11011117
}
11021118

1119+
int PluginList::formVersion(const QString& name) const
1120+
{
1121+
auto iter = m_ESPsByName.find(name);
1122+
if (iter == m_ESPsByName.end()) {
1123+
return -1;
1124+
} else {
1125+
return m_ESPs[iter->second].formVersion;
1126+
}
1127+
}
1128+
1129+
float PluginList::headerVersion(const QString& name) const
1130+
{
1131+
auto iter = m_ESPsByName.find(name);
1132+
if (iter == m_ESPsByName.end()) {
1133+
return -1;
1134+
} else {
1135+
return m_ESPs[iter->second].headerVersion;
1136+
}
1137+
}
1138+
11031139
QString PluginList::author(const QString& name) const
11041140
{
11051141
auto iter = m_ESPsByName.find(name);
@@ -1279,17 +1315,30 @@ QVariant PluginList::data(const QModelIndex& modelIndex, int role) const
12791315

12801316
QVariant PluginList::displayData(const QModelIndex& modelIndex) const
12811317
{
1282-
const int index = modelIndex.row();
1318+
const int index = modelIndex.row();
1319+
const auto& plugin = m_ESPs[index];
12831320

12841321
switch (modelIndex.column()) {
12851322
case COL_NAME:
1286-
return m_ESPs[index].name;
1323+
return plugin.name;
12871324

12881325
case COL_PRIORITY:
1289-
return QString::number(m_ESPs[index].priority);
1326+
return QString::number(plugin.priority);
12901327

12911328
case COL_MODINDEX:
1292-
return m_ESPs[index].index;
1329+
return plugin.index;
1330+
1331+
case COL_FORMVERSION:
1332+
return plugin.formVersion != 0 ? QString::number(plugin.formVersion) : QString();
1333+
1334+
case COL_HEADERVERSION:
1335+
return QString::number(plugin.headerVersion);
1336+
1337+
case COL_AUTHOR:
1338+
return plugin.author;
1339+
1340+
case COL_DESCRIPTION:
1341+
return plugin.description;
12931342

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

1440+
if (esp.formVersion != 0) {
1441+
// Oblivion-style plugin headers don't have a form version
1442+
toolTip +=
1443+
"<br><b>" + tr("Form Version") + "</b>: " + QString::number(esp.formVersion);
1444+
}
1445+
1446+
toolTip +=
1447+
"<br><b>" + tr("Header Version") + "</b>: " + QString::number(esp.headerVersion);
1448+
13911449
if (!esp.author.isEmpty()) {
13921450
toolTip += "<br><b>" + tr("Author") + "</b>: " + TruncateString(esp.author);
13931451
}
@@ -1960,8 +2018,10 @@ PluginList::ESPInfo::ESPInfo(const QString& name, bool forceLoaded, bool forceEn
19602018
file.isBlueprint();
19612019
hasNoRecords = file.isDummy();
19622020

1963-
author = QString::fromLatin1(file.author().c_str());
1964-
description = QString::fromLatin1(file.description().c_str());
2021+
formVersion = file.formVersion();
2022+
headerVersion = file.headerVersion();
2023+
author = QString::fromLatin1(file.author().c_str());
2024+
description = QString::fromLatin1(file.description().c_str());
19652025

19662026
for (auto&& m : file.masters()) {
19672027
masters.insert(QString::fromStdString(m));

src/pluginlist.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,12 @@ class PluginList : public QAbstractItemModel
9393
COL_FLAGS,
9494
COL_PRIORITY,
9595
COL_MODINDEX,
96+
COL_FORMVERSION,
97+
COL_HEADERVERSION,
98+
COL_AUTHOR,
99+
COL_DESCRIPTION,
96100

97-
COL_LASTCOLUMN = COL_MODINDEX
101+
COL_LASTCOLUMN = COL_DESCRIPTION,
98102
};
99103

100104
using PluginStates = MOBase::IPluginList::PluginStates;
@@ -210,6 +214,8 @@ class PluginList : public QAbstractItemModel
210214

211215
QString getName(int index) const { return m_ESPs.at(index).name; }
212216
int getPriority(int index) const { return m_ESPs.at(index).priority; }
217+
QString getAuthor(int index) const { return m_ESPs.at(index).author; }
218+
QString getDescription(int index) const { return m_ESPs.at(index).description; }
213219
QString getIndexPriority(int index) const;
214220
bool isESPLocked(int index) const;
215221
void lockESPIndex(int index, bool lock);
@@ -247,6 +253,8 @@ class PluginList : public QAbstractItemModel
247253
bool isBlueprintFlagged(const QString& name) const;
248254
bool hasNoRecords(const QString& name) const;
249255

256+
int formVersion(const QString& name) const;
257+
float headerVersion(const QString& name) const;
250258
QString author(const QString& name) const;
251259
QString description(const QString& name) const;
252260

@@ -345,6 +353,8 @@ public slots:
345353
bool hasNoRecords;
346354
bool modSelected;
347355
bool isMasterOfSelectedPlugin;
356+
int formVersion;
357+
float headerVersion;
348358
QString author;
349359
QString description;
350360
bool hasIni;

src/pluginlistproxy.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ bool PluginListProxy::hasNoRecords(const QString& name) const
134134
return m_Proxied->hasNoRecords(name);
135135
}
136136

137+
int PluginListProxy::formVersion(const QString& name) const
138+
{
139+
return m_Proxied->formVersion(name);
140+
}
141+
142+
float PluginListProxy::headerVersion(const QString& name) const
143+
{
144+
return m_Proxied->headerVersion(name);
145+
}
146+
137147
QString PluginListProxy::author(const QString& name) const
138148
{
139149
return m_Proxied->author(name);

src/pluginlistproxy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class PluginListProxy : public MOBase::IPluginList
3737
bool isBlueprintFlagged(const QString& name) const override;
3838
bool hasNoRecords(const QString& name) const override;
3939

40+
int formVersion(const QString& name) const override;
41+
float headerVersion(const QString& name) const override;
4042
QString author(const QString& name) const override;
4143
QString description(const QString& name) const override;
4244

src/pluginlistsortproxy.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ bool PluginListSortProxy::lessThan(const QModelIndex& left,
8383
QString rightVal = plugins->getIndexPriority(right.row());
8484
return leftVal < rightVal;
8585
} break;
86+
case PluginList::COL_AUTHOR: {
87+
return QString::compare(plugins->getAuthor(left.row()),
88+
plugins->getAuthor(right.row()), Qt::CaseInsensitive) < 0;
89+
} break;
90+
case PluginList::COL_DESCRIPTION: {
91+
return QString::compare(plugins->getDescription(left.row()),
92+
plugins->getDescription(right.row()),
93+
Qt::CaseInsensitive) < 0;
94+
} break;
8695
default: {
8796
return plugins->getPriority(left.row()) < plugins->getPriority(right.row());
8897
} break;

0 commit comments

Comments
 (0)