SVN_SILENT made messages (after extraction)
[kdepim.git] / kaddressbook / contactselectiondialog.cpp
blob24f6df384ad55bd9391ba87df6d58ad856a15bc8
1 /*
2 Copyright (c) 2009 Tobias Koenig <tokoe@kde.org>
3 Copyright (c) 2015 Laurent Montel <montel@kde.org>
5 This library is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Library General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or (at your
8 option) any later version.
10 This library is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 License for more details.
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 02110-1301, USA.
21 #include "contactselectiondialog.h"
22 #include "contactselectionwidget.h"
24 #include <QVBoxLayout>
25 #include <KLocalizedString>
26 #include <QDialogButtonBox>
27 #include <QPushButton>
29 ContactSelectionDialog::ContactSelectionDialog(QItemSelectionModel *selectionModel, bool allowToSelectTypeToExport,
30 QWidget *parent)
31 : QDialog(parent),
32 mVCardExport(Q_NULLPTR)
34 setWindowTitle(i18n("Select Contacts"));
35 QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
36 QWidget *mainWidget = new QWidget(this);
37 QVBoxLayout *mainLayout = new QVBoxLayout;
38 setLayout(mainLayout);
39 mainLayout->addWidget(mainWidget);
41 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
42 okButton->setDefault(true);
43 okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
44 connect(buttonBox, &QDialogButtonBox::accepted, this, &ContactSelectionDialog::accept);
45 connect(buttonBox, &QDialogButtonBox::rejected, this, &ContactSelectionDialog::reject);
47 QVBoxLayout *layout = new QVBoxLayout;
48 mainWidget->setLayout(layout);
50 mSelectionWidget = new ContactSelectionWidget(selectionModel, this);
51 if (allowToSelectTypeToExport) {
52 layout->addWidget(mSelectionWidget);
53 mVCardExport = new VCardExportSelectionWidget;
54 layout->addWidget(mVCardExport);
55 } else {
56 layout->addWidget(mSelectionWidget);
58 mainLayout->addWidget(buttonBox);
60 resize(QSize(450, 220));
63 void ContactSelectionDialog::setMessageText(const QString &message)
65 mSelectionWidget->setMessageText(message);
68 void ContactSelectionDialog::setDefaultAddressBook(const Akonadi::Collection &addressBook)
70 mSelectionWidget->setDefaultAddressBook(addressBook);
73 Akonadi::Item::List ContactSelectionDialog::selectedItems() const
75 return mSelectionWidget->selectedItems();
78 ContactList ContactSelectionDialog::selectedContacts() const
80 return mSelectionWidget->selectedContacts();
83 VCardExportSelectionWidget::ExportFields ContactSelectionDialog::exportType() const
85 if (mVCardExport) {
86 return mVCardExport->exportType();
87 } else {
88 return VCardExportSelectionWidget::None;
92 void ContactSelectionDialog::setAddGroupContact(bool addGroupContact)
94 mSelectionWidget->setAddGroupContact(addGroupContact);