File indexing completed on 2024-11-24 04:39:33
0001 /* 0002 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org> 0003 SPDX-License-Identifier: LGPL-2.0-or-later 0004 */ 0005 0006 #include "selectaddressbookdialog.h" 0007 0008 #include <KConfigGroup> 0009 #include <KLocalizedString> 0010 0011 #include <KContacts/Addressee> 0012 #include <KSharedConfig> 0013 0014 using namespace Akonadi; 0015 namespace 0016 { 0017 static const char mySelectAddressBookDialogGroupName[] = "SelectAddressBookDialog"; 0018 } 0019 class Akonadi::SelectAddressBookDialogPrivate 0020 { 0021 public: 0022 SelectAddressBookDialogPrivate(SelectAddressBookDialog *qq) 0023 : q(qq) 0024 { 0025 const QStringList mimeTypes(KContacts::Addressee::mimeType()); 0026 q->setMimeTypeFilter(mimeTypes); 0027 q->setAccessRightsFilter(Akonadi::Collection::CanCreateItem); 0028 q->setWindowTitle(i18nc("@title:window", "Select Address Book")); 0029 q->setDescription(i18nc("@info", "Select the address book where the contact will be saved:")); 0030 q->changeCollectionDialogOptions(Akonadi::CollectionDialog::KeepTreeExpanded); 0031 readConfig(); 0032 } 0033 0034 ~SelectAddressBookDialogPrivate() 0035 { 0036 writeConfig(); 0037 } 0038 0039 SelectAddressBookDialog *const q; 0040 void readConfig(); 0041 void writeConfig(); 0042 }; 0043 0044 void SelectAddressBookDialogPrivate::readConfig() 0045 { 0046 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(mySelectAddressBookDialogGroupName)); 0047 const QSize size = group.readEntry("Size", QSize(600, 400)); 0048 if (size.isValid()) { 0049 q->resize(size); 0050 } 0051 } 0052 0053 void SelectAddressBookDialogPrivate::writeConfig() 0054 { 0055 KConfigGroup group(KSharedConfig::openStateConfig(), QLatin1StringView(mySelectAddressBookDialogGroupName)); 0056 group.writeEntry("Size", q->size()); 0057 group.sync(); 0058 } 0059 0060 SelectAddressBookDialog::SelectAddressBookDialog(QWidget *parent) 0061 : Akonadi::CollectionDialog(parent) 0062 , d(new Akonadi::SelectAddressBookDialogPrivate(this)) 0063 { 0064 } 0065 0066 SelectAddressBookDialog::~SelectAddressBookDialog() = default; 0067 0068 #include "moc_selectaddressbookdialog.cpp"