From 982996e31bcd37dfb8ce59b3fc3fb846f1332b01 Mon Sep 17 00:00:00 2001 From: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com> Date: Tue, 4 Oct 2016 11:15:43 -0400 Subject: [PATCH] improve selection behaviour in RecentModel When the CallModel selection is cleared, check if there is still a call selected in the RecentModel; if so, then select that call in the CallModel so that the UserActionModel is updated correctly. Change-Id: Ie8262762ad28865ea454f4dba21111fa9501f2e7 Tuleap: #1072 --- src/recentmodel.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/recentmodel.cpp b/src/recentmodel.cpp index 9e9a70fd..63432b9a 100644 --- a/src/recentmodel.cpp +++ b/src/recentmodel.cpp @@ -1091,12 +1091,18 @@ RecentModelPrivate::slotCurrentCallChanged(const QModelIndex ¤t, const QMo q_ptr->selectionModel()->setCurrentIndex(callIdx, QItemSelectionModel::ClearAndSelect); else q_ptr->selectionModel()->setCurrentIndex(callIdx.parent(), QItemSelectionModel::ClearAndSelect); + } else { + /* nothing is selected in the CallModel; however, if we still have a call selected in the + * RecentModel, we need to select it in the CallModel, or else all the actions of the call + * will be invalid, since the UserActionModel is based on the selection of the CallModel */ + auto recentIdx = q_ptr->selectionModel()->currentIndex(); + auto recentCall = q_ptr->getActiveCall(recentIdx); + if (recentIdx.isValid() && recentCall) { + CallModel::instance().selectCall(recentCall); + } + /* otherwise do not update the selection in the RecentModel, eg: if a Person was selected + * and the Call is over, we still want the Person to be selected */ } - /* do not update the selection in the RecentModel if no calls selected in the CallModel; - * eg: if a Call was selected in the RecentModel, when its removed, the seleciton will - * change automatically, so no action is needed; - * if a Person was selected and the Call is over, we still want the Person to be selected; - */ } ///Filter out every data relevant to a person -- GitLab