Akonadi Contacts

selectaddressbookdialog.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2021 Laurent Montel <[email protected]>
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 <KSharedConfig>
12 #include <kcontacts/addressee.h>
13 
14 using namespace Akonadi;
15 class Akonadi::SelectAddressBookDialogPrivate
16 {
17 public:
18  SelectAddressBookDialogPrivate(SelectAddressBookDialog *qq)
19  : q(qq)
20  {
22  q->setMimeTypeFilter(mimeTypes);
23  q->setAccessRightsFilter(Akonadi::Collection::CanCreateItem);
24  q->setWindowTitle(i18nc("@title:window", "Select Address Book"));
25  q->setDescription(i18nc("@info", "Select the address book where the contact will be saved:"));
26  q->changeCollectionDialogOptions(Akonadi::CollectionDialog::KeepTreeExpanded);
27  readConfig();
28  }
29 
30  ~SelectAddressBookDialogPrivate()
31  {
32  writeConfig();
33  }
34 
35  SelectAddressBookDialog *const q;
36  void readConfig();
37  void writeConfig();
38 };
39 
40 void SelectAddressBookDialogPrivate::readConfig()
41 {
42  KConfigGroup group(KSharedConfig::openStateConfig(), "SelectAddressBookDialog");
43  const QSize size = group.readEntry("Size", QSize(600, 400));
44  if (size.isValid()) {
45  q->resize(size);
46  }
47 }
48 
49 void SelectAddressBookDialogPrivate::writeConfig()
50 {
51  KConfigGroup group(KSharedConfig::openStateConfig(), "SelectAddressBookDialog");
52  group.writeEntry("Size", q->size());
53  group.sync();
54 }
55 
56 SelectAddressBookDialog::SelectAddressBookDialog(QWidget *parent)
57  : Akonadi::CollectionDialog(parent)
58  , d(new Akonadi::SelectAddressBookDialogPrivate(this))
59 {
60 }
61 
62 SelectAddressBookDialog::~SelectAddressBookDialog()
63 {
64  delete d;
65 }
static QString mimeType()
bool isValid() const const
The SelectAddressBookDialog class This class allows to select addressbook where saving contacts...
static KSharedConfig::Ptr openStateConfig(const QString &fileName=QString())
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QStringList mimeTypes(Types)
void readConfig()
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Jun 18 2021 23:08:56 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.