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
59c0154f
Commit
59c0154f
authored
Dec 16, 2016
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(ui/views/App/MainWindow/ContactEdit): support address edition (unstable)
parent
3839f917
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
74 additions
and
24 deletions
+74
-24
VcardModel.cpp
tests/src/components/contact/VcardModel.cpp
+34
-15
VcardModel.hpp
tests/src/components/contact/VcardModel.hpp
+6
-3
ListForm.qml
tests/ui/modules/Common/Form/ListForm.qml
+1
-1
StaticListForm.qml
tests/ui/modules/Common/Form/StaticListForm.qml
+13
-1
TransparentTextInput.qml
tests/ui/modules/Common/Form/TransparentTextInput.qml
+1
-1
ContactEdit.qml
tests/ui/views/App/MainWindow/ContactEdit.qml
+19
-3
No files found.
tests/src/components/contact/VcardModel.cpp
View file @
59c0154f
...
...
@@ -149,6 +149,20 @@ bool VcardModel::setAvatar (const QString &path) {
// -----------------------------------------------------------------------------
inline
shared_ptr
<
belcard
::
BelCardAddress
>
getOrCreateBelCardAddress
(
shared_ptr
<
belcard
::
BelCard
>
belcard
)
{
list
<
shared_ptr
<
belcard
::
BelCardAddress
>
>
addresses
=
belcard
->
getAddresses
();
shared_ptr
<
belcard
::
BelCardAddress
>
address
;
if
(
addresses
.
empty
())
{
address
=
belcard
::
BelCardGeneric
::
create
<
belcard
::
BelCardAddress
>
();
if
(
!
belcard
->
addAddress
(
address
))
qWarning
()
<<
"Unable to create a new address."
;
}
else
address
=
addresses
.
front
();
return
address
;
}
QVariantMap
VcardModel
::
getAddress
()
const
{
list
<
shared_ptr
<
belcard
::
BelCardAddress
>
>
addresses
=
m_vcard
->
getBelcard
()
->
getAddresses
();
QVariantMap
map
;
...
...
@@ -165,27 +179,32 @@ QVariantMap VcardModel::getAddress () const {
return
map
;
}
bool
VcardModel
::
setAddress
(
const
QVariantMap
&
address
)
{
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m_vcard
->
getBelcard
();
list
<
shared_ptr
<
belcard
::
BelCardAddress
>
>
addresses
=
belcard
->
getAddresses
();
while
(
!
addresses
.
empty
())
belcard
->
removeAddress
(
addresses
.
front
());
shared_ptr
<
belcard
::
BelCardAddress
>
belcard_address
=
belcard
::
BelCardGeneric
::
create
<
belcard
::
BelCardAddress
>
();
void
VcardModel
::
setStreet
(
const
QString
&
street
)
{
shared_ptr
<
belcard
::
BelCardAddress
>
address
=
getOrCreateBelCardAddress
(
m_vcard
->
getBelcard
());
address
->
setStreet
(
::
Utils
::
qStringToLinphoneString
(
street
));
emit
vcardUpdated
();
}
belcard_address
->
setStreet
(
::
Utils
::
qStringToLinphoneString
(
address
[
"street"
].
toString
()));
belcard_address
->
setLocality
(
::
Utils
::
qStringToLinphoneString
(
address
[
"locality"
].
toString
()));
belcard_address
->
setPostalCode
(
::
Utils
::
qStringToLinphoneString
(
address
[
"postalCode"
].
toString
()));
belcard_address
->
setCountry
(
::
Utils
::
qStringToLinphoneString
(
address
[
"country"
].
toString
()));
void
VcardModel
::
setLocality
(
const
QString
&
locality
)
{
shared_ptr
<
belcard
::
BelCardAddress
>
address
=
getOrCreateBelCardAddress
(
m_vcard
->
getBelcard
());
address
->
setLocality
(
::
Utils
::
qStringToLinphoneString
(
locality
));
emit
vcardUpdated
();
}
if
(
!
belcard
->
addAddress
(
belcard_address
))
return
false
;
void
VcardModel
::
setPostalCode
(
const
QString
&
postal_code
)
{
shared_ptr
<
belcard
::
BelCardAddress
>
address
=
getOrCreateBelCardAddress
(
m_vcard
->
getBelcard
());
address
->
setPostalCode
(
::
Utils
::
qStringToLinphoneString
(
postal_code
));
emit
vcardUpdated
();
}
void
VcardModel
::
setCountry
(
const
QString
&
country
)
{
shared_ptr
<
belcard
::
BelCardAddress
>
address
=
getOrCreateBelCardAddress
(
m_vcard
->
getBelcard
());
address
->
setCountry
(
::
Utils
::
qStringToLinphoneString
(
country
));
emit
vcardUpdated
();
return
true
;
}
// -----------------------------------------------------------------------------
QVariantList
VcardModel
::
getSipAddresses
()
const
{
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
QVariantList
list
;
...
...
tests/src/components/contact/VcardModel.hpp
View file @
59c0154f
...
...
@@ -11,7 +11,7 @@ class VcardModel : public QObject {
Q_PROPERTY
(
QString
username
READ
getUsername
WRITE
setUsername
NOTIFY
vcardUpdated
);
Q_PROPERTY
(
QString
avatar
READ
getAvatar
WRITE
setAvatar
NOTIFY
vcardUpdated
);
Q_PROPERTY
(
QVariantMap
address
READ
getAddress
WRITE
setAddress
NOTIFY
vcardUpdated
);
Q_PROPERTY
(
QVariantMap
address
READ
getAddress
NOTIFY
vcardUpdated
);
Q_PROPERTY
(
QVariantList
sipAddresses
READ
getSipAddresses
NOTIFY
vcardUpdated
);
Q_PROPERTY
(
QVariantList
companies
READ
getCompanies
NOTIFY
vcardUpdated
);
Q_PROPERTY
(
QVariantList
emails
READ
getEmails
NOTIFY
vcardUpdated
);
...
...
@@ -43,6 +43,11 @@ public slots:
void
removeUrl
(
const
QString
&
url
);
bool
updateUrl
(
const
QString
&
old_url
,
const
QString
&
url
);
void
setStreet
(
const
QString
&
street
);
void
setLocality
(
const
QString
&
locality
);
void
setPostalCode
(
const
QString
&
postal_code
);
void
setCountry
(
const
QString
&
country
);
signals:
void
vcardUpdated
();
...
...
@@ -53,8 +58,6 @@ private:
bool
setAvatar
(
const
QString
&
path
);
QVariantMap
getAddress
()
const
;
bool
setAddress
(
const
QVariantMap
&
address
);
QVariantList
getSipAddresses
()
const
;
QVariantList
getCompanies
()
const
;
QVariantList
getEmails
()
const
;
...
...
tests/ui/modules/Common/Form/ListForm.qml
View file @
59c0154f
...
...
@@ -132,7 +132,7 @@ RowLayout {
}
padding
:
ListFormStyle
.
value
.
text
.
padding
visible
:
values
.
model
.
count
===
0
&&
!
listForm
.
readOnly
visible
:
values
.
model
.
count
===
0
// TODO: placeholder click machin
verticalAlignment
:
Text
.
AlignVCenter
MouseArea
{
...
...
tests/ui/modules/Common/Form/StaticListForm.qml
View file @
59c0154f
...
...
@@ -12,6 +12,16 @@ RowLayout {
property
bool
readOnly
:
false
property
var
fields
signal
changed
(
int
index
,
string
value
)
// ---------------------------------------------------------------------------
function
_handleEditionFinished
(
index
,
text
)
{
if
(
text
!==
fields
[
index
].
text
)
{
form
.
changed
(
index
,
text
)
}
}
// ---------------------------------------------------------------------------
spacing
:
0
...
...
@@ -48,7 +58,9 @@ RowLayout {
placeholder
:
modelData
.
placeholder
||
''
readOnly
:
form
.
readOnly
text
:
modelData
.
text
||
''
onEditingFinished
:
_handleEditionFinished
(
index
,
text
)
}
}
}
}
}
tests/ui/modules/Common/Form/TransparentTextInput.qml
View file @
59c0154f
...
...
@@ -76,7 +76,7 @@ Item {
width
:
textInput
.
width
verticalAlignment
:
Text
.
AlignVCenter
visible
:
textInput
.
text
.
length
===
0
&&
!
textInput
.
activeFocus
&&
!
textInput
.
readOnly
visible
:
textInput
.
text
.
length
===
0
&&
(
!
textInput
.
activeFocus
||
textInput
.
readOnly
)
}
TextInput
{
...
...
tests/ui/views/App/MainWindow/ContactEdit.qml
View file @
59c0154f
...
...
@@ -237,13 +237,27 @@ ColumnLayout {
return
}
var
so_far_so_good
=
(
defaultValue
.
length
===
0
)
?
url
&&
_vcard
.
addUrl
(
newValue
)
:
url
&&
_vcard
.
updateUrl
(
defaultValue
,
newValue
)
var
so_far_so_good
=
url
&&
(
defaultValue
.
length
===
0
?
_vcard
.
addUrl
(
newValue
)
:
_vcard
.
updateUrl
(
defaultValue
,
newValue
)
)
urls
.
setInvalid
(
index
,
!
so_far_so_good
)
}
function
_handleAddressChanged
(
index
,
value
)
{
if
(
index
===
0
)
{
// Street.
_vcard
.
setStreet
(
value
)
}
else
if
(
index
===
1
)
{
// Locality.
_vcard
.
setLocality
(
value
)
}
else
if
(
index
===
2
)
{
// Postal code.
_vcard
.
setPostalCode
(
value
)
}
else
if
(
index
===
3
)
{
// Country.
_vcard
.
setCountry
(
value
)
}
}
// -----------------------------------------------------------------------
ScrollBar.vertical
:
ForceScrollBar
{}
...
...
@@ -371,6 +385,8 @@ ColumnLayout {
readOnly
:
!
_edition
title
:
qsTr
(
'
address
'
)
onChanged
:
_handleAddressChanged
(
index
,
value
)
}
// ---------------------------------------------------------------------
...
...
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