diff options
| author | Silarn <jrim@rimpo.org> | 2018-05-04 18:26:57 -0500 |
|---|---|---|
| committer | Silarn <jrim@rimpo.org> | 2018-05-04 18:26:57 -0500 |
| commit | 9998727dbac0eb77b597cb299576d9ca7561b7cf (patch) | |
| tree | 08d3e2bebaaced7604debc01521f4d043e39a72a /src/pluginlist.cpp | |
| parent | a76d9876472c6bc43cc78a5c6642d58d364bd843 (diff) | |
Vastly improved plugin index generation and sorting
Diffstat (limited to 'src/pluginlist.cpp')
| -rw-r--r-- | src/pluginlist.cpp | 56 |
1 files changed, 21 insertions, 35 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();
|
