Akonadi::AkonadiContactEditor Class
An widget to edit contacts in Akonadi. More...
| Header: | #include <Akonadi/ContactEditor> |
| CMake: | find_package(KPim6AkonadiContactWidgets REQUIRED)target_link_libraries(mytarget PRIVATE KPim6::AkonadiContactWidgets) |
Public Types
| enum | Mode { CreateMode, EditMode } |
Public Functions
| AkonadiContactEditor(Akonadi::AkonadiContactEditor::Mode mode, QWidget *parent = nullptr) | |
| AkonadiContactEditor(Akonadi::AkonadiContactEditor::Mode mode, Akonadi::AbstractContactEditorWidget *editorWidget, QWidget *parent = nullptr) | |
| AkonadiContactEditor(Akonadi::AkonadiContactEditor::Mode mode, Akonadi::AkonadiContactEditor::DisplayMode displayMode, QWidget *parent = nullptr) | |
| virtual | ~AkonadiContactEditor() override |
| KContacts::Addressee | contact() |
| bool | hasNoSavedData() const |
| void | setContactTemplate(const KContacts::Addressee &contact) |
| void | setDefaultAddressBook(const Akonadi::Collection &addressbook) |
Public Slots
| void | loadContact(const Akonadi::Item &contact) |
| void | saveContactInAddressBook() |
Signals
| void | contactStored(const Akonadi::Item &contact) |
| void | error(const QString &errorMsg) |
| void | finished() |
Detailed Description
This widget provides a way to create a new contact or edit an existing contact in Akonadi.
Example for creating a new contact:
using namespace Akonadi;
ContactEditor *editor = new ContactEditor( Akonadi::ContactEditor::CreateMode, this );
...
if ( !editor->saveContactInAddressBook() ) {
qCDebug(AKONADICONTACT_LOG) << "Unable to save new contact to storage";
return;
}
Example for editing an existing contact:
const Akonadi::Item contact = ...;
ContactEditor *editor = new ContactEditor( Akonadi::ContactEditor::EditMode, this );
editor->loadContact( contact );
...
editor->saveContactInAddressBook();
Author: Tobias Koenig <tokoe@kde.org>
Member Type Documentation
enum AkonadiContactEditor::Mode
Describes the mode of the editor.
Member Function Documentation
[explicit] AkonadiContactEditor::AkonadiContactEditor(Akonadi::AkonadiContactEditor::Mode mode, QWidget *parent = nullptr)
Creates a new contact editor with the standard editor widget.
mode The mode of the editor. parent The parent widget of the editor.
AkonadiContactEditor::AkonadiContactEditor(Akonadi::AkonadiContactEditor::Mode mode, Akonadi::AbstractContactEditorWidget *editorWidget, QWidget *parent = nullptr)
Creates a new contact editor with a custom editor widget.
mode The mode of the editor. editorWidget The contact editor widget that shall be used for editing. parent The parent widget of the editor.
AkonadiContactEditor::AkonadiContactEditor(Akonadi::AkonadiContactEditor::Mode mode, Akonadi::AkonadiContactEditor::DisplayMode displayMode, QWidget *parent = nullptr)
Creates a new contact editor dialog with a custom editor widget.
mode The mode of the dialog. displayMode mode for displaying the editor parent The parent widget of the dialog.
[override virtual noexcept] AkonadiContactEditor::~AkonadiContactEditor()
Destroys the contact editor.
KContacts::Addressee AkonadiContactEditor::contact()
Returns the currently edited contact.
\returnsThe contact object as edited in the editor.
[signal] void AkonadiContactEditor::contactStored(const Akonadi::Item &contact)
This signal is emitted when the contact has been saved back to the storage.
[signal] void AkonadiContactEditor::error(const QString &errorMsg)
This signal is emitted when an error occurred during the save.
errorMsg The error message.
[signal] void AkonadiContactEditor::finished()
This signal is emitted when the save operation has finished.
bool AkonadiContactEditor::hasNoSavedData() const
Returns whether there is unsaved data in the editor.
\returnsTrue if the editor has no saved data, false otherwise.
[slot] void AkonadiContactEditor::loadContact(const Akonadi::Item &contact)
Loads the contact into the editor.
[slot] void AkonadiContactEditor::saveContactInAddressBook()
Saves the contact from the editor back to the storage. Connect to the finished() signal to know when the save operation is complete.
void AkonadiContactEditor::setContactTemplate(const KContacts::Addressee &contact)
Sets a contact that is used as template in create mode. The fields of the editor will be prefilled with the content of the contact. contact the contact to use as template content
void AkonadiContactEditor::setDefaultAddressBook(const Akonadi::Collection &addressbook)
Sets the addressbook which shall be used to store new contacts.