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
Show 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) {
...
@@ -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
{
QVariantMap
VcardModel
::
getAddress
()
const
{
list
<
shared_ptr
<
belcard
::
BelCardAddress
>
>
addresses
=
m_vcard
->
getBelcard
()
->
getAddresses
();
list
<
shared_ptr
<
belcard
::
BelCardAddress
>
>
addresses
=
m_vcard
->
getBelcard
()
->
getAddresses
();
QVariantMap
map
;
QVariantMap
map
;
...
@@ -165,27 +179,32 @@ QVariantMap VcardModel::getAddress () const {
...
@@ -165,27 +179,32 @@ QVariantMap VcardModel::getAddress () const {
return
map
;
return
map
;
}
}
bool
VcardModel
::
setAddress
(
const
QVariantMap
&
address
)
{
void
VcardModel
::
setStreet
(
const
QString
&
street
)
{
shared_ptr
<
belcard
::
BelCard
>
belcard
=
m_vcard
->
getBelcard
();
shared_ptr
<
belcard
::
BelCardAddress
>
address
=
getOrCreateBelCardAddress
(
m_vcard
->
getBelcard
());
list
<
shared_ptr
<
belcard
::
BelCardAddress
>
>
addresses
=
belcard
->
getAddresses
();
address
->
setStreet
(
::
Utils
::
qStringToLinphoneString
(
street
));
emit
vcardUpdated
();
while
(
!
addresses
.
empty
())
}
belcard
->
removeAddress
(
addresses
.
front
());
shared_ptr
<
belcard
::
BelCardAddress
>
belcard_address
=
belcard
::
BelCardGeneric
::
create
<
belcard
::
BelCardAddress
>
();
belcard_address
->
setStreet
(
::
Utils
::
qStringToLinphoneString
(
address
[
"street"
].
toString
()));
void
VcardModel
::
setLocality
(
const
QString
&
locality
)
{
belcard_address
->
setLocality
(
::
Utils
::
qStringToLinphoneString
(
address
[
"locality"
].
toString
()));
shared_ptr
<
belcard
::
BelCardAddress
>
address
=
getOrCreateBelCardAddress
(
m_vcard
->
getBelcard
());
belcard_address
->
setPostalCode
(
::
Utils
::
qStringToLinphoneString
(
address
[
"postalCode"
].
toString
()));
address
->
setLocality
(
::
Utils
::
qStringToLinphoneString
(
locality
));
belcard_address
->
setCountry
(
::
Utils
::
qStringToLinphoneString
(
address
[
"country"
].
toString
()));
emit
vcardUpdated
();
}
if
(
!
belcard
->
addAddress
(
belcard_address
))
void
VcardModel
::
setPostalCode
(
const
QString
&
postal_code
)
{
return
false
;
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
();
emit
vcardUpdated
();
return
true
;
}
}
// -----------------------------------------------------------------------------
QVariantList
VcardModel
::
getSipAddresses
()
const
{
QVariantList
VcardModel
::
getSipAddresses
()
const
{
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
QVariantList
list
;
QVariantList
list
;
...
...
tests/src/components/contact/VcardModel.hpp
View file @
59c0154f
...
@@ -11,7 +11,7 @@ class VcardModel : public QObject {
...
@@ -11,7 +11,7 @@ class VcardModel : public QObject {
Q_PROPERTY
(
QString
username
READ
getUsername
WRITE
setUsername
NOTIFY
vcardUpdated
);
Q_PROPERTY
(
QString
username
READ
getUsername
WRITE
setUsername
NOTIFY
vcardUpdated
);
Q_PROPERTY
(
QString
avatar
READ
getAvatar
WRITE
setAvatar
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
sipAddresses
READ
getSipAddresses
NOTIFY
vcardUpdated
);
Q_PROPERTY
(
QVariantList
companies
READ
getCompanies
NOTIFY
vcardUpdated
);
Q_PROPERTY
(
QVariantList
companies
READ
getCompanies
NOTIFY
vcardUpdated
);
Q_PROPERTY
(
QVariantList
emails
READ
getEmails
NOTIFY
vcardUpdated
);
Q_PROPERTY
(
QVariantList
emails
READ
getEmails
NOTIFY
vcardUpdated
);
...
@@ -43,6 +43,11 @@ public slots:
...
@@ -43,6 +43,11 @@ public slots:
void
removeUrl
(
const
QString
&
url
);
void
removeUrl
(
const
QString
&
url
);
bool
updateUrl
(
const
QString
&
old_url
,
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:
signals:
void
vcardUpdated
();
void
vcardUpdated
();
...
@@ -53,8 +58,6 @@ private:
...
@@ -53,8 +58,6 @@ private:
bool
setAvatar
(
const
QString
&
path
);
bool
setAvatar
(
const
QString
&
path
);
QVariantMap
getAddress
()
const
;
QVariantMap
getAddress
()
const
;
bool
setAddress
(
const
QVariantMap
&
address
);
QVariantList
getSipAddresses
()
const
;
QVariantList
getSipAddresses
()
const
;
QVariantList
getCompanies
()
const
;
QVariantList
getCompanies
()
const
;
QVariantList
getEmails
()
const
;
QVariantList
getEmails
()
const
;
...
...
tests/ui/modules/Common/Form/ListForm.qml
View file @
59c0154f
...
@@ -132,7 +132,7 @@ RowLayout {
...
@@ -132,7 +132,7 @@ RowLayout {
}
}
padding
:
ListFormStyle
.
value
.
text
.
padding
padding
:
ListFormStyle
.
value
.
text
.
padding
visible
:
values
.
model
.
count
===
0
&&
!
listForm
.
readOnly
visible
:
values
.
model
.
count
===
0
// TODO: placeholder click machin
verticalAlignment
:
Text
.
AlignVCenter
verticalAlignment
:
Text
.
AlignVCenter
MouseArea
{
MouseArea
{
...
...
tests/ui/modules/Common/Form/StaticListForm.qml
View file @
59c0154f
...
@@ -12,6 +12,16 @@ RowLayout {
...
@@ -12,6 +12,16 @@ RowLayout {
property
bool
readOnly
:
false
property
bool
readOnly
:
false
property
var
fields
property
var
fields
signal
changed
(
int
index
,
string
value
)
// ---------------------------------------------------------------------------
function
_handleEditionFinished
(
index
,
text
)
{
if
(
text
!==
fields
[
index
].
text
)
{
form
.
changed
(
index
,
text
)
}
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
spacing
:
0
spacing
:
0
...
@@ -48,6 +58,8 @@ RowLayout {
...
@@ -48,6 +58,8 @@ RowLayout {
placeholder
:
modelData
.
placeholder
||
''
placeholder
:
modelData
.
placeholder
||
''
readOnly
:
form
.
readOnly
readOnly
:
form
.
readOnly
text
:
modelData
.
text
||
''
text
:
modelData
.
text
||
''
onEditingFinished
:
_handleEditionFinished
(
index
,
text
)
}
}
}
}
}
}
...
...
tests/ui/modules/Common/Form/TransparentTextInput.qml
View file @
59c0154f
...
@@ -76,7 +76,7 @@ Item {
...
@@ -76,7 +76,7 @@ Item {
width
:
textInput
.
width
width
:
textInput
.
width
verticalAlignment
:
Text
.
AlignVCenter
verticalAlignment
:
Text
.
AlignVCenter
visible
:
textInput
.
text
.
length
===
0
&&
!
textInput
.
activeFocus
&&
!
textInput
.
readOnly
visible
:
textInput
.
text
.
length
===
0
&&
(
!
textInput
.
activeFocus
||
textInput
.
readOnly
)
}
}
TextInput
{
TextInput
{
...
...
tests/ui/views/App/MainWindow/ContactEdit.qml
View file @
59c0154f
...
@@ -237,13 +237,27 @@ ColumnLayout {
...
@@ -237,13 +237,27 @@ ColumnLayout {
return
return
}
}
var
so_far_so_good
=
(
defaultValue
.
length
===
0
)
var
so_far_so_good
=
url
&&
(
?
url
&&
_vcard
.
addUrl
(
newValue
)
defaultValue
.
length
===
0
:
url
&&
_vcard
.
updateUrl
(
defaultValue
,
newValue
)
?
_vcard
.
addUrl
(
newValue
)
:
_vcard
.
updateUrl
(
defaultValue
,
newValue
)
)
urls
.
setInvalid
(
index
,
!
so_far_so_good
)
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
{}
ScrollBar.vertical
:
ForceScrollBar
{}
...
@@ -371,6 +385,8 @@ ColumnLayout {
...
@@ -371,6 +385,8 @@ ColumnLayout {
readOnly
:
!
_edition
readOnly
:
!
_edition
title
:
qsTr
(
'
address
'
)
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