summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLostDragonist <lost.dragonist@gmail.com>2018-12-24 19:46:31 -0600
committerLostDragonist <lost.dragonist@gmail.com>2018-12-24 19:46:31 -0600
commit7fa230411e3615e923f39fe85d9ccb985e3d4e5d (patch)
tree52f93e6dd2423e1e9f39bd9ba0ead33de4119cd3
parent23cf8e60fd7144294ee1ffc013f76d4917518a76 (diff)
Improvements to the plugin and mod counters
* Fix style * Add whatsThis * Add tooltips with additional statistics * Don't count mods like overwrite, unmanaged, DLC, etc.
-rw-r--r--src/mainwindow.cpp106
-rw-r--r--src/mainwindow.h3
-rw-r--r--src/mainwindow.ui10
3 files changed, 110 insertions, 9 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 657f89bd..e3f12e39 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -458,11 +458,8 @@ MainWindow::MainWindow(QSettings &initSettings
// set the name of the widget to the name of the action to allow styling
ui->toolBar->widgetForAction(action)->setObjectName(action->objectName());
}
- ui->activePluginsCounter->display(m_OrganizerCore.pluginList()->enabledCount());
- ui->activeModsCounter->display((int)m_OrganizerCore.currentProfile()->getActiveMods().size());
-
-
-
+ emit updatePluginCount();
+ emit updateModCount();
}
@@ -2193,7 +2190,7 @@ void MainWindow::directory_refreshed()
void MainWindow::esplist_changed()
{
- ui->activePluginsCounter->display(m_OrganizerCore.pluginList()->enabledCount());
+ emit updatePluginCount();
}
void MainWindow::modorder_changed()
@@ -2453,7 +2450,7 @@ void MainWindow::restoreBackup_clicked()
void MainWindow::modlistChanged(const QModelIndex&, int)
{
m_OrganizerCore.currentProfile()->writeModlist();
- ui->activeModsCounter->display((int)m_OrganizerCore.currentProfile()->getActiveMods().size());
+ emit updateModCount();
}
void MainWindow::modlistSelectionChanged(const QModelIndex &current, const QModelIndex&)
@@ -3004,6 +3001,101 @@ void MainWindow::searchClear_activated()
}
}
+void MainWindow::updateModCount()
+{
+ int activeCount = 0;
+ int backupCount = 0;
+ int foreignCount = 0;
+ int separatorCount = 0;
+ int regularCount = 0;
+
+ QStringList allMods = m_OrganizerCore.modList()->allMods();
+
+ auto hasFlag = [](std::vector<ModInfo::EFlag> flags, ModInfo::EFlag filter) {
+ return std::find(flags.begin(), flags.end(), filter) != flags.end();
+ };
+
+ for (QString mod : allMods) {
+ int modIndex = ModInfo::getIndex(mod);
+ ModInfo::Ptr modInfo = ModInfo::getByIndex(modIndex);
+ std::vector<ModInfo::EFlag> modFlags = modInfo->getFlags();
+ for (auto flag : modFlags) {
+ switch (flag) {
+ case ModInfo::FLAG_BACKUP: backupCount++; break;
+ case ModInfo::FLAG_FOREIGN: foreignCount++; break;
+ case ModInfo::FLAG_SEPARATOR: separatorCount++; break;
+ }
+ }
+
+ if (!hasFlag(modFlags, ModInfo::FLAG_BACKUP) &&
+ !hasFlag(modFlags, ModInfo::FLAG_FOREIGN) &&
+ !hasFlag(modFlags, ModInfo::FLAG_SEPARATOR) &&
+ !hasFlag(modFlags, ModInfo::FLAG_OVERWRITE)) {
+ if (m_OrganizerCore.currentProfile()->modEnabled(modIndex))
+ activeCount++;
+ regularCount++;
+ }
+ }
+
+ ui->activeModsCounter->display(activeCount);
+ ui->activeModsCounter->setToolTip(tr("<table>"
+ "<tr><td>Active mods:&emsp;</td><td>%1 of %2</td></tr>"
+ "<tr><td>Unmanaged mods/DLC:&emsp;</td><td>%3</td></tr>"
+ "<tr><td>Mod backups:&emsp;</td><td>%4</td></tr>"
+ "<tr><td>Separators:&emsp;</td><td>%5</td></tr>"
+ "</table>")
+ .arg(activeCount)
+ .arg(regularCount)
+ .arg(foreignCount)
+ .arg(backupCount)
+ .arg(separatorCount)
+ );
+}
+
+void MainWindow::updatePluginCount()
+{
+ int activeMasterCount = 0;
+ int activeLightMasterCount = 0;
+ int activeRegularCount = 0;
+ int masterCount = 0;
+ int lightMasterCount = 0;
+ int regularCount = 0;
+
+ PluginList *list = m_OrganizerCore.pluginList();
+
+ for (QString plugin : list->pluginNames()) {
+ bool active = list->isEnabled(plugin);
+ if (list->isMaster(plugin)) {
+ masterCount++;
+ activeMasterCount += active;
+ } else if (list->isLight(plugin) || list->isLightFlagged(plugin)) {
+ lightMasterCount++;
+ activeLightMasterCount += active;
+ } else {
+ regularCount++;
+ activeRegularCount += active;
+ }
+ }
+
+ int activeCount = activeMasterCount + activeLightMasterCount + activeRegularCount;
+ int totalCount = masterCount + lightMasterCount + regularCount;
+
+ ui->activePluginsCounter->display(activeCount);
+ ui->activePluginsCounter->setToolTip(tr("<table>"
+ "<tr><td>Active plugins:&emsp;</td><td>%1 of %2</td></tr>"
+ "<tr><td>Active ESMs:&emsp;</td><td>%3 of %4</td></tr>"
+ "<tr><td>Active ESLs:&emsp;</td><td>%5 of %6</td></tr>"
+ "<tr><td>Active ESPs:&emsp;</td><td>%7 of %8</td></tr>"
+ "<tr><td>Active ESMs+ESPs:&emsp;</td><td>%9 of %10</td></tr>"
+ "</table>")
+ .arg(activeCount).arg(totalCount)
+ .arg(activeMasterCount).arg(masterCount)
+ .arg(activeLightMasterCount).arg(lightMasterCount)
+ .arg(activeRegularCount).arg(regularCount)
+ .arg(activeMasterCount+activeRegularCount).arg(masterCount+regularCount)
+ );
+}
+
void MainWindow::information_clicked()
{
try {
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 61113b8c..654a11d5 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -586,6 +586,9 @@ private slots:
void search_activated();
void searchClear_activated();
+ void updateModCount();
+ void updatePluginCount();
+
private slots: // ui slots
// actions
void on_actionAdd_Profile_triggered();
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index 1c2a5aed..1180dee0 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -304,6 +304,9 @@ p, li { white-space: pre-wrap; }
</item>
<item>
<widget class="QLCDNumber" name="activeModsCounter">
+ <property name="whatsThis">
+ <string>This provides statistics about the mod list. The total number of active mod is normally displayed. Other statistics may be accessed with the tooltip of this counter.</string>
+ </property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
@@ -916,14 +919,17 @@ p, li { white-space: pre-wrap; }
</item>
<item>
<widget class="QLCDNumber" name="activePluginsCounter">
+ <property name="whatsThis">
+ <string>This provides statistics about the plugin list. The total number of active plugins is normally displayed. Other statistics may be accessed with the tooltip of this counter.</string>
+ </property>
<property name="frameShadow">
<enum>QFrame::Sunken</enum>
</property>
<property name="digitCount">
- <number>3</number>
+ <number>4</number>
</property>
<property name="segmentStyle">
- <enum>QLCDNumber::Outline</enum>
+ <enum>QLCDNumber::Flat</enum>
</property>
</widget>
</item>