From bc9cf90c1b464da53d31014e63a80b8928974359 Mon Sep 17 00:00:00 2001 From: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com> Date: Thu, 7 Jan 2016 14:27:55 -0500 Subject: [PATCH] recentmodel: improve selection behaviour The parent idx should not be selected if the child is part of a conference or if the parent has multiple calls. Change-Id: I2b74fd2c5bfee959487b3437e3aa9f9a490a5d04 Tuleap: #203 --- src/recentmodel.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/recentmodel.cpp b/src/recentmodel.cpp index 308fd9dd..ebf19ed3 100644 --- a/src/recentmodel.cpp +++ b/src/recentmodel.cpp @@ -1048,7 +1048,15 @@ RecentModelPrivate::slotCurrentCallChanged(const QModelIndex ¤t, const QMo { auto callIdx = q_ptr->getIndex(CallModel::instance().getCall(current)); if (callIdx.isValid()) { - q_ptr->selectionModel()->setCurrentIndex(q_ptr->isConference(callIdx) ? callIdx : callIdx.parent(), 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 parentIdx = callIdx.parent(); + 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); } else { q_ptr->selectionModel()->clearCurrentIndex(); } -- GitLab