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

KDE's Doxygen guidelines are available online.