File indexing completed on 2024-11-17 04:40:42

0001 /*
0002     This file is part of Akonadi Contact.
0003 
0004     SPDX-FileCopyrightText: 2010 KDAB
0005     SPDX-FileContributor: Tobias Koenig <tokoe@kde.org>
0006 
0007     SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 
0010 #pragma once
0011 
0012 #include "akonadi-contact-widgets_export.h"
0013 
0014 #include "abstractemailaddressselectiondialog.h"
0015 #include "emailaddressselectionwidget.h"
0016 
0017 #include <memory>
0018 
0019 namespace Akonadi
0020 {
0021 class EmailAddressSelectionDialogPrivate;
0022 
0023 /**
0024  * @short A dialog to select email addresses from Akonadi.
0025  *
0026  * This dialog allows the user to select an name and email address from
0027  * the Akonadi storage.
0028  * The selected addresses are returned as EmailAddressSelectionWidget::Selection objects
0029  * which encapsulate the name, email address and the Akonadi item that has been selected.
0030  *
0031  * Example:
0032  *
0033  * @code
0034  *
0035  * Akonadi::EmailAddressSelectionDialog dlg( this );
0036  * if ( dlg.exec() ) {
0037  *   const Akonadi::EmailAddressSelectionWidget::Selection::List selections = dlg.selectedAddresses();
0038  *   foreach ( const Akonadi::EmailAddressSelectionWidget::Selection &selection, selections ) {
0039  *     qCDebug(AKONADICONTACT_LOG) << "Name:" << selection.name() << "Email:" << selection.email();
0040  *   }
0041  * }
0042  *
0043  * @endcode
0044  *
0045  * @author Tobias Koenig <tokoe@kde.org>
0046  * @since 4.5
0047  */
0048 class AKONADI_CONTACT_WIDGETS_EXPORT EmailAddressSelectionDialog : public AbstractEmailAddressSelectionDialog
0049 {
0050     Q_OBJECT
0051 
0052 public:
0053     /**
0054      * Creates a new email address selection dialog.
0055      *
0056      * @param parent The parent widget.
0057      */
0058     explicit EmailAddressSelectionDialog(QWidget *parent = nullptr);
0059 
0060     /**
0061      * Creates a new email address selection dialog.
0062      *
0063      * @param model A custom, ContactsTreeModel based model to use.
0064      * @param parent The parent widget.
0065      */
0066     explicit EmailAddressSelectionDialog(QAbstractItemModel *model, QWidget *parent = nullptr);
0067 
0068     /**
0069      * Destroys the email address selection dialog.
0070      */
0071     ~EmailAddressSelectionDialog() override;
0072 
0073     /**
0074      * Returns the list of selected email addresses.
0075      */
0076     [[nodiscard]] Akonadi::EmailAddressSelection::List selectedAddresses() const override;
0077 
0078     /**
0079      * Returns the email address selection view that is used.
0080      */
0081     [[nodiscard]] Akonadi::EmailAddressSelectionWidget *view() const override;
0082 
0083 private:
0084     //@cond PRIVATE
0085     std::unique_ptr<EmailAddressSelectionDialogPrivate> const d;
0086     //@endcond
0087 };
0088 }