Skip to content
Snippets Groups Projects
Commit f957600b authored by Stepan Salenikovich's avatar Stepan Salenikovich
Browse files

improve RecentModel::getIndex(ContactMethod*) behaviour

ContactMethods which are associated with a Person are not contained
in the RecentModel as items. Thus we amend the getIndex function to
also check if the given ContactMethod is associated with a Person
which is an item in the model, instead of just returning an invalid
QModelIndex in this case.

Change-Id: I996d08bb7d9a550bd3f027348b350b3b0bc631b9
Tuleap: #956
parent 0d89d690
No related branches found
No related tags found
No related merge requests found
...@@ -400,11 +400,16 @@ RecentModel::getIndex(Person *p) const ...@@ -400,11 +400,16 @@ RecentModel::getIndex(Person *p) const
QModelIndex QModelIndex
RecentModel::getIndex(ContactMethod *cm) const RecentModel::getIndex(ContactMethod *cm) const
{ {
// check if the CM is an item the RecentModel
if (d_ptr->m_hCMsToNodes.contains(cm)) { if (d_ptr->m_hCMsToNodes.contains(cm)) {
if (auto node = d_ptr->m_hCMsToNodes.value(cm)) if (auto node = d_ptr->m_hCMsToNodes.value(cm))
return index(node->m_Index, 0); return index(node->m_Index, 0);
} }
// otherwise, its possible the CM is contained within a Person item
if (auto person = cm->contact())
return getIndex(person);
return {}; return {};
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment