Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
c5b89574
Commit
c5b89574
authored
Jun 28, 2012
by
Emmanuel Lepage
Browse files
Options
Downloads
Patches
Plain Diff
[ #13018,#11953 ] Fix saving contact
parent
de857403
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
kde/src/klib/AkonadiBackend.cpp
+50
-21
50 additions, 21 deletions
kde/src/klib/AkonadiBackend.cpp
kde/src/klib/AkonadiBackend.h
+10
-7
10 additions, 7 deletions
kde/src/klib/AkonadiBackend.h
kde/src/widgets/ContactItemWidget.cpp
+6
-0
6 additions, 0 deletions
kde/src/widgets/ContactItemWidget.cpp
with
66 additions
and
28 deletions
kde/src/klib/AkonadiBackend.cpp
+
50
−
21
View file @
c5b89574
...
@@ -105,6 +105,32 @@ Contact* AkonadiBackend::getContactByUid(const QString& uid)
...
@@ -105,6 +105,32 @@ Contact* AkonadiBackend::getContactByUid(const QString& uid)
}
}
/*****************************************************************************
* *
* Helper *
* *
****************************************************************************/
KABC
::
PhoneNumber
::
Type
nameToType
(
QString
name
)
{
if
(
name
==
"Home"
)
return
KABC
::
PhoneNumber
::
Home
;
else
if
(
name
==
"Work"
)
return
KABC
::
PhoneNumber
::
Work
;
else
if
(
name
==
"Msg"
)
return
KABC
::
PhoneNumber
::
Msg
;
else
if
(
name
==
"Pref"
)
return
KABC
::
PhoneNumber
::
Pref
;
else
if
(
name
==
"Voice"
)
return
KABC
::
PhoneNumber
::
Voice
;
else
if
(
name
==
"Fax"
)
return
KABC
::
PhoneNumber
::
Fax
;
else
if
(
name
==
"Cell"
)
return
KABC
::
PhoneNumber
::
Cell
;
else
if
(
name
==
"Video"
)
return
KABC
::
PhoneNumber
::
Video
;
else
if
(
name
==
"Bbs"
)
return
KABC
::
PhoneNumber
::
Bbs
;
else
if
(
name
==
"Modem"
)
return
KABC
::
PhoneNumber
::
Modem
;
else
if
(
name
==
"Car"
)
return
KABC
::
PhoneNumber
::
Car
;
else
if
(
name
==
"Isdn"
)
return
KABC
::
PhoneNumber
::
Isdn
;
else
if
(
name
==
"Pcs"
)
return
KABC
::
PhoneNumber
::
Pcs
;
else
if
(
name
==
"Pager"
)
return
KABC
::
PhoneNumber
::
Pager
;
return
KABC
::
PhoneNumber
::
Home
;
}
/*****************************************************************************
/*****************************************************************************
* *
* *
* Mutator *
* Mutator *
...
@@ -159,6 +185,7 @@ ContactList AkonadiBackend::update(Akonadi::Collection collection)
...
@@ -159,6 +185,7 @@ ContactList AkonadiBackend::update(Akonadi::Collection collection)
aContact
->
setPhoto
(
0
);
aContact
->
setPhoto
(
0
);
m_AddrHash
[
tmp
.
uid
()]
=
tmp
;
m_AddrHash
[
tmp
.
uid
()]
=
tmp
;
m_ItemHash
[
tmp
.
uid
()]
=
item
;
}
}
}
}
m_pContacts
=
m_ContactByUid
.
values
();
m_pContacts
=
m_ContactByUid
.
values
();
...
@@ -169,18 +196,22 @@ ContactList AkonadiBackend::update(Akonadi::Collection collection)
...
@@ -169,18 +196,22 @@ ContactList AkonadiBackend::update(Akonadi::Collection collection)
///Edit backend value using an updated frontend contact
///Edit backend value using an updated frontend contact
void
AkonadiBackend
::
editContact
(
Contact
*
contact
,
QWidget
*
parent
)
void
AkonadiBackend
::
editContact
(
Contact
*
contact
,
QWidget
*
parent
)
{
{
KABC
::
Addressee
ct
=
m_
Addr
Hash
[
contact
->
getUid
()];
Akonadi
::
Item
item
=
m_
Item
Hash
[
contact
->
getUid
()];
if
(
ct
.
uid
()
!
=
contact
->
getUid
())
{
if
(
!
(
item
.
hasPayload
<
KABC
::
Addressee
>
()
&&
item
.
payload
<
KABC
::
Addressee
>
()
.
uid
()
=
=
contact
->
getUid
())
)
{
kDebug
()
<<
"Contact not found"
;
kDebug
()
<<
"Contact not found"
;
return
;
return
;
}
}
Akonadi
::
ContactEditorDialog
*
editor
=
new
Akonadi
::
ContactEditorDialog
(
Akonadi
::
ContactEditorDialog
::
EditMode
,
parent
);
Akonadi
::
ContactEditor
*
editor
=
new
Akonadi
::
ContactEditor
(
Akonadi
::
ContactEditor
::
EditMode
,
parent
);
Akonadi
::
Item
item
(
rand
());
item
.
setPayload
<
KABC
::
Addressee
>
(
ct
);
if
(
item
.
isValid
()
)
{
if
(
item
.
isValid
()
)
{
editor
->
setContact
(
item
);
editor
->
loadContact
(
item
);
editor
->
exec
();
KDialog
*
dlg
=
new
KDialog
(
parent
);
dlg
->
setMainWidget
(
editor
);
dlg
->
exec
();
if
(
!
editor
->
saveContact
()
)
{
kDebug
()
<<
"Unable to save new contact to storage"
;
return
;
}
}
}
}
//editContact
}
//editContact
...
@@ -198,20 +229,7 @@ void AkonadiBackend::addNewContact(Contact* contact,QWidget* parent)
...
@@ -198,20 +229,7 @@ void AkonadiBackend::addNewContact(Contact* contact,QWidget* parent)
foreach
(
Contact
::
PhoneNumber
*
nb
,
contact
->
getPhoneNumbers
())
{
foreach
(
Contact
::
PhoneNumber
*
nb
,
contact
->
getPhoneNumbers
())
{
KABC
::
PhoneNumber
pn
;
KABC
::
PhoneNumber
pn
;
if
(
nb
->
getType
()
==
"Home"
)
pn
.
setType
(
KABC
::
PhoneNumber
::
Home
);
pn
.
setType
(
nameToType
(
nb
->
getType
()));
else
if
(
nb
->
getType
()
==
"Work"
)
pn
.
setType
(
KABC
::
PhoneNumber
::
Work
);
else
if
(
nb
->
getType
()
==
"Msg"
)
pn
.
setType
(
KABC
::
PhoneNumber
::
Msg
);
else
if
(
nb
->
getType
()
==
"Pref"
)
pn
.
setType
(
KABC
::
PhoneNumber
::
Pref
);
else
if
(
nb
->
getType
()
==
"Voice"
)
pn
.
setType
(
KABC
::
PhoneNumber
::
Voice
);
else
if
(
nb
->
getType
()
==
"Fax"
)
pn
.
setType
(
KABC
::
PhoneNumber
::
Fax
);
else
if
(
nb
->
getType
()
==
"Cell"
)
pn
.
setType
(
KABC
::
PhoneNumber
::
Cell
);
else
if
(
nb
->
getType
()
==
"Video"
)
pn
.
setType
(
KABC
::
PhoneNumber
::
Video
);
else
if
(
nb
->
getType
()
==
"Bbs"
)
pn
.
setType
(
KABC
::
PhoneNumber
::
Bbs
);
else
if
(
nb
->
getType
()
==
"Modem"
)
pn
.
setType
(
KABC
::
PhoneNumber
::
Modem
);
else
if
(
nb
->
getType
()
==
"Car"
)
pn
.
setType
(
KABC
::
PhoneNumber
::
Car
);
else
if
(
nb
->
getType
()
==
"Isdn"
)
pn
.
setType
(
KABC
::
PhoneNumber
::
Isdn
);
else
if
(
nb
->
getType
()
==
"Pcs"
)
pn
.
setType
(
KABC
::
PhoneNumber
::
Pcs
);
else
if
(
nb
->
getType
()
==
"Pager"
)
pn
.
setType
(
KABC
::
PhoneNumber
::
Pager
);
pn
.
setNumber
(
nb
->
getNumber
());
pn
.
setNumber
(
nb
->
getNumber
());
newContact
.
insertPhoneNumber
(
pn
);
newContact
.
insertPhoneNumber
(
pn
);
...
@@ -245,6 +263,17 @@ void AkonadiBackend::addNewContact(Contact* contact)
...
@@ -245,6 +263,17 @@ void AkonadiBackend::addNewContact(Contact* contact)
addNewContact
(
contact
,
0
);
addNewContact
(
contact
,
0
);
}
}
///Add a new phone number to an existing contact
void
AkonadiBackend
::
addPhoneNumber
(
Contact
*
contact
,
QString
number
,
QString
type
)
{
KABC
::
Addressee
ct
=
m_AddrHash
[
contact
->
getUid
()];
if
(
ct
.
uid
()
!=
contact
->
getUid
())
{
kDebug
()
<<
"Contact not found"
;
return
;
}
ct
.
insertPhoneNumber
(
KABC
::
PhoneNumber
(
number
,
nameToType
(
type
)));
}
/*****************************************************************************
/*****************************************************************************
* *
* *
...
...
This diff is collapsed.
Click to expand it.
kde/src/klib/AkonadiBackend.h
+
10
−
7
View file @
c5b89574
...
@@ -39,6 +39,7 @@ namespace Akonadi {
...
@@ -39,6 +39,7 @@ namespace Akonadi {
class
Session
;
class
Session
;
class
CollectionModel
;
class
CollectionModel
;
class
Collection
;
class
Collection
;
class
Item
;
}
}
//SFLPhone
//SFLPhone
...
@@ -53,6 +54,7 @@ public:
...
@@ -53,6 +54,7 @@ public:
Contact
*
getContactByUid
(
const
QString
&
uid
);
Contact
*
getContactByUid
(
const
QString
&
uid
);
void
editContact
(
Contact
*
contact
,
QWidget
*
parent
=
0
);
void
editContact
(
Contact
*
contact
,
QWidget
*
parent
=
0
);
void
addNewContact
(
Contact
*
contact
,
QWidget
*
parent
=
0
);
void
addNewContact
(
Contact
*
contact
,
QWidget
*
parent
=
0
);
virtual
void
addPhoneNumber
(
Contact
*
contact
,
QString
number
,
QString
type
);
virtual
void
editContact
(
Contact
*
contact
);
virtual
void
editContact
(
Contact
*
contact
);
virtual
void
addNewContact
(
Contact
*
contact
);
virtual
void
addNewContact
(
Contact
*
contact
);
...
@@ -66,6 +68,7 @@ private:
...
@@ -66,6 +68,7 @@ private:
Akonadi
::
Session
*
m_pSession
;
Akonadi
::
Session
*
m_pSession
;
Akonadi
::
Collection
m_Collection
;
Akonadi
::
Collection
m_Collection
;
QHash
<
QString
,
KABC
::
Addressee
>
m_AddrHash
;
QHash
<
QString
,
KABC
::
Addressee
>
m_AddrHash
;
QHash
<
QString
,
Akonadi
::
Item
>
m_ItemHash
;
ContactList
m_pContacts
;
ContactList
m_pContacts
;
protected:
protected:
...
...
This diff is collapsed.
Click to expand it.
kde/src/widgets/ContactItemWidget.cpp
+
6
−
0
View file @
c5b89574
...
@@ -418,6 +418,12 @@ void ContactItemWidget::editContact()
...
@@ -418,6 +418,12 @@ void ContactItemWidget::editContact()
void
ContactItemWidget
::
addPhone
()
void
ContactItemWidget
::
addPhone
()
{
{
kDebug
()
<<
"Adding to contact"
;
kDebug
()
<<
"Adding to contact"
;
bool
ok
;
//QString number = QInputDialog::getText(0, i18n("Enter a new number"),i18n("New number:"),QLineEdit::Normal,QString(),ok,0);
QString
text
=
QInputDialog
::
getText
(
this
,
i18n
(
"Enter a new number"
),
i18n
(
"New number:"
),
QLineEdit
::
Normal
,
QString
(),
&
ok
);
if
(
ok
&&
!
text
.
isEmpty
())
{
}
}
}
///Add this contact to the bookmark list
///Add this contact to the bookmark list
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment