Akonadi Contacts

emailaddressselectiondialog.cpp
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#include "emailaddressselectiondialog.h"
11#include "recipientspicker/recipientspickerwidget.h"
12
13#include <KConfigGroup>
14
15#include <KSharedConfig>
16#include <QDialogButtonBox>
17#include <QPushButton>
18#include <QTreeView>
19#include <QVBoxLayout>
20
21using namespace Akonadi;
22
23class Akonadi::EmailAddressSelectionDialogPrivate
24{
25public:
26 EmailAddressSelectionDialogPrivate(EmailAddressSelectionDialog *qq, QAbstractItemModel *model)
27 : q(qq)
28 {
29 auto mainLayout = new QVBoxLayout(q);
30 if (model) {
31 mView = new RecipientsPickerWidget(true, model, q);
32 } else {
33 mView = new RecipientsPickerWidget(true, nullptr, q);
34 }
35 mainLayout->addWidget(mView);
36 q->connect(mView->emailAddressSelectionWidget()->view(), &QTreeView::doubleClicked, q, &QDialog::accept);
38 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
39 okButton->setDefault(true);
43
44 mainLayout->addWidget(buttonBox);
45 readConfig();
46 }
47
48 void readConfig()
49 {
50 KConfigGroup group(KSharedConfig::openStateConfig(), QStringLiteral("EmailAddressSelectionDialog"));
51 const QSize size = group.readEntry("Size", QSize());
52 if (size.isValid()) {
53 q->resize(size);
54 } else {
55 q->resize(q->sizeHint().width(), q->sizeHint().height());
56 }
57 }
58
59 void writeConfig()
60 {
61 KConfigGroup group(KSharedConfig::openStateConfig(), QStringLiteral("EmailAddressSelectionDialog"));
62 group.writeEntry("Size", q->size());
63 }
64
66 RecipientsPickerWidget *mView = nullptr;
67};
68
70 : AbstractEmailAddressSelectionDialog(parent)
71 , d(new EmailAddressSelectionDialogPrivate(this, nullptr))
72{
73}
74
76 : AbstractEmailAddressSelectionDialog(parent)
77 , d(new EmailAddressSelectionDialogPrivate(this, model))
78{
79}
80
85
87{
88 return d->mView->emailAddressSelectionWidget()->selectedAddresses();
89}
90
92{
93 return d->mView->emailAddressSelectionWidget();
94}
95
96#include "moc_emailaddressselectiondialog.cpp"
A dialog to select email addresses from Akonadi.
Akonadi::EmailAddressSelection::List selectedAddresses() const override
Returns the list of selected email addresses.
Akonadi::EmailAddressSelectionWidget * view() const override
Returns the email address selection view that is used.
~EmailAddressSelectionDialog() override
Destroys the email address selection dialog.
EmailAddressSelectionDialog(QWidget *parent=nullptr)
Creates a new email address selection dialog.
A widget to select email addresses from Akonadi.
QTreeView * view() const
Returns the tree view that is used to list the items.
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
A widget for editing the display name of a contact.
void setShortcut(const QKeySequence &key)
void doubleClicked(const QModelIndex &index)
virtual void accept()
virtual void reject()
virtual QSize sizeHint() const const override
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void setDefault(bool)
int height() const const
bool isValid() const const
int width() const const
Key_Return
void resize(const QSize &)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:13:20 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.