diff options
| author | Silarn <jrim@rimpo.org> | 2019-12-08 20:47:45 -0600 |
|---|---|---|
| committer | Silarn <jrim@rimpo.org> | 2019-12-08 20:48:14 -0600 |
| commit | 44084bfa415f906b8ba8b5d19e1be60a7612d692 (patch) | |
| tree | 05cd7150f80ba890f95d5b8a331d06accf5707e3 | |
| parent | a4db0db94ff67b52a7a3b9b43eca5cce5fae5fc3 (diff) | |
Rework column insertion to move to the intended position post-facto
| -rw-r--r-- | src/main.cpp | 2 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 41 | ||||
| -rw-r--r-- | src/mainwindow.h | 2 | ||||
| -rw-r--r-- | src/modlist.h | 5 |
4 files changed, 29 insertions, 21 deletions
diff --git a/src/main.cpp b/src/main.cpp index 1f6c57d1..eeabd497 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -735,8 +735,6 @@ int runApplication(MOApplication &application, SingleInstance &instance, QObject::connect(&instance, SIGNAL(messageSent(QString)), &organizer, SLOT(externalMessage(QString))); - mainWindow.processUpdates(settings); - // this must be before readSettings(), see DockFixer in mainwindow.cpp splash.finish(&mainWindow); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8eff26c5..585be402 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -178,6 +178,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>. #include <stdexcept> #include <sstream> #include <utility> +#include <iterator> #ifdef TEST_MODELS #include "modeltest.h" @@ -511,6 +512,7 @@ MainWindow::MainWindow(Settings &settings resetActionIcons(); updatePluginCount(); updateModCount(); + processUpdates(); } void MainWindow::setupModList() @@ -2299,7 +2301,8 @@ void MainWindow::readSettings() } } -void MainWindow::processUpdates(Settings& settings) { +void MainWindow::processUpdates() { + auto& settings = m_OrganizerCore.settings(); const auto earliest = QVersionNumber::fromString("2.1.2").normalized(); const auto lastVersion = settings.version().value_or(earliest); @@ -2308,15 +2311,6 @@ void MainWindow::processUpdates(Settings& settings) { settings.processUpdates(currentVersion, lastVersion); if (!settings.firstStart()) { - if (lastVersion < QVersionNumber(2, 1, 3)) { - bool lastHidden = true; - for (int i = ui->modList->header()->visualIndex(ModList::COL_GAME); i < ui->modList->header()->count(); ++i) { - bool hidden = ui->modList->header()->isSectionHidden(ui->modList->header()->logicalIndex(i)); - ui->modList->header()->setSectionHidden(ui->modList->header()->logicalIndex(i), lastHidden); - lastHidden = hidden; - } - } - if (lastVersion < QVersionNumber(2, 1, 6)) { ui->modList->header()->setSectionHidden(ModList::COL_NOTES, true); } @@ -2329,11 +2323,28 @@ void MainWindow::processUpdates(Settings& settings) { } if (lastVersion < QVersionNumber(2, 2, 2)) { - bool lastHidden = true; - for (int i = ui->modList->header()->visualIndex(ModList::COL_CONFLICTFLAGS); i < ui->modList->header()->count(); ++i) { - bool hidden = ui->modList->header()->isSectionHidden(ui->modList->header()->logicalIndex(i)); - ui->modList->header()->setSectionHidden(ui->modList->header()->logicalIndex(i), lastHidden); - lastHidden = hidden; + int pos1 = ui->modList->columnViewportPosition(ModList::COL_FLAGS); + int pos2 = 0; + if (pos1) { + ui->modList->showColumn(ModList::COL_CONFLICTFLAGS); + pos2 = ui->modList->columnViewportPosition(ModList::COL_CONFLICTFLAGS); + ui->modList->header()->moveSection( + ui->modList->header()->visualIndexAt(pos2), + ui->modList->header()->visualIndexAt(pos1) + ); + } + } + } else { + { // Move conflict flags + int pos1 = ui->modList->columnViewportPosition(ModList::COL_FLAGS); + int pos2 = 0; + if (pos1) { + ui->modList->showColumn(ModList::COL_CONFLICTFLAGS); + pos2 = ui->modList->columnViewportPosition(ModList::COL_CONFLICTFLAGS); + ui->modList->header()->moveSection( + ui->modList->header()->visualIndexAt(pos2), + ui->modList->header()->visualIndexAt(pos1) + ); } } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 2020b1a3..fcbbe039 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -116,7 +116,7 @@ public: QWidget *parent = 0); ~MainWindow(); - void processUpdates(Settings& settings); + void processUpdates(); QWidget* qtWidget() override; diff --git a/src/modlist.h b/src/modlist.h index 8841ec29..ce439f7b 100644 --- a/src/modlist.h +++ b/src/modlist.h @@ -57,7 +57,6 @@ public: enum EColumn {
COL_NAME,
- COL_CONFLICTFLAGS,
COL_FLAGS,
COL_CONTENT,
COL_CATEGORY,
@@ -67,8 +66,8 @@ public: COL_INSTALLTIME,
COL_PRIORITY,
COL_NOTES,
-
- COL_LASTCOLUMN = COL_NOTES
+ COL_CONFLICTFLAGS,
+ COL_LASTCOLUMN = COL_CONFLICTFLAGS,
};
typedef boost::signals2::signal<void (const QString &, ModStates)> SignalModStateChanged;
|
