Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
cc3fff24
Commit
cc3fff24
authored
Oct 03, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(ContactsListProxyModel): supports weight filter (use integer instead float to compare weight)
parent
8bf12ac5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
8 deletions
+7
-8
ContactsListProxyModel.cpp
tests/src/components/contacts/ContactsListProxyModel.cpp
+5
-6
ContactsListProxyModel.hpp
tests/src/components/contacts/ContactsListProxyModel.hpp
+2
-2
No files found.
tests/src/components/contacts/ContactsListProxyModel.cpp
View file @
cc3fff24
...
...
@@ -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
);
}
floa
t
ContactsListProxyModel
::
computeContactWeight
(
const
ContactModel
&
contact
)
const
{
in
t
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
<
int
>
(
weight
)
;
}
tests/src/components/contacts/ContactsListProxyModel.hpp
View file @
cc3fff24
...
...
@@ -19,7 +19,7 @@ protected:
bool
lessThan
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
;
private:
floa
t
computeContactWeight
(
const
ContactModel
&
contact
)
const
;
in
t
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
<
const
ContactModel
*
,
floa
t
>
m_weights
;
mutable
QHash
<
const
ContactModel
*
,
in
t
>
m_weights
;
};
#endif // CONTACTS_LIST_PROXY_MODEL_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment