Akonadi Contacts

selectaddressbookdialog.cpp
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4 */
5
6#include "selectaddressbookdialog.h"
7
8#include <KConfigGroup>
9#include <KLocalizedString>
10
11#include <KContacts/Addressee>
12#include <KSharedConfig>
13
14using namespace Akonadi;
15namespace
16{
17static const char mySelectAddressBookDialogGroupName[] = "SelectAddressBookDialog";
18}
19class Akonadi::SelectAddressBookDialogPrivate
20{
21public:
22 SelectAddressBookDialogPrivate(SelectAddressBookDialog *qq)
23 : q(qq)
24 {
26 q->setMimeTypeFilter(mimeTypes);
28 q->setWindowTitle(i18nc("@title:window", "Select Address Book"));
29 q->setDescription(i18nc("@info", "Select the address book where the contact will be saved:"));
30 q->changeCollectionDialogOptions(Akonadi::CollectionDialog::KeepTreeExpanded);
31 readConfig();
32 }
33
34 ~SelectAddressBookDialogPrivate()
35 {
36 writeConfig();
37 }
38
40 void readConfig();
41 void writeConfig();
42};
43
44void SelectAddressBookDialogPrivate::readConfig()
45{
46 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(mySelectAddressBookDialogGroupName));
47 const QSize size = group.readEntry("Size", QSize(600, 400));
48 if (size.isValid()) {
49 q->resize(size);
50 }
51}
52
53void SelectAddressBookDialogPrivate::writeConfig()
54{
55 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(mySelectAddressBookDialogGroupName));
56 group.writeEntry("Size", q->size());
57 group.sync();
58}
59
60SelectAddressBookDialog::SelectAddressBookDialog(QWidget *parent)
61 : Akonadi::CollectionDialog(parent)
62 , d(new Akonadi::SelectAddressBookDialogPrivate(this))
63{
64}
65
66SelectAddressBookDialog::~SelectAddressBookDialog() = default;
67
68#include "moc_selectaddressbookdialog.cpp"
void changeCollectionDialogOptions(CollectionDialogOptions options)
void setAccessRightsFilter(Collection::Rights rights)
void setMimeTypeFilter(const QStringList &mimeTypes)
void setDescription(const QString &text)
The SelectAddressBookDialog class This class allows to select addressbook where saving contacts.
static QString mimeType()
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
QString i18nc(const char *context, const char *text, const TYPE &arg...)
A widget for editing the display name of a contact.
bool isValid() const const
void resize(const QSize &)
void setWindowTitle(const QString &)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:08 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.