recipientseditor.h 3.09 KB
Newer Older
1
/*
2
3
    SPDX-FileCopyrightText: 2010 Casey Link <unnamedrambler@gmail.com>
    SPDX-FileCopyrightText: 2009-2010 Klaralvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
4
5

    Refactored from earlier code by:
6
7
    SPDX-FileCopyrightText: 2010 Volker Krause <vkrause@kde.org>
    SPDX-FileCopyrightText: 2004 Cornelius Schumacher <schumacher@kde.org>
8

9
    SPDX-License-Identifier: LGPL-2.0-or-later
10
11
12
13
14
15
16
17
18
19
*/
#ifndef MESSAGECOMPOSER_RECIPIENTSEDITORNG_H
#define MESSAGECOMPOSER_RECIPIENTSEDITORNG_H

#include "messagecomposer_export.h"

#include "recipientline.h"

#include <Libkdepim/MultiplyingLineEditor>

Laurent Montel's avatar
Laurent Montel committed
20
21
22
23
namespace KMime
{
namespace Types
{
24
25
26
class Mailbox;
}
}
Laurent Montel's avatar
Laurent Montel committed
27
28
namespace MessageComposer
{
29
30
31
/**
 * @brief The RecipientLineFactory class
 */
32
33
34
35
36
class MESSAGECOMPOSER_EXPORT RecipientLineFactory : public KPIM::MultiplyingLineFactory
{
    Q_OBJECT
public:
    explicit RecipientLineFactory(QObject *parent);
37
38
    KPIM::MultiplyingLine *newLine(QWidget *parent) override;
    int maximumRecipients() override;
39
40
41
42
};

class RecipientsPicker;
class RecipientsEditorPrivate;
43
44
45
/**
 * @brief The RecipientsEditor class
 */
46
47
48
49
class MESSAGECOMPOSER_EXPORT RecipientsEditor : public KPIM::MultiplyingLineEditor
{
    Q_OBJECT
public:
Laurent Montel's avatar
Laurent Montel committed
50
51
    explicit RecipientsEditor(QWidget *parent = nullptr);
    explicit RecipientsEditor(RecipientLineFactory *lineFactory, QWidget *parent = nullptr);
Laurent Montel's avatar
Laurent Montel committed
52
    ~RecipientsEditor() override;
53

Laurent Montel's avatar
Laurent Montel committed
54
55
    Q_REQUIRED_RESULT Recipient::List recipients() const;
    Q_REQUIRED_RESULT QSharedPointer<Recipient> activeRecipient() const;
56

Laurent Montel's avatar
Laurent Montel committed
57
    Q_REQUIRED_RESULT MessageComposer::RecipientsPicker *picker() const;
58
59

    void setRecipientString(const QVector<KMime::Types::Mailbox> &mailboxes, Recipient::Type);
Laurent Montel's avatar
Laurent Montel committed
60
61
    Q_REQUIRED_RESULT QString recipientString(Recipient::Type) const;
    Q_REQUIRED_RESULT QStringList recipientStringList(Recipient::Type) const;
62
63
64
65
66

    /** Adds a recipient (or multiple recipients) to one line of the editor.
        @param recipient The recipient(s) you want to add.
        @param type      The recipient type.
    */
Laurent Montel's avatar
Laurent Montel committed
67
    Q_REQUIRED_RESULT bool addRecipient(const QString &recipient, Recipient::Type type);
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91

    /** Removes the recipient provided it can be found and has the given type.
        @param recipient The recipient(s) you want to remove.
        @param type      The recipient type.
    */
    void removeRecipient(const QString &recipient, Recipient::Type type);

    /**
     * Sets the config file used for storing recent addresses.
     */
    void setRecentAddressConfig(KConfig *config);

public Q_SLOTS:
    void selectRecipients();
    void saveDistributionList();

protected Q_SLOTS:
    void slotPickedRecipient(const Recipient &, bool &tooManyAddress);
    void slotLineAdded(KPIM::MultiplyingLine *);
    void slotLineDeleted(int pos);
    void slotCalculateTotal();
    void addRecipient(RecipientLineNG *, const QString &);

protected:
92
    bool eventFilter(QObject *object, QEvent *event) override;
Laurent Montel's avatar
Laurent Montel committed
93
    Q_REQUIRED_RESULT RecipientLineNG *activeLine() const override;
94

95
96
97
Q_SIGNALS:
    void focusInRecipientLineEdit();

98
99
100
101
102
private:
    RecipientsEditorPrivate *const d;
};
}

Laurent Montel's avatar
Laurent Montel committed
103
#endif // MESSAGECOMPOSER_RECIPIENTSEDITORNG_H