diff --git a/tests/src/components/contacts/ContactsListProxyModel.cpp b/tests/src/components/contacts/ContactsListProxyModel.cpp index 1851958a6..bbf8998f1 100644 --- a/tests/src/components/contacts/ContactsListProxyModel.cpp +++ b/tests/src/components/contacts/ContactsListProxyModel.cpp @@ -2,9 +2,9 @@ #include "ContactsListProxyModel.hpp" -#define USERNAME_WEIGHT 0.5 -#define MAIN_SIP_ADDRESS_WEIGHT 0.3 -#define OTHER_SIP_ADDRESSES_WEIGHT 0.2 +#define USERNAME_WEIGHT 50.0 +#define MAIN_SIP_ADDRESS_WEIGHT 30.0 +#define OTHER_SIP_ADDRESSES_WEIGHT 20.0 // =================================================================== @@ -12,7 +12,6 @@ ContactsListModel *ContactsListProxyModel::m_list = nullptr; ContactsListProxyModel::ContactsListProxyModel (QObject *parent) : QSortFilterProxyModel(parent) { setSourceModel(m_list); - setDynamicSortFilter(true); setFilterCaseSensitivity(Qt::CaseInsensitive); foreach (const ContactModel *contact, m_list->m_list) @@ -56,7 +55,7 @@ bool ContactsListProxyModel::lessThan (const QModelIndex &left, const QModelInde ); } -float ContactsListProxyModel::computeContactWeight (const ContactModel &contact) const { +int ContactsListProxyModel::computeContactWeight (const ContactModel &contact) const { float weight = 0; if (filterRegExp().indexIn(contact.m_username) != -1) @@ -74,5 +73,5 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel &contact) if (filterRegExp().indexIn(*it) != -1) weight += OTHER_SIP_ADDRESSES_WEIGHT / size; - return weight; + return static_cast(weight); } diff --git a/tests/src/components/contacts/ContactsListProxyModel.hpp b/tests/src/components/contacts/ContactsListProxyModel.hpp index 2060ccdb3..cd9fab2e5 100644 --- a/tests/src/components/contacts/ContactsListProxyModel.hpp +++ b/tests/src/components/contacts/ContactsListProxyModel.hpp @@ -19,7 +19,7 @@ protected: bool lessThan (const QModelIndex &left, const QModelIndex &right) const; private: - float computeContactWeight (const ContactModel &contact) const; + int computeContactWeight (const ContactModel &contact) const; // The contacts list is shared between `ContactsListProxyModel` // it's necessary to initialize it with `initContactsListModel`. @@ -27,7 +27,7 @@ private: // It's just a cache to save values computed by `filterAcceptsRow` // and reused by `lessThan`. - mutable QHash m_weights; + mutable QHash m_weights; }; #endif // CONTACTS_LIST_PROXY_MODEL_H