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
338fe8c0
Commit
338fe8c0
authored
Dec 14, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(ui/views/App/MainWindow/ContactEdit): use vcard of Contact (in progress)
parent
08fbc20c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
75 deletions
+63
-75
ChatModel.cpp
tests/src/components/chat/ChatModel.cpp
+35
-44
CallControls.qml
tests/ui/modules/Linphone/Call/CallControls.qml
+1
-1
Timeline.qml
tests/ui/modules/Linphone/Timeline.qml
+3
-3
ContactEdit.qml
tests/ui/views/App/MainWindow/ContactEdit.qml
+24
-27
No files found.
tests/src/components/chat/ChatModel.cpp
View file @
338fe8c0
...
...
@@ -20,7 +20,7 @@ QHash<int, QByteArray> ChatModel::roleNames () const {
return
roles
;
}
int
ChatModel
::
rowCount
(
const
QModelIndex
&
)
const
{
int
ChatModel
::
rowCount
(
const
QModelIndex
&
)
const
{
return
m_entries
.
count
();
}
...
...
@@ -40,7 +40,7 @@ QVariant ChatModel::data (const QModelIndex &index, int role) const {
return
QVariant
();
}
bool
ChatModel
::
removeRow
(
int
row
,
const
QModelIndex
&
)
{
bool
ChatModel
::
removeRow
(
int
row
,
const
QModelIndex
&
)
{
return
removeRows
(
row
,
1
);
}
...
...
@@ -92,12 +92,8 @@ void ChatModel::fillMessageEntry (
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
dest
[
"type"
]
=
EntryType
::
MessageEntry
;
dest
[
"timestamp"
]
=
QDateTime
::
fromMSecsSinceEpoch
(
static_cast
<
qint64
>
(
message
->
getTime
())
*
1000
);
dest
[
"content"
]
=
Utils
::
linphoneStringToQString
(
message
->
getText
()
);
dest
[
"timestamp"
]
=
QDateTime
::
fromMSecsSinceEpoch
(
static_cast
<
qint64
>
(
message
->
getTime
())
*
1000
);
dest
[
"content"
]
=
::
Utils
::
linphoneStringToQString
(
message
->
getText
());
dest
[
"isOutgoing"
]
=
message
->
isOutgoing
();
}
...
...
@@ -105,9 +101,7 @@ void ChatModel::fillCallStartEntry (
QVariantMap
&
dest
,
const
shared_ptr
<
linphone
::
CallLog
>
&
call_log
)
{
QDateTime
timestamp
=
QDateTime
::
fromMSecsSinceEpoch
(
static_cast
<
qint64
>
(
call_log
->
getStartDate
())
*
1000
);
QDateTime
timestamp
=
QDateTime
::
fromMSecsSinceEpoch
(
static_cast
<
qint64
>
(
call_log
->
getStartDate
())
*
1000
);
dest
[
"type"
]
=
EntryType
::
CallEntry
;
dest
[
"timestamp"
]
=
timestamp
;
...
...
@@ -121,8 +115,8 @@ void ChatModel::fillCallEndEntry (
const
shared_ptr
<
linphone
::
CallLog
>
&
call_log
)
{
QDateTime
timestamp
=
QDateTime
::
fromMSecsSinceEpoch
(
static_cast
<
qint64
>
(
call_log
->
getStartDate
()
+
call_log
->
getDuration
())
*
1000
);
static_cast
<
qint64
>
(
call_log
->
getStartDate
()
+
call_log
->
getDuration
())
*
1000
);
dest
[
"type"
]
=
EntryType
::
CallEntry
;
dest
[
"timestamp"
]
=
timestamp
;
...
...
@@ -138,9 +132,7 @@ void ChatModel::removeEntry (ChatEntryData &pair) {
switch
(
type
)
{
case
ChatModel
:
:
MessageEntry
:
m_chat_room
->
deleteMessage
(
static_pointer_cast
<
linphone
::
ChatMessage
>
(
pair
.
second
)
);
m_chat_room
->
deleteMessage
(
static_pointer_cast
<
linphone
::
ChatMessage
>
(
pair
.
second
));
break
;
case
ChatModel
:
:
CallEntry
:
if
(
pair
.
first
[
"status"
].
toInt
()
==
linphone
::
CallStatusSuccess
)
{
...
...
@@ -148,22 +140,21 @@ void ChatModel::removeEntry (ChatEntryData &pair) {
// We are between `beginRemoveRows` and `endRemoveRows`.
// A solution is to schedule a `removeEntry` call in the Qt main loop.
shared_ptr
<
void
>
linphone_ptr
=
pair
.
second
;
QTimer
::
singleShot
(
0
,
this
,
[
this
,
linphone_ptr
]()
{
auto
it
=
find_if
(
m_entries
.
begin
(),
m_entries
.
end
(),
[
linphone_ptr
](
const
ChatEntryData
&
pair
)
{
return
pair
.
second
==
linphone_ptr
;
}
);
if
(
it
!=
m_entries
.
end
())
removeEntry
(
static_cast
<
int
>
(
distance
(
m_entries
.
begin
(),
it
)));
});
QTimer
::
singleShot
(
0
,
this
,
[
this
,
linphone_ptr
]()
{
auto
it
=
find_if
(
m_entries
.
begin
(),
m_entries
.
end
(),
[
linphone_ptr
](
const
ChatEntryData
&
pair
)
{
return
pair
.
second
==
linphone_ptr
;
}
);
if
(
it
!=
m_entries
.
end
())
removeEntry
(
static_cast
<
int
>
(
distance
(
m_entries
.
begin
(),
it
)));
}
);
}
CoreManager
::
getInstance
()
->
getCore
()
->
removeCallLog
(
static_pointer_cast
<
linphone
::
CallLog
>
(
pair
.
second
)
);
CoreManager
::
getInstance
()
->
getCore
()
->
removeCallLog
(
static_pointer_cast
<
linphone
::
CallLog
>
(
pair
.
second
));
break
;
default:
qWarning
()
<<
QStringLiteral
(
"Unknown chat entry type: %1."
).
arg
(
type
);
...
...
@@ -174,7 +165,7 @@ QString ChatModel::getSipAddress () const {
if
(
!
m_chat_room
)
return
""
;
return
Utils
::
linphoneStringToQString
(
return
::
Utils
::
linphoneStringToQString
(
m_chat_room
->
getPeerAddress
()
->
asString
()
);
}
...
...
@@ -189,7 +180,7 @@ void ChatModel::setSipAddress (const QString &sip_address) {
m_entries
.
clear
();
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
string
std_sip_address
=
Utils
::
qStringToLinphoneString
(
sip_address
);
string
std_sip_address
=
::
Utils
::
qStringToLinphoneString
(
sip_address
);
m_chat_room
=
core
->
getChatRoomFromUri
(
std_sip_address
);
...
...
@@ -203,18 +194,18 @@ void ChatModel::setSipAddress (const QString &sip_address) {
// Get calls.
auto
insert_entry
=
[
this
](
const
ChatEntryData
&
pair
,
const
QList
<
ChatEntryData
>::
iterator
*
start
=
NULL
)
{
auto
it
=
lower_bound
(
start
?
*
start
:
m_entries
.
begin
(),
m_entries
.
end
(),
pair
,
[](
const
ChatEntryData
&
a
,
const
ChatEntryData
&
b
)
{
return
a
.
first
[
"timestamp"
]
<
b
.
first
[
"timestamp"
];
}
);
return
m_entries
.
insert
(
it
,
pair
);
};
const
ChatEntryData
&
pair
,
const
QList
<
ChatEntryData
>::
iterator
*
start
=
NULL
)
{
auto
it
=
lower_bound
(
start
?
*
start
:
m_entries
.
begin
(),
m_entries
.
end
(),
pair
,
[](
const
ChatEntryData
&
a
,
const
ChatEntryData
&
b
)
{
return
a
.
first
[
"timestamp"
]
<
b
.
first
[
"timestamp"
];
}
);
return
m_entries
.
insert
(
it
,
pair
);
};
for
(
auto
&
call_log
:
core
->
getCallHistoryForAddress
(
m_chat_room
->
getPeerAddress
()))
{
linphone
::
CallStatus
status
=
call_log
->
getStatus
();
...
...
tests/ui/modules/Linphone/Call/CallControls.qml
View file @
338fe8c0
...
...
@@ -11,7 +11,7 @@ RowLayout {
property
string
sipAddress
// TODO.
property
var
contact
:
ContactsListModel
.
mapSipAddressTo
Contact
(
property
var
contact
:
ContactsListModel
.
mapSipAddressTo
cd
(
sipAddress
)
...
...
tests/ui/modules/Linphone/Timeline.qml
View file @
338fe8c0
...
...
@@ -6,7 +6,7 @@ import Linphone 1.0
import
Linphone
.
Styles
1.0
import
Utils
1.0
// ===================================================================
// ===================================================================
==========
ColumnLayout
{
id
:
timeline
...
...
@@ -15,13 +15,13 @@ ColumnLayout {
signal
entrySelected
(
var
entry
)
// -----------------------------------------------------------------
// -----------------------------------------------------------------
----------
function
resetSelectedItem
()
{
view
.
currentIndex
=
-
1
}
// -----------------------------------------------------------------
// -----------------------------------------------------------------
----------
spacing
:
0
...
...
tests/ui/views/App/MainWindow/ContactEdit.qml
View file @
338fe8c0
...
...
@@ -18,6 +18,7 @@ ColumnLayout {
property
string
sipAddress
:
''
property
var
_contact
property
var
_vcard
// -----------------------------------------------------------------
...
...
@@ -35,18 +36,14 @@ ColumnLayout {
}
function
_setAvatar
(
path
)
{
if
(
Utils
.
isObject
(
_contact
)
&&
path
)
{
_contact
.
avatar
=
path
.
match
(
/^
(?:
file:
\/\/)?(
.*
)
$/
)[
1
]
}
_vcard
.
avatar
=
path
.
match
(
/^
(?:
file:
\/\/)?(
.*
)
$/
)[
1
]
}
function
_setUsername
(
username
)
{
if
(
Utils
.
isObject
(
_contact
))
{
_contact
.
username
=
username
_vcard
.
username
=
username
// Update current text with new username.
usernameInput
.
text
=
_contact
.
username
}
// Update current text with new username.
usernameInput
.
text
=
_vcard
.
username
}
function
_handleSipAddressChanged
(
index
,
default_value
,
new_value
)
{
...
...
@@ -59,8 +56,8 @@ ColumnLayout {
}
var
so_far_so_good
=
(
default_value
.
length
===
0
)
?
_
contact
.
addSipAddress
(
new_value
)
:
_
contact
.
updateSipAddress
(
default_value
,
new_value
)
?
_
vcard
.
addSipAddress
(
new_value
)
:
_
vcard
.
updateSipAddress
(
default_value
,
new_value
)
addresses
.
setInvalid
(
index
,
!
so_far_so_good
)
}
...
...
@@ -72,8 +69,8 @@ ColumnLayout {
}
var
so_far_so_good
=
(
default_value
.
length
===
0
)
?
url
&&
_
contact
.
addUrl
(
new_value
)
:
url
&&
_
contact
.
updateUrl
(
default_value
,
new_value
)
?
url
&&
_
vcard
.
addUrl
(
new_value
)
:
url
&&
_
vcard
.
updateUrl
(
default_value
,
new_value
)
urls
.
setInvalid
(
index
,
!
so_far_so_good
)
}
...
...
@@ -84,7 +81,7 @@ ColumnLayout {
Component.onCompleted
:
{
_contact
=
ContactsListModel
.
mapSipAddressToContact
(
sipAddress
)
||
ContactsListModel
.
createDetachedContact
()
_vcard
=
_contact
.
vcard
}
// -----------------------------------------------------------------
...
...
@@ -126,7 +123,7 @@ ColumnLayout {
id
:
avatar
anchors.fill
:
parent
image
:
_
contact
.
avatar
image
:
_
vcard
.
avatar
username
:
LinphoneUtils
.
getContactUsername
(
_contact
)
||
'
John Doe
'
visible
:
isLoaded
()
&&
!
parent
.
hovered
}
...
...
@@ -154,7 +151,7 @@ ColumnLayout {
Layout.alignment
:
Qt
.
AlignRight
iconSize
:
ContactEditStyle
.
infoBar
.
buttons
.
size
spacing
:
ContactEditStyle
.
infoBar
.
buttons
.
spacing
visible
:
Utils
.
isObject
(
_contact
)
visible
:
_contact
!=
null
ActionButton
{
icon
:
'
history
'
...
...
@@ -200,13 +197,13 @@ ColumnLayout {
Layout.rightMargin
:
ContactEditStyle
.
values
.
rightMargin
Layout.topMargin
:
ContactEditStyle
.
values
.
topMargin
defaultData
:
_contact
.
sipAddresses
defaultData
:
_vcard
.
sipAddresses
minValues
:
1
placeholder
:
qsTr
(
'
sipAccountsInput
'
)
title
:
qsTr
(
'
sipAccounts
'
)
onChanged
:
_handleSipAddressChanged
(
index
,
default_value
,
new_value
)
onRemoved
:
_
contact
.
removeSipAddress
(
value
)
onRemoved
:
_
vcard
.
removeSipAddress
(
value
)
}
Rectangle
{
...
...
@@ -221,14 +218,14 @@ ColumnLayout {
Layout.leftMargin
:
ContactEditStyle
.
values
.
leftMargin
Layout.rightMargin
:
ContactEditStyle
.
values
.
rightMargin
defaultData
:
_
contact
.
companies
defaultData
:
_
vcard
.
companies
placeholder
:
qsTr
(
'
companiesInput
'
)
title
:
qsTr
(
'
companies
'
)
onChanged
:
default_value
.
length
===
0
?
_
contact
.
addCompany
(
new_value
)
:
_
contact
.
updateCompany
(
default_value
,
new_value
)
onRemoved
:
_
contact
.
removeCompany
(
value
)
?
_
vcard
.
addCompany
(
new_value
)
:
_
vcard
.
updateCompany
(
default_value
,
new_value
)
onRemoved
:
_
vcard
.
removeCompany
(
value
)
}
Rectangle
{
...
...
@@ -243,15 +240,15 @@ ColumnLayout {
Layout.leftMargin
:
ContactEditStyle
.
values
.
leftMargin
Layout.rightMargin
:
ContactEditStyle
.
values
.
rightMargin
defaultData
:
_
contact
.
emails
defaultData
:
_
vcard
.
emails
inputMethodHints
:
Qt
.
ImhEmailCharactersOnly
placeholder
:
qsTr
(
'
emailsInput
'
)
title
:
qsTr
(
'
emails
'
)
onChanged
:
default_value
.
length
===
0
?
_
contact
.
addEmail
(
new_value
)
:
_
contact
.
updateEmail
(
default_value
,
new_value
)
onRemoved
:
_
contact
.
removeEmail
(
value
)
?
_
vcard
.
addEmail
(
new_value
)
:
_
vcard
.
updateEmail
(
default_value
,
new_value
)
onRemoved
:
_
vcard
.
removeEmail
(
value
)
}
Rectangle
{
...
...
@@ -266,13 +263,13 @@ ColumnLayout {
Layout.leftMargin
:
ContactEditStyle
.
values
.
leftMargin
Layout.rightMargin
:
ContactEditStyle
.
values
.
rightMargin
defaultData
:
_
contact
.
urls
defaultData
:
_
vcard
.
urls
inputMethodHints
:
Qt
.
ImhUrlCharactersOnly
placeholder
:
qsTr
(
'
webSitesInput
'
)
title
:
qsTr
(
'
webSites
'
)
onChanged
:
_handleUrlChanged
(
index
,
default_value
,
new_value
)
onRemoved
:
_
contact
.
removeUrl
(
value
)
onRemoved
:
_
vcard
.
removeUrl
(
value
)
}
Rectangle
{
...
...
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