Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Akonadi Contacts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PIM
Akonadi Contacts
Commits
b96f004a
Commit
b96f004a
authored
Feb 28, 2013
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Bug 309324 - No error message when ItemCreateJob or ItemModifyJob fails
FIXED-IN: 4.11 BUG: 309324
parent
374fee39
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
8 deletions
+101
-8
akonadi/contact/contacteditor.cpp
akonadi/contact/contacteditor.cpp
+50
-0
akonadi/contact/contacteditor.h
akonadi/contact/contacteditor.h
+17
-5
akonadi/contact/contacteditordialog.cpp
akonadi/contact/contacteditordialog.cpp
+15
-3
akonadi/contact/contacteditordialog.h
akonadi/contact/contacteditordialog.h
+11
-0
akonadi/contact/standardcontactactionmanager.cpp
akonadi/contact/standardcontactactionmanager.cpp
+7
-0
akonadi/contact/standardcontactactionmanager.h
akonadi/contact/standardcontactactionmanager.h
+1
-0
No files found.
akonadi/contact/contacteditor.cpp
View file @
b96f004a
...
...
@@ -149,6 +149,7 @@ void ContactEditor::Private::storeDone( KJob *job )
{
if
(
job
->
error
()
!=
KJob
::
NoError
)
{
emit
mParent
->
error
(
job
->
errorString
()
);
emit
mParent
->
finished
();
return
;
}
...
...
@@ -157,6 +158,7 @@ void ContactEditor::Private::storeDone( KJob *job )
}
else
if
(
mMode
==
CreateMode
)
{
emit
mParent
->
contactStored
(
static_cast
<
Akonadi
::
ItemCreateJob
*>
(
job
)
->
item
()
);
}
emit
mParent
->
finished
();
}
void
ContactEditor
::
Private
::
itemChanged
(
const
Akonadi
::
Item
&
,
const
QSet
<
QByteArray
>&
)
...
...
@@ -245,6 +247,54 @@ KABC::Addressee ContactEditor::contact()
return
addr
;
}
void
ContactEditor
::
saveContactInAddressBook
()
{
if
(
d
->
mMode
==
EditMode
)
{
if
(
!
d
->
mItem
.
isValid
()
||
d
->
mReadOnly
)
{
emit
finished
();
return
;
}
KABC
::
Addressee
addr
=
d
->
mItem
.
payload
<
KABC
::
Addressee
>
();
d
->
storeContact
(
addr
,
d
->
mContactMetaData
);
d
->
mContactMetaData
.
store
(
d
->
mItem
);
d
->
mItem
.
setPayload
<
KABC
::
Addressee
>
(
addr
);
Akonadi
::
ItemModifyJob
*
job
=
new
Akonadi
::
ItemModifyJob
(
d
->
mItem
);
connect
(
job
,
SIGNAL
(
result
(
KJob
*
)),
SLOT
(
storeDone
(
KJob
*
))
);
}
else
if
(
d
->
mMode
==
CreateMode
)
{
if
(
!
d
->
mDefaultCollection
.
isValid
()
)
{
const
QStringList
mimeTypeFilter
(
KABC
::
Addressee
::
mimeType
()
);
AutoQPointer
<
CollectionDialog
>
dlg
=
new
CollectionDialog
(
this
);
dlg
->
setMimeTypeFilter
(
mimeTypeFilter
);
dlg
->
setAccessRightsFilter
(
Collection
::
CanCreateItem
);
dlg
->
setCaption
(
i18n
(
"Select Address Book"
)
);
dlg
->
setDescription
(
i18n
(
"Select the address book the new contact shall be saved in:"
)
);
if
(
dlg
->
exec
()
==
KDialog
::
Accepted
)
{
setDefaultAddressBook
(
dlg
->
selectedCollection
()
);
}
else
{
return
;
}
}
KABC
::
Addressee
addr
;
d
->
storeContact
(
addr
,
d
->
mContactMetaData
);
Akonadi
::
Item
item
;
item
.
setPayload
<
KABC
::
Addressee
>
(
addr
);
item
.
setMimeType
(
KABC
::
Addressee
::
mimeType
()
);
d
->
mContactMetaData
.
store
(
item
);
Akonadi
::
ItemCreateJob
*
job
=
new
Akonadi
::
ItemCreateJob
(
item
,
d
->
mDefaultCollection
);
connect
(
job
,
SIGNAL
(
result
(
KJob
*
)),
SLOT
(
storeDone
(
KJob
*
))
);
}
}
bool
ContactEditor
::
saveContact
()
{
if
(
d
->
mMode
==
EditMode
)
{
...
...
akonadi/contact/contacteditor.h
View file @
b96f004a
...
...
@@ -70,10 +70,7 @@ class Item;
*
* ...
*
* if ( !editor->saveContact() ) {
* qDebug() << "Unable to save changed contact to storage";
* return;
* }
* editor->saveContactInAddressBook();
*
* @endcode
*
...
...
@@ -158,8 +155,17 @@ class AKONADI_CONTACT_EXPORT ContactEditor : public QWidget
/**
* Saves the contact from the editor back to the storage.
* @deprecated use saveContactInAddressBook. We can't get contactStored and error infos.
* Remove it for KDE SC5
*/
KDE_DEPRECATED
bool
saveContact
();
/**
* Save the contact from the editor back to the storage. And return error.
* Need to connect to finished() signal, to keep time to emit signal.
* @since 4.11
*/
bool
saveContact
();
void
saveContactInAddressBook
();
Q_SIGNALS:
/**
...
...
@@ -171,9 +177,15 @@ class AKONADI_CONTACT_EXPORT ContactEditor : public QWidget
/**
* This signal is emitted when an error occurred during the save.
* @param errorMsg The error message.
* @since 4.11
*/
void
error
(
const
QString
&
errorMsg
);
/**
* @brief finished
* @since 4.11
*/
void
finished
();
private:
//@cond PRIVATE
class
Private
;
...
...
akonadi/contact/contacteditordialog.cpp
View file @
b96f004a
...
...
@@ -76,8 +76,12 @@ class ContactEditorDialog::Private
connect
(
mEditor
,
SIGNAL
(
contactStored
(
Akonadi
::
Item
)),
q
,
SIGNAL
(
contactStored
(
Akonadi
::
Item
))
);
connect
(
mEditor
,
SIGNAL
(
error
(
QString
)),
q
,
SIGNAL
(
error
(
QString
))
);
connect
(
q
,
SIGNAL
(
okClicked
()),
q
,
SLOT
(
slotOkClicked
())
);
connect
(
q
,
SIGNAL
(
cancelClicked
()),
q
,
SLOT
(
slotCancelClicked
())
);
connect
(
mEditor
,
SIGNAL
(
finished
()),
q
,
SLOT
(
slotFinish
())
);
q
->
setInitialSize
(
QSize
(
800
,
500
)
);
}
...
...
@@ -87,10 +91,12 @@ class ContactEditorDialog::Private
if
(
mAddressBookBox
)
{
mEditor
->
setDefaultAddressBook
(
mAddressBookBox
->
currentCollection
()
);
}
mEditor
->
saveContactInAddressBook
();
}
if
(
mEditor
->
saveContact
()
)
{
q
->
accept
();
}
void
slotFinish
()
{
q
->
KDialog
::
accept
();
}
void
slotCancelClicked
()
...
...
@@ -143,4 +149,10 @@ ContactEditor* ContactEditorDialog::editor() const
return
d
->
mEditor
;
}
void
ContactEditorDialog
::
accept
()
{
//Nothing
}
#include "moc_contacteditordialog.cpp"
akonadi/contact/contacteditordialog.h
View file @
b96f004a
...
...
@@ -150,6 +150,16 @@ class AKONADI_CONTACT_EXPORT ContactEditorDialog : public KDialog
*/
void
contactStored
(
const
Akonadi
::
Item
&
contact
);
/**
* This signal is emitted whenever a contact is not updated or stored.
*
* @param errMsg The error during updating or storing contact.
*/
void
error
(
const
QString
&
errMsg
);
public
Q_SLOTS
:
void
accept
();
private:
//@cond PRIVATE
class
Private
;
...
...
@@ -157,6 +167,7 @@ class AKONADI_CONTACT_EXPORT ContactEditorDialog : public KDialog
Q_PRIVATE_SLOT
(
d
,
void
slotOkClicked
()
)
Q_PRIVATE_SLOT
(
d
,
void
slotCancelClicked
()
)
Q_PRIVATE_SLOT
(
d
,
void
slotFinish
()
)
//@endcond
};
...
...
akonadi/contact/standardcontactactionmanager.cpp
View file @
b96f004a
...
...
@@ -491,6 +491,8 @@ class StandardContactActionManager::Private
QPointer
<
Akonadi
::
ContactEditorDialog
>
dlg
=
new
Akonadi
::
ContactEditorDialog
(
Akonadi
::
ContactEditorDialog
::
EditMode
,
mParentWidget
);
connect
(
dlg
,
SIGNAL
(
error
(
QString
)),
mParent
,
SLOT
(
slotContactEditorError
(
QString
))
);
dlg
->
setContact
(
item
);
dlg
->
setAttribute
(
Qt
::
WA_DeleteOnClose
);
dlg
->
show
();
...
...
@@ -504,6 +506,11 @@ class StandardContactActionManager::Private
}
}
void
slotContactEditorError
(
const
QString
&
error
)
{
KMessageBox
::
error
(
mParentWidget
,
i18n
(
"Contact can not stored: %1"
,
error
),
i18n
(
"Failed to store contact"
));
}
KActionCollection
*
mActionCollection
;
QWidget
*
mParentWidget
;
StandardActionManager
*
mGenericManager
;
...
...
akonadi/contact/standardcontactactionmanager.h
View file @
b96f004a
...
...
@@ -186,6 +186,7 @@ class AKONADI_CONTACT_EXPORT StandardContactActionManager : public QObject
Q_PRIVATE_SLOT
(
d
,
void
slotCreateContact
()
)
Q_PRIVATE_SLOT
(
d
,
void
slotCreateContactGroup
()
)
Q_PRIVATE_SLOT
(
d
,
void
slotEditItem
()
)
Q_PRIVATE_SLOT
(
d
,
void
slotContactEditorError
(
const
QString
&
)
)
//@endcond
};
...
...
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