summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-11 05:23:47 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-11 05:23:47 (GMT)
commitd978e647edb38a699e73de85f5a1cbd8a3f76a01 (patch)
tree5c5f87917ba9ede64d2ecd3a0ec63322cdcdfdf5
parent94b411c1c17eab3712ba6a61701596b75ac1a579 (diff)
Add import csv
-rw-r--r--kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp34
-rw-r--r--kaddressbook/importexportplugins/csv/csvimportexportplugininterface.h5
2 files changed, 36 insertions, 3 deletions
diff --git a/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp b/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp
index 893743f..ee26090 100644
--- a/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp
+++ b/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp
@@ -18,6 +18,7 @@
*/
#include "csvimportexportplugininterface.h"
+#include "../shared/importexportengine.h"
#include <KLocalizedString>
#include <KActionCollection>
#include <QAction>
@@ -29,10 +30,12 @@
#include <QTextStream>
#include <QFileDialog>
#include <QTextCodec>
+#include <QPointer>
#include <KIO/Job>
CSVImportExportPluginInterface::CSVImportExportPluginInterface(QObject *parent)
- : KAddressBookImportExport::KAddressBookImportExportPluginInterface(parent)
+ : KAddressBookImportExport::KAddressBookImportExportPluginInterface(parent),
+ mEngine(Q_NULLPTR)
{
}
@@ -63,14 +66,41 @@ void CSVImportExportPluginInterface::exec()
{
switch(mImportExportAction) {
case Import:
+ importCSV();
break;
case Export:
exportCSV();
break;
}
- //TODO
}
+void CSVImportExportPluginInterface::importCSV()
+{
+#if 0
+ KAddressBookImportExport::KAddressBookImportExportContactList contactList;
+ QPointer<CSVImportDialog> dlg = new CSVImportDialog(parentWidget());
+ if (dlg->exec() && dlg) {
+ contactList.setAddressList(dlg->contacts());
+ }
+
+ delete dlg;
+ if (!mEngine) {
+ mEngine = new ImportExportEngine(this);
+ }
+ mEngine->setContactList(contactList);
+ mEngine->setDefaultAddressBook(defaultCollection());
+ connect(mEngine, &ImportExportEngine::finished, this, &CSVImportExportPluginInterface::slotFinished);
+ mEngine->importContacts();
+#endif
+}
+
+void CSVImportExportPluginInterface::slotFinished()
+{
+ mEngine->deleteLater();
+ mEngine = Q_NULLPTR;
+}
+
+
void CSVImportExportPluginInterface::slotImportCVS()
{
mImportExportAction = Import;
diff --git a/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.h b/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.h
index 57c19d0..521e9ff 100644
--- a/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.h
+++ b/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.h
@@ -23,7 +23,7 @@
#include <KAddressBookImportExport/KAddressBookImportExportPluginInterface>
#include <KContacts/Addressee>
class QFile;
-
+class ImportExportEngine;
class CSVImportExportPluginInterface : public KAddressBookImportExport::KAddressBookImportExportPluginInterface
{
Q_OBJECT
@@ -34,10 +34,13 @@ public:
void createAction(KActionCollection *ac) Q_DECL_OVERRIDE;
void exec() Q_DECL_OVERRIDE;
private:
+ void slotFinished();
void exportCSV();
void slotImportCVS();
void slotExportCVS();
void exportToFile(QFile *file, const KContacts::Addressee::List &contacts) const;
+ void importCSV();
+ ImportExportEngine *mEngine;
};
#endif // CSVIMPORTEXPORTPLUGININTERFACE_H