Commit ceef883d authored by Ronan Abhamon's avatar Ronan Abhamon

fix(ui/views/App/MainWindow/Contacts): $contact was undefined in some cases

parent 31321a4d
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include "ContactsListProxyModel.hpp" #include "ContactsListProxyModel.hpp"
#define USERNAME_WEIGHT 50.0 #define USERNAME_WEIGHT 50.0
#define MAIN_SIP_ADDRESS_WEIGHT 30.0 #define MAIN_SIP_ADDRESS_WEIGHT 25.0
#define OTHER_SIP_ADDRESSES_WEIGHT 20.0 #define OTHER_SIP_ADDRESSES_WEIGHT 25.0
#define FACTOR_POS_1 0.90 #define FACTOR_POS_1 0.90
#define FACTOR_POS_2 0.80 #define FACTOR_POS_2 0.80
...@@ -44,6 +44,7 @@ ContactsListProxyModel::ContactsListProxyModel (QObject *parent) : QSortFilterPr ...@@ -44,6 +44,7 @@ ContactsListProxyModel::ContactsListProxyModel (QObject *parent) : QSortFilterPr
for (const ContactModel *contact : m_list->m_list) for (const ContactModel *contact : m_list->m_list)
m_weights[contact] = 0; m_weights[contact] = 0;
setDynamicSortFilter(false);
sort(0); sort(0);
} }
......
...@@ -24,6 +24,12 @@ public: ...@@ -24,6 +24,12 @@ public:
return m_list; return m_list;
} }
public slots:
void setFilter (const QString &pattern) {
setFilterFixedString(pattern);
sort(0);
}
protected: protected:
bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const; bool filterAcceptsRow (int source_row, const QModelIndex &source_parent) const;
bool lessThan (const QModelIndex &left, const QModelIndex &right) const; bool lessThan (const QModelIndex &left, const QModelIndex &right) const;
......
...@@ -10,21 +10,6 @@ import App.Styles 1.0 ...@@ -10,21 +10,6 @@ import App.Styles 1.0
// =================================================================== // ===================================================================
ColumnLayout { ColumnLayout {
function _filter (text) {
Utils.assert(
contacts.setFilterFixedString != null,
'`contacts.setFilterFixedString` must be defined.'
)
Utils.assert(
contacts.invalidate != null,
'`contacts.invalidate` must be defined.'
)
contacts.setFilterFixedString(text)
contacts.invalidate()
}
function _removeContact (contact) { function _removeContact (contact) {
Utils.openConfirmDialog(window, { Utils.openConfirmDialog(window, {
descriptionText: qsTr('removeContactDescription'), descriptionText: qsTr('removeContactDescription'),
...@@ -62,7 +47,7 @@ ColumnLayout { ...@@ -62,7 +47,7 @@ ColumnLayout {
icon: 'filter' icon: 'filter'
placeholderText: qsTr('searchContactPlaceholder') placeholderText: qsTr('searchContactPlaceholder')
onTextChanged: _filter(text) onTextChanged: contacts.setFilter(text)
} }
ExclusiveButtons { ExclusiveButtons {
...@@ -71,7 +56,7 @@ ColumnLayout { ...@@ -71,7 +56,7 @@ ColumnLayout {
qsTr('selectConnectedContacts') qsTr('selectConnectedContacts')
] ]
onClicked: contacts.useConnectedFilter = (button === 1) onClicked: contacts.useConnectedFilter = !!button
} }
TextButtonB { TextButtonB {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment