emailaddressselectiondialog.h 2.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*
    This file is part of Akonadi Contact.

    Copyright (c) 2010 KDAB
    Author: Tobias Koenig <tokoe@kde.org>

    This library is free software; you can redistribute it and/or modify it
    under the terms of the GNU Library General Public License as published by
    the Free Software Foundation; either version 2 of the License, or (at your
    option) any later version.

    This library is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
    License for more details.

    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to the
    Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
*/

#ifndef AKONADI_EMAILADDRESSSELECTIONDIALOG_H
#define AKONADI_EMAILADDRESSSELECTIONDIALOG_H

#include "akonadi-contact_export.h"

28
#include "emailaddressselectionwidget.h"
29

Laurent Montel's avatar
Laurent Montel committed
30
#include <QDialog>
31

Laurent Montel's avatar
Laurent Montel committed
32 33
namespace Akonadi
{
34 35 36 37

/**
 * @short A dialog to select email addresses from Akonadi.
 *
Tobias Koenig's avatar
Tobias Koenig committed
38 39
 * This dialog allows the user to select an name and email address from
 * the Akonadi storage.
40
 * The selected addresses are returned as EmailAddressSelectionWidget::Selection objects
Tobias Koenig's avatar
Tobias Koenig committed
41 42 43 44 45 46 47 48
 * which encapsulate the name, email address and the Akonadi item that has been selected.
 *
 * Example:
 *
 * @code
 *
 * Akonadi::EmailAddressSelectionDialog dlg( this );
 * if ( dlg.exec() ) {
49 50
 *   const Akonadi::EmailAddressSelectionWidget::Selection::List selections = dlg.selectedAddresses();
 *   foreach ( const Akonadi::EmailAddressSelectionWidget::Selection &selection, selections ) {
Laurent Montel's avatar
Laurent Montel committed
51
 *     qCDebug(AKONADICONTACT_LOG) << "Name:" << selection.name() << "Email:" << selection.email();
Tobias Koenig's avatar
Tobias Koenig committed
52 53 54 55 56
 *   }
 * }
 *
 * @endcode
 *
57
 * @author Tobias Koenig <tokoe@kde.org>
58
 * @since 4.5
59
 */
Laurent Montel's avatar
Laurent Montel committed
60
class AKONADI_CONTACT_EXPORT EmailAddressSelectionDialog : public QDialog
61
{
Guy Maurel's avatar
Guy Maurel committed
62
    Q_OBJECT
63

Guy Maurel's avatar
Guy Maurel committed
64
public:
65 66 67 68 69
    /**
     * Creates a new email address selection dialog.
     *
     * @param parent The parent widget.
     */
Laurent Montel's avatar
Laurent Montel committed
70
    explicit EmailAddressSelectionDialog(QWidget *parent = nullptr);
71 72 73 74 75 76 77

    /**
     * Creates a new email address selection dialog.
     *
     * @param model A custom, ContactsTreeModel based model to use.
     * @param parent The parent widget.
     */
Laurent Montel's avatar
Laurent Montel committed
78
    explicit EmailAddressSelectionDialog(QAbstractItemModel *model, QWidget *parent = nullptr);
79 80 81 82 83 84 85 86 87

    /**
     * Destroys the email address selection dialog.
     */
    ~EmailAddressSelectionDialog();

    /**
     * Returns the list of selected email addresses.
     */
88
    EmailAddressSelection::List selectedAddresses() const;
89 90 91 92

    /**
     * Returns the email address selection view that is used.
     */
93
    EmailAddressSelectionWidget *view() const;
94

Guy Maurel's avatar
Guy Maurel committed
95
private:
96 97
    //@cond PRIVATE
    class Private;
Guy Maurel's avatar
Guy Maurel committed
98
    Private *const d;
99 100 101 102 103 104
    //@endcond
};

}

#endif