summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-11 20:02:52 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-11 20:02:52 (GMT)
commitdc473a0a6396f3fe131f93600c18db160b2478b6 (patch)
tree73652d5612b2a6d29e685fe01c348324c12aa550
parent84fba0ea2db2d292ec7c6f2c95283c6915f412fa (diff)
improve plugins
-rw-r--r--CMakeLists.txt3
-rw-r--r--kaddressbook/importexportplugins/CMakeLists.txt6
-rw-r--r--kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp30
-rw-r--r--kaddressbook/importexportplugins/csv/csvimportexportplugininterface.h4
-rw-r--r--kaddressbook/importexportplugins/gmx/gmximportexportplugininterface.cpp7
-rw-r--r--kaddressbook/importexportplugins/gmx/gmximportexportplugininterface.h1
-rw-r--r--kaddressbook/importexportplugins/ldif/ldifimportexportplugininterface.cpp31
-rw-r--r--kaddressbook/importexportplugins/ldif/ldifimportexportplugininterface.h3
-rw-r--r--kaddressbook/importexportplugins/vcards/vcardimportexportplugininterface.cpp119
-rw-r--r--kaddressbook/importexportplugins/vcards/vcardimportexportplugininterface.h5
-rw-r--r--kmail/editorplugins/changecase/kmail_changecaseeditorplugin.json4
11 files changed, 198 insertions, 15 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 645663a..393face 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -72,7 +72,7 @@ set(MESSAGELIB_LIB_VERSION "5.3.64")
set(AKONADICALENDAR_LIB_VERSION "5.3.40")
set(CALENDAR_UTILS_VERSION "5.3.40")
set(KPIMTEXTEDIT_LIB_VERSION "5.3.42")
-
+set(GPGMEPP_LIB_VERSION "5.3.40")
find_package(KF5CalendarUtils ${CALENDAR_UTILS_VERSION} CONFIG REQUIRED)
find_package(KF5WebEngineViewer ${MESSAGELIB_LIB_VERSION} CONFIG REQUIRED)
@@ -94,6 +94,7 @@ find_package(KF5Akonadi ${AKONADI_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5AkonadiCalendar ${AKONADICALENDAR_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5Gravatar ${GRAVATAR_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5PimTextEdit ${KPIMTEXTEDIT_LIB_VERSION} CONFIG REQUIRED)
+find_package(KF5Gpgmepp ${GPGMEPP_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5Tnef ${KTNEF_LIB_VERSION} CONFIG REQUIRED)
diff --git a/kaddressbook/importexportplugins/CMakeLists.txt b/kaddressbook/importexportplugins/CMakeLists.txt
index 021bd53..9cbd7d5 100644
--- a/kaddressbook/importexportplugins/CMakeLists.txt
+++ b/kaddressbook/importexportplugins/CMakeLists.txt
@@ -1,6 +1,10 @@
add_definitions(-DTRANSLATION_DOMAIN=\"kaddressbook_importexportplugins\")
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/shared)
+include_directories(${CMAKE_CURRENT_BINARY_DIR}/shared)
+
+if(KF5Gpgmepp_FOUND)
+ add_definitions(-DQGPGME_FOUND)
+endif()
add_subdirectory(shared)
diff --git a/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp b/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp
index ec2cf96..0b24568 100644
--- a/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp
+++ b/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp
@@ -32,6 +32,7 @@
#include <QFileDialog>
#include <QTextCodec>
#include <QPointer>
+#include <KAddressBookContactSelectionDialog>
#include <KIO/Job>
CSVImportExportPluginInterface::CSVImportExportPluginInterface(QObject *parent)
@@ -162,6 +163,24 @@ void CSVImportExportPluginInterface::exportToFile(QFile *file, const KContacts::
void CSVImportExportPluginInterface::exportCSV()
{
+ QPointer<KAddressBookImportExport::KAddressBookContactSelectionDialog> dlg =
+ new KAddressBookImportExport::KAddressBookContactSelectionDialog(itemSelectionModel(), false, parentWidget());
+ dlg->setMessageText(i18n("Which contact do you want to export?"));
+ dlg->setDefaultAddressBook(defaultCollection());
+ if (!dlg->exec() || !dlg) {
+ delete dlg;
+ return;
+ }
+ const KContacts::AddresseeList contacts = dlg->selectedContacts().addressList();
+ delete dlg;
+
+ if (contacts.isEmpty()) {
+ KMessageBox::sorry(Q_NULLPTR, i18n("You have not selected any contacts to export."));
+ return;
+ }
+
+ KAddressBookImportExport::KAddressBookImportExportContactList contactLists;
+ contactLists.setAddressList(contacts);
QUrl url = QFileDialog::getSaveFileUrl(parentWidget(), QString(), QUrl::fromLocalFile(QStringLiteral("addressbook.csv")));
if (url.isEmpty()) {
return;
@@ -189,7 +208,7 @@ void CSVImportExportPluginInterface::exportCSV()
KMessageBox::error(parentWidget(), msg);
return;
}
- exportToFile(&tmpFile, addressBookImportExportList().addressList());
+ exportToFile(&tmpFile, contactLists.addressList());
tmpFile.flush();
auto job = KIO::file_copy(QUrl::fromLocalFile(tmpFile.fileName()), url, -1, KIO::Overwrite);
KJobWidgets::setWindow(job, parentWidget());
@@ -202,8 +221,13 @@ void CSVImportExportPluginInterface::exportCSV()
return;
}
- exportToFile(&file, addressBookImportExportList().addressList());
+ exportToFile(&file, contactLists.addressList());
file.close();
-
}
}
+
+
+bool CSVImportExportPluginInterface::canImportFileType(const QUrl &url)
+{
+ return url.path().endsWith(QStringLiteral(".csv"));
+}
diff --git a/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.h b/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.h
index d7f2e47..e53d4e5 100644
--- a/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.h
+++ b/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.h
@@ -32,6 +32,9 @@ public:
void createAction(KActionCollection *ac) Q_DECL_OVERRIDE;
void exec() Q_DECL_OVERRIDE;
+
+ bool canImportFileType(const QUrl &url) Q_DECL_OVERRIDE;
+
private:
void slotFinished();
void exportCSV();
@@ -39,6 +42,7 @@ private:
void slotExportCVS();
void exportToFile(QFile *file, const KContacts::Addressee::List &contacts) const;
void importCSV();
+
};
#endif // CSVIMPORTEXPORTPLUGININTERFACE_H
diff --git a/kaddressbook/importexportplugins/gmx/gmximportexportplugininterface.cpp b/kaddressbook/importexportplugins/gmx/gmximportexportplugininterface.cpp
index bd195ea..5a90950 100644
--- a/kaddressbook/importexportplugins/gmx/gmximportexportplugininterface.cpp
+++ b/kaddressbook/importexportplugins/gmx/gmximportexportplugininterface.cpp
@@ -21,6 +21,7 @@
#include <KLocalizedString>
#include <KActionCollection>
#include <QAction>
+#include <QUrl>
GMXImportExportPluginInterface::GMXImportExportPluginInterface(QObject *parent)
: KAddressBookImportExport::KAddressBookImportExportPluginInterface(parent)
@@ -82,3 +83,9 @@ void GMXImportExportPluginInterface::importGMX()
{
}
+
+
+bool GMXImportExportPluginInterface::canImportFileType(const QUrl &url)
+{
+ return url.path().endsWith(QStringLiteral(".gmx"));
+}
diff --git a/kaddressbook/importexportplugins/gmx/gmximportexportplugininterface.h b/kaddressbook/importexportplugins/gmx/gmximportexportplugininterface.h
index 2e1af7a..d6b9cce 100644
--- a/kaddressbook/importexportplugins/gmx/gmximportexportplugininterface.h
+++ b/kaddressbook/importexportplugins/gmx/gmximportexportplugininterface.h
@@ -31,6 +31,7 @@ public:
void createAction(KActionCollection *ac) Q_DECL_OVERRIDE;
void exec() Q_DECL_OVERRIDE;
+ bool canImportFileType(const QUrl &url) Q_DECL_OVERRIDE;
private:
void slotImportGmx();
void slotExportGmx();
diff --git a/kaddressbook/importexportplugins/ldif/ldifimportexportplugininterface.cpp b/kaddressbook/importexportplugins/ldif/ldifimportexportplugininterface.cpp
index 19deac6..a7fe757 100644
--- a/kaddressbook/importexportplugins/ldif/ldifimportexportplugininterface.cpp
+++ b/kaddressbook/importexportplugins/ldif/ldifimportexportplugininterface.cpp
@@ -28,9 +28,11 @@
#include <KMessageBox>
#include <QTemporaryFile>
#include <KJobWidgets>
+#include <QPointer>
#include <KIOCore/kio/filecopyjob.h>
#include <PimCommon/RenameFileDialog>
#include <KContacts/LDIFConverter>
+#include <KAddressBookImportExport/KAddressBookContactSelectionDialog>
#include <KAddressBookImportExport/KAddressBookImportExportContactList>
LDifImportExportPluginInterface::LDifImportExportPluginInterface(QObject *parent)
@@ -130,6 +132,25 @@ void doExport(QFile *file, const KAddressBookImportExport::KAddressBookImportExp
void LDifImportExportPluginInterface::exportLdif()
{
+ QPointer<KAddressBookImportExport::KAddressBookContactSelectionDialog> dlg =
+ new KAddressBookImportExport::KAddressBookContactSelectionDialog(itemSelectionModel(), false, parentWidget());
+ dlg->setMessageText(i18n("Which contact do you want to export?"));
+ dlg->setDefaultAddressBook(defaultCollection());
+ if (!dlg->exec() || !dlg) {
+ delete dlg;
+ return;
+ }
+ const KContacts::AddresseeList contacts = dlg->selectedContacts().addressList();
+ delete dlg;
+
+ if (contacts.isEmpty()) {
+ KMessageBox::sorry(Q_NULLPTR, i18n("You have not selected any contacts to export."));
+ return;
+ }
+
+ KAddressBookImportExport::KAddressBookImportExportContactList contactLists;
+ contactLists.setAddressList(contacts);
+
const QUrl url =
QFileDialog::getSaveFileUrl(parentWidget(), QString(), QUrl::fromLocalFile(QDir::homePath() + QLatin1String("/addressbook.ldif")), i18n("LDif Files (*.ldif)"));
if (url.isEmpty()) {
@@ -144,7 +165,7 @@ void LDifImportExportPluginInterface::exportLdif()
return;
}
- doExport(&tmpFile, addressBookImportExportList());
+ doExport(&tmpFile, contactLists);
tmpFile.flush();
auto job = KIO::file_copy(QUrl::fromLocalFile(tmpFile.fileName()), url, -1, KIO::Overwrite);
KJobWidgets::setWindow(job, parentWidget());
@@ -176,7 +197,7 @@ void LDifImportExportPluginInterface::exportLdif()
return;
}
QString data;
- KContacts::LDIFConverter::addresseeAndContactGroupToLDIF(addressBookImportExportList().addressList(), addressBookImportExportList().contactGroupList(), data);
+ KContacts::LDIFConverter::addresseeAndContactGroupToLDIF(contactLists.addressList(), contactLists.contactGroupList(), data);
QTextStream stream(&file);
stream.setCodec("UTF-8");
@@ -184,3 +205,9 @@ void LDifImportExportPluginInterface::exportLdif()
file.close();
}
}
+
+
+bool LDifImportExportPluginInterface::canImportFileType(const QUrl &url)
+{
+ return url.path().endsWith(QStringLiteral(".ldif"));
+}
diff --git a/kaddressbook/importexportplugins/ldif/ldifimportexportplugininterface.h b/kaddressbook/importexportplugins/ldif/ldifimportexportplugininterface.h
index 655bf87..3457f2e 100644
--- a/kaddressbook/importexportplugins/ldif/ldifimportexportplugininterface.h
+++ b/kaddressbook/importexportplugins/ldif/ldifimportexportplugininterface.h
@@ -30,11 +30,12 @@ public:
void createAction(KActionCollection *ac) Q_DECL_OVERRIDE;
void exec() Q_DECL_OVERRIDE;
+ bool canImportFileType(const QUrl &url) Q_DECL_OVERRIDE;
private:
void slotImportLdif();
void slotExportLdif();
void import();
- void exportLdif();
+ void exportLdif();
};
#endif // LDIFIMPORTEXPORTPLUGININTERFACE_H
diff --git a/kaddressbook/importexportplugins/vcards/vcardimportexportplugininterface.cpp b/kaddressbook/importexportplugins/vcards/vcardimportexportplugininterface.cpp
index 4ef6171..d01649c 100644
--- a/kaddressbook/importexportplugins/vcards/vcardimportexportplugininterface.cpp
+++ b/kaddressbook/importexportplugins/vcards/vcardimportexportplugininterface.cpp
@@ -21,6 +21,10 @@
#include <KLocalizedString>
#include <KActionCollection>
#include <QAction>
+#include <KAddressBookImportExport/KAddressBookContactSelectionDialog>
+#include <QPointer>
+#include <KMessageBox>
+#include <QUrl>
VCardImportExportPluginInterface::VCardImportExportPluginInterface(QObject *parent)
: KAddressBookImportExport::KAddressBookImportExportPluginInterface(parent)
@@ -43,11 +47,6 @@ void VCardImportExportPluginInterface::createAction(KActionCollection *ac)
QList<QAction *> exportActionList;
- action = ac->addAction(QStringLiteral("file_import_vcard"));
- action->setText(i18n("Import vCard..."));
- action->setWhatsThis(i18n("Import contacts from a vCard file."));
- exportActionList << action;
-
action = ac->addAction(QStringLiteral("file_export_vcard40"));
action->setWhatsThis(i18n("Export contacts to a vCard 4.0 file."));
action->setText(i18n("Export vCard 4.0..."));
@@ -67,4 +66,114 @@ void VCardImportExportPluginInterface::createAction(KActionCollection *ac)
void VCardImportExportPluginInterface::exec()
{
+ switch(mImportExportAction) {
+ case Import:
+ importVCard();
+ break;
+ case Export:
+ exportVCard();
+ break;
+ }
+}
+
+void VCardImportExportPluginInterface::importVCard()
+{
+#if 0
+ KAddressBookImportExport::KAddressBookImportExportContactList contactList;
+ KContacts::Addressee::List addrList;
+ QList<QUrl> urls;
+
+ if (!option(QStringLiteral("importData")).isEmpty()) {
+ addrList = parseVCard(option(QStringLiteral("importData")).toUtf8());
+ } else {
+ if (!option(QStringLiteral("importUrl")).isEmpty()) {
+ urls.append(QUrl::fromLocalFile(option(QStringLiteral("importUrl"))));
+ } else {
+ const QString filter = i18n("*.vcf|vCard (*.vcf)\n*|all files (*)");
+ urls =
+ QFileDialog::getOpenFileUrls(parentWidget(), i18nc("@title:window", "Select vCard to Import"),
+ QUrl(),
+ filter);
+ }
+
+ if (urls.isEmpty()) {
+ return contactList;
+ }
+
+ const QString caption(i18nc("@title:window", "vCard Import Failed"));
+ bool anyFailures = false;
+
+ const int numberOfUrl(urls.count());
+ for (int i = 0; i < numberOfUrl; ++i) {
+ const QUrl url = urls.at(i);
+
+ auto job = KIO::storedGet(url);
+ KJobWidgets::setWindow(job, parentWidget());
+ if (job->exec()) {
+
+ const QByteArray data = job->data();
+ if (!data.isEmpty()) {
+ addrList += parseVCard(data);
+ }
+ } else {
+ const QString msg = xi18nc(
+ "@info",
+ "<para>Unable to access vCard:</para><para>%1</para>",
+ job->errorString());
+ KMessageBox::error(parentWidget(), msg, caption);
+ anyFailures = true;
+ }
+ }
+
+ if (!option(QStringLiteral("importUrl")).isEmpty()) { // a vcard was passed via cmd
+ if (addrList.isEmpty()) {
+ if (anyFailures && urls.count() > 1) {
+ KMessageBox::information(
+ parentWidget(),
+ i18nc("@info", "No contacts were imported, due to errors with the vCards."));
+ } else if (!anyFailures) {
+ KMessageBox::information(
+ parentWidget(),
+ i18nc("@info", "The vCard does not contain any contacts."));
+ }
+ } else {
+ QPointer<VCardViewerDialog> dlg = new VCardViewerDialog(addrList, parentWidget());
+ if (dlg->exec() && dlg) {
+ addrList = dlg->contacts();
+ } else {
+ addrList.clear();
+ }
+ delete dlg;
+ }
+ }
+ }
+ contactList.setAddressList(addrList);
+#endif
+}
+
+void VCardImportExportPluginInterface::exportVCard()
+{
+ QPointer<KAddressBookImportExport::KAddressBookContactSelectionDialog> dlg =
+ new KAddressBookImportExport::KAddressBookContactSelectionDialog(itemSelectionModel(), true, parentWidget());
+ dlg->setMessageText(i18n("Which contact do you want to export?"));
+ dlg->setDefaultAddressBook(defaultCollection());
+ if (!dlg->exec() || !dlg) {
+ delete dlg;
+ return;
+ }
+
+ const KContacts::AddresseeList contacts = dlg->selectedContacts().addressList();
+ const KAddressBookImportExport::KAddressBookExportSelectionWidget::ExportFields exportFields = dlg->exportType();
+ delete dlg;
+
+ if (contacts.isEmpty()) {
+ KMessageBox::sorry(Q_NULLPTR, i18n("You have not selected any contacts to export."));
+ return;
+ }
+}
+
+
+bool VCardImportExportPluginInterface::canImportFileType(const QUrl &url)
+{
+ return url.path().endsWith(QStringLiteral(".vcf"));
}
diff --git a/kaddressbook/importexportplugins/vcards/vcardimportexportplugininterface.h b/kaddressbook/importexportplugins/vcards/vcardimportexportplugininterface.h
index 5295251..a845fe5 100644
--- a/kaddressbook/importexportplugins/vcards/vcardimportexportplugininterface.h
+++ b/kaddressbook/importexportplugins/vcards/vcardimportexportplugininterface.h
@@ -31,6 +31,11 @@ public:
void createAction(KActionCollection *ac) Q_DECL_OVERRIDE;
void exec() Q_DECL_OVERRIDE;
+ bool canImportFileType(const QUrl &url) Q_DECL_OVERRIDE;
+private:
+ void exportVCard();
+ void importVCard();
+
};
#endif // VCARDIMPORTEXPORTPLUGININTERFACE_H
diff --git a/kmail/editorplugins/changecase/kmail_changecaseeditorplugin.json b/kmail/editorplugins/changecase/kmail_changecaseeditorplugin.json
index 62f2964..d846677 100644
--- a/kmail/editorplugins/changecase/kmail_changecaseeditorplugin.json
+++ b/kmail/editorplugins/changecase/kmail_changecaseeditorplugin.json
@@ -11,7 +11,7 @@
"Description[sv]": "Insticksprogrammet gör det möjligt att ändra skiftläge på markerad text.",
"Description[uk]": "За допомогою цього додатка можна змінювати регістр символів позначеного фрагмента тексту.",
"Description[x-test]": "xxThis plugins allows you to change selected text case.xx",
- "EnabledByDefault": "true",
+ "EnabledByDefault": "false",
"Id": "kmailchangecase",
"Name": "Change Case",
"Name[ca@valencia]": "Canvia la caixa",
@@ -42,4 +42,4 @@
"Version": "1.0"
},
"X-KDE-KMailEditor-Order": "1"
-} \ No newline at end of file
+}