From de41e85c3b17f6ed1db11e9a358edaae6d9492c7 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Tue, 27 Sep 2016 12:40:46 +0200 Subject: Sessions: select created session This was a regression after refactoring the session dialog. Change-Id: I891b037d512a70a591f32e0ca5e0f801799ce424 Reviewed-by: Eike Ziller --- src/plugins/projectexplorer/sessionmodel.cpp | 1 + src/plugins/projectexplorer/sessionmodel.h | 1 + src/plugins/projectexplorer/sessionview.cpp | 11 +++++++++-- src/plugins/projectexplorer/sessionview.h | 1 + 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/sessionmodel.cpp b/src/plugins/projectexplorer/sessionmodel.cpp index 590393054a..ffb811983a 100644 --- a/src/plugins/projectexplorer/sessionmodel.cpp +++ b/src/plugins/projectexplorer/sessionmodel.cpp @@ -228,6 +228,7 @@ void SessionModel::runNewSessionDialog(const QString &suggestedName, std::functi if (newSessionInputDialog.isSwitchToRequested()) switchToSession(newSession); + emit sessionCreated(newSession); } } diff --git a/src/plugins/projectexplorer/sessionmodel.h b/src/plugins/projectexplorer/sessionmodel.h index 42a4c0df4d..66a75242d4 100644 --- a/src/plugins/projectexplorer/sessionmodel.h +++ b/src/plugins/projectexplorer/sessionmodel.h @@ -55,6 +55,7 @@ public: signals: void sessionSwitched(); + void sessionCreated(const QString &sessionName); public slots: void resetSessions(); diff --git a/src/plugins/projectexplorer/sessionview.cpp b/src/plugins/projectexplorer/sessionview.cpp index 1958a20e87..f08438d07b 100644 --- a/src/plugins/projectexplorer/sessionview.cpp +++ b/src/plugins/projectexplorer/sessionview.cpp @@ -75,11 +75,13 @@ SessionView::SessionView(QWidget *parent) (const QModelIndex &index) { emit selected(m_sessionModel.sessionAt(index.row())); }); + connect(&m_sessionModel, &SessionModel::sessionSwitched, this, &SessionView::sessionSwitched); - connect(&m_sessionModel, &SessionModel::modelReset, this, &SessionView::selectActiveSession); + connect(&m_sessionModel, &SessionModel::sessionCreated, + this, &SessionView::selectSession); } void SessionView::createNewSession() @@ -119,7 +121,12 @@ SessionModel *SessionView::sessionModel() void SessionView::selectActiveSession() { - int row = m_sessionModel.indexOfSession(SessionManager::activeSession()); + selectSession(SessionManager::activeSession()); +} + +void SessionView::selectSession(const QString &sessionName) +{ + int row = m_sessionModel.indexOfSession(sessionName); selectionModel()->setCurrentIndex(model()->index(row, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); } diff --git a/src/plugins/projectexplorer/sessionview.h b/src/plugins/projectexplorer/sessionview.h index efbc576e96..ba42e33d5d 100644 --- a/src/plugins/projectexplorer/sessionview.h +++ b/src/plugins/projectexplorer/sessionview.h @@ -48,6 +48,7 @@ public: QString currentSession(); SessionModel* sessionModel(); void selectActiveSession(); + void selectSession(const QString &sessionName); protected: void showEvent(QShowEvent* event) override; -- cgit v1.2.1