Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jami-libclient
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
savoirfairelinux
jami-libclient
Commits
5fa1ad22
Commit
5fa1ad22
authored
10 years ago
by
Emmanuel Lepage Vallee
Browse files
Options
Downloads
Patches
Plain Diff
[ #54559 ] Improve Contact view filtering
parent
086b14b1
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/contact.cpp
+32
-0
32 additions, 0 deletions
src/contact.cpp
src/contact.h
+3
-0
3 additions, 0 deletions
src/contact.h
src/contactproxymodel.cpp
+2
-10
2 additions, 10 deletions
src/contactproxymodel.cpp
with
37 additions
and
10 deletions
src/contact.cpp
+
32
−
0
View file @
5fa1ad22
...
...
@@ -49,6 +49,11 @@ public:
AbstractContactBackend
*
m_pBackend
;
bool
m_isPlaceHolder
;
//Cache
QString
m_CachedFilterString
;
QString
filterString
();
//Helper code to help handle multiple parents
QList
<
Contact
*>
m_lParents
;
...
...
@@ -61,8 +66,29 @@ public:
void
phoneNumberCountAboutToChange
(
int
,
int
);
};
QString
ContactPrivate
::
filterString
()
{
if
(
m_CachedFilterString
.
size
())
return
m_CachedFilterString
;
//Also filter by phone numbers, accents are negligible
foreach
(
const
PhoneNumber
*
n
,
m_Numbers
)
{
m_CachedFilterString
+=
n
->
uri
();
}
//Strip non essential characters like accents from the filter string
foreach
(
const
QChar
&
char2
,
QString
(
m_FormattedName
+
'\n'
+
m_Organization
+
'\n'
+
m_Group
+
'\n'
+
m_Department
+
'\n'
+
m_PreferredEmail
).
toLower
().
normalized
(
QString
::
NormalizationForm_KD
)
)
{
if
(
!
char2
.
combiningClass
())
m_CachedFilterString
+=
char2
;
}
return
m_CachedFilterString
;
}
void
ContactPrivate
::
changed
()
{
m_CachedFilterString
.
clear
();
foreach
(
Contact
*
c
,
m_lParents
)
{
emit
c
->
changed
();
}
...
...
@@ -352,6 +378,12 @@ time_t Contact::PhoneNumbers::lastUsedTimeStamp() const
return
t
;
}
///Recomputing the filter string is heavy, cache it
QString
Contact
::
filterString
()
const
{
return
d
->
filterString
();
}
///Callback when one of the phone number presence change
void
Contact
::
slotPresenceChanged
()
{
...
...
This diff is collapsed.
Click to expand it.
src/contact.h
+
3
−
0
View file @
5fa1ad22
...
...
@@ -107,6 +107,9 @@ public:
const
QString
&
department
()
const
;
bool
isActive
()
const
;
//Cache
QString
filterString
()
const
;
//Number related getters (proxies)
bool
isPresent
()
const
;
bool
isTracked
()
const
;
...
...
This diff is collapsed.
Click to expand it.
src/contactproxymodel.cpp
+
2
−
10
View file @
5fa1ad22
...
...
@@ -275,16 +275,8 @@ QVariant ContactProxyModel::data( const QModelIndex& index, int role) const
return
c
->
isActive
();
case
ContactModel
::
Role
::
DatedLastUsed
:
return
QVariant
(
QDateTime
::
fromTime_t
(
c
->
phoneNumbers
().
lastUsedTimeStamp
()));
case
ContactModel
::
Role
::
Filter
:
{
//Strip non essential characters like accents from the filter string
QString
normStripppedC
;
foreach
(
QChar
char2
,
QString
(
c
->
formattedName
()
+
'\n'
+
c
->
organization
()
+
'\n'
+
c
->
group
()
+
'\n'
+
c
->
department
()
+
'\n'
+
c
->
preferredEmail
()).
toLower
().
normalized
(
QString
::
NormalizationForm_KD
)
)
{
if
(
!
char2
.
combiningClass
())
normStripppedC
+=
char2
;
}
return
normStripppedC
;
}
case
ContactModel
::
Role
::
Filter
:
return
c
->
filterString
();
default:
break
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment