Akonadi::ContactGroupEditor Class

An widget to edit contact groups in Akonadi. More...

Header: #include <Akonadi/ContactGroupEditor>
CMake: find_package(KPim6AkonadiContactWidgets REQUIRED)
target_link_libraries(mytarget PRIVATE KPim6::AkonadiContactWidgets)

Public Types

enum Mode { CreateMode, EditMode }

Public Functions

ContactGroupEditor(Akonadi::ContactGroupEditor::Mode mode, QWidget *parent = nullptr)
virtual ~ContactGroupEditor() override
void setContactGroupTemplate(const KContacts::ContactGroup &group)
void setDefaultAddressBook(const Akonadi::Collection &addressbook)

Public Slots

void loadContactGroup(const Akonadi::Item &group)
bool saveContactGroup()

Signals

void contactGroupStored(const Akonadi::Item &group)
void error(const QString &errorMsg)

Detailed Description

This widget provides a way to create a new contact group or edit an existing contact group in Akonadi.

Example for creating a new contact group:

using namespace Akonadi;

ContactGroupEditor *editor = new ContactGroupEditor( Akonadi::ContactGroupEditor::CreateMode, this );

...

if ( !editor->saveContactGroup() ) {
  qCDebug(AKONADICONTACT_LOG) << "Unable to save new contact group to storage";
  return;
}

Example for editing an existing contact group:

const Akonadi::Item contactGroup = ...;

ContactGroupEditor *editor = new ContactGroupEditor( Akonadi::ContactGroupEditor::EditMode, this );
editor->loadContactGroup( contactGroup );

...

if ( !editor->saveContactGroup() ) {
  qCDebug(AKONADICONTACT_LOG) << "Unable to save changed contact group to storage";
  return;
}

Author: Tobias Koenig <tokoe@kde.org>

Member Type Documentation

enum ContactGroupEditor::Mode

Describes the mode of the contact group editor.

Member Function Documentation

[explicit] ContactGroupEditor::ContactGroupEditor(Akonadi::ContactGroupEditor::Mode mode, QWidget *parent = nullptr)

Creates a new contact group editor.

mode The mode of the editor. parent The parent widget of the editor.

[override virtual noexcept] ContactGroupEditor::~ContactGroupEditor()

Destroys the contact group editor.

[signal] void ContactGroupEditor::contactGroupStored(const Akonadi::Item &group)

This signal is emitted when the contact group has been saved back to the storage.

[signal] void ContactGroupEditor::error(const QString &errorMsg)

This signal is emitted when an error occurred during the save. errorMsg The error message.

[slot] void ContactGroupEditor::loadContactGroup(const Akonadi::Item &group)

Loads the contact group into the editor.

[slot] bool ContactGroupEditor::saveContactGroup()

Saves the contact group from the editor back to the storage.

Returns \ true if the contact group has been saved successfully, false otherwise.

void ContactGroupEditor::setContactGroupTemplate(const KContacts::ContactGroup &group)

Sets a contact group that is used as template in create mode. The fields of the editor will be prefilled with the content of the group. group the group to use as template content

void ContactGroupEditor::setDefaultAddressBook(const Akonadi::Collection &addressbook)

Sets the addressbook which shall be used to store new contact groups.