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
57813f00
Commit
57813f00
authored
Nov 22, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(components/contacts): set parent to `ContactModel` because qt can delete it in qml...
parent
179cbedd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
15 deletions
+18
-15
ContactModel.hpp
tests/src/components/contacts/ContactModel.hpp
+4
-1
ContactsListModel.cpp
tests/src/components/contacts/ContactsListModel.cpp
+4
-9
ContactsListModel.hpp
tests/src/components/contacts/ContactsListModel.hpp
+0
-4
ContactsListProxyModel.cpp
tests/src/components/contacts/ContactsListProxyModel.cpp
+3
-0
Contact.qml
tests/ui/modules/Linphone/Contact/Contact.qml
+6
-1
Timeline.qml
tests/ui/modules/Linphone/Timeline.qml
+1
-0
No files found.
tests/src/components/contacts/ContactModel.hpp
View file @
57813f00
...
@@ -45,7 +45,10 @@ class ContactModel : public QObject {
...
@@ -45,7 +45,10 @@ class ContactModel : public QObject {
);
);
public:
public:
ContactModel
(
std
::
shared_ptr
<
linphone
::
Friend
>
linphone_friend
)
{
ContactModel
(
QObject
*
parent
,
std
::
shared_ptr
<
linphone
::
Friend
>
linphone_friend
)
:
QObject
(
parent
)
{
m_linphone_friend
=
linphone_friend
;
m_linphone_friend
=
linphone_friend
;
}
}
...
...
tests/src/components/contacts/ContactsListModel.cpp
View file @
57813f00
...
@@ -14,7 +14,7 @@ ContactsListModel::ContactsListModel (QObject *parent): QAbstractListModel(paren
...
@@ -14,7 +14,7 @@ ContactsListModel::ContactsListModel (QObject *parent): QAbstractListModel(paren
// Init contacts with linphone friends list.
// Init contacts with linphone friends list.
for
(
const
auto
&
friend_
:
m_linphone_friends
->
getFriends
())
{
for
(
const
auto
&
friend_
:
m_linphone_friends
->
getFriends
())
{
ContactModel
*
contact
=
new
ContactModel
(
friend_
);
ContactModel
*
contact
=
new
ContactModel
(
this
,
friend_
);
m_friend_to_contact
[
friend_
.
get
()]
=
contact
;
m_friend_to_contact
[
friend_
.
get
()]
=
contact
;
m_list
<<
contact
;
m_list
<<
contact
;
}
}
...
@@ -40,18 +40,13 @@ QVariant ContactsListModel::data (const QModelIndex &index, int role) const {
...
@@ -40,18 +40,13 @@ QVariant ContactsListModel::data (const QModelIndex &index, int role) const {
// -------------------------------------------------------------------
// -------------------------------------------------------------------
ContactModel
*
ContactsListModel
::
mapLinphoneFriendToContact
(
const
shared_ptr
<
linphone
::
Friend
>
&
friend_
)
const
{
return
m_friend_to_contact
[
friend_
.
get
()];
}
ContactModel
*
ContactsListModel
::
mapSipAddressToContact
(
const
QString
&
sipAddress
)
const
{
ContactModel
*
ContactsListModel
::
mapSipAddressToContact
(
const
QString
&
sipAddress
)
const
{
ContactModel
*
contact
=
m_friend_to_contact
[
// Maybe use a hashtable in future version to get a lower cost?
ContactModel
*
contact
=
m_friend_to_contact
.
value
(
m_linphone_friends
->
findFriendByUri
(
m_linphone_friends
->
findFriendByUri
(
sipAddress
.
toStdString
()
sipAddress
.
toStdString
()
).
get
()
).
get
()
]
;
)
;
qInfo
()
<<
"Map sip address to contact:"
<<
sipAddress
<<
"->"
<<
contact
;
qInfo
()
<<
"Map sip address to contact:"
<<
sipAddress
<<
"->"
<<
contact
;
...
...
tests/src/components/contacts/ContactsListModel.hpp
View file @
57813f00
...
@@ -22,10 +22,6 @@ public:
...
@@ -22,10 +22,6 @@ public:
QHash
<
int
,
QByteArray
>
roleNames
()
const
;
QHash
<
int
,
QByteArray
>
roleNames
()
const
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
;
QVariant
data
(
const
QModelIndex
&
index
,
int
role
)
const
;
ContactModel
*
mapLinphoneFriendToContact
(
const
std
::
shared_ptr
<
linphone
::
Friend
>
&
friend_
)
const
;
public
slots
:
public
slots
:
ContactModel
*
mapSipAddressToContact
(
const
QString
&
sipAddress
)
const
;
ContactModel
*
mapSipAddressToContact
(
const
QString
&
sipAddress
)
const
;
...
...
tests/src/components/contacts/ContactsListProxyModel.cpp
View file @
57813f00
...
@@ -31,6 +31,9 @@ const QRegExp ContactsListProxyModel::m_search_separators("^[^_.-;@ ][_.-;@ ]");
...
@@ -31,6 +31,9 @@ const QRegExp ContactsListProxyModel::m_search_separators("^[^_.-;@ ][_.-;@ ]");
// -------------------------------------------------------------------
// -------------------------------------------------------------------
ContactsListProxyModel
::
ContactsListProxyModel
(
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
)
{
ContactsListProxyModel
::
ContactsListProxyModel
(
QObject
*
parent
)
:
QSortFilterProxyModel
(
parent
)
{
if
(
m_list
==
nullptr
)
qFatal
(
"Contacts list model is undefined."
);
setSourceModel
(
m_list
);
setSourceModel
(
m_list
);
setFilterCaseSensitivity
(
Qt
::
CaseInsensitive
);
setFilterCaseSensitivity
(
Qt
::
CaseInsensitive
);
...
...
tests/ui/modules/Linphone/Contact/Contact.qml
View file @
57813f00
...
@@ -9,6 +9,8 @@ import Utils 1.0
...
@@ -9,6 +9,8 @@ import Utils 1.0
// ===================================================================
// ===================================================================
Rectangle
{
Rectangle
{
id
:
item
property
alias
actions
:
actionBar
.
data
property
alias
actions
:
actionBar
.
data
property
alias
sipAddressColor
:
description
.
sipAddressColor
property
alias
sipAddressColor
:
description
.
sipAddressColor
property
alias
usernameColor
:
description
.
usernameColor
property
alias
usernameColor
:
description
.
usernameColor
...
@@ -16,6 +18,9 @@ Rectangle {
...
@@ -16,6 +18,9 @@ Rectangle {
// Can be a contact object or just a sip address.
// Can be a contact object or just a sip address.
property
var
contact
property
var
contact
// Override contact.sipAddress if used.
property
var
sipAddress
color
:
'
transparent
'
// No color by default.
color
:
'
transparent
'
// No color by default.
height
:
ContactStyle
.
height
height
:
ContactStyle
.
height
...
@@ -46,7 +51,7 @@ Rectangle {
...
@@ -46,7 +51,7 @@ Rectangle {
Layout.fillWidth
:
true
Layout.fillWidth
:
true
sipAddress
:
Utils
.
isString
(
contact
)
sipAddress
:
Utils
.
isString
(
contact
)
?
contact
?
contact
:
contact
.
sipAddress
:
item
.
sipAddress
||
contact
.
sipAddress
username
:
avatar
.
username
username
:
avatar
.
username
}
}
...
...
tests/ui/modules/Linphone/Timeline.qml
View file @
57813f00
...
@@ -88,6 +88,7 @@ ColumnLayout {
...
@@ -88,6 +88,7 @@ ColumnLayout {
:
TimelineStyle
.
contact
.
backgroundColor
.
b
:
TimelineStyle
.
contact
.
backgroundColor
.
b
)
)
contact
:
parent
.
contact
contact
:
parent
.
contact
sipAddress
:
$timelineEntry
.
sipAddresses
sipAddressColor
:
view
.
currentIndex
===
index
sipAddressColor
:
view
.
currentIndex
===
index
?
TimelineStyle
.
contact
.
sipAddress
.
color
.
selected
?
TimelineStyle
.
contact
.
sipAddress
.
color
.
selected
:
TimelineStyle
.
contact
.
sipAddress
.
color
.
normal
:
TimelineStyle
.
contact
.
sipAddress
.
color
.
normal
...
...
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