From f145e1de8e421a4f01f7c22614f7ecbce3b15727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20G=C3=A2teau?= Date: Tue, 29 May 2012 17:36:24 +0200 Subject: [PATCH] Fix behavior of "runners" property This commit changes the behavior of the "runners" property when no manager has been created yet: - Setting the property emits runnersChanged() (unless it is the same as the old value) - Reading the property after setting it returns the new value REVIEW: 105024 --- declarativeimports/krunnermodel/runnermodel.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/declarativeimports/krunnermodel/runnermodel.cpp b/declarativeimports/krunnermodel/runnermodel.cpp index 0c925544a..5bd5db1e1 100644 --- a/declarativeimports/krunnermodel/runnermodel.cpp +++ b/declarativeimports/krunnermodel/runnermodel.cpp @@ -69,14 +69,20 @@ int RunnerModel::count() const QStringList RunnerModel::runners() const { - return m_manager ? m_manager->allowedRunners() : QStringList(); + return m_manager ? m_manager->allowedRunners() : m_pendingRunnersList; } void RunnerModel::setRunners(const QStringList &allowedRunners) { + //use sets to ensure comparison is order-independent + if (allowedRunners.toSet() == runners().toSet()) { + return; + } if (m_manager) { m_manager->setAllowedRunners(allowedRunners); - emit runnersChanged(); + + //automagically enter single runner mode if there's only 1 allowed runner + m_manager->setSingleMode(allowedRunners.count() == 1); } else { m_pendingRunnersList = allowedRunners; kDebug() << "runners set" << m_pendingRunnersList.count(); @@ -89,6 +95,7 @@ void RunnerModel::setRunners(const QStringList &allowedRunners) } else { m_singleRunnerId.clear(); } + emit runnersChanged(); } void RunnerModel::run(int index)