summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-11 05:05:33 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-11 05:05:33 (GMT)
commited27421a96327e7aa2e9825d4df23d84c2eda748 (patch)
treedb6a53394f694a1a60d049193369fece350bfe0c
parent7887f9b3047498f9248eb79e27f8a40c4a132ff3 (diff)
Add more widget
-rw-r--r--kaddressbookimportexport/src/CMakeLists.txt2
-rw-r--r--kaddressbookimportexport/src/kaddressbookcontactselectiondialog.h2
-rw-r--r--kaddressbookimportexport/src/kaddressbookexportselectionwidget.cpp162
-rw-r--r--kaddressbookimportexport/src/kaddressbookexportselectionwidget.h58
4 files changed, 223 insertions, 1 deletions
diff --git a/kaddressbookimportexport/src/CMakeLists.txt b/kaddressbookimportexport/src/CMakeLists.txt
index 6e32fd0..d49ca37 100644
--- a/kaddressbookimportexport/src/CMakeLists.txt
+++ b/kaddressbookimportexport/src/CMakeLists.txt
@@ -9,6 +9,7 @@ set(kaddressbook_importexport_LIB_SRCS
kaddressbookimportexportcontactlist.cpp
kaddressbookcontactselectionwidget.cpp
kaddressbookcontactselectiondialog.cpp
+ kaddressbookexportselectionwidget.cpp
)
ecm_qt_declare_logging_category(kaddressbook_importexport_LIB_SRCS HEADER libkaddressbookexportimport_debug.h IDENTIFIER LIBKADDRESSBOOKIMPORTEXPORT_LOG CATEGORY_NAME org.kde.pim.kaddressbookimportexport)
@@ -51,6 +52,7 @@ ecm_generate_headers(KaddressbookImportExport_CamelCase_HEADERS
KAddressBookImportExportPluginManager
KAddressBookImportExportContactList
KAddressBookContactSelectionDialog
+ KAddressBookExportSelectionWidget
REQUIRED_HEADERS KaddressbookImportExport_HEADERS
PREFIX KAddressBookImportExport
)
diff --git a/kaddressbookimportexport/src/kaddressbookcontactselectiondialog.h b/kaddressbookimportexport/src/kaddressbookcontactselectiondialog.h
index bb2e4b8..eca3e26 100644
--- a/kaddressbookimportexport/src/kaddressbookcontactselectiondialog.h
+++ b/kaddressbookimportexport/src/kaddressbookcontactselectiondialog.h
@@ -21,7 +21,7 @@
#ifndef CONTACTEXPORTSELECTIONDIALOG_H
#define CONTACTEXPORTSELECTIONDIALOG_H
-#include "kaddressbookimportexportplugin.h"
+#include "kaddressbook_importexport_export.h"
#include <KContacts/Addressee>
#include <QDialog>
#include <KAddressBookImportExport/KAddressBookImportExportContactList>
diff --git a/kaddressbookimportexport/src/kaddressbookexportselectionwidget.cpp b/kaddressbookimportexport/src/kaddressbookexportselectionwidget.cpp
new file mode 100644
index 0000000..1a2d8cf
--- /dev/null
+++ b/kaddressbookimportexport/src/kaddressbookexportselectionwidget.cpp
@@ -0,0 +1,162 @@
+/*
+ Copyright (C) 2015-2016 Montel Laurent <montel@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "kaddressbookexportselectionwidget.h"
+
+#include <KLocalizedString>
+
+#include <kconfig.h>
+#include <KConfigGroup>
+#include <qcheckbox.h>
+#include <qgridlayout.h>
+#include <qgroupbox.h>
+
+using namespace KAddressBookImportExport;
+KAddressBookExportSelectionWidget::KAddressBookExportSelectionWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
+ mainLayout->setMargin(0);
+ QGroupBox *gbox = new QGroupBox(
+ i18nc("@title:group", "Fields to be exported"), this);
+ mainLayout->addWidget(gbox);
+ QGridLayout *layout = new QGridLayout;
+ gbox->setLayout(layout);
+ gbox->setFlat(true);
+ layout->addWidget(gbox, 0, 0, 1, 2);
+
+ mPrivateBox = new QCheckBox(i18nc("@option:check", "Private fields"), this);
+ mPrivateBox->setToolTip(
+ i18nc("@info:tooltip", "Export private fields"));
+ mPrivateBox->setWhatsThis(
+ i18nc("@info:whatsthis",
+ "Check this box if you want to export the contact's "
+ "private fields to the vCard output file."));
+ layout->addWidget(mPrivateBox, 1, 0);
+
+ mBusinessBox = new QCheckBox(i18nc("@option:check", "Business fields"), this);
+ mBusinessBox->setToolTip(
+ i18nc("@info:tooltip", "Export business fields"));
+ mBusinessBox->setWhatsThis(
+ i18nc("@info:whatsthis",
+ "Check this box if you want to export the contact's "
+ "business fields to the vCard output file."));
+ layout->addWidget(mBusinessBox, 2, 0);
+
+ mOtherBox = new QCheckBox(i18nc("@option:check", "Other fields"), this);
+ mOtherBox->setToolTip(
+ i18nc("@info:tooltip", "Export other fields"));
+ mOtherBox->setWhatsThis(
+ i18nc("@info:whatsthis",
+ "Check this box if you want to export the contact's "
+ "other fields to the vCard output file."));
+ layout->addWidget(mOtherBox, 3, 0);
+
+ mEncryptionKeys = new QCheckBox(i18nc("@option:check", "Encryption keys"), this);
+ mEncryptionKeys->setToolTip(
+ i18nc("@info:tooltip", "Export encryption keys"));
+ mEncryptionKeys->setWhatsThis(
+ i18nc("@info:whatsthis",
+ "Check this box if you want to export the contact's "
+ "encryption keys to the vCard output file."));
+ layout->addWidget(mEncryptionKeys, 1, 1);
+
+ mPictureBox = new QCheckBox(i18nc("@option:check", "Pictures"), this);
+ mPictureBox->setToolTip(
+ i18nc("@info:tooltip", "Export pictures"));
+ mPictureBox->setWhatsThis(
+ i18nc("@info:whatsthis",
+ "Check this box if you want to export the contact's "
+ "picture to the vCard output file."));
+ layout->addWidget(mPictureBox, 2, 1);
+
+ gbox = new QGroupBox(
+ i18nc("@title:group", "Export options"), this);
+ gbox->setFlat(true);
+ mainLayout->addWidget(gbox);
+ QHBoxLayout *gbLayout = new QHBoxLayout;
+ gbox->setLayout(gbLayout);
+
+ mDisplayNameBox = new QCheckBox(i18nc("@option:check", "Display name as full name"), this);
+ mDisplayNameBox->setToolTip(
+ i18nc("@info:tooltip", "Export display name as full name"));
+ mDisplayNameBox->setWhatsThis(
+ i18nc("@info:whatsthis",
+ "Check this box if you want to export the contact's display name "
+ "in the vCard's full name field. This may be required to get the "
+ "name shown correctly in GMail or Android."));
+ gbLayout->addWidget(mDisplayNameBox);
+
+ readSettings();
+}
+
+KAddressBookExportSelectionWidget::~KAddressBookExportSelectionWidget()
+{
+ writeSettings();
+}
+
+void KAddressBookExportSelectionWidget::readSettings()
+{
+ KConfig config(QStringLiteral("kaddressbookrc"));
+ const KConfigGroup group(&config, "XXPortVCard");
+
+ mPrivateBox->setChecked(group.readEntry("ExportPrivateFields", true));
+ mBusinessBox->setChecked(group.readEntry("ExportBusinessFields", true));
+ mOtherBox->setChecked(group.readEntry("ExportOtherFields", true));
+ mEncryptionKeys->setChecked(group.readEntry("ExportEncryptionKeys", true));
+ mPictureBox->setChecked(group.readEntry("ExportPictureFields", true));
+ mDisplayNameBox->setChecked(group.readEntry("ExportDisplayName", false));
+}
+
+void KAddressBookExportSelectionWidget::writeSettings()
+{
+ KConfig config(QStringLiteral("kaddressbookrc"));
+ KConfigGroup group(&config, "XXPortVCard");
+
+ group.writeEntry("ExportPrivateFields", mPrivateBox->isChecked());
+ group.writeEntry("ExportBusinessFields", mBusinessBox->isChecked());
+ group.writeEntry("ExportOtherFields", mOtherBox->isChecked());
+ group.writeEntry("ExportEncryptionKeys", mEncryptionKeys->isChecked());
+ group.writeEntry("ExportPictureFields", mPictureBox->isChecked());
+ group.writeEntry("ExportDisplayName", mDisplayNameBox->isChecked());
+}
+
+KAddressBookExportSelectionWidget::ExportFields KAddressBookExportSelectionWidget::exportType() const
+{
+ ExportFields type = None;
+ if (mPrivateBox->isChecked()) {
+ type |= Private;
+ }
+ if (mBusinessBox->isChecked()) {
+ type |= Business;
+ }
+ if (mOtherBox->isChecked()) {
+ type |= Other;
+ }
+ if (mEncryptionKeys->isChecked()) {
+ type |= Encryption;
+ }
+ if (mPictureBox->isChecked()) {
+ type |= Picture;
+ }
+ if (mDisplayNameBox->isChecked()) {
+ type |= DiplayName;
+ }
+ return type;
+}
diff --git a/kaddressbookimportexport/src/kaddressbookexportselectionwidget.h b/kaddressbookimportexport/src/kaddressbookexportselectionwidget.h
new file mode 100644
index 0000000..acbd773
--- /dev/null
+++ b/kaddressbookimportexport/src/kaddressbookexportselectionwidget.h
@@ -0,0 +1,58 @@
+/*
+ Copyright (C) 2015-2016 Montel Laurent <montel@kde.org>
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef KADDRESSBOOKEXPORTSELECTIONWIDGET_H
+#define KADDRESSBOOKEXPORTSELECTIONWIDGET_H
+
+#include <QWidget>
+#include "kaddressbook_importexport_export.h"
+class QCheckBox;
+namespace KAddressBookImportExport
+{
+class KADDRESSBOOK_IMPORTEXPORT_EXPORT KAddressBookExportSelectionWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit KAddressBookExportSelectionWidget(QWidget *parent = Q_NULLPTR);
+ ~KAddressBookExportSelectionWidget();
+ enum ExportField {
+ None = 0,
+ Private = 1,
+ Business = 2,
+ Other = 4,
+ Encryption = 8,
+ Picture = 16,
+ DiplayName = 32
+ };
+ Q_ENUMS(ExportField)
+ Q_DECLARE_FLAGS(ExportFields, ExportField)
+
+ ExportFields exportType() const;
+private:
+ void readSettings();
+ void writeSettings();
+ QCheckBox *mPrivateBox;
+ QCheckBox *mBusinessBox;
+ QCheckBox *mOtherBox;
+ QCheckBox *mEncryptionKeys;
+ QCheckBox *mPictureBox;
+ QCheckBox *mDisplayNameBox;
+};
+}
+#endif // KADDRESSBOOKEXPORTSELECTIONWIDGET_H