Akonadi Contacts

contacteditordialog.h
1 /*
2  This file is part of Akonadi Contact.
3 
4  SPDX-FileCopyrightText: 2007-2009 Tobias Koenig <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 
9 #pragma once
10 
11 #include "akonadi-contact_export.h"
12 
13 #include <QDialog>
14 
15 namespace ContactEditor
16 {
17 class AbstractContactEditorWidget;
18 }
19 namespace Akonadi
20 {
21 class AkonadiContactEditor;
22 class Collection;
23 class Item;
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 <[email protected]>
62  * @since 4.4
63  */
64 class AKONADI_CONTACT_EXPORT ContactEditorDialog : public QDialog
65 {
66  Q_OBJECT
67 
68 public:
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, ContactEditor::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  Q_REQUIRED_RESULT AkonadiContactEditor *editor() const;
131 
132  void reject() override;
133 
134 Q_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 
149 public Q_SLOTS:
150  void accept() override;
151 
152 private:
153  //@cond PRIVATE
154  class Private;
155  Private *const d;
156  //@endcond
157 };
158 }
159 
A dialog for creating or editing a contact in Akonadi.
Mode
Describes the mode of the editor dialog.
An widget to edit contacts in Akonadi.
Definition: contacteditor.h:69
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Jun 23 2021 23:09:24 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.