Akonadi Contacts

contacteditordialog.h
1/*
2 This file is part of Akonadi Contact.
3
4 SPDX-FileCopyrightText: 2007-2009 Tobias Koenig <tokoe@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#pragma once
10
11#include "akonadi-contact-widgets_export.h"
12
13#include <QDialog>
14
15#include <memory>
16
17namespace Akonadi
18{
19class Collection;
20class Item;
21class AkonadiContactEditor;
22class AbstractContactEditorWidget;
23class ContactEditorDialogPrivate;
24
25/**
26 * @short A dialog for creating or editing a contact in Akonadi.
27 *
28 * This dialog provides a way to create a new contact or edit
29 * an existing contact in Akonadi.
30 *
31 * Example for creating a new contact:
32 *
33 * @code
34 *
35 * using namespace Akonadi;
36 *
37 * ContactEditorDialog *dlg = new ContactEditorDialog( ContactEditorDialog::CreateMode, this );
38 * connect( dlg, SIGNAL(contactStored(Akonadi::Item)),
39 * this, SLOT(contactStored(Akonadi::Item)) );
40 * dlg->show();
41 *
42 *
43 * @endcode
44 *
45 * Example for editing an existing contact:
46 *
47 * @code
48 *
49 * using namespace Akonadi;
50 *
51 * const Item contact = ...;
52 *
53 * ContactEditorDialog *dlg = new ContactEditorDialog( ContactEditorDialog::EditMode, this );
54 * connect( dlg, SIGNAL(contactStored(Akonadi::Item)),
55 * this, SLOT(contactStored(Akonadi::Item)) );
56 * dlg->setContact( contact );
57 * dlg->show();
58 *
59 * @endcode
60 *
61 * @author Tobias Koenig <tokoe@kde.org>
62 * @since 4.4
63 */
64class AKONADI_CONTACT_WIDGETS_EXPORT ContactEditorDialog : public QDialog
65{
66 Q_OBJECT
67
68public:
69 /**
70 * Describes the mode of the editor dialog.
71 */
72 enum Mode {
73 CreateMode, ///< Creates a new contact
74 EditMode ///< Edits an existing contact
75 };
76
77 enum DisplayMode {
78 FullMode, // Show all pages
79 VCardMode // Show just pages with elements stored in vcard.
80 };
81
82 /**
83 * Creates a new contact editor dialog with the standard editor widget.
84 *
85 * @param mode The mode of the dialog.
86 * @param parent The parent widget of the dialog.
87 */
88 explicit ContactEditorDialog(Mode mode, QWidget *parent = nullptr);
89
90 /**
91 * Creates a new contact editor dialog with a custom editor widget.
92 *
93 * @param mode The mode of the dialog.
94 * @param editorWidget The contact editor widget that shall be used for editing.
95 * @param parent The parent widget of the dialog.
96 */
97 ContactEditorDialog(Mode mode, Akonadi::AbstractContactEditorWidget *editorWidget, QWidget *parent = nullptr);
98
99 /**
100 * Creates a new contact editor dialog with a custom editor widget.
101 *
102 * @param mode The mode of the dialog.
103 * @param displayMode The mode of displaying: full or vcard
104 * @param parent The parent widget of the dialog.
105 * @since 4.10
106 */
107 ContactEditorDialog(Mode mode, DisplayMode displayMode, QWidget *parent = nullptr);
108
109 /**
110 * Destroys the contact editor dialog.
111 */
112 ~ContactEditorDialog() override;
113
114 /**
115 * Sets the @p contact to edit when in EditMode.
116 * @param contact the contact to edit
117 * @note The contact item just must have a uid set, all
118 * other data are fetched by the dialog automatically.
119 */
120 void setContact(const Akonadi::Item &contact);
121
122 /**
123 * Sets the @p addressbook that shall be selected as default in create mode.
124 */
125 void setDefaultAddressBook(const Akonadi::Collection &addressbook);
126
127 /**
128 * Returns the ContactEditor that is used by this dialog.
129 */
130 [[nodiscard]] Akonadi::AkonadiContactEditor *editor() const;
131
132 void reject() override;
133
134Q_SIGNALS:
135 /**
136 * This signal is emitted whenever a contact was updated or stored.
137 *
138 * @param contact The data reference of the contact.
139 */
140 void contactStored(const Akonadi::Item &contact);
141
142 /**
143 * This signal is emitted whenever a contact is not updated or stored.
144 *
145 * @param errMsg The error during updating or storing contact.
146 */
147 void error(const QString &errMsg);
148
149public Q_SLOTS:
150 void accept() override;
151
152private:
153 //@cond PRIVATE
154 std::unique_ptr<ContactEditorDialogPrivate> const d;
155 //@endcond
156};
157}
An widget to edit contacts in Akonadi.
A dialog for creating or editing a contact in Akonadi.
Mode
Describes the mode of the editor dialog.
@ CreateMode
Creates a new contact.
void error(const QString &errMsg)
This signal is emitted whenever a contact is not updated or stored.
void contactStored(const Akonadi::Item &contact)
This signal is emitted whenever a contact was updated or stored.
A widget for editing the display name of a contact.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:05:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.