diff --git a/linphone-app/src/components/chat-room/ChatRoomModel.cpp b/linphone-app/src/components/chat-room/ChatRoomModel.cpp index cfa87a798..c7ffde1f2 100644 --- a/linphone-app/src/components/chat-room/ChatRoomModel.cpp +++ b/linphone-app/src/components/chat-room/ChatRoomModel.cpp @@ -215,6 +215,11 @@ ChatRoomModel::ChatRoomModel (std::shared_ptr chatRoom, QObj QObject::connect(coreHandlers, &CoreHandlers::callStateChanged, this, &ChatRoomModel::handleCallStateChanged); QObject::connect(coreHandlers, &CoreHandlers::presenceStatusReceived, this, &ChatRoomModel::handlePresenceStatusReceived); //QObject::connect(coreHandlers, &CoreHandlers::isComposingChanged, this, &ChatRoomModel::handleIsComposingChanged); + + QObject::connect(coreManager->getContactsListModel(), &ContactsListModel::contactAdded, this, &ChatRoomModel::usernameChanged); + QObject::connect(coreManager->getContactsListModel(), &ContactsListModel::contactAdded, this, &ChatRoomModel::fullPeerAddressChanged); + QObject::connect(coreManager->getContactsListModel(), &ContactsListModel::contactRemoved, this, &ChatRoomModel::usernameChanged); + QObject::connect(coreManager->getContactsListModel(), &ContactsListModel::contactRemoved, this, &ChatRoomModel::fullPeerAddressChanged); //QObject::connect(this, &ChatRoomModel::messageCountReset, coreManager, &CoreManager::eventCountChanged ); if(mChatRoom){ diff --git a/linphone-app/src/components/search/SearchSipAddressesProxyModel.cpp b/linphone-app/src/components/search/SearchSipAddressesProxyModel.cpp index 6e1baaefc..4088e03e5 100644 --- a/linphone-app/src/components/search/SearchSipAddressesProxyModel.cpp +++ b/linphone-app/src/components/search/SearchSipAddressesProxyModel.cpp @@ -78,8 +78,8 @@ bool SearchSipAddressesProxyModel::filterAcceptsRow (int sourceRow, const QModel } bool SearchSipAddressesProxyModel::lessThan (const QModelIndex &left, const QModelIndex &right) const { - const QVariantMap mapA = sourceModel()->data(left).toMap(); - const QVariantMap mapB = sourceModel()->data(right).toMap(); - return SipAddressesSorter::lessThan(mFilter, mapA, mapB); + const SearchResultModel * modelA = sourceModel()->data(left).value(); + const SearchResultModel * modelB = sourceModel()->data(right).value(); + return SipAddressesSorter::lessThan(mFilter, modelA, modelB); } diff --git a/linphone-app/src/components/sip-addresses/SipAddressesSorter.cpp b/linphone-app/src/components/sip-addresses/SipAddressesSorter.cpp index 1c4cbad9e..128b4578d 100644 --- a/linphone-app/src/components/sip-addresses/SipAddressesSorter.cpp +++ b/linphone-app/src/components/sip-addresses/SipAddressesSorter.cpp @@ -24,6 +24,8 @@ #include "SipAddressesSorter.hpp" +#include "../search/SearchResultModel.hpp" + // ============================================================================= namespace { @@ -43,9 +45,10 @@ SipAddressesSorter::SipAddressesSorter (QObject *parent) : QObject(parent) { // ----------------------------------------------------------------------------- -bool SipAddressesSorter::lessThan (const QString& filter, const QVariantMap &left, const QVariantMap &right) { - const QString sipAddressA = left["sipAddress"].toString(); - const QString sipAddressB = right["sipAddress"].toString(); +//bool SipAddressesSorter::lessThan (const QString& filter, const QVariantMap &left, const QVariantMap &right) { +bool SipAddressesSorter::lessThan (const QString& filter, const SearchResultModel *left, const SearchResultModel *right) { + const QString sipAddressA = left->getAddressString(); + const QString sipAddressB = right->getAddressString(); // TODO: Use a cache, do not compute the same value as `filterAcceptsRow`. int weightA = computeEntryWeight(filter, left); @@ -55,8 +58,8 @@ bool SipAddressesSorter::lessThan (const QString& filter, const QVariantMap &lef if (weightA != weightB) return weightA > weightB; - const ContactModel *contactA = left.value("contact").value(); - const ContactModel *contactB = right.value("contact").value(); + const ContactModel *contactA = left->getContactModel(); + const ContactModel *contactB = right->getContactModel(); // 2. No contacts. if (!contactA && !contactB) @@ -79,10 +82,10 @@ bool SipAddressesSorter::lessThan (const QString& filter, const QVariantMap &lef return sipAddressA <= sipAddressB; } -int SipAddressesSorter::computeEntryWeight (const QString& filter, const QVariantMap &entry) { - int weight = computeStringWeight(filter, entry["sipAddress"].toString().mid(4)); +int SipAddressesSorter::computeEntryWeight (const QString& filter, const SearchResultModel *entry) { + int weight = computeStringWeight(filter, entry->getAddressString().mid(4)); - const ContactModel *contact = entry.value("contact").value(); + const ContactModel *contact = entry->getContactModel(); if (contact) weight += computeStringWeight(filter, contact->getVcardModel()->getUsername()); diff --git a/linphone-app/src/components/sip-addresses/SipAddressesSorter.hpp b/linphone-app/src/components/sip-addresses/SipAddressesSorter.hpp index 634cde640..3c42b1282 100644 --- a/linphone-app/src/components/sip-addresses/SipAddressesSorter.hpp +++ b/linphone-app/src/components/sip-addresses/SipAddressesSorter.hpp @@ -26,6 +26,7 @@ #include // ============================================================================= +class SearchResultModel; class SipAddressesSorter : public QObject{ Q_OBJECT @@ -33,10 +34,11 @@ class SipAddressesSorter : public QObject{ public: SipAddressesSorter (QObject *parent = Q_NULLPTR); - static bool lessThan( const QString& filter, const QVariantMap &left, const QVariantMap &right); + //static bool lessThan( const QString& filter, const QVariantMap &left, const QVariantMap &right); + static bool lessThan (const QString& filter, const SearchResultModel *left, const SearchResultModel *right); private: - static int computeEntryWeight (const QString& filter, const QVariantMap &entry); + static int computeEntryWeight (const QString& filter, const SearchResultModel *entry); static int computeStringWeight (const QString& filter, const QString &string); static const QRegExp SearchSeparators; diff --git a/linphone-app/ui/modules/Common/Form/ListForm.qml b/linphone-app/ui/modules/Common/Form/ListForm.qml index 6f08a2cf6..1ce4de8f4 100644 --- a/linphone-app/ui/modules/Common/Form/ListForm.qml +++ b/linphone-app/ui/modules/Common/Form/ListForm.qml @@ -116,7 +116,7 @@ RowLayout { delegate: Item { implicitHeight: textInput.height - width: parent.width + width: ListView.width TransparentTextInput { id: textInput diff --git a/linphone-app/ui/views/App/Main/MainWindow.qml b/linphone-app/ui/views/App/Main/MainWindow.qml index a4f988f1b..18f6b9743 100644 --- a/linphone-app/ui/views/App/Main/MainWindow.qml +++ b/linphone-app/ui/views/App/Main/MainWindow.qml @@ -178,7 +178,7 @@ ApplicationWindow { if (entry.contact && SettingsModel.contactsEnabled) { window.setView('ContactEdit', { sipAddress: entry.sipAddress }) } else { - CallsListModel.createChatRoom( "", false, sipAddress ) + CallsListModel.createChatRoom( "", false, [entry] ) } }