Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KDE PIM Add-ons
Commits
1bad745a
Commit
1bad745a
authored
Aug 05, 2020
by
Laurent Montel
😁
Browse files
Continue to implement it
CCBUG: 424940
parent
a4a17c34
Pipeline
#29699
failed with stage
in 8 minutes and 3 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
kaddressbook/importexportplugins/windows-contacts/autotests/CMakeLists.txt
View file @
1bad745a
...
...
@@ -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"
)
kaddressbook/importexportplugins/windows-contacts/importwindowcontact.cpp
View file @
1bad745a
...
...
@@ -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
()
<<
" ta
h
g "
<<
tag
;
qDebug
()
<<
" tag "
<<
tag
;
}
}
}
return
lst
;
}
bool
ImportWindowContact
::
loadDomElement
(
QDomDocument
&
doc
,
QFile
*
file
)
...
...
kaddressbook/importexportplugins/windows-contacts/importwindowcontact.h
View file @
1bad745a
...
...
@@ -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:
...
...
kaddressbook/importexportplugins/windows-contacts/windowscontactimportexportplugininterface.cpp
View file @
1bad745a
...
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment