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
5692ec5b
Commit
5692ec5b
authored
Nov 18, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(app): supports contacts from sqlite3
parent
9cb733a2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
49 deletions
+40
-49
ContactModel.cpp
tests/src/components/contacts/ContactModel.cpp
+0
-16
ContactModel.hpp
tests/src/components/contacts/ContactModel.hpp
+8
-11
ContactsListProxyModel.cpp
tests/src/components/contacts/ContactsListProxyModel.cpp
+18
-14
utils.hpp
tests/src/utils.hpp
+7
-0
Avatar.qml
tests/ui/modules/Linphone/Contact/Avatar.qml
+6
-7
Contacts.qml
tests/ui/views/App/MainWindow/Contacts.qml
+1
-1
No files found.
tests/src/components/contacts/ContactModel.cpp
View file @
5692ec5b
...
...
@@ -2,22 +2,6 @@
// ===================================================================
QString
ContactModel
::
getUsername
()
const
{
return
m_username
;
}
void
ContactModel
::
setUsername
(
const
QString
&
username
)
{
m_username
=
username
;
}
QString
ContactModel
::
getAvatar
()
const
{
return
m_avatar
;
}
void
ContactModel
::
setAvatar
(
const
QString
&
avatar
)
{
m_avatar
=
avatar
;
}
Presence
::
PresenceStatus
ContactModel
::
getPresenceStatus
()
const
{
return
m_presence_status
;
}
...
...
tests/src/components/contacts/ContactModel.hpp
View file @
5692ec5b
...
...
@@ -17,14 +17,12 @@ class ContactModel : public QObject {
Q_PROPERTY
(
QString
username
READ
getUsername
WRITE
setUsername
NOTIFY
contactUpdated
);
Q_PROPERTY
(
QString
avatar
READ
getAvatar
WRITE
setAvatar
NOTIFY
contactUpdated
);
...
...
@@ -55,26 +53,25 @@ signals:
void
contactUpdated
();
private:
QString
getUsername
()
const
;
void
setUsername
(
const
QString
&
username
);
QString
getUsername
()
const
{
return
Utils
::
linphoneStringToQString
(
m_linphone_friend
->
getName
()
);
}
QString
getAvatar
()
const
;
void
setAvatar
(
const
QString
&
avatar
);
QString
getAvatar
()
const
{
return
""
;
}
Presence
::
PresenceStatus
getPresenceStatus
()
const
;
Presence
::
PresenceLevel
getPresenceLevel
()
const
;
QString
getSipAddress
()
const
{
// FIXME.
return
"toto@linphone.org"
;
return
Utils
::
linphoneStringToQString
(
m_linphone_friend
->
getAddress
()
->
asString
()
);
}
QString
m_username
;
QString
m_avatar
;
Presence
::
PresenceStatus
m_presence_status
=
Presence
::
Offline
;
std
::
shared_ptr
<
linphone
::
Friend
>
m_linphone_friend
;
...
...
tests/src/components/contacts/ContactsListProxyModel.cpp
View file @
5692ec5b
...
...
@@ -45,7 +45,9 @@ void ContactsListProxyModel::initContactsListModel (ContactsListModel *list) {
qWarning
()
<<
"Contacts list model is already defined."
;
}
bool
ContactsListProxyModel
::
filterAcceptsRow
(
int
source_row
,
const
QModelIndex
&
source_parent
)
const
{
bool
ContactsListProxyModel
::
filterAcceptsRow
(
int
source_row
,
const
QModelIndex
&
source_parent
)
const
{
QModelIndex
index
=
sourceModel
()
->
index
(
source_row
,
0
,
source_parent
);
const
ContactModel
*
contact
=
qvariant_cast
<
ContactModel
*>
(
index
.
data
()
...
...
@@ -74,7 +76,7 @@ bool ContactsListProxyModel::lessThan (const QModelIndex &left, const QModelInde
return
(
weight_a
>
weight_b
||
(
weight_a
==
weight_b
&&
contact_a
->
m_
username
<=
contact_b
->
m_username
contact_a
->
m_
linphone_friend
->
getName
()
<=
contact_b
->
m_linphone_friend
->
getName
()
)
);
}
...
...
@@ -112,26 +114,28 @@ float ContactsListProxyModel::computeStringWeight (const QString &string, float
}
float
ContactsListProxyModel
::
computeContactWeight
(
const
ContactModel
&
contact
)
const
{
float
weight
=
computeStringWeight
(
contact
.
m_username
,
USERNAME_WEIGHT
);
float
weight
=
computeStringWeight
(
contact
.
getUsername
()
,
USERNAME_WEIGHT
);
//
It exists at least one sip addres
s.
//
Get all contact's addresse
s.
const
std
::
list
<
std
::
shared_ptr
<
linphone
::
Address
>
>
addresses
=
contact
.
m_linphone_friend
->
getAddresses
();
// FIXME.
return
0
;
weight
+=
computeStringWeight
(
contact
.
getSipAddress
(),
MAIN_SIP_ADDRESS_WEIGHT
);
auto
it
=
addresses
.
cbegin
();
// It exists at least one sip address.
weight
+=
computeStringWeight
(
Utils
::
linphoneStringToQString
((
*
it
)
->
asString
()),
MAIN_SIP_ADDRESS_WEIGHT
);
// Compute for other addresses.
int
size
=
addresses
.
size
();
return
0
;
if
(
size
>
1
)
for
(
auto
it
=
++
addresses
.
cbegin
();
it
!=
addresses
.
cend
();
++
it
)
weight
+=
computeStringWeight
(
Utils
::
linphoneStringToQString
((
*
it
)
->
asString
()),
OTHER_SIP_ADDRESSES_WEIGHT
/
size
);
for
(
++
it
;
it
!=
addresses
.
cend
();
++
it
)
weight
+=
computeStringWeight
(
Utils
::
linphoneStringToQString
((
*
it
)
->
asString
()),
OTHER_SIP_ADDRESSES_WEIGHT
/
size
);
return
weight
;
}
...
...
tests/src/utils.hpp
0 → 100644
View file @
5692ec5b
#include <QString>
namespace
Utils
{
inline
QString
linphoneStringToQString
(
const
std
::
string
&
string
)
{
return
QString
::
fromLocal8Bit
(
string
.
c_str
(),
string
.
size
());
}
}
tests/ui/modules/Linphone/Contact/Avatar.qml
View file @
5692ec5b
...
...
@@ -12,7 +12,7 @@ Item {
property
alias
presenceLevel
:
presenceLevel
.
level
property
string
username
property
var
_initialsRegex
:
/^
\s
*
([^\s
]
+
)(?:\s
+
([^\s
]
+
))?
/
property
var
_initialsRegex
:
/^
\s
*
([^\s
\.]
+
)(?:[\s\.]
+
([^\s\.
]
+
))?
/
function
_computeInitials
()
{
var
result
=
username
.
match
(
_initialsRegex
)
...
...
@@ -22,12 +22,11 @@ Item {
'
Unable to get initials of:
\'
'
+
username
+
'
\'
'
)
return
result
[
1
].
charAt
(
0
).
toUpperCase
()
+
(
result
[
2
]
!=
null
?
result
[
2
].
charAt
(
0
).
toUpperCase
()
:
''
)
return
result
[
1
].
charAt
(
0
).
toUpperCase
()
+
(
result
[
2
]
!=
null
?
result
[
2
].
charAt
(
0
).
toUpperCase
()
:
''
)
}
// Image mask. (Circle)
...
...
tests/ui/views/App/MainWindow/Contacts.qml
View file @
5692ec5b
...
...
@@ -36,7 +36,7 @@ ColumnLayout {
})
}
spacing
:
Notifier
.
showCallMessage
(
5000
,
"
toto@toto.com
"
)
||
0
spacing
:
0
// -----------------------------------------------------------------
// Search Bar & actions.
...
...
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