summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2015-09-10 12:41:02 (GMT)
committerKevin Smith <kevin.smith@isode.com>2015-09-22 15:13:59 (GMT)
commit4f2824b115a9c713e6439d91360a7c7362522b91 (patch)
tree5c491bc757438012a80a6884196ddc186c4d5419
parent74116593461c0c7b233dad96034768264e7a59ec (diff)
downloadswift-4f2824b115a9c713e6439d91360a7c7362522b91.zip
swift-4f2824b115a9c713e6439d91360a7c7362522b91.tar.bz2
Keep scroll position in highlight rule editor when moving rules
When moving a rule up or down in the highlight rule editor on Linux, the scroll area scrolled all the way down after each move. This problem is not reproducible on OS X. With this commit the dialog remembers the scroll area position before moving a rule and sets the scroll position back to the remembered value after the move of the highlight rule. Test-Information: Verified that the scroll position is not changed when moving highlight rules up or down on Debian 8.2 and OS X 10.9.5. Change-Id: Ide7c99e1311671c77cbf72da5cad4f64bfaab11f
-rw-r--r--Swift/QtUI/QtHighlightEditor.cpp17
-rw-r--r--Swift/QtUI/QtHighlightEditor.h4
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_;