diff --git a/tests/src/components/contacts/ContactsListModel.cpp b/tests/src/components/contacts/ContactsListModel.cpp index 8fbd7ab01..37fd6f69b 100644 --- a/tests/src/components/contacts/ContactsListModel.cpp +++ b/tests/src/components/contacts/ContactsListModel.cpp @@ -9,11 +9,11 @@ ContactsListModel::ContactsListModel (QObject *parent): QAbstractListModel(paren m_list << new ContactModel("Cecelia Cyler", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org")); m_list << new ContactModel("Daniel Elliott", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org")); m_list << new ContactModel("Effie Forton", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org")); - m_list << new ContactModel("Agnes Hurner", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org")); + m_list << new ContactModel("Agnes Hurner", "", Presence::Offline, QStringList("toto.linphone.sip.linphone.org")); m_list << new ContactModel("Luke Lemin", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org")); m_list << new ContactModel("Claire Manning", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org")); m_list << new ContactModel("Isabella Ahornton", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org")); - m_list << new ContactModel("Mary Boreno", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org")); + m_list << new ContactModel("Mary Boreno", "", Presence::Offline, QStringList("toto.linphone.sip.linphone.org")); m_list << new ContactModel("Aman Than", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org")); m_list << new ContactModel(" abdoul", "", Presence::Online, QStringList("toto.linphone.sip.linphone.org")); diff --git a/tests/src/components/contacts/ContactsListProxyModel.cpp b/tests/src/components/contacts/ContactsListProxyModel.cpp index b80935156..dea313fbc 100644 --- a/tests/src/components/contacts/ContactsListProxyModel.cpp +++ b/tests/src/components/contacts/ContactsListProxyModel.cpp @@ -54,7 +54,11 @@ bool ContactsListProxyModel::filterAcceptsRow (int source_row, const QModelIndex int weight = m_weights[contact] = static_cast( computeContactWeight(*contact) ); - return weight > 0; + + return weight > 0 && ( + !m_use_connected_filter || + contact->getPresenceLevel() != Presence::PresenceLevel::White + ); } bool ContactsListProxyModel::lessThan (const QModelIndex &left, const QModelIndex &right) const { @@ -124,3 +128,15 @@ float ContactsListProxyModel::computeContactWeight (const ContactModel &contact) return weight; } + +// ------------------------------------------------------------------- + +bool ContactsListProxyModel::isConnectedFilterUsed () const { + return m_use_connected_filter; +} + +void ContactsListProxyModel::setConnectedFilter (bool useConnectedFilter) { + m_use_connected_filter = useConnectedFilter; + qDebug() << useConnectedFilter; + invalidate(); +} diff --git a/tests/src/components/contacts/ContactsListProxyModel.hpp b/tests/src/components/contacts/ContactsListProxyModel.hpp index 1c1844081..89aea3978 100644 --- a/tests/src/components/contacts/ContactsListProxyModel.hpp +++ b/tests/src/components/contacts/ContactsListProxyModel.hpp @@ -10,6 +10,13 @@ class ContactsListProxyModel : public QSortFilterProxyModel { Q_OBJECT; + Q_PROPERTY( + bool useConnectedFilter + READ isConnectedFilterUsed + WRITE setConnectedFilter + CONSTANT + ); + public: ContactsListProxyModel (QObject *parent = Q_NULLPTR); static void initContactsListModel (ContactsListModel *list); @@ -22,6 +29,9 @@ private: float computeStringWeight (const QString &string, float percentage) const; float computeContactWeight (const ContactModel &contact) const; + bool isConnectedFilterUsed () const; + void setConnectedFilter (bool useConnectedFilter); + static const QRegExp m_search_separators; // The contacts list is shared between `ContactsListProxyModel` @@ -31,6 +41,8 @@ private: // It's just a cache to save values computed by `filterAcceptsRow` // and reused by `lessThan`. mutable QHash m_weights; + + bool m_use_connected_filter; }; #endif // CONTACTS_LIST_PROXY_MODEL_H diff --git a/tests/ui/modules/Linphone/Form/ExclusiveButtons.qml b/tests/ui/modules/Linphone/Form/ExclusiveButtons.qml index a8be70843..bf14d071b 100644 --- a/tests/ui/modules/Linphone/Form/ExclusiveButtons.qml +++ b/tests/ui/modules/Linphone/Form/ExclusiveButtons.qml @@ -5,6 +5,8 @@ import Linphone.Styles 1.0 // =================================================================== Row { + id: item + property var texts property int _selectedButton: 0 @@ -32,7 +34,7 @@ Row { onClicked: { if (_selectedButton !== index) { _selectedButton = index - clicked(index) + item.clicked(index) } } } diff --git a/tests/ui/views/MainWindow/Contacts.qml b/tests/ui/views/MainWindow/Contacts.qml index 5bde6fcad..48552f0de 100644 --- a/tests/ui/views/MainWindow/Contacts.qml +++ b/tests/ui/views/MainWindow/Contacts.qml @@ -43,6 +43,8 @@ ColumnLayout { qsTr('selectAllContacts'), qsTr('selectConnectedContacts') ] + + onClicked: contacts.useConnectedFilter = (button === 1) } TextButtonB { diff --git a/tests/ui/views/MainWindow/Conversation.qml b/tests/ui/views/MainWindow/Conversation.qml index c436ae0c9..00bd7e8a5 100644 --- a/tests/ui/views/MainWindow/Conversation.qml +++ b/tests/ui/views/MainWindow/Conversation.qml @@ -26,7 +26,7 @@ ColumnLayout { Avatar { Layout.fillHeight: true Layout.preferredWidth: 80 - presence: 'connected' // TODO: Use C++. + presenceLevel: Presence.Green // TODO: Use C++. username: 'Cameron Andrews' // TODO: Use C++. } diff --git a/tests/ui/views/MainWindow/MainWindow.qml b/tests/ui/views/MainWindow/MainWindow.qml index 1804ac2e4..46a0a1f47 100644 --- a/tests/ui/views/MainWindow/MainWindow.qml +++ b/tests/ui/views/MainWindow/MainWindow.qml @@ -40,7 +40,7 @@ ApplicationWindow { Layout.fillHeight: parent.height id: collapse - onCollapsed: windowStates.state = isCollapsed() + onCollapsed: windowStates.state = collapsed ? 'collapsed' : '' }