summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-11 07:02:42 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-11 07:02:42 (GMT)
commited65673984db1c9f08377f5c7998cf4141a9a955 (patch)
tree0e439d438ce9d69a9ff7e038dd474c6c29d6ff4d
parent6eeb71266d02028119b66296f96ae2ddb6ea6dd4 (diff)
Port to new api
-rw-r--r--kaddressbook/importexportplugins/csv/CMakeLists.txt4
-rw-r--r--kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp3
-rw-r--r--kaddressbook/importexportplugins/csv/import/csvimportdialog.cpp36
-rw-r--r--kaddressbook/importexportplugins/csv/import/csvimportdialog.h4
4 files changed, 24 insertions, 23 deletions
diff --git a/kaddressbook/importexportplugins/csv/CMakeLists.txt b/kaddressbook/importexportplugins/csv/CMakeLists.txt
index e1f11e7..10ad871 100644
--- a/kaddressbook/importexportplugins/csv/CMakeLists.txt
+++ b/kaddressbook/importexportplugins/csv/CMakeLists.txt
@@ -1,7 +1,7 @@
set(kaddressbook_importexport_csv_SRCS
csvimportexportplugin.cpp
csvimportexportplugininterface.cpp
- #import/csvimportdialog.cpp
+ import/csvimportdialog.cpp
import/dateparser.cpp
import/qcsvmodel.cpp
import/qcsvreader.cpp
@@ -18,5 +18,7 @@ target_link_libraries(kaddressbook_importexportcsvplugin KF5::KaddressbookImport
KF5::XmlGui
KF5::Contacts
KF5::JobWidgets
+ KF5::Completion
+ KF5::KIOWidgets
kaddressbookimportexportlibprivate
)
diff --git a/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp b/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp
index ee26090..1c8a7cb 100644
--- a/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp
+++ b/kaddressbook/importexportplugins/csv/csvimportexportplugininterface.cpp
@@ -19,6 +19,7 @@
#include "csvimportexportplugininterface.h"
#include "../shared/importexportengine.h"
+#include "import/csvimportdialog.h"
#include <KLocalizedString>
#include <KActionCollection>
#include <QAction>
@@ -76,7 +77,6 @@ void CSVImportExportPluginInterface::exec()
void CSVImportExportPluginInterface::importCSV()
{
-#if 0
KAddressBookImportExport::KAddressBookImportExportContactList contactList;
QPointer<CSVImportDialog> dlg = new CSVImportDialog(parentWidget());
if (dlg->exec() && dlg) {
@@ -91,7 +91,6 @@ void CSVImportExportPluginInterface::importCSV()
mEngine->setDefaultAddressBook(defaultCollection());
connect(mEngine, &ImportExportEngine::finished, this, &CSVImportExportPluginInterface::slotFinished);
mEngine->importContacts();
-#endif
}
void CSVImportExportPluginInterface::slotFinished()
diff --git a/kaddressbook/importexportplugins/csv/import/csvimportdialog.cpp b/kaddressbook/importexportplugins/csv/import/csvimportdialog.cpp
index 3ad90dd..dbe8d1e 100644
--- a/kaddressbook/importexportplugins/csv/import/csvimportdialog.cpp
+++ b/kaddressbook/importexportplugins/csv/import/csvimportdialog.cpp
@@ -71,9 +71,9 @@ public:
{
fillFieldMap();
- addItem(ContactFields::label(ContactFields::Undefined), ContactFields::Undefined);
+ addItem(KAddressBookImportExport::KAddressBookImportExportContactFields::label(KAddressBookImportExport::KAddressBookImportExportContactFields::Undefined), KAddressBookImportExport::KAddressBookImportExportContactFields::Undefined);
- QMapIterator<QString, ContactFields::Field> it(mFieldMap);
+ QMapIterator<QString, KAddressBookImportExport::KAddressBookImportExportContactFields::Field> it(mFieldMap);
while (it.hasNext()) {
it.next();
@@ -90,14 +90,14 @@ public:
setFixedSize(sizeHint());
}
- void setCurrentField(ContactFields::Field field)
+ void setCurrentField(KAddressBookImportExport::KAddressBookImportExportContactFields::Field field)
{
setCurrentIndex(findData((uint)field));
}
- ContactFields::Field currentField() const
+ KAddressBookImportExport::KAddressBookImportExportContactFields::Field currentField() const
{
- return (ContactFields::Field)itemData(currentIndex()).toUInt();
+ return (KAddressBookImportExport::KAddressBookImportExportContactFields::Field)itemData(currentIndex()).toUInt();
}
private:
@@ -107,18 +107,18 @@ private:
return;
}
- ContactFields::Fields fields = ContactFields::allFields();
- fields.remove(ContactFields::Undefined);
+ KAddressBookImportExport::KAddressBookImportExportContactFields::Fields fields = KAddressBookImportExport::KAddressBookImportExportContactFields::allFields();
+ fields.remove(KAddressBookImportExport::KAddressBookImportExportContactFields::Undefined);
for (int i = 0; i < fields.count(); ++i) {
- mFieldMap.insert(ContactFields::label(fields.at(i)), fields.at(i));
+ mFieldMap.insert(KAddressBookImportExport::KAddressBookImportExportContactFields::label(fields.at(i)), fields.at(i));
}
}
- static QMap<QString, ContactFields::Field> mFieldMap;
+ static QMap<QString, KAddressBookImportExport::KAddressBookImportExportContactFields::Field> mFieldMap;
};
-QMap<QString, ContactFields::Field> ContactFieldComboBox::mFieldMap;
+QMap<QString, KAddressBookImportExport::KAddressBookImportExportContactFields::Field> ContactFieldComboBox::mFieldMap;
class ContactFieldDelegate : public QStyledItemDelegate
{
@@ -130,7 +130,7 @@ public:
QString displayText(const QVariant &value, const QLocale &) const Q_DECL_OVERRIDE
{
- return ContactFields::label((ContactFields::Field)value.toUInt());
+ return KAddressBookImportExport::KAddressBookImportExportContactFields::label((KAddressBookImportExport::KAddressBookImportExportContactFields::Field)value.toUInt());
}
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
@@ -146,7 +146,7 @@ public:
const unsigned int value = index.model()->data(index, Qt::EditRole).toUInt();
ContactFieldComboBox *fieldCombo = static_cast<ContactFieldComboBox *>(editor);
- fieldCombo->setCurrentField((ContactFields::Field)value);
+ fieldCombo->setCurrentField((KAddressBookImportExport::KAddressBookImportExportContactFields::Field)value);
}
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const Q_DECL_OVERRIDE
@@ -233,17 +233,17 @@ KContacts::AddresseeList CSVImportDialog::contacts() const
if (!value.isEmpty()) {
emptyRow = false;
- const ContactFields::Field field =
- (ContactFields::Field)mModel->data(mModel->index(0, column)).toUInt();
+ const KAddressBookImportExport::KAddressBookImportExportContactFields::Field field =
+ (KAddressBookImportExport::KAddressBookImportExportContactFields::Field)mModel->data(mModel->index(0, column)).toUInt();
// convert the custom date format to ISO format
- if (field == ContactFields::Birthday || field == ContactFields::Anniversary) {
+ if (field == KAddressBookImportExport::KAddressBookImportExportContactFields::Birthday || field == KAddressBookImportExport::KAddressBookImportExportContactFields::Anniversary) {
value = dateParser.parse(value).toString(Qt::ISODate);
}
value.replace(QLatin1String("\\n"), QStringLiteral("\n"));
- ContactFields::setValue(field, value, contact);
+ KAddressBookImportExport::KAddressBookImportExportContactFields::setValue(field, value, contact);
}
}
@@ -563,7 +563,7 @@ void CSVImportDialog::skipFirstRowChanged(bool checked, bool reload)
mFieldSelection.clear();
for (int column = 0; column < mModel->columnCount(); ++column) {
mFieldSelection.append(
- (ContactFields::Field)mModel->data(mModel->index(0, column)).toInt());
+ (KAddressBookImportExport::KAddressBookImportExportContactFields::Field)mModel->data(mModel->index(0, column)).toInt());
}
if (checked) {
@@ -593,7 +593,7 @@ void CSVImportDialog::slotOk()
for (int column = 0; column < mModel->columnCount(); ++column) {
if (mModel->data(mModel->index(0, column),
- Qt::DisplayRole).toUInt() != ContactFields::Undefined) {
+ Qt::DisplayRole).toUInt() != KAddressBookImportExport::KAddressBookImportExportContactFields::Undefined) {
assigned = true;
break;
}
diff --git a/kaddressbook/importexportplugins/csv/import/csvimportdialog.h b/kaddressbook/importexportplugins/csv/import/csvimportdialog.h
index b1e1cf5..8536e7d 100644
--- a/kaddressbook/importexportplugins/csv/import/csvimportdialog.h
+++ b/kaddressbook/importexportplugins/csv/import/csvimportdialog.h
@@ -20,7 +20,7 @@
#ifndef CSVIMPORTDIALOG_H
#define CSVIMPORTDIALOG_H
-#include "contactfields.h"
+#include <kaddressbookimportexport/kaddressbookimportexportcontactfields.h>
#include <KContacts/Addressee>
@@ -89,7 +89,7 @@ private:
QString mDelimiter;
QMap<QString, uint> mTypeMap;
QIODevice *mDevice;
- ContactFields::Fields mFieldSelection;
+ KAddressBookImportExport::KAddressBookImportExportContactFields::Fields mFieldSelection;
QPushButton *mUser1Button;
QPushButton *mUser2Button;
QPushButton *mOkButton;