Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
PIM Data Exporter
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PIM
PIM Data Exporter
Commits
77d4f7f8
Commit
77d4f7f8
authored
Jun 22, 2017
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port to QXMlStreamReader
parent
a1eba222
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
87 deletions
+79
-87
console/pimsettingexporterconsole.cpp
console/pimsettingexporterconsole.cpp
+2
-2
core/xml/templateselection.cpp
core/xml/templateselection.cpp
+70
-78
core/xml/templateselection.h
core/xml/templateselection.h
+5
-5
gui/widgets/selectiontypetreewidget.cpp
gui/widgets/selectiontypetreewidget.cpp
+2
-2
No files found.
console/pimsettingexporterconsole.cpp
View file @
77d4f7f8
...
...
@@ -147,8 +147,8 @@ void PimSettingExporterConsole::start()
{
//Load template if necessary
if
(
!
mTemplateFileName
.
isEmpty
())
{
TemplateSelection
selection
(
mTemplateFileName
)
;
const
QHash
<
Utils
::
AppsType
,
Utils
::
importExportParameters
>
templateElements
=
selection
.
loadTemplate
();
TemplateSelection
selection
;
const
QHash
<
Utils
::
AppsType
,
Utils
::
importExportParameters
>
templateElements
=
selection
.
loadTemplate
(
mTemplateFileName
);
mPimSettingsBackupRestore
->
setStoredParameters
(
templateElements
);
}
switch
(
mMode
)
{
...
...
core/xml/templateselection.cpp
View file @
77d4f7f8
...
...
@@ -22,105 +22,97 @@
#include <QFile>
#include <QXmlStreamWriter>
TemplateSelection
::
TemplateSelection
(
const
QString
&
path
)
:
mStreamWriter
(
nullptr
)
TemplateSelection
::
TemplateSelection
()
:
mStreamWriter
(
nullptr
),
mStreamReader
(
nullptr
)
{
if
(
!
path
.
isEmpty
())
{
QDomDocument
doc
;
QString
errorMsg
;
int
errorRow
;
int
errorCol
;
QFile
file
(
path
);
if
(
file
.
open
(
QIODevice
::
ReadOnly
))
{
if
(
!
doc
.
setContent
(
&
file
,
&
errorMsg
,
&
errorRow
,
&
errorCol
))
{
qCDebug
(
PIMSETTINGEXPORTERCORE_LOG
)
<<
"Unable to load document.Parse error in line "
<<
errorRow
<<
", col "
<<
errorCol
<<
": "
<<
errorMsg
;
}
else
{
mDocument
=
doc
;
}
}
else
{
qCDebug
(
PIMSETTINGEXPORTERCORE_LOG
)
<<
"Unable to load file:"
<<
path
;
}
}
}
TemplateSelection
::~
TemplateSelection
()
{
delete
mStreamWriter
;
delete
mStreamReader
;
}
Utils
::
StoredTypes
TemplateSelection
::
loadStoredTypes
(
const
QDomElement
&
element
,
int
&
numberOfStep
)
Utils
::
StoredTypes
TemplateSelection
::
loadStoredTypes
(
int
&
numberOfStep
)
{
Utils
::
StoredTypes
types
=
Utils
::
None
;
QDomNode
n
=
element
.
firstChild
();
while
(
!
n
.
isNull
())
{
QDomElement
e
=
n
.
toElement
();
if
(
!
e
.
isNull
())
{
const
QString
tagName
(
e
.
tagName
());
if
(
tagName
==
QLatin1String
(
"mailtransport"
))
{
types
|=
Utils
::
MailTransport
;
numberOfStep
++
;
}
else
if
(
tagName
==
QLatin1String
(
"mail"
))
{
types
|=
Utils
::
Mails
;
numberOfStep
++
;
}
else
if
(
tagName
==
QLatin1String
(
"resources"
))
{
types
|=
Utils
::
Resources
;
numberOfStep
++
;
}
else
if
(
tagName
==
QLatin1String
(
"identity"
))
{
types
|=
Utils
::
Identity
;
numberOfStep
++
;
}
else
if
(
tagName
==
QLatin1String
(
"config"
))
{
types
|=
Utils
::
Config
;
numberOfStep
++
;
}
else
if
(
tagName
==
QLatin1String
(
"data"
))
{
types
|=
Utils
::
Data
;
numberOfStep
++
;
}
while
(
mStreamReader
->
readNextStartElement
())
{
if
(
mStreamReader
->
name
()
==
QLatin1String
(
"mailtransport"
))
{
types
|=
Utils
::
MailTransport
;
numberOfStep
++
;
}
else
if
(
mStreamReader
->
name
()
==
QLatin1String
(
"mail"
))
{
types
|=
Utils
::
Mails
;
numberOfStep
++
;
}
else
if
(
mStreamReader
->
name
()
==
QLatin1String
(
"resources"
))
{
types
|=
Utils
::
Resources
;
numberOfStep
++
;
}
else
if
(
mStreamReader
->
name
()
==
QLatin1String
(
"identity"
))
{
types
|=
Utils
::
Identity
;
numberOfStep
++
;
}
else
if
(
mStreamReader
->
name
()
==
QLatin1String
(
"config"
))
{
types
|=
Utils
::
Config
;
numberOfStep
++
;
}
else
if
(
mStreamReader
->
name
()
==
QLatin1String
(
"data"
))
{
types
|=
Utils
::
Data
;
numberOfStep
++
;
}
n
=
n
.
nextSibling
();
mStreamReader
->
skipCurrentElement
();
}
return
types
;
}
QHash
<
Utils
::
AppsType
,
Utils
::
importExportParameters
>
TemplateSelection
::
loadTemplate
()
QHash
<
Utils
::
AppsType
,
Utils
::
importExportParameters
>
TemplateSelection
::
loadTemplate
(
const
QString
&
path
)
{
if
(
path
.
isEmpty
())
{
return
{};
}
QFile
file
(
path
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
qCDebug
(
PIMSETTINGEXPORTERCORE_LOG
)
<<
"Unable to load file:"
<<
path
;
return
{};
}
else
{
mStreamReader
=
new
QXmlStreamReader
(
&
file
);
}
QHash
<
Utils
::
AppsType
,
Utils
::
importExportParameters
>
value
;
QDomElement
docElem
=
mDocument
.
documentElement
();
QDomNode
n
=
docElem
.
firstChild
();
while
(
!
n
.
isNull
())
{
QDomElement
e
=
n
.
toElement
();
if
(
!
e
.
isNull
())
{
const
QString
tagName
(
e
.
tagName
());
//qCDebug(PIMSETTINGEXPORTERCORE_LOG) << "tag :" << tagName;
Utils
::
AppsType
type
=
Utils
::
Unknown
;
if
(
tagName
==
QLatin1String
(
"kmail"
))
{
type
=
Utils
::
KMail
;
}
else
if
(
tagName
==
QLatin1String
(
"kaddressbook"
))
{
type
=
Utils
::
KAddressBook
;
}
else
if
(
tagName
==
QLatin1String
(
"kalarm"
))
{
type
=
Utils
::
KAlarm
;
}
else
if
(
tagName
==
QLatin1String
(
"korganizer"
))
{
type
=
Utils
::
KOrganizer
;
}
else
if
(
tagName
==
QLatin1String
(
"knotes"
))
{
type
=
Utils
::
KNotes
;
}
else
if
(
tagName
==
QLatin1String
(
"akregator"
))
{
type
=
Utils
::
Akregator
;
}
else
if
(
tagName
==
QLatin1String
(
"blogilo"
))
{
type
=
Utils
::
Blogilo
;
}
if
(
type
!=
Utils
::
Unknown
)
{
int
numberOfSteps
=
0
;
Utils
::
StoredTypes
storedType
=
loadStoredTypes
(
e
,
numberOfSteps
);
if
(
storedType
!=
Utils
::
None
)
{
Utils
::
importExportParameters
utils
;
utils
.
types
=
storedType
;
utils
.
numberSteps
=
numberOfSteps
;
value
.
insert
(
type
,
utils
);
if
(
mStreamReader
->
readNextStartElement
())
{
if
(
mStreamReader
->
name
()
==
QLatin1String
(
"pimsettingexporter"
))
{
while
(
mStreamReader
->
readNextStartElement
())
{
Utils
::
AppsType
type
=
Utils
::
Unknown
;
if
(
mStreamReader
->
name
()
==
QLatin1String
(
"kmail"
))
{
type
=
Utils
::
KMail
;
}
else
if
(
mStreamReader
->
name
()
==
QLatin1String
(
"kaddressbook"
))
{
type
=
Utils
::
KAddressBook
;
}
else
if
(
mStreamReader
->
name
()
==
QLatin1String
(
"kalarm"
))
{
type
=
Utils
::
KAlarm
;
}
else
if
(
mStreamReader
->
name
()
==
QLatin1String
(
"korganizer"
))
{
type
=
Utils
::
KOrganizer
;
}
else
if
(
mStreamReader
->
name
()
==
QLatin1String
(
"knotes"
))
{
type
=
Utils
::
KNotes
;
}
else
if
(
mStreamReader
->
name
()
==
QLatin1String
(
"akregator"
))
{
type
=
Utils
::
Akregator
;
}
else
if
(
mStreamReader
->
name
()
==
QLatin1String
(
"blogilo"
))
{
type
=
Utils
::
Blogilo
;
}
if
(
type
!=
Utils
::
Unknown
)
{
int
numberOfSteps
=
0
;
Utils
::
StoredTypes
storedType
=
loadStoredTypes
(
numberOfSteps
);
if
(
storedType
!=
Utils
::
None
)
{
Utils
::
importExportParameters
utils
;
utils
.
types
=
storedType
;
utils
.
numberSteps
=
numberOfSteps
;
value
.
insert
(
type
,
utils
);
}
}
}
}
else
{
qCDebug
(
PIMSETTINGEXPORTERCORE_LOG
)
<<
"Toplevel xml is not correct"
;
}
n
=
n
.
nextSibling
();
}
else
{
qCDebug
(
PIMSETTINGEXPORTERCORE_LOG
)
<<
"Impossible to parse file"
;
}
return
value
;
}
...
...
core/xml/templateselection.h
View file @
77d4f7f8
...
...
@@ -22,26 +22,26 @@
#include "pimsettingexporter_export.h"
#include <QHash>
#include <QDomDocument>
#include "utils.h"
class
QXmlStreamWriter
;
class
QXmlStreamReader
;
class
PIMSETTINGEXPORTER_EXPORT
TemplateSelection
{
public:
TemplateSelection
(
const
QString
&
path
=
QString
()
);
TemplateSelection
();
~
TemplateSelection
();
void
createTemplate
(
const
QHash
<
Utils
::
AppsType
,
Utils
::
importExportParameters
>
&
stored
);
QHash
<
Utils
::
AppsType
,
Utils
::
importExportParameters
>
loadTemplate
();
QHash
<
Utils
::
AppsType
,
Utils
::
importExportParameters
>
loadTemplate
(
const
QString
&
path
);
QString
saveTemplate
()
const
;
private:
static
Utils
::
StoredTypes
loadStoredTypes
(
const
QDomElement
&
element
,
int
&
numberOfStep
);
Utils
::
StoredTypes
loadStoredTypes
(
int
&
numberOfStep
);
void
saveParameters
(
Utils
::
StoredTypes
type
);
QDomDocument
mDocument
;
QXmlStreamWriter
*
mStreamWriter
;
QXmlStreamReader
*
mStreamReader
;
QString
mSaveTemplate
;
};
...
...
gui/widgets/selectiontypetreewidget.cpp
View file @
77d4f7f8
...
...
@@ -308,8 +308,8 @@ void SelectionTypeTreeWidget::slotItemChanged(QTreeWidgetItem *item, int column)
void
SelectionTypeTreeWidget
::
loadFileName
(
const
QString
&
fileName
)
{
unSelectAllItems
();
TemplateSelection
templateSelection
(
fileName
)
;
const
QHash
<
Utils
::
AppsType
,
Utils
::
importExportParameters
>
params
=
templateSelection
.
loadTemplate
();
TemplateSelection
templateSelection
;
const
QHash
<
Utils
::
AppsType
,
Utils
::
importExportParameters
>
params
=
templateSelection
.
loadTemplate
(
fileName
);
setParameters
(
params
);
}
...
...
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