Akonadi Contacts

emailaddressselectionwidget.h
1 /*
2  This file is part of Akonadi Contact.
3 
4  SPDX-FileCopyrightText: 2010 KDAB
5  SPDX-FileContributor: Tobias Koenig <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 
10 #pragma once
11 
12 #include "akonadi-contact_export.h"
13 
14 #include "emailaddressselection.h"
15 
16 #include <Akonadi/Item>
17 
18 #include <QAbstractItemView>
19 #include <QWidget>
20 
21 #include <memory>
22 
23 class QLineEdit;
24 class QAbstractItemModel;
25 class QTreeView;
26 
27 namespace Akonadi
28 {
29 class EmailAddressSelectionWidgetPrivate;
30 
31 /**
32  * @short A widget to select email addresses from Akonadi.
33  *
34  * This widget allows the user to select an name and email address from
35  * the Akonadi storage.
36  * The selected addresses are returned as EmailAddressSelectionWidget::Selection objects
37  * which encapsulate the name, email address and the Akonadi item that has been selected.
38  *
39  * Example:
40  *
41  * @code
42  *
43  * Akonadi::EmailAddressSelectionWidget *widget = new Akonadi::EmailAddressSelectionWidget( this );
44  * widget->view()->setSelectionMode( QAbstractItemView::MultiSelection );
45  * ...
46  *
47  * foreach ( const Akonadi::EmailAddressSelection &selection, widget->selectedAddresses() ) {
48  * qCDebug(AKONADICONTACT_LOG) << "Name:" << selection.name() << "Email:" << selection.email();
49  * }
50  *
51  * @endcode
52  *
53  * @author Tobias Koenig <[email protected]>
54  * @since 4.5
55  */
56 class AKONADI_CONTACT_EXPORT EmailAddressSelectionWidget : public QWidget
57 {
58  Q_OBJECT
59 
60 public:
61  /**
62  * Creates a new email address selection widget.
63  *
64  * @param parent The parent widget.
65  */
66  explicit EmailAddressSelectionWidget(QWidget *parent = nullptr);
67 
68  /**
69  * Creates a new email address selection widget.
70  *
71  * @param model A custom, ContactsTreeModel based model to use.
72  * @param parent The parent widget.
73  */
74  explicit EmailAddressSelectionWidget(QAbstractItemModel *model, QWidget *parent = nullptr);
75 
76  /**
77  * @brief Creates a new email address selection widget.
78  * @param showOnlyContactWithEmail Allow to specify if you want to see only contact with email (by default yes in other constructor)
79  * @param model A custom ContactsTreeModel based model to use.
80  * @param parent The parent widget.
81  */
82  explicit EmailAddressSelectionWidget(bool showOnlyContactWithEmail, QAbstractItemModel *model = nullptr, QWidget *parent = nullptr);
83 
84  /**
85  * Destroys the email address selection widget.
86  */
87  ~EmailAddressSelectionWidget() override;
88 
89  /**
90  * Returns the list of selected email addresses.
91  */
92  Q_REQUIRED_RESULT EmailAddressSelection::List selectedAddresses() const;
93 
94  /**
95  * Returns the line edit that is used for the search line.
96  */
97  QLineEdit *searchLineEdit() const;
98 
99  /**
100  * Returns the tree view that is used to list the items.
101  */
102  QTreeView *view() const;
103 
104 Q_SIGNALS:
105  /**
106  * @since 4.10.1
107  */
108  void doubleClicked();
109 
110 private:
111  //@cond PRIVATE
112  std::unique_ptr<EmailAddressSelectionWidgetPrivate> const d;
113  //@endcond
114 };
115 }
A widget to select email addresses from Akonadi.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Mar 26 2023 03:56:46 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.