diff options
| -rw-r--r-- | src/pluginlist.cpp | 56 | ||||
| -rw-r--r-- | src/pluginlist.h | 3 | ||||
| -rw-r--r-- | src/pluginlistsortproxy.cpp | 4 |
3 files changed, 25 insertions, 38 deletions
diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index f4bdf418..fe654c7e 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -485,23 +485,9 @@ int PluginList::enabledCount() const return enabled;
}
-int PluginList::getIndexPriority(int index) const
+QString PluginList::getIndexPriority(int index) const
{
- int numESLs = 0;
- std::vector<ESPInfo> sortESPs(m_ESPs);
- std::sort(sortESPs.begin(), sortESPs.end());
- for (auto sortedESP : sortESPs) {
- if (sortedESP.m_LoadOrder == m_ESPs[index].m_LoadOrder)
- break;
- if ((sortedESP.m_IsLight || sortedESP.m_IsLightFlagged) && sortedESP.m_LoadOrder != -1)
- ++numESLs;
- }
- if (m_ESPs[index].m_IsLight || m_ESPs[index].m_IsLightFlagged) {
- int ESLpos = 254 + ((numESLs + 1) / 4096);
- return ESLpos + (numESLs % 4096);
- } else {
- return m_ESPs[index].m_LoadOrder - numESLs;
- }
+ return m_ESPs[index].m_Index;
}
bool PluginList::isESPLocked(int index) const
@@ -751,6 +737,24 @@ void PluginList::updateIndices() m_ESPsByName[m_ESPs[i].m_Name.toLower()] = i;
m_ESPsByPriority.at(static_cast<size_t>(m_ESPs[i].m_Priority)) = i;
}
+
+ int numESLs = 0;
+ int numSkipped = 0;
+ for (int l = 0; l < m_ESPs.size(); ++l) {
+ int i = m_ESPsByPriority.at(l);
+ if (!m_ESPs[i].m_Enabled) {
+ m_ESPs[i].m_Index = QString();
+ ++numSkipped;
+ continue;
+ }
+ if (m_ESPs[i].m_IsLight || m_ESPs[i].m_IsLightFlagged) {
+ int ESLpos = 254 + ((numESLs + 1) / 4096);
+ m_ESPs[i].m_Index = QString("%1:%2").arg(ESLpos, 2, 16, QChar('0')).arg((numESLs) % 4096, 3, 16, QChar('0')).toUpper();
+ ++numESLs;
+ } else {
+ m_ESPs[i].m_Index = QString("%1").arg(l - numESLs - numSkipped, 2, 16, QChar('0')).toUpper();
+ }
+ }
}
@@ -808,25 +812,7 @@ QVariant PluginList::data(const QModelIndex &modelIndex, int role) const return m_ESPs[index].m_Priority;
} break;
case COL_MODINDEX: {
- if (m_ESPs[index].m_LoadOrder == -1) {
- return QString();
- } else {
- int numESLs = 0;
- std::vector<ESPInfo> sortESPs(m_ESPs);
- std::sort(sortESPs.begin(), sortESPs.end());
- for (auto sortedESP: sortESPs) {
- if (sortedESP.m_LoadOrder == m_ESPs[index].m_LoadOrder)
- break;
- if ((sortedESP.m_IsLight || sortedESP.m_IsLightFlagged) && sortedESP.m_LoadOrder != -1)
- ++numESLs;
- }
- if (m_ESPs[index].m_IsLight || m_ESPs[index].m_IsLightFlagged) {
- int ESLpos = 254 + ((numESLs+1) / 4096);
- return QString("%1:%2").arg(ESLpos, 2, 16, QChar('0')).arg((numESLs)%4096, 3, 16, QChar('0')).toUpper();
- } else {
- return QString("%1").arg(m_ESPs[index].m_LoadOrder - numESLs, 2, 16, QChar('0')).toUpper();
- }
- }
+ return m_ESPs[index].m_Index;
} break;
default: {
return QVariant();
diff --git a/src/pluginlist.h b/src/pluginlist.h index 6a53614a..b3b0ee13 100644 --- a/src/pluginlist.h +++ b/src/pluginlist.h @@ -194,7 +194,7 @@ public: QString getName(int index) const { return m_ESPs.at(index).m_Name; }
int getPriority(int index) const { return m_ESPs.at(index).m_Priority; }
- int getIndexPriority(int index) const;
+ QString getIndexPriority(int index) const;
bool isESPLocked(int index) const;
void lockESPIndex(int index, bool lock);
@@ -278,6 +278,7 @@ private: bool m_Enabled;
bool m_ForceEnabled;
int m_Priority;
+ QString m_Index;
int m_LoadOrder;
FILETIME m_Time;
QString m_OriginName;
diff --git a/src/pluginlistsortproxy.cpp b/src/pluginlistsortproxy.cpp index b844e1d8..e09e64a5 100644 --- a/src/pluginlistsortproxy.cpp +++ b/src/pluginlistsortproxy.cpp @@ -100,8 +100,8 @@ bool PluginListSortProxy::lessThan(const QModelIndex &left, }
} break;
case PluginList::COL_MODINDEX: {
- int leftVal = plugins->isEnabled(left.row()) ? plugins->getIndexPriority(left.row()) : -1;
- int rightVal = plugins->isEnabled(right.row()) ? plugins->getIndexPriority(right.row()) : -1;
+ QString leftVal = plugins->getIndexPriority(left.row());
+ QString rightVal = plugins->getIndexPriority(right.row());
return leftVal < rightVal;
} break;
default: {
|
