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
1de0129e
Commit
1de0129e
authored
May 02, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(ui/views/App/Main/ContactEdit): smart edition
parent
40f5c1a4
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
227 additions
and
217 deletions
+227
-217
CallsListModel.cpp
linphone-desktop/src/components/calls/CallsListModel.cpp
+1
-1
ContactModel.cpp
linphone-desktop/src/components/contact/ContactModel.cpp
+47
-13
ContactModel.hpp
linphone-desktop/src/components/contact/ContactModel.hpp
+8
-11
VcardModel.cpp
linphone-desktop/src/components/contact/VcardModel.cpp
+13
-2
VcardModel.hpp
linphone-desktop/src/components/contact/VcardModel.hpp
+4
-2
ListForm.qml
linphone-desktop/ui/modules/Common/Form/ListForm.qml
+0
-11
utils.js
linphone-desktop/ui/scripts/Utils/utils.js
+1
-13
ContactEdit.js
linphone-desktop/ui/views/App/Main/ContactEdit.js
+41
-41
ContactEdit.qml
linphone-desktop/ui/views/App/Main/ContactEdit.qml
+112
-123
No files found.
linphone-desktop/src/components/calls/CallsListModel.cpp
View file @
1de0129e
...
@@ -195,7 +195,7 @@ void CallsListModel::removeCall (const shared_ptr<linphone::Call> &call) {
...
@@ -195,7 +195,7 @@ void CallsListModel::removeCall (const shared_ptr<linphone::Call> &call) {
}
catch
(
const
out_of_range
&
)
{
}
catch
(
const
out_of_range
&
)
{
// Can be a bug. Or the call model not exists because the linphone call state
// Can be a bug. Or the call model not exists because the linphone call state
// `CallStateIncomingReceived`/`CallStateOutgoingInit` was not notified.
// `CallStateIncomingReceived`/`CallStateOutgoingInit` was not notified.
qWarning
()
<<
QStringLiteral
(
"Unable to found
call in:"
)
<<
callModel
;
qWarning
()
<<
QStringLiteral
(
"Unable to found
linphone call:"
)
<<
&
(
*
call
)
;
return
;
return
;
}
}
...
...
linphone-desktop/src/components/contact/ContactModel.cpp
View file @
1de0129e
...
@@ -31,28 +31,39 @@ using namespace std;
...
@@ -31,28 +31,39 @@ using namespace std;
// =============================================================================
// =============================================================================
ContactModel
::
ContactModel
(
QObject
*
parent
,
shared_ptr
<
linphone
::
Friend
>
linphoneFriend
)
:
QObject
(
parent
)
{
ContactModel
::
ContactModel
(
QObject
*
parent
,
shared_ptr
<
linphone
::
Friend
>
linphoneFriend
)
:
QObject
(
parent
)
{
Q_ASSERT
(
linphoneFriend
!=
nullptr
);
mLinphoneFriend
=
linphoneFriend
;
mLinphoneFriend
=
linphoneFriend
;
mVcard
=
make_shared
<
VcardModel
>
(
linphoneFriend
->
getVcard
());
App
::
getInstance
()
->
getEngine
()
->
setObjectOwnership
(
mVcard
.
get
(),
QQmlEngine
::
CppOwnership
);
mVcardModel
=
new
VcardModel
(
linphoneFriend
->
getVcard
());
App
::
getInstance
()
->
getEngine
()
->
setObjectOwnership
(
mVcardModel
,
QQmlEngine
::
CppOwnership
);
mLinphoneFriend
->
setData
(
"contact-model"
,
*
this
);
mLinphoneFriend
->
setData
(
"contact-model"
,
*
this
);
}
}
ContactModel
::
ContactModel
(
QObject
*
parent
,
VcardModel
*
vcard
)
:
QObject
(
parent
)
{
ContactModel
::
ContactModel
(
QObject
*
parent
,
VcardModel
*
vcard
Model
)
:
QObject
(
parent
)
{
Q_ASSERT
(
vcard
!=
nullptr
);
Q_ASSERT
(
vcard
Model
!=
nullptr
);
QQmlEngine
*
engine
=
App
::
getInstance
()
->
getEngine
();
QQmlEngine
*
engine
=
App
::
getInstance
()
->
getEngine
();
if
(
engine
->
objectOwnership
(
vcard
)
==
QQmlEngine
::
CppOwnership
)
if
(
engine
->
objectOwnership
(
vcardModel
)
==
QQmlEngine
::
CppOwnership
)
{
throw
invalid_argument
(
"A contact is already linked to this vcard."
);
qWarning
()
<<
QStringLiteral
(
"A contact is already linked to this vcard:"
)
<<
vcardModel
;
abort
();
}
mLinphoneFriend
=
linphone
::
Friend
::
newFromVcard
(
vcard
->
mVcard
);
Q_ASSERT
(
vcardModel
->
mVcard
!=
nullptr
);
mLinphoneFriend
=
linphone
::
Friend
::
newFromVcard
(
vcardModel
->
mVcard
);
mLinphoneFriend
->
setData
(
"contact-model"
,
*
this
);
mLinphoneFriend
->
setData
(
"contact-model"
,
*
this
);
mVcard
.
reset
(
vcard
);
mVcardModel
=
vcardModel
;
engine
->
setObjectOwnership
(
vcardModel
,
QQmlEngine
::
CppOwnership
);
engine
->
setObjectOwnership
(
vcard
,
QQmlEngine
::
CppOwnership
)
;
qInfo
()
<<
QStringLiteral
(
"Create contact from vcard:"
)
<<
this
<<
vcardModel
;
}
}
// -----------------------------------------------------------------------------
void
ContactModel
::
refreshPresence
()
{
void
ContactModel
::
refreshPresence
()
{
Presence
::
PresenceStatus
status
=
static_cast
<
Presence
::
PresenceStatus
>
(
Presence
::
PresenceStatus
status
=
static_cast
<
Presence
::
PresenceStatus
>
(
mLinphoneFriend
->
getConsolidatedPresence
()
mLinphoneFriend
->
getConsolidatedPresence
()
...
@@ -62,15 +73,17 @@ void ContactModel::refreshPresence () {
...
@@ -62,15 +73,17 @@ void ContactModel::refreshPresence () {
emit
presenceLevelChanged
(
Presence
::
getPresenceLevel
(
status
));
emit
presenceLevelChanged
(
Presence
::
getPresenceLevel
(
status
));
}
}
// -----------------------------------------------------------------------------
void
ContactModel
::
startEdit
()
{
void
ContactModel
::
startEdit
()
{
mLinphoneFriend
->
edit
();
mLinphoneFriend
->
edit
();
mOldSipAddresses
=
mVcard
->
getSipAddresses
();
mOldSipAddresses
=
mVcard
Model
->
getSipAddresses
();
}
}
void
ContactModel
::
endEdit
()
{
void
ContactModel
::
endEdit
()
{
mLinphoneFriend
->
done
();
mLinphoneFriend
->
done
();
QVariantList
sipAddresses
=
mVcard
->
getSipAddresses
();
QVariantList
sipAddresses
=
mVcard
Model
->
getSipAddresses
();
QSet
<
QString
>
done
;
QSet
<
QString
>
done
;
for
(
const
auto
&
variantA
:
mOldSipAddresses
)
{
for
(
const
auto
&
variantA
:
mOldSipAddresses
)
{
...
@@ -104,13 +117,13 @@ next:
...
@@ -104,13 +117,13 @@ next:
}
}
void
ContactModel
::
abortEdit
()
{
void
ContactModel
::
abortEdit
()
{
// TODO: call linphone friend abort function when available.
// mLinphoneFriend->abort();
mOldSipAddresses
.
clear
();
mOldSipAddresses
.
clear
();
emit
contactUpdated
();
emit
contactUpdated
();
}
}
// -----------------------------------------------------------------------------
Presence
::
PresenceStatus
ContactModel
::
getPresenceStatus
()
const
{
Presence
::
PresenceStatus
ContactModel
::
getPresenceStatus
()
const
{
return
static_cast
<
Presence
::
PresenceStatus
>
(
mLinphoneFriend
->
getConsolidatedPresence
());
return
static_cast
<
Presence
::
PresenceStatus
>
(
mLinphoneFriend
->
getConsolidatedPresence
());
}
}
...
@@ -118,3 +131,24 @@ Presence::PresenceStatus ContactModel::getPresenceStatus () const {
...
@@ -118,3 +131,24 @@ Presence::PresenceStatus ContactModel::getPresenceStatus () const {
Presence
::
PresenceLevel
ContactModel
::
getPresenceLevel
()
const
{
Presence
::
PresenceLevel
ContactModel
::
getPresenceLevel
()
const
{
return
Presence
::
getPresenceLevel
(
getPresenceStatus
());
return
Presence
::
getPresenceLevel
(
getPresenceStatus
());
}
}
// -----------------------------------------------------------------------------
VcardModel
*
ContactModel
::
getVcardModel
()
const
{
return
mVcardModel
;
}
void
ContactModel
::
setVcardModel
(
VcardModel
*
vcardModel
)
{
Q_ASSERT
(
vcardModel
!=
nullptr
);
Q_ASSERT
(
vcardModel
!=
mVcardModel
);
QQmlEngine
*
engine
=
App
::
getInstance
()
->
getEngine
();
engine
->
setObjectOwnership
(
vcardModel
,
QQmlEngine
::
CppOwnership
);
engine
->
setObjectOwnership
(
mVcardModel
,
QQmlEngine
::
JavaScriptOwnership
);
qInfo
()
<<
QStringLiteral
(
"Set vcard on contact:"
)
<<
this
<<
vcardModel
;
qInfo
()
<<
QStringLiteral
(
"Remove vcard on contact:"
)
<<
this
<<
mVcardModel
;
mLinphoneFriend
->
setVcard
(
vcardModel
->
mVcard
);
mVcardModel
=
vcardModel
;
}
linphone-desktop/src/components/contact/ContactModel.hpp
View file @
1de0129e
...
@@ -33,29 +33,30 @@ class ContactModel : public QObject {
...
@@ -33,29 +33,30 @@ class ContactModel : public QObject {
Q_PROPERTY
(
Presence
::
PresenceStatus
presenceStatus
READ
getPresenceStatus
NOTIFY
presenceStatusChanged
);
Q_PROPERTY
(
Presence
::
PresenceStatus
presenceStatus
READ
getPresenceStatus
NOTIFY
presenceStatusChanged
);
Q_PROPERTY
(
Presence
::
PresenceLevel
presenceLevel
READ
getPresenceLevel
NOTIFY
presenceLevelChanged
);
Q_PROPERTY
(
Presence
::
PresenceLevel
presenceLevel
READ
getPresenceLevel
NOTIFY
presenceLevelChanged
);
Q_PROPERTY
(
VcardModel
*
vcard
READ
getVcardModel
Ptr
NOTIFY
contactUpdated
);
Q_PROPERTY
(
VcardModel
*
vcard
READ
getVcardModel
WRITE
setVcardModel
NOTIFY
contactUpdated
);
// Grant access to `mLinphoneFriend`.
friend
class
ContactsListModel
;
friend
class
ContactsListModel
;
friend
class
ContactsListProxyModel
;
friend
class
ContactsListProxyModel
;
friend
class
SmartSearchBarModel
;
friend
class
SmartSearchBarModel
;
public:
public:
ContactModel
(
QObject
*
parent
,
std
::
shared_ptr
<
linphone
::
Friend
>
linphoneFriend
);
ContactModel
(
QObject
*
parent
,
std
::
shared_ptr
<
linphone
::
Friend
>
linphoneFriend
);
ContactModel
(
QObject
*
parent
,
VcardModel
*
vcard
);
ContactModel
(
QObject
*
parent
,
VcardModel
*
vcard
Model
);
~
ContactModel
()
=
default
;
~
ContactModel
()
=
default
;
std
::
shared_ptr
<
VcardModel
>
getVcardModel
()
const
{
return
mVcard
;
}
void
refreshPresence
();
void
refreshPresence
();
Q_INVOKABLE
void
startEdit
();
Q_INVOKABLE
void
startEdit
();
Q_INVOKABLE
void
endEdit
();
Q_INVOKABLE
void
endEdit
();
Q_INVOKABLE
void
abortEdit
();
Q_INVOKABLE
void
abortEdit
();
VcardModel
*
getVcardModel
()
const
;
void
setVcardModel
(
VcardModel
*
vcardModel
);
signals:
signals:
void
contactUpdated
();
void
contactUpdated
();
void
presenceStatusChanged
(
Presence
::
PresenceStatus
status
);
void
presenceStatusChanged
(
Presence
::
PresenceStatus
status
);
void
presenceLevelChanged
(
Presence
::
PresenceLevel
level
);
void
presenceLevelChanged
(
Presence
::
PresenceLevel
level
);
void
sipAddressAdded
(
const
QString
&
sipAddress
);
void
sipAddressAdded
(
const
QString
&
sipAddress
);
...
@@ -65,13 +66,9 @@ private:
...
@@ -65,13 +66,9 @@ private:
Presence
::
PresenceStatus
getPresenceStatus
()
const
;
Presence
::
PresenceStatus
getPresenceStatus
()
const
;
Presence
::
PresenceLevel
getPresenceLevel
()
const
;
Presence
::
PresenceLevel
getPresenceLevel
()
const
;
VcardModel
*
getVcardModelPtr
()
const
{
return
mVcard
.
get
();
}
QVariantList
mOldSipAddresses
;
QVariantList
mOldSipAddresses
;
std
::
shared_ptr
<
VcardModel
>
mVcard
;
VcardModel
*
mVcardModel
;
std
::
shared_ptr
<
linphone
::
Friend
>
mLinphoneFriend
;
std
::
shared_ptr
<
linphone
::
Friend
>
mLinphoneFriend
;
};
};
...
...
linphone-desktop/src/components/contact/VcardModel.cpp
View file @
1de0129e
...
@@ -71,6 +71,8 @@ inline shared_ptr<belcard::BelCardPhoto> findBelCardPhoto (const list<shared_ptr
...
@@ -71,6 +71,8 @@ inline shared_ptr<belcard::BelCardPhoto> findBelCardPhoto (const list<shared_ptr
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
VcardModel
::
VcardModel
(
shared_ptr
<
linphone
::
Vcard
>
vcard
)
:
mVcard
(
vcard
)
{}
VcardModel
::~
VcardModel
()
{
VcardModel
::~
VcardModel
()
{
// If it's a detached Vcard, the linked photo must be destroyed from fs.
// If it's a detached Vcard, the linked photo must be destroyed from fs.
if
(
App
::
getInstance
()
->
getEngine
()
->
objectOwnership
(
this
)
!=
QQmlEngine
::
CppOwnership
)
{
if
(
App
::
getInstance
()
->
getEngine
()
->
objectOwnership
(
this
)
!=
QQmlEngine
::
CppOwnership
)
{
...
@@ -87,7 +89,16 @@ VcardModel::~VcardModel () {
...
@@ -87,7 +89,16 @@ VcardModel::~VcardModel () {
if
(
!
QFile
::
remove
(
imagePath
))
if
(
!
QFile
::
remove
(
imagePath
))
qWarning
()
<<
QStringLiteral
(
"Unable to remove `%1`."
).
arg
(
imagePath
);
qWarning
()
<<
QStringLiteral
(
"Unable to remove `%1`."
).
arg
(
imagePath
);
}
qInfo
()
<<
QStringLiteral
(
"Destroy detached vcard:"
)
<<
this
;
}
else
qInfo
()
<<
QStringLiteral
(
"Destroy attached vcard:"
)
<<
this
;
}
// -----------------------------------------------------------------------------
VcardModel
*
VcardModel
::
clone
()
const
{
return
new
VcardModel
(
mVcard
->
clone
());
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
@@ -113,7 +124,7 @@ QString VcardModel::getAvatar () const {
...
@@ -113,7 +124,7 @@ QString VcardModel::getAvatar () const {
// No path found.
// No path found.
if
(
!
photo
)
if
(
!
photo
)
return
""
;
return
QStringLiteral
(
""
)
;
// Returns right path.
// Returns right path.
return
QStringLiteral
(
"image://%1/%2"
).
arg
(
AvatarProvider
::
PROVIDER_ID
).
arg
(
return
QStringLiteral
(
"image://%1/%2"
).
arg
(
AvatarProvider
::
PROVIDER_ID
).
arg
(
...
...
linphone-desktop/src/components/contact/VcardModel.hpp
View file @
1de0129e
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
// =============================================================================
// =============================================================================
class
VcardModel
:
public
QObject
{
class
VcardModel
:
public
QObject
{
friend
class
ContactModel
;
friend
class
ContactModel
;
// Grant access to `mVcard`.
Q_OBJECT
;
Q_OBJECT
;
...
@@ -42,13 +42,15 @@ class VcardModel : public QObject {
...
@@ -42,13 +42,15 @@ class VcardModel : public QObject {
Q_PROPERTY
(
QVariantList
urls
READ
getUrls
NOTIFY
vcardUpdated
);
Q_PROPERTY
(
QVariantList
urls
READ
getUrls
NOTIFY
vcardUpdated
);
public:
public:
VcardModel
(
std
::
shared_ptr
<
linphone
::
Vcard
>
vcard
)
:
mVcard
(
vcard
)
{}
VcardModel
(
std
::
shared_ptr
<
linphone
::
Vcard
>
vcard
)
;
~
VcardModel
();
~
VcardModel
();
QString
getUsername
()
const
;
QString
getUsername
()
const
;
QVariantList
getSipAddresses
()
const
;
QVariantList
getSipAddresses
()
const
;
Q_INVOKABLE
VcardModel
*
clone
()
const
;
Q_INVOKABLE
bool
addSipAddress
(
const
QString
&
sipAddress
);
Q_INVOKABLE
bool
addSipAddress
(
const
QString
&
sipAddress
);
Q_INVOKABLE
void
removeSipAddress
(
const
QString
&
sipAddress
);
Q_INVOKABLE
void
removeSipAddress
(
const
QString
&
sipAddress
);
Q_INVOKABLE
bool
updateSipAddress
(
const
QString
&
oldSipAddress
,
const
QString
&
sipAddress
);
Q_INVOKABLE
bool
updateSipAddress
(
const
QString
&
oldSipAddress
,
const
QString
&
sipAddress
);
...
...
linphone-desktop/ui/modules/Common/Form/ListForm.qml
View file @
1de0129e
...
@@ -16,7 +16,6 @@ RowLayout {
...
@@ -16,7 +16,6 @@ RowLayout {
property
alias
title
:
text
.
text
property
alias
title
:
text
.
text
property
bool
readOnly
:
false
property
bool
readOnly
:
false
property
int
inputMethodHints
property
int
inputMethodHints
property
var
defaultData
:
[]
property
var
minValues
property
var
minValues
readonly
property
int
count
:
values
.
count
readonly
property
int
count
:
values
.
count
...
@@ -193,15 +192,5 @@ RowLayout {
...
@@ -193,15 +192,5 @@ RowLayout {
}
}
model
:
ListModel
{}
model
:
ListModel
{}
// -------------------------------------------------------------------------
// Init values.
// -------------------------------------------------------------------------
Component
.
onCompleted
:
{
if
(
defaultData
)
{
setData
(
defaultData
)
}
}
}
}
}
}
linphone-desktop/ui/scripts/Utils/utils.js
View file @
1de0129e
...
@@ -332,7 +332,7 @@ function extractProperties (obj, pattern) {
...
@@ -332,7 +332,7 @@ function extractProperties (obj, pattern) {
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
// Returns an array from a `object` or `array` argument.
// Returns an array from a
n
`object` or `array` argument.
function
ensureArray
(
obj
)
{
function
ensureArray
(
obj
)
{
if
(
isArray
(
obj
))
{
if
(
isArray
(
obj
))
{
return
obj
return
obj
...
@@ -502,18 +502,6 @@ function includes (obj, value, startIndex) {
...
@@ -502,18 +502,6 @@ function includes (obj, value, startIndex) {
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
function
invert
(
obj
)
{
var
out
=
{}
for
(
var
key
in
obj
)
{
out
[
key
]
=
obj
[
key
]
}
return
out
}
// -----------------------------------------------------------------------------
function
isArray
(
array
)
{
function
isArray
(
array
)
{
return
(
array
instanceof
Array
)
return
(
array
instanceof
Array
)
}
}
...
...
linphone-desktop/ui/views/App/Main/ContactEdit.js
View file @
1de0129e
...
@@ -16,31 +16,37 @@ function handleCreation () {
...
@@ -16,31 +16,37 @@ function handleCreation () {
if
(
!
contact
)
{
if
(
!
contact
)
{
var
vcard
=
Linphone
.
CoreManager
.
createDetachedVcardModel
()
var
vcard
=
Linphone
.
CoreManager
.
createDetachedVcardModel
()
contactEdit
.
_vcard
=
vcard
if
(
sipAddress
&&
sipAddress
.
length
>
0
)
{
if
(
sipAddress
&&
sipAddress
.
length
>
0
)
{
vcard
.
addSipAddress
(
sipAddress
)
vcard
.
addSipAddress
(
sipAddress
)
}
}
contactEdit
.
_vcard
=
vcard
contactEdit
.
_edition
=
true
contactEdit
.
_edition
=
true
}
else
{
}
else
{
contactEdit
.
_vcard
=
contact
.
vcard
contactEdit
.
_vcard
=
contact
.
vcard
}
}
}
}
function
handleDestruction
()
{
function
handleVcardChanged
(
vcard
)
{
var
contact
=
contactEdit
.
_contact
if
(
!
vcard
)
{
vcard
=
{}
if
(
contactEdit
.
_edition
&&
contact
)
{
contact
.
abortEdit
()
}
}
addresses
.
setData
(
vcard
.
sipAddresses
)
companies
.
setData
(
vcard
.
companies
)
emails
.
setData
(
vcard
.
emails
)
urls
.
setData
(
vcard
.
urls
)
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
function
editContact
()
{
function
editContact
()
{
contactEdit
.
_contact
.
startEdit
()
var
contact
=
contactEdit
.
_contact
contact
.
startEdit
()
contactEdit
.
_vcard
=
contact
.
vcard
.
clone
()
contactEdit
.
_edition
=
true
contactEdit
.
_edition
=
true
window
.
lockView
({
window
.
lockView
({
...
@@ -64,12 +70,14 @@ function removeContact () {
...
@@ -64,12 +70,14 @@ function removeContact () {
function
save
()
{
function
save
()
{
var
contact
=
contactEdit
.
_contact
var
contact
=
contactEdit
.
_contact
var
vcard
=
contactEdit
.
_vcard
if
(
contact
)
{
if
(
contact
)
{
contact
.
vcard
=
vcard
contact
.
endEdit
()
contact
.
endEdit
()
window
.
unlockView
()
window
.
unlockView
()
}
else
{
}
else
{
contactEdit
.
_contact
=
Linphone
.
ContactsListModel
.
addContact
(
contactEdit
.
_
vcard
)
contactEdit
.
_contact
=
Linphone
.
ContactsListModel
.
addContact
(
vcard
)
}
}
contactEdit
.
_edition
=
false
contactEdit
.
_edition
=
false
...
@@ -79,9 +87,11 @@ function cancel () {
...
@@ -79,9 +87,11 @@ function cancel () {
var
contact
=
contactEdit
.
_contact
var
contact
=
contactEdit
.
_contact
if
(
contact
)
{
if
(
contact
)
{
contactEdit
.
_vcard
=
contact
.
vcard
contact
.
abortEdit
()
contact
.
abortEdit
()
contactEdit
.
_edition
=
false
window
.
unlockView
()
window
.
unlockView
()
contactEdit
.
_edition
=
false
}
else
{
}
else
{
window
.
setView
(
'
Contacts
'
)
window
.
setView
(
'
Contacts
'
)
}
}
...
@@ -104,51 +114,41 @@ function setUsername (username) {
...
@@ -104,51 +114,41 @@ function setUsername (username) {
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
function
handle
SipAddressChanged
(
sipAddresses
,
index
,
defaultValue
,
newValu
e
)
{
function
handle
ValueChanged
(
fields
,
index
,
defaultValue
,
newValue
,
add
,
updat
e
)
{
if
(
newValue
===
defaultValue
)
{
if
(
newValue
===
defaultValue
)
{
return
return
}
}
var
vcard
=
contactEdit
.
_vcard
var
vcard
=
contactEdit
.
_vcard
var
soFarSoGood
=
(
defaultValue
.
length
===
0
)
var
soFarSoGood
=
(
defaultValue
.
length
===
0
)
?
vcard
.
addSipAddress
(
newValue
)
?
vcard
[
add
]
(
newValue
)
:
vcard
.
updateSipAddress
(
defaultValue
,
newValue
)
:
vcard
[
update
]
(
defaultValue
,
newValue
)
sipAddresse
s
.
setInvalid
(
index
,
!
soFarSoGood
)
field
s
.
setInvalid
(
index
,
!
soFarSoGood
)
}
}
function
handleCompanyChanged
(
companies
,
index
,
defaultValue
,
newValue
)
{
function
handleSipAddressChanged
()
{
var
vcard
=
contactEdit
.
_vcard
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
)
var
soFarSoGood
=
(
defaultValue
.
length
===
0
)
args
.
push
(
'
addSipAddress
'
,
'
updateSipAddress
'
)
?
vcard
.
addCompany
(
newValue
)
handleValueChanged
.
apply
(
this
,
args
)
:
vcard
.
updateCompany
(
defaultValue
,
newValue
)
companies
.
setInvalid
(
index
,
!
soFarSoGood
)
}
}
function
handleEmailChanged
(
emails
,
index
,
defaultValue
,
newValue
)
{
function
handleCompanyChanged
()
{
var
vcard
=
contactEdit
.
_vcard
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
)
var
soFarSoGood
=
(
defaultValue
.
length
===
0
)
args
.
push
(
'
addCompany
'
,
'
updateCompany
'
)
?
vcard
.
addEmail
(
newValue
)
handleValueChanged
.
apply
(
this
,
args
)
:
vcard
.
updateEmail
(
defaultValue
,
newValue
)
emails
.
setInvalid
(
index
,
!
soFarSoGood
)
}
}
function
handleUrlChanged
(
urls
,
index
,
defaultValue
,
newValue
)
{
function
handleEmailChanged
()
{
var
url
=
Utils
.
extractFirstUri
(
newValue
)
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
)
if
(
url
===
defaultValue
)
{
args
.
push
(
'
addEmail
'
,
'
updateEmail
'
)
return
handleValueChanged
.
apply
(
this
,
args
)
}
}
var
vcard
=
contactEdit
.
_vcard
var
soFarSoGood
=
url
&&
(
defaultValue
.
length
===
0
?
vcard
.
addUrl
(
newValue
)
:
vcard
.
updateUrl
(
defaultValue
,
newValue
)
)
urls
.
setInvalid
(
index
,
!
soFarSoGood
)
function
handleUrlChanged
()
{
var
args
=
Array
.
prototype
.
slice
.
call
(
arguments
)
args
.
push
(
'
addUrl
'
,
'
updateUrl
'
)
handleValueChanged
.
apply
(
this
,
args
)
}
}
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
...
...
linphone-desktop/ui/views/App/Main/ContactEdit.qml
View file @
1de0129e
...
@@ -18,6 +18,8 @@ ColumnLayout {
...
@@ -18,6 +18,8 @@ ColumnLayout {
property
string
sipAddress
property
string
sipAddress
readonly
property
alias
vcard
:
contactEdit
.
_vcard
property
bool
_edition
:
false
property
bool
_edition
:
false
property
var
_contact
property
var
_contact
property
var
_vcard
property
var
_vcard
...
@@ -27,10 +29,20 @@ ColumnLayout {
...
@@ -27,10 +29,20 @@ ColumnLayout {
spacing
:
0
spacing
:
0
Component.onCompleted
:
Logic
.
handleCreation
()
Component.onCompleted
:
Logic
.
handleCreation
()
Component.onDestruction
:
Logic
.
handleDestruction
()
onVcardChanged
:
Logic
.
handleVcardChanged
(
vcard
)
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
Loader
{
active
:
contactEdit
.
_contact
!=
null
sourceComponent
:
Connections
{
target
:
contactEdit
.
_contact
onContactUpdated
:
Logic
.
handleVcardChanged
(
contactEdit
.
_contact
.
vcard
)
}
}
FileDialog
{
FileDialog
{
id
:
avatarChooser
id
:
avatarChooser
...
@@ -163,35 +175,19 @@ ColumnLayout {
...
@@ -163,35 +175,19 @@ ColumnLayout {
color
:
ContactEditStyle
.
content
.
color
color
:
ContactEditStyle
.
content
.
color
Loader
{
Flickable
{
anchors.fill
:
parent
active
:
_vcard
!=
null
sourceComponent
:
Flickable
{
id
:
flick
id
:
flick
ScrollBar.vertical
:
ForceScrollBar
{}
ScrollBar.vertical
:
ForceScrollBar
{}
anchors.fill
:
parent
boundsBehavior
:
Flickable
.
StopAtBounds
boundsBehavior
:
Flickable
.
StopAtBounds
clip
:
true
clip
:
true
contentHeight
:
infoList
.
height
contentHeight
:
infoList
.
height
contentWidth
:
width
-
ScrollBar
.
vertical
.
width
contentWidth
:
width
-
ScrollBar
.
vertical
.
width
flickableDirection
:
Flickable
.
VerticalFlick
flickableDirection
:
Flickable
.
VerticalFlick
// ---------------------------------------------------------------------
// -----------------------------------------------------------------------
Connections
{
target
:
_vcard
onVcardUpdated
:
{
addresses
.
setData
(
_vcard
.
sipAddresses
)
companies
.
setData
(
_vcard
.
companies
)
emails
.
setData
(
_vcard
.
emails
)
urls
.
setData
(
_vcard
.
urls
)
}
}
// ---------------------------------------------------------------------
ColumnLayout
{
ColumnLayout
{
id
:
infoList
id
:
infoList
...
@@ -205,7 +201,6 @@ ColumnLayout {
...
@@ -205,7 +201,6 @@ ColumnLayout {
Layout.rightMargin
:
ContactEditStyle
.
values
.
rightMargin
Layout.rightMargin
:
ContactEditStyle
.
values
.
rightMargin
Layout.topMargin
:
ContactEditStyle
.
values
.
topMargin
Layout.topMargin
:
ContactEditStyle
.
values
.
topMargin
defaultData
:
_vcard
.
sipAddresses
minValues
:
_contact
?
1
:
0
minValues
:
_contact
?
1
:
0
placeholder
:
qsTr
(
'
sipAccountsPlaceholder
'
)
placeholder
:
qsTr
(
'
sipAccountsPlaceholder
'
)
readOnly
:
!
_edition
readOnly
:
!
_edition
...
@@ -227,7 +222,6 @@ ColumnLayout {
...
@@ -227,7 +222,6 @@ ColumnLayout {
Layout.leftMargin
:
ContactEditStyle
.
values
.
leftMargin
Layout.leftMargin
:
ContactEditStyle
.
values
.
leftMargin
Layout.rightMargin
:
ContactEditStyle
.
values
.
rightMargin
Layout.rightMargin
:
ContactEditStyle
.
values
.
rightMargin
defaultData
:
_vcard
.
companies
placeholder
:
qsTr
(
'
companiesPlaceholder
'
)
placeholder
:
qsTr
(
'
companiesPlaceholder
'
)
readOnly
:
!
_edition
readOnly
:
!
_edition
title
:
qsTr
(
'
companies
'
)
title
:
qsTr
(
'
companies
'
)
...
@@ -248,8 +242,6 @@ ColumnLayout {
...
@@ -248,8 +242,6 @@ ColumnLayout {
Layout.leftMargin
:
ContactEditStyle
.
values
.
leftMargin
Layout.leftMargin
:
ContactEditStyle
.
values
.
leftMargin
Layout.rightMargin
:
ContactEditStyle
.
values
.
rightMargin
Layout.rightMargin
:
ContactEditStyle
.
values
.
rightMargin
defaultData
:
_vcard
.
emails
inputMethodHints
:
Qt
.
ImhEmailCharactersOnly
placeholder
:
qsTr
(
'
emailsPlaceholder
'
)
placeholder
:
qsTr
(
'
emailsPlaceholder
'
)
readOnly
:
!
_edition
readOnly
:
!
_edition
title
:
qsTr
(
'
emails
'
)
title
:
qsTr
(
'
emails
'
)
...
@@ -270,8 +262,6 @@ ColumnLayout {
...
@@ -270,8 +262,6 @@ ColumnLayout {
Layout.leftMargin
:
ContactEditStyle
.
values
.
leftMargin
Layout.leftMargin
:
ContactEditStyle
.
values
.
leftMargin
Layout.rightMargin
:
ContactEditStyle
.
values
.
rightMargin
Layout.rightMargin
:
ContactEditStyle
.
values
.
rightMargin
defaultData
:
_vcard
.
urls
inputMethodHints
:
Qt
.
ImhUrlCharactersOnly
placeholder
:
qsTr
(
'
webSitesPlaceholder
'
)
placeholder
:
qsTr
(
'
webSitesPlaceholder
'
)
readOnly
:
!
_edition
readOnly
:
!
_edition
title
:
qsTr
(
'
webSites
'
)
title
:
qsTr
(
'
webSites
'
)
...
@@ -298,9 +288,9 @@ ColumnLayout {
...
@@ -298,9 +288,9 @@ ColumnLayout {
onChanged
:
Logic
.
handleAddressChanged
(
index
,
value
)
onChanged
:
Logic
.
handleAddressChanged
(
index
,
value
)
}
}
//
-------------------------------------------------------------------
// --
-------------------------------------------------------------------
// Edition buttons.
// Edition buttons.
//
-------------------------------------------------------------------
// --
-------------------------------------------------------------------
Row
{
Row
{
Layout.alignment
:
Qt
.
AlignHCenter
Layout.alignment
:
Qt
.
AlignHCenter
...
@@ -324,5 +314,4 @@ ColumnLayout {
...
@@ -324,5 +314,4 @@ ColumnLayout {
}
}
}
}
}
}
}
}
}
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