diff options
-rw-r--r-- | Swift/QtUI/QtHighlightEditor.cpp | 17 | ||||
-rw-r--r-- | Swift/QtUI/QtHighlightEditor.h | 4 |
2 files changed, 14 insertions, 7 deletions
diff --git a/Swift/QtUI/QtHighlightEditor.cpp b/Swift/QtUI/QtHighlightEditor.cpp index 7aea26b..50d1f78 100644 --- a/Swift/QtUI/QtHighlightEditor.cpp +++ b/Swift/QtUI/QtHighlightEditor.cpp @@ -17,6 +17,7 @@ #include <boost/lexical_cast.hpp> #include <QFileDialog> +#include <QScrollBar> #include <QTreeWidgetItem> #include <Swift/Controllers/HighlightManager.cpp> @@ -203,20 +204,24 @@ void QtHighlightEditor::onDeleteButtonClicked() } } +void QtHighlightEditor::moveRowFromTo(int fromRow, int toRow) { + int verticalScrollAreaPosition = ui_.scrollArea->verticalScrollBar()->value(); + highlightManager_->swapRules(fromRow, toRow); + populateList(); + selectRow(toRow); + ui_.scrollArea->verticalScrollBar()->setValue(verticalScrollAreaPosition); +} + void QtHighlightEditor::onUpButtonClicked() { const size_t moveFrom = ui_.listWidget->currentRow(); const size_t moveTo = moveFrom - 1; - highlightManager_->swapRules(moveFrom, moveTo); - populateList(); - selectRow(moveTo); + moveRowFromTo(moveFrom, moveTo); } void QtHighlightEditor::onDownButtonClicked() { const size_t moveFrom = ui_.listWidget->currentRow(); const size_t moveTo = moveFrom + 1; - highlightManager_->swapRules(moveFrom, moveTo); - populateList(); - selectRow(moveTo); + moveRowFromTo(moveFrom, moveTo); } void QtHighlightEditor::onCurrentRowChanged(int currentRow) diff --git a/Swift/QtUI/QtHighlightEditor.h b/Swift/QtUI/QtHighlightEditor.h index bcceb72..eb6a52b 100644 --- a/Swift/QtUI/QtHighlightEditor.h +++ b/Swift/QtUI/QtHighlightEditor.h @@ -12,9 +12,10 @@ #pragma once +#include <Swift/QtUI/ui_QtHighlightEditor.h> + #include <Swift/Controllers/HighlightRule.h> #include <Swift/Controllers/UIInterfaces/HighlightEditorWindow.h> -#include <Swift/QtUI/ui_QtHighlightEditor.h> namespace Swift { @@ -61,6 +62,7 @@ namespace Swift { HighlightRule ruleFromDialog(); void ruleToDialog(const HighlightRule& rule); void updateResetToDefaultRulesVisibility(); + void moveRowFromTo(int fromRow, int toRow); Ui::QtHighlightEditor ui_; QtSettingsProvider* settings_; |