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
3a785172
Commit
3a785172
authored
May 03, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(ui/views/App/Main/ContactEdit): handle correctly new info
parent
da8bdb43
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
119 additions
and
89 deletions
+119
-89
resources.qrc
linphone-desktop/resources.qrc
+1
-0
VcardModel.cpp
linphone-desktop/src/components/contact/VcardModel.cpp
+8
-8
ComboBox.qml
linphone-desktop/ui/modules/Common/Form/ComboBox.qml
+0
-2
ListForm.js
linphone-desktop/ui/modules/Common/Form/ListForm.js
+86
-0
ListForm.qml
linphone-desktop/ui/modules/Common/Form/ListForm.qml
+15
-71
ContactEdit.js
linphone-desktop/ui/views/App/Main/ContactEdit.js
+5
-4
ContactEdit.qml
linphone-desktop/ui/views/App/Main/ContactEdit.qml
+4
-4
No files found.
linphone-desktop/resources.qrc
View file @
3a785172
...
...
@@ -194,6 +194,7 @@
<file>
ui/modules/Common/Form/Fields/TextAreaField.qml
</file>
<file>
ui/modules/Common/Form/Fields/TextField.qml
</file>
<file>
ui/modules/Common/Form/+linux/SearchBox.qml
</file>
<file>
ui/modules/Common/Form/ListForm.js
</file>
<file>
ui/modules/Common/Form/ListForm.qml
</file>
<file>
ui/modules/Common/Form/Placements/FormEmptyLine.qml
</file>
<file>
ui/modules/Common/Form/Placements/FormGroup.qml
</file>
...
...
linphone-desktop/src/components/contact/VcardModel.cpp
View file @
3a785172
...
...
@@ -280,13 +280,13 @@ bool VcardModel::addSipAddress (const QString &sipAddress) {
shared_ptr
<
belcard
::
BelCardImpp
>
value
=
belcard
::
BelCardGeneric
::
create
<
belcard
::
BelCardImpp
>
();
value
->
setValue
(
linphoneAddress
->
asStringUriOnly
());
qInfo
()
<<
QStringLiteral
(
"Add new sip address on vcard: `%1`."
).
arg
(
sipAddress
);
if
(
!
belcard
->
addImpp
(
value
))
{
qWarning
()
<<
QStringLiteral
(
"Unable to add sip address on vcard: `%1`."
).
arg
(
sipAddress
);
return
false
;
}
qInfo
()
<<
QStringLiteral
(
"Add new sip address on vcard: `%1`."
).
arg
(
sipAddress
);
emit
vcardUpdated
();
return
true
;
}
...
...
@@ -338,13 +338,13 @@ bool VcardModel::addCompany (const QString &company) {
shared_ptr
<
belcard
::
BelCardRole
>
value
=
belcard
::
BelCardGeneric
::
create
<
belcard
::
BelCardRole
>
();
value
->
setValue
(
::
Utils
::
qStringToLinphoneString
(
company
));
qInfo
()
<<
QStringLiteral
(
"Add new company on vcard: `%1`."
).
arg
(
company
);
if
(
!
belcard
->
addRole
(
value
))
{
qWarning
()
<<
QStringLiteral
(
"Unable to add company on vcard: `%1`."
).
arg
(
company
);
return
false
;
}
qInfo
()
<<
QStringLiteral
(
"Add new company on vcard: `%1`."
).
arg
(
company
);
emit
vcardUpdated
();
return
true
;
}
...
...
@@ -389,13 +389,13 @@ bool VcardModel::addEmail (const QString &email) {
shared_ptr
<
belcard
::
BelCardEmail
>
value
=
belcard
::
BelCardGeneric
::
create
<
belcard
::
BelCardEmail
>
();
value
->
setValue
(
::
Utils
::
qStringToLinphoneString
(
email
));
qInfo
()
<<
QStringLiteral
(
"Add new email on vcard: `%1`."
).
arg
(
email
);
if
(
!
belcard
->
addEmail
(
value
))
{
qWarning
()
<<
QStringLiteral
(
"Unable to add email on vcard: `%1`."
).
arg
(
email
);
return
false
;
}
qInfo
()
<<
QStringLiteral
(
"Add new email on vcard: `%1`."
).
arg
(
email
);
emit
vcardUpdated
();
return
true
;
}
...
...
@@ -440,13 +440,13 @@ bool VcardModel::addUrl (const QString &url) {
shared_ptr
<
belcard
::
BelCardURL
>
value
=
belcard
::
BelCardGeneric
::
create
<
belcard
::
BelCardURL
>
();
value
->
setValue
(
::
Utils
::
qStringToLinphoneString
(
url
));
qInfo
()
<<
QStringLiteral
(
"Add new url on vcard: `%1`."
).
arg
(
url
);
if
(
!
belcard
->
addURL
(
value
))
{
qWarning
()
<<
QStringLiteral
(
"Unable to add url on vcard: `%1`."
).
arg
(
url
);
return
false
;
}
qInfo
()
<<
QStringLiteral
(
"Add new url on vcard: `%1`."
).
arg
(
url
);
emit
vcardUpdated
();
return
true
;
}
...
...
linphone-desktop/ui/modules/Common/Form/ComboBox.qml
View file @
3a785172
...
...
@@ -5,8 +5,6 @@ import QtQuick.Layouts 1.3
import
Common
1.0
import
Common
.
Styles
1.0
import
Utils
1.0
import
'
ComboBox.js
'
as
Logic
// =============================================================================
...
...
linphone-desktop/ui/modules/Common/Form/ListForm.js
0 → 100644
View file @
3a785172
// =============================================================================
// `ListForm.qml` Logic.
// =============================================================================
.
import
'
qrc:/ui/scripts/Utils/utils.js
'
as
Utils
// =============================================================================
function
setData
(
data
)
{
var
model
=
values
.
model
model
.
clear
()
data
.
forEach
(
function
(
data
)
{
model
.
append
({
$value
:
data
,
$isInvalid
:
false
})
})
}
function
setInvalid
(
index
,
status
)
{
Utils
.
assert
(
index
>=
0
&&
index
<
values
.
model
.
count
,
'
Index
'
+
index
+
'
not exists.
'
)
values
.
model
.
setProperty
(
index
,
'
$isInvalid
'
,
status
)
}
function
updateValue
(
index
,
value
)
{
var
model
=
values
.
model
// Unable to set property directly. Qt uses a cache of the value.
// It's necessary to remove then insert.
model
.
remove
(
index
)
model
.
insert
(
index
,
{
$isInvalid
:
false
,
$value
:
value
})
}
// -----------------------------------------------------------------------------
function
addValue
(
value
)
{
values
.
model
.
append
({
$value
:
value
,
$isInvalid
:
false
})
if
(
value
.
length
===
0
)
{
addButton
.
enabled
=
false
}
}
function
handleEditionFinished
(
index
,
text
)
{
var
model
=
values
.
model
var
oldValue
=
model
.
get
(
index
).
$value
if
(
text
.
length
===
0
)
{
// No changes. It must exists at least n min values.
if
(
minValues
!=
null
&&
minValues
>=
model
.
count
)
{
updateValue
(
index
,
oldValue
)
return
}
model
.
remove
(
index
)
if
(
oldValue
.
length
!==
0
)
{
listForm
.
removed
(
index
,
oldValue
)
}
}
else
if
(
text
!==
oldValue
)
{
// Update changes.
updateValue
(
index
,
text
)
listForm
.
changed
(
index
,
oldValue
,
text
)
}
addButton
.
enabled
=
true
}
function
handleItemCreation
()
{
if
(
this
.
text
.
length
===
0
)
{
// FIXME: Find the source of this problem.
//
// Magic code. If it's the first inserted value,
// an event or a callback steal the item focus.
// I suppose it's an internal Qt qml event...
//
// So, I choose to run a callback executed after this
// internal event.
Utils
.
setTimeout
(
values
,
0
,
this
.
forceActiveFocus
)
}
}
linphone-desktop/ui/modules/Common/Form/ListForm.qml
View file @
3a785172
...
...
@@ -3,7 +3,8 @@ import QtQuick.Layouts 1.3
import
Common
1.0
import
Common
.
Styles
1.0
import
Utils
1.0
import
'
ListForm.js
'
as
Logic
// =============================================================================
...
...
@@ -21,64 +22,21 @@ RowLayout {
// ---------------------------------------------------------------------------
signal
changed
(
int
index
,
string
default
Value
,
string
newValue
)
signal
changed
(
int
index
,
string
old
Value
,
string
newValue
)
signal
removed
(
int
index
,
string
value
)
// ---------------------------------------------------------------------------
function
setInvalid
(
index
,
status
)
{
Utils
.
assert
(
index
>=
0
&&
index
<
values
.
model
.
count
,
'
Index
'
+
index
+
'
not exists.
'
)
values
.
model
.
setProperty
(
index
,
'
$isInvalid
'
,
status
)
function
setData
()
{
Logic
.
setData
.
apply
(
this
,
arguments
)
}
function
setData
(
data
)
{
var
model
=
values
.
model
model
.
clear
()
data
.
forEach
(
function
(
data
)
{
model
.
append
({
$value
:
data
,
$isInvalid
:
false
})
})
}
function
_addValue
(
value
)
{
values
.
model
.
append
({
$value
:
value
,
$isInvalid
:
false
})
if
(
value
.
length
===
0
)
{
addButton
.
enabled
=
false
}
function
setInvalid
()
{
Logic
.
setInvalid
.
apply
(
this
,
arguments
)
}
function
_handleEditionFinished
(
index
,
text
)
{
var
model
=
values
.
model
var
defaultValue
=
model
.
get
(
index
).
$value
if
(
text
.
length
===
0
)
{
// No changes. It must exists at least n min values.
if
(
minValues
!=
null
&&
minValues
>=
model
.
count
)
{
// Unable to set property directly. Qt uses a cache of the value.
model
.
remove
(
index
)
model
.
insert
(
index
,
{
$isInvalid
:
false
,
$value
:
defaultValue
})
return
}
model
.
remove
(
index
)
if
(
defaultValue
.
length
!==
0
)
{
listForm
.
removed
(
index
,
defaultValue
)
}
}
else
if
(
text
!==
defaultValue
)
{
// Update changes.
listForm
.
changed
(
index
,
defaultValue
,
text
)
}
addButton
.
enabled
=
true
function
updateValue
()
{
Logic
.
updateValue
.
apply
(
this
,
arguments
)
}
// ---------------------------------------------------------------------------
...
...
@@ -99,9 +57,9 @@ RowLayout {
icon
:
'
add
'
iconSize
:
ListFormStyle
.
titleArea
.
iconSize
opacity
:
_edition
?
1
:
0
opacity
:
!
listForm
.
readOnly
?
1
:
0
onClicked
:
_edition
&&
_
addValue
(
''
)
onClicked
:
!
listForm
.
readOnly
&&
Logic
.
addValue
(
''
)
}
Text
{
...
...
@@ -140,7 +98,7 @@ RowLayout {
MouseArea
{
anchors.fill
:
parent
onClicked
:
!
listForm
.
readOnly
&&
_
addValue
(
''
)
onClicked
:
!
listForm
.
readOnly
&&
Logic
.
addValue
(
''
)
}
}
...
...
@@ -171,23 +129,9 @@ RowLayout {
height
:
ListFormStyle
.
lineHeight
width
:
parent
.
width
onEditingFinished
:
_handleEditionFinished
(
index
,
text
)
Component.onCompleted
:
{
if
(
$value
.
length
===
0
)
{
// FIXME: Find the source of this problem.
//
// Magic code. If it's the first inserted value,
// an event or a callback steal the item focus.
// I suppose it's an internal Qt qml event...
//
// So, I choose to run a callback executed after this
// internal event.
Utils
.
setTimeout
(
values
,
0
,
function
()
{
textInput
.
forceActiveFocus
()
})
}
}
Component.onCompleted
:
Logic
.
handleItemCreation
.
apply
(
this
)
onEditingFinished
:
Logic
.
handleEditionFinished
(
index
,
text
)
}
}
...
...
linphone-desktop/ui/views/App/Main/ContactEdit.js
View file @
3a785172
...
...
@@ -116,15 +116,16 @@ function setUsername (username) {
// -----------------------------------------------------------------------------
function
handleValueChanged
(
fields
,
index
,
default
Value
,
newValue
,
add
,
update
)
{
if
(
newValue
===
default
Value
)
{
function
handleValueChanged
(
fields
,
index
,
old
Value
,
newValue
,
add
,
update
)
{
if
(
newValue
===
old
Value
)
{
return
}
console
.
log
(
'
handle
'
,
oldValue
,
newValue
)
var
vcard
=
contactEdit
.
_vcard
var
soFarSoGood
=
(
default
Value
.
length
===
0
)
var
soFarSoGood
=
(
old
Value
.
length
===
0
)
?
vcard
[
add
](
newValue
)
:
vcard
[
update
](
default
Value
,
newValue
)
:
vcard
[
update
](
old
Value
,
newValue
)
fields
.
setInvalid
(
index
,
!
soFarSoGood
)
}
...
...
linphone-desktop/ui/views/App/Main/ContactEdit.qml
View file @
3a785172
...
...
@@ -206,7 +206,7 @@ ColumnLayout {
readOnly
:
!
_edition
title
:
qsTr
(
'
sipAccounts
'
)
onChanged
:
Logic
.
handleSipAddressChanged
(
addresses
,
index
,
default
Value
,
newValue
)
onChanged
:
Logic
.
handleSipAddressChanged
(
addresses
,
index
,
old
Value
,
newValue
)
onRemoved
:
_vcard
.
removeSipAddress
(
value
)
}
...
...
@@ -226,7 +226,7 @@ ColumnLayout {
readOnly
:
!
_edition
title
:
qsTr
(
'
companies
'
)
onChanged
:
Logic
.
handleCompanyChanged
(
companies
,
index
,
default
Value
,
newValue
)
onChanged
:
Logic
.
handleCompanyChanged
(
companies
,
index
,
old
Value
,
newValue
)
onRemoved
:
_vcard
.
removeCompany
(
value
)
}
...
...
@@ -246,7 +246,7 @@ ColumnLayout {
readOnly
:
!
_edition
title
:
qsTr
(
'
emails
'
)
onChanged
:
Logic
.
handleEmailChanged
(
emails
,
index
,
default
Value
,
newValue
)
onChanged
:
Logic
.
handleEmailChanged
(
emails
,
index
,
old
Value
,
newValue
)
onRemoved
:
_vcard
.
removeEmail
(
value
)
}
...
...
@@ -266,7 +266,7 @@ ColumnLayout {
readOnly
:
!
_edition
title
:
qsTr
(
'
webSites
'
)
onChanged
:
Logic
.
handleUrlChanged
(
urls
,
index
,
default
Value
,
newValue
)
onChanged
:
Logic
.
handleUrlChanged
(
urls
,
index
,
old
Value
,
newValue
)
onRemoved
:
_vcard
.
removeUrl
(
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