From 68142cd11a28af1724cdf20327f9a68f88befed8 Mon Sep 17 00:00:00 2001 From: Tobias Hunger <tobias.hunger@digia.com> Date: Mon, 11 Nov 2013 16:52:22 +0100 Subject: [PATCH] Session: Make Switch to button work when cloning sessions Make Switch to button work in dialog shown when cloning sessions in the session manager. Task-number: QTCREATORBUG-10701 Change-Id: I6901a6cb842eabbfa38b25f3cc4925bec43c61a4 Reviewed-by: Christian Stenger <christian.stenger@digia.com> --- src/plugins/projectexplorer/sessiondialog.cpp | 34 +++++++++---------- src/plugins/projectexplorer/sessiondialog.h | 1 + 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/plugins/projectexplorer/sessiondialog.cpp b/src/plugins/projectexplorer/sessiondialog.cpp index 0aa6b5be98e..e83b05656bf 100644 --- a/src/plugins/projectexplorer/sessiondialog.cpp +++ b/src/plugins/projectexplorer/sessiondialog.cpp @@ -186,6 +186,17 @@ void SessionDialog::markItems() } } +void SessionDialog::addSessionToUi(const QString &name, bool switchTo) +{ + m_ui.sessionList->clear(); + QStringList sessions = SessionManager::sessions(); + m_ui.sessionList->addItems(sessions); + m_ui.sessionList->setCurrentRow(sessions.indexOf(name)); + markItems(); + if (switchTo) + switchToSession(); +} + void SessionDialog::updateActions() { if (m_ui.sessionList->currentItem()) { @@ -209,18 +220,12 @@ void SessionDialog::createNew() newSessionInputDialog.setWindowTitle(tr("New session name")); if (newSessionInputDialog.exec() == QDialog::Accepted) { - QString newSession = newSessionInputDialog.value(); - if (newSession.isEmpty() || SessionManager::sessions().contains(newSession)) + QString sessionName = newSessionInputDialog.value(); + if (sessionName.isEmpty() || SessionManager::sessions().contains(sessionName)) return; - SessionManager::createSession(newSession); - m_ui.sessionList->clear(); - QStringList sessions = SessionManager::sessions(); - m_ui.sessionList->addItems(sessions); - m_ui.sessionList->setCurrentRow(sessions.indexOf(newSession)); - markItems(); - if (newSessionInputDialog.isSwitchToRequested()) - switchToSession(); + SessionManager::createSession(sessionName); + addSessionToUi(sessionName, newSessionInputDialog.isSwitchToRequested()); } } @@ -232,13 +237,8 @@ void SessionDialog::clone() if (newSessionInputDialog.exec() == QDialog::Accepted) { QString newSession = newSessionInputDialog.value(); - if (SessionManager::cloneSession(m_ui.sessionList->currentItem()->text(), newSession)) { - m_ui.sessionList->clear(); - QStringList sessions = SessionManager::sessions(); - m_ui.sessionList->addItems(sessions); - m_ui.sessionList->setCurrentRow(sessions.indexOf(newSession)); - markItems(); - } + if (SessionManager::cloneSession(m_ui.sessionList->currentItem()->text(), newSession)) + addSessionToUi(newSession, newSessionInputDialog.isSwitchToRequested()); } } diff --git a/src/plugins/projectexplorer/sessiondialog.h b/src/plugins/projectexplorer/sessiondialog.h index a00cff6e171..c3d0d76109c 100644 --- a/src/plugins/projectexplorer/sessiondialog.h +++ b/src/plugins/projectexplorer/sessiondialog.h @@ -65,6 +65,7 @@ private slots: private: void addItems(bool setDefaultSession); void markItems(); + void addSessionToUi(const QString &name, bool switchTo); Ui::SessionDialog m_ui; }; -- GitLab