Akonadi Contacts

emailaddressselectionwidget.h
1/*
2 This file is part of Akonadi Contact.
3
4 SPDX-FileCopyrightText: 2010 KDAB
5 SPDX-FileContributor: Tobias Koenig <tokoe@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#pragma once
11
12#include "akonadi-contact-widgets_export.h"
13
14#include <Akonadi/EmailAddressSelection>
15
16#include <Akonadi/Item>
17
18#include <QAbstractItemView>
19#include <QWidget>
20
21#include <memory>
22
23class QLineEdit;
25class QTreeView;
26
27namespace Akonadi
28{
29class 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 <tokoe@kde.org>
54 * @since 4.5
55 */
56class AKONADI_CONTACT_WIDGETS_EXPORT EmailAddressSelectionWidget : public QWidget
57{
58 Q_OBJECT
59
60public:
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 */
88
89 /**
90 * Returns the list of selected email addresses.
91 */
92 [[nodiscard]] Akonadi::EmailAddressSelection::List selectedAddresses() const;
93
94 /**
95 * Returns the line edit that is used for the search line.
96 */
97 [[nodiscard]] QLineEdit *searchLineEdit() const;
98
99 /**
100 * Returns the tree view that is used to list the items.
101 */
102 [[nodiscard]] QTreeView *view() const;
103
104Q_SIGNALS:
105 /**
106 * @since 4.10.1
107 */
109
110private:
111 //@cond PRIVATE
112 std::unique_ptr<EmailAddressSelectionWidgetPrivate> const d;
113 //@endcond
114};
115}
A widget to select email addresses from Akonadi.
~EmailAddressSelectionWidget() override
Destroys the email address selection widget.
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:47 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.