diff --git a/tests/src/components/contacts/ContactModel.hpp b/tests/src/components/contacts/ContactModel.hpp index a6f509a52..46c4517e1 100644 --- a/tests/src/components/contacts/ContactModel.hpp +++ b/tests/src/components/contacts/ContactModel.hpp @@ -45,7 +45,10 @@ class ContactModel : public QObject { ); public: - ContactModel (std::shared_ptr linphone_friend) { + ContactModel ( + QObject *parent, + std::shared_ptr linphone_friend + ) : QObject(parent) { m_linphone_friend = linphone_friend; } diff --git a/tests/src/components/contacts/ContactsListModel.cpp b/tests/src/components/contacts/ContactsListModel.cpp index 5122c62e6..1cda53af8 100644 --- a/tests/src/components/contacts/ContactsListModel.cpp +++ b/tests/src/components/contacts/ContactsListModel.cpp @@ -14,7 +14,7 @@ ContactsListModel::ContactsListModel (QObject *parent): QAbstractListModel(paren // Init contacts with linphone friends list. for (const auto &friend_ : m_linphone_friends->getFriends()) { - ContactModel *contact = new ContactModel(friend_); + ContactModel *contact = new ContactModel(this, friend_); m_friend_to_contact[friend_.get()] = contact; m_list << contact; } @@ -40,18 +40,13 @@ QVariant ContactsListModel::data (const QModelIndex &index, int role) const { // ------------------------------------------------------------------- -ContactModel *ContactsListModel::mapLinphoneFriendToContact ( - const shared_ptr &friend_ -) const { - return m_friend_to_contact[friend_.get()]; -} - ContactModel *ContactsListModel::mapSipAddressToContact (const QString &sipAddress) const { - ContactModel *contact = m_friend_to_contact[ + // Maybe use a hashtable in future version to get a lower cost? + ContactModel *contact = m_friend_to_contact.value( m_linphone_friends->findFriendByUri( sipAddress.toStdString() ).get() - ]; + ); qInfo() << "Map sip address to contact:" << sipAddress << "->" << contact; diff --git a/tests/src/components/contacts/ContactsListModel.hpp b/tests/src/components/contacts/ContactsListModel.hpp index 87c25e37f..9de9ca4d0 100644 --- a/tests/src/components/contacts/ContactsListModel.hpp +++ b/tests/src/components/contacts/ContactsListModel.hpp @@ -22,10 +22,6 @@ public: QHash roleNames () const; QVariant data (const QModelIndex &index, int role) const; - ContactModel *mapLinphoneFriendToContact ( - const std::shared_ptr &friend_ - ) const; - public slots: ContactModel *mapSipAddressToContact (const QString &sipAddress) const; diff --git a/tests/src/components/contacts/ContactsListProxyModel.cpp b/tests/src/components/contacts/ContactsListProxyModel.cpp index 40461d86d..5fe087625 100644 --- a/tests/src/components/contacts/ContactsListProxyModel.cpp +++ b/tests/src/components/contacts/ContactsListProxyModel.cpp @@ -31,6 +31,9 @@ const QRegExp ContactsListProxyModel::m_search_separators("^[^_.-;@ ][_.-;@ ]"); // ------------------------------------------------------------------- ContactsListProxyModel::ContactsListProxyModel (QObject *parent) : QSortFilterProxyModel(parent) { + if (m_list == nullptr) + qFatal("Contacts list model is undefined."); + setSourceModel(m_list); setFilterCaseSensitivity(Qt::CaseInsensitive); diff --git a/tests/ui/modules/Linphone/Contact/Contact.qml b/tests/ui/modules/Linphone/Contact/Contact.qml index f6b708bad..a1b36ddbd 100644 --- a/tests/ui/modules/Linphone/Contact/Contact.qml +++ b/tests/ui/modules/Linphone/Contact/Contact.qml @@ -9,6 +9,8 @@ import Utils 1.0 // =================================================================== Rectangle { + id: item + property alias actions: actionBar.data property alias sipAddressColor: description.sipAddressColor property alias usernameColor: description.usernameColor @@ -16,6 +18,9 @@ Rectangle { // Can be a contact object or just a sip address. property var contact + // Override contact.sipAddress if used. + property var sipAddress + color: 'transparent' // No color by default. height: ContactStyle.height @@ -46,7 +51,7 @@ Rectangle { Layout.fillWidth: true sipAddress: Utils.isString(contact) ? contact - : contact.sipAddress + : item.sipAddress || contact.sipAddress username: avatar.username } diff --git a/tests/ui/modules/Linphone/Timeline.qml b/tests/ui/modules/Linphone/Timeline.qml index c5d47fe1a..afb4ee777 100644 --- a/tests/ui/modules/Linphone/Timeline.qml +++ b/tests/ui/modules/Linphone/Timeline.qml @@ -88,6 +88,7 @@ ColumnLayout { : TimelineStyle.contact.backgroundColor.b ) contact: parent.contact + sipAddress: $timelineEntry.sipAddresses sipAddressColor: view.currentIndex === index ? TimelineStyle.contact.sipAddress.color.selected : TimelineStyle.contact.sipAddress.color.normal