diff options
| author | isanae <14251494+isanae@users.noreply.github.com> | 2019-12-09 12:53:29 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-09 12:53:29 -0500 |
| commit | b9fd1092c62f728ff55879ff98be2cddbb2f0610 (patch) | |
| tree | 10f2c976fa355171230ea4f978f2cb6af7d9d0f5 /src/mainwindow.cpp | |
| parent | 292cee7f6a2de28d13d7a3c32e668dfab41ab5ac (diff) | |
| parent | ea6c793ce6047e0c958c13b3743976bcf953bf1a (diff) | |
Merge pull request #933 from isanae/conflicts-position-on-reset
Move the conflicts column when resetting geometries
Diffstat (limited to 'src/mainwindow.cpp')
| -rw-r--r-- | src/mainwindow.cpp | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index eaecfca1..44011e5f 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -528,6 +528,8 @@ void MainWindow::setupModList() ui->modList->header()->resizeSection(column, sectionSize); } } else { + fixConflictsColumn(); + // hide these columns by default ui->modList->header()->setSectionHidden(ModList::COL_CONTENT, true); ui->modList->header()->setSectionHidden(ModList::COL_MODID, true); @@ -549,6 +551,25 @@ void MainWindow::setupModList() ui->modList->installEventFilter(m_OrganizerCore.modList()); } +void MainWindow::fixConflictsColumn() +{ + // the conflicts column should sit to the left of the flags column, but its + // enum is at the end to preserve compatibility + // + // this is called when updating from 2.2.1, or when there is no state saved + // for the mod list, so it's free to do whatever it wants with the column + + const auto flags = ui->modList->header()->visualIndex(ModList::COL_FLAGS); + const auto conflicts = ui->modList->header()->visualIndex(ModList::COL_CONFLICTFLAGS); + + // this can be called twice when migrating from 2.2.1: once in + // processUpdates() and again in setupModList() because the geometry names in + // the ini have changed; to a simple check to see if the column has been moved + if (conflicts > flags) { + ui->modList->header()->moveSection(conflicts, flags); + } +} + void MainWindow::resetActionIcons() { // this is a bit of a hack @@ -2258,29 +2279,7 @@ void MainWindow::processUpdates() { } if (lastVersion < QVersionNumber(2, 2, 2)) { - 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) - ); - } + fixConflictsColumn(); } } |
