diff options
author | Christian Stenger <christian.stenger@theqtcompany.com> | 2015-04-16 08:54:41 +0200 |
---|---|---|
committer | Christian Stenger <christian.stenger@theqtcompany.com> | 2015-06-17 15:06:45 +0300 |
commit | 0afd504748f49ae6c6d77403fd1d6f6604b6eaa8 (patch) | |
tree | ac76947fe1d4e0ea0275bc3d01bb868fe4fc2d53 /plugins/autotest/testresultspane.cpp | |
parent | eeccdfbd54359d26690fdb53610cd122a12db09f (diff) | |
download | qt-creator-0afd504748f49ae6c6d77403fd1d6f6604b6eaa8.tar.gz |
Add auto-scroll feature for results pane
Change-Id: Iff209384c2bf30b3ce2b9241ce1c719a44592e65
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
Diffstat (limited to 'plugins/autotest/testresultspane.cpp')
-rw-r--r-- | plugins/autotest/testresultspane.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/plugins/autotest/testresultspane.cpp b/plugins/autotest/testresultspane.cpp index 0d6b9052b8..9ebb1c09fb 100644 --- a/plugins/autotest/testresultspane.cpp +++ b/plugins/autotest/testresultspane.cpp @@ -37,6 +37,7 @@ #include <QDebug> #include <QHBoxLayout> #include <QMenu> +#include <QScrollBar> #include <QToolButton> #include <QVBoxLayout> @@ -46,7 +47,8 @@ namespace Internal { TestResultsPane::TestResultsPane(QObject *parent) : Core::IOutputPane(parent), m_context(new Core::IContext(this)), - m_wasVisibleBefore(false) + m_wasVisibleBefore(false), + m_autoScroll(false) { m_outputWidget = new QWidget; QVBoxLayout *outputLayout = new QVBoxLayout; @@ -144,6 +146,9 @@ TestResultsPane::~TestResultsPane() void TestResultsPane::addTestResult(const TestResult &result) { + const QScrollBar *scrollBar = m_treeView->verticalScrollBar(); + m_atEnd = scrollBar ? scrollBar->value() == scrollBar->maximum() : true; + m_model->addTestResult(result); if (!m_treeView->isVisible()) popup(Core::IOutputPane::NoModeSwitch); @@ -181,6 +186,9 @@ void TestResultsPane::clearContents() m_filterModel->clearTestResults(); navigateStateChanged(); m_summaryWidget->setVisible(false); + m_autoScroll = AutotestPlugin::instance()->settings()->autoScroll; + connect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged, + this, &TestResultsPane::onScrollBarRangeChanged, Qt::UniqueConnection); } void TestResultsPane::visibilityChanged(bool visible) @@ -381,6 +389,14 @@ void TestResultsPane::onTestRunFinished() updateSummaryLabel(); m_summaryWidget->setVisible(true); m_model->removeCurrentTestMessage(); + disconnect(m_treeView->verticalScrollBar(), &QScrollBar::rangeChanged, + this, &TestResultsPane::onScrollBarRangeChanged); +} + +void TestResultsPane::onScrollBarRangeChanged(int, int max) +{ + if (m_autoScroll && m_atEnd) + m_treeView->verticalScrollBar()->setValue(max); } void TestResultsPane::onTestTreeModelChanged() |