diff --git a/tests/src/components/contacts/ContactModel.cpp b/tests/src/components/contacts/ContactModel.cpp index c26e2a047..107dbd395 100644 --- a/tests/src/components/contacts/ContactModel.cpp +++ b/tests/src/components/contacts/ContactModel.cpp @@ -2,22 +2,6 @@ // =================================================================== -QString ContactModel::getUsername () const { - return m_username; -} - -void ContactModel::setUsername (const QString &username) { - m_username = username; -} - -QString ContactModel::getAvatar () const { - return m_avatar; -} - -void ContactModel::setAvatar (const QString &avatar) { - m_avatar = avatar; -} - Presence::PresenceStatus ContactModel::getPresenceStatus () const { return m_presence_status; } diff --git a/tests/src/components/contacts/ContactModel.hpp b/tests/src/components/contacts/ContactModel.hpp index 5c41e0c39..a6f509a52 100644 --- a/tests/src/components/contacts/ContactModel.hpp +++ b/tests/src/components/contacts/ContactModel.hpp @@ -17,14 +17,12 @@ class ContactModel : public QObject { Q_PROPERTY( QString username READ getUsername - WRITE setUsername NOTIFY contactUpdated ); Q_PROPERTY( QString avatar READ getAvatar - WRITE setAvatar NOTIFY contactUpdated ); @@ -55,26 +53,25 @@ signals: void contactUpdated (); private: - QString getUsername () const; - void setUsername (const QString &username); + QString getUsername () const { + return Utils::linphoneStringToQString( + m_linphone_friend->getName() + ); + } - QString getAvatar () const; - void setAvatar (const QString &avatar); + QString getAvatar () const { + return ""; + } Presence::PresenceStatus getPresenceStatus () const; Presence::PresenceLevel getPresenceLevel () const; QString getSipAddress () const { - // FIXME. - return "toto@linphone.org"; - return Utils::linphoneStringToQString( m_linphone_friend->getAddress()->asString() ); } - QString m_username; - QString m_avatar; Presence::PresenceStatus m_presence_status = Presence::Offline; std::shared_ptr m_linphone_friend; diff --git a/tests/src/components/contacts/ContactsListProxyModel.cpp b/tests/src/components/contacts/ContactsListProxyModel.cpp index 57751032b..8a236e898 100644 --- a/tests/src/components/contacts/ContactsListProxyModel.cpp +++ b/tests/src/components/contacts/ContactsListProxyModel.cpp @@ -45,7 +45,9 @@ void ContactsListProxyModel::initContactsListModel (ContactsListModel *list) { qWarning() << "Contacts list model is already defined."; } -bool ContactsListProxyModel::filterAcceptsRow (int source_row, const QModelIndex &source_parent) const { +bool ContactsListProxyModel::filterAcceptsRow ( + int source_row, const QModelIndex &source_parent +) const { QModelIndex index = sourceModel()->index(source_row, 0, source_parent); const ContactModel *contact = qvariant_cast( index.data() @@ -74,7 +76,7 @@ bool ContactsListProxyModel::lessThan (const QModelIndex &left, const QModelInde return ( weight_a > weight_b || ( weight_a == weight_b && - contact_a->m_username <= contact_b->m_username + contact_a->m_linphone_friend->getName() <= contact_b->m_linphone_friend->getName() ) ); } @@ -112,26 +114,28 @@ float ContactsListProxyModel::computeStringWeight (const QString &string, float } float ContactsListProxyModel::computeContactWeight (const ContactModel &contact) const { - float weight = computeStringWeight(contact.m_username, USERNAME_WEIGHT); + float weight = computeStringWeight(contact.getUsername(), USERNAME_WEIGHT); - // It exists at least one sip address. + // Get all contact's addresses. const std::list > addresses = contact.m_linphone_friend->getAddresses(); - // FIXME. - return 0; - weight += computeStringWeight(contact.getSipAddress(), MAIN_SIP_ADDRESS_WEIGHT); + auto it = addresses.cbegin(); + + // It exists at least one sip address. + weight += computeStringWeight( + Utils::linphoneStringToQString((*it)->asString()), + MAIN_SIP_ADDRESS_WEIGHT + ); // Compute for other addresses. int size = addresses.size(); - return 0; - if (size > 1) - for (auto it = ++addresses.cbegin(); it != addresses.cend(); ++it) - weight += computeStringWeight( - Utils::linphoneStringToQString((*it)->asString()), - OTHER_SIP_ADDRESSES_WEIGHT / size - ); + for (++it; it != addresses.cend(); ++it) + weight += computeStringWeight( + Utils::linphoneStringToQString((*it)->asString()), + OTHER_SIP_ADDRESSES_WEIGHT / size + ); return weight; } diff --git a/tests/src/utils.hpp b/tests/src/utils.hpp new file mode 100644 index 000000000..ac6aa1f55 --- /dev/null +++ b/tests/src/utils.hpp @@ -0,0 +1,7 @@ +#include + +namespace Utils { + inline QString linphoneStringToQString (const std::string &string) { + return QString::fromLocal8Bit(string.c_str(), string.size()); + } +} diff --git a/tests/ui/modules/Linphone/Contact/Avatar.qml b/tests/ui/modules/Linphone/Contact/Avatar.qml index 8edde27e2..ddeb65ba5 100644 --- a/tests/ui/modules/Linphone/Contact/Avatar.qml +++ b/tests/ui/modules/Linphone/Contact/Avatar.qml @@ -12,7 +12,7 @@ Item { property alias presenceLevel: presenceLevel.level property string username - property var _initialsRegex: /^\s*([^\s]+)(?:\s+([^\s]+))?/ + property var _initialsRegex: /^\s*([^\s\.]+)(?:[\s\.]+([^\s\.]+))?/ function _computeInitials () { var result = username.match(_initialsRegex) @@ -22,12 +22,11 @@ Item { 'Unable to get initials of: \'' + username + '\'' ) - return result[1].charAt(0).toUpperCase() + - ( - result[2] != null - ? result[2].charAt(0).toUpperCase() - : '' - ) + return result[1].charAt(0).toUpperCase() + ( + result[2] != null + ? result[2].charAt(0).toUpperCase() + : '' + ) } // Image mask. (Circle) diff --git a/tests/ui/views/App/MainWindow/Contacts.qml b/tests/ui/views/App/MainWindow/Contacts.qml index d42206755..84930eefc 100644 --- a/tests/ui/views/App/MainWindow/Contacts.qml +++ b/tests/ui/views/App/MainWindow/Contacts.qml @@ -36,7 +36,7 @@ ColumnLayout { }) } - spacing: Notifier.showCallMessage(5000, "toto@toto.com") || 0 + spacing: 0 // ----------------------------------------------------------------- // Search Bar & actions.