Commit 1bad745a authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Continue to implement it

CCBUG: 424940
parent a4a17c34
Pipeline #29699 failed with stage
in 8 minutes and 3 seconds
......@@ -10,7 +10,7 @@ macro(add_windowscontact_unittest _source _additional)
add_test(NAME ${_name} COMMAND ${_name} )
ecm_mark_as_test(${_name})
target_link_libraries( ${_name} Qt5::Widgets Qt5::Test KF5::I18n KF5::WidgetsAddons Qt5::Xml)
target_link_libraries( ${_name} Qt5::Widgets Qt5::Test KF5::I18n KF5::WidgetsAddons Qt5::Xml KF5::Contacts)
endmacro ()
add_windowscontact_unittest(importwindowcontacttest.cpp "../importwindowcontact.cpp")
......@@ -34,13 +34,14 @@ ImportWindowContact::~ImportWindowContact()
}
void ImportWindowContact::importFile(const QString &fileName)
KContacts::Addressee::List ImportWindowContact::importFile(const QString &fileName)
{
KContacts::Addressee::List lst;
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly)) {
const QString msg = i18n("<qt>Unable to open <b>%1</b> for reading.</qt>", fileName);
KMessageBox::error(mParentWidget, msg);
return;
return lst;
}
QDomDocument doc;
if (loadDomElement(doc, &file)) {
......@@ -50,11 +51,11 @@ void ImportWindowContact::importFile(const QString &fileName)
} else {
for (QDomElement e = list.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {
const QString tag = e.tagName();
qDebug() << " tahg " << tag;
qDebug() << " tag " << tag;
}
}
}
return lst;
}
bool ImportWindowContact::loadDomElement(QDomDocument &doc, QFile *file)
......
......@@ -21,6 +21,7 @@
#define IMPORTCONTACTEXPORT_H
#include <QString>
#include <KContacts/Addressee>
class QDomDocument;
class QFile;
class QWidget;
......@@ -30,7 +31,7 @@ public:
ImportWindowContact();
~ImportWindowContact();
void importFile(const QString &fileName);
Q_REQUIRED_RESULT KContacts::Addressee::List importFile(const QString &fileName);
void setParentWidget(QWidget *parentWidget);
private:
......
......@@ -90,7 +90,6 @@ void WindowsContactImportExportPluginInterface::exec()
void WindowsContactImportExportPluginInterface::importWindowsContact()
{
KAddressBookImportExport::KAddressBookImportExportContactList contactList;
const QString fileName
= QFileDialog::getOpenFileName(parentWidget(), QString(), QDir::homePath(), i18n("Windows Contact file (*.contact)"));
......@@ -98,9 +97,18 @@ void WindowsContactImportExportPluginInterface::importWindowsContact()
return;
}
KContacts::Addressee::List addresseeList;
ImportWindowContact importer;
importer.setParentWidget(parentWidget());
importer.importFile(fileName);
addresseeList = importer.importFile(fileName);
KAddressBookImportExport::KAddressBookImportExportContactList contactList;
contactList.setAddressList(addresseeList);
ImportExportEngine *engine = new ImportExportEngine(this);
engine->setContactList(contactList);
engine->setDefaultAddressBook(defaultCollection());
engine->importContacts();
}
void WindowsContactImportExportPluginInterface::exportWindowsContact()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment