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

KDE's Doxygen guidelines are available online.