From 33405a6f5cd40d82fd81480596ef2b551c404ca7 Mon Sep 17 00:00:00 2001 From: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com> Date: Wed, 13 Jan 2016 12:03:56 -0500 Subject: [PATCH] RecentModel: fix selection on insertCallNode The index it was trying to select was wrong as it did not take its parent index as an argument. The selection is also now consistent with what happens when the CallModel selection changes. Change-Id: I364b059f872feaf17529eb57198d69ee8101e034 Tuleap: #203 --- src/recentmodel.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/recentmodel.cpp b/src/recentmodel.cpp index c689765c..acb17c48 100644 --- a/src/recentmodel.cpp +++ b/src/recentmodel.cpp @@ -782,8 +782,15 @@ RecentModelPrivate::insertCallNode(RecentViewNode *parent, RecentViewNode* callN emit q_ptr->dataChanged(firstChild, firstChild); } - // Select the newly inserted call - q_ptr->selectionModel()->setCurrentIndex(q_ptr->index(callNode->m_Index, 0), QItemSelectionModel::ClearAndSelect); + /* in the case of a conference, we select the call; + * in case the parent only has one call, we select the parent; + * in case the parent has multiple calls, we select the call; + */ + auto callIdx = q_ptr->index(callNode->m_Index, 0, parentIdx); + if (q_ptr->isConference(callIdx) || q_ptr->isConference(parentIdx) || q_ptr->rowCount(parentIdx) > 1) + q_ptr->selectionModel()->setCurrentIndex(callIdx, QItemSelectionModel::ClearAndSelect); + else + q_ptr->selectionModel()->setCurrentIndex(callIdx.parent(), QItemSelectionModel::ClearAndSelect); } void -- GitLab