contactgroupeditordialog.h 3.57 KB
Newer Older
1 2 3 4 5
/*
    This file is part of Akonadi Contact.

    Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>

Tobias Koenig's avatar
Tobias Koenig committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19
    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.
20 21 22 23 24 25 26
*/

#ifndef AKONADI_CONTACTGROUPEDITORDIALOG_H
#define AKONADI_CONTACTGROUPEDITORDIALOG_H

#include "akonadi-contact_export.h"

Laurent Montel's avatar
Laurent Montel committed
27
#include <QDialog>
28

Laurent Montel's avatar
Laurent Montel committed
29 30
namespace Akonadi
{
31 32

class Item;
33
class Collection;
34 35
class ContactGroupEditor;

Tobias Koenig's avatar
Tobias Koenig committed
36
/**
Tobias Koenig's avatar
Tobias Koenig committed
37 38 39 40 41 42 43 44 45
 * @short A dialog for creating or editing a contact group in Akonadi.
 *
 * This dialog provides a way to create a new contact group or edit
 * an existing contact group in Akonadi.
 *
 * Example for creating a new contact group:
 *
 * @code
 *
46
 * using namespace Akonadi;
Tobias Koenig's avatar
Tobias Koenig committed
47
 *
48
 * ContactGroupEditorDialog *dlg = new ContactGroupEditorDialog( ContactGroupEditorDialog::CreateMode, this );
Guy Maurel's avatar
Guy Maurel committed
49 50
 * connect( dlg, SIGNAL(contactGroupStored(Akonadi::Item)),
 *          this, SLOT(contactGroupStored(Akonadi::Item)) );
51
 * dlg->show();
Tobias Koenig's avatar
Tobias Koenig committed
52 53 54 55 56 57 58
 *
 * @endcode
 *
 * Example for editing an existing contact group:
 *
 * @code
 *
59
 * using namespace Akonadi;
Tobias Koenig's avatar
Tobias Koenig committed
60
 *
61
 * const Item contactGroup = ...;
Tobias Koenig's avatar
Tobias Koenig committed
62
 *
63
 * ContactGroupEditorDialog *dlg = new ContactGroupEditorDialog( ContactGroupEditorDialog::EditMode, this );
Guy Maurel's avatar
Guy Maurel committed
64 65
 * connect( dlg, SIGNAL(contactGroupStored(Akonadi::Item)),
 *          this, SLOT(contactGroupStored(Akonadi::Item)) );
66 67
 * dlg->setContactGroup( contactGroup );
 * dlg->show();
Tobias Koenig's avatar
Tobias Koenig committed
68 69
 *
 * @endcode
Tobias Koenig's avatar
Tobias Koenig committed
70 71
 *
 * @author Tobias Koenig <tokoe@kde.org>
Tobias Koenig's avatar
Tobias Koenig committed
72
 * @since 4.4
Tobias Koenig's avatar
Tobias Koenig committed
73
 */
Laurent Montel's avatar
Laurent Montel committed
74
class AKONADI_CONTACT_EXPORT ContactGroupEditorDialog : public QDialog
75
{
Guy Maurel's avatar
Guy Maurel committed
76
    Q_OBJECT
77

Guy Maurel's avatar
Guy Maurel committed
78
public:
Tobias Koenig's avatar
Tobias Koenig committed
79 80 81
    /**
     * Describes the mode of the contact group editor.
     */
82
    enum Mode {
Guy Maurel's avatar
Guy Maurel committed
83 84
        CreateMode, ///< Creates a new contact group
        EditMode    ///< Edits an existing contact group
85 86 87 88 89 90 91 92
    };

    /**
     * Creates a new contact group editor dialog.
     *
     * @param mode The mode of the dialog.
     * @param parent The parent widget of the dialog.
     */
Laurent Montel's avatar
Laurent Montel committed
93
    explicit ContactGroupEditorDialog(Mode mode, QWidget *parent = nullptr);
94 95 96 97 98 99 100 101 102

    /**
     * Destroys the contact group editor dialog.
     */
    ~ContactGroupEditorDialog();

    /**
     * Sets the contact @p group to edit when in EditMode.
     */
Guy Maurel's avatar
Guy Maurel committed
103
    void setContactGroup(const Akonadi::Item &group);
104

105
    /**
106 107
     * Sets the @p addressbook that shall be selected as default
     * for storage in create mode.
108
     */
Guy Maurel's avatar
Guy Maurel committed
109
    void setDefaultAddressBook(const Akonadi::Collection &addressbook);
110

111 112 113
    /**
     * Returns the ContactGroupEditor that is used by the dialog.
     */
Guy Maurel's avatar
Guy Maurel committed
114
    ContactGroupEditor *editor() const;
115

Guy Maurel's avatar
Guy Maurel committed
116
Q_SIGNALS:
117 118 119 120 121
    /**
     * This signal is emitted whenever a contact group was updated or stored.
     *
     * @param group The contact group.
     */
Guy Maurel's avatar
Guy Maurel committed
122
    void contactGroupStored(const Akonadi::Item &group);
123

Guy Maurel's avatar
Guy Maurel committed
124
private Q_SLOTS:
Laurent Montel's avatar
Laurent Montel committed
125
    void slotAccepted();
126

Guy Maurel's avatar
Guy Maurel committed
127
private:
Tobias Koenig's avatar
Tobias Koenig committed
128 129
    //@cond PRIVATE
    class Private;
Guy Maurel's avatar
Guy Maurel committed
130
    Private *const d;
Tobias Koenig's avatar
Tobias Koenig committed
131

Guy Maurel's avatar
Guy Maurel committed
132
    Q_PRIVATE_SLOT(d, void slotGroupNameChanged(const QString &))
Tobias Koenig's avatar
Tobias Koenig committed
133
    //@endcond
134 135 136 137 138
};

}

#endif