Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
PIM Messagelib
Commits
e2658eef
Commit
e2658eef
authored
Mar 30, 2020
by
Laurent Montel
Browse files
Extract code for allowing to autotest code
parent
ffc72526
Changes
3
Hide whitespace changes
Inline
Side-by-side
messageviewer/src/htmlwriter/webengineparthtmlwriter.cpp
View file @
e2658eef
...
...
@@ -20,7 +20,7 @@
#include
"messageviewer_debug.h"
#include
"viewer/webengine/mailwebengineview.h"
#include
"messageviewer/messageviewerutil.h"
#include
<QUrl>
#include
<cassert>
...
...
@@ -72,15 +72,8 @@ void WebEnginePartHtmlWriter::end()
mTempFile
=
new
QTemporaryFile
(
QDir
::
tempPath
()
+
QLatin1String
(
"/messageviewer_XXXXXX"
)
+
QLatin1String
(
".html"
));
mTempFile
->
open
();
QTextStream
stream
(
mTempFile
);
//TODO we need to change codec when mail use different codec.
QByteArray
codecValue
=
codec
();
if
(
codecValue
.
isEmpty
())
{
codecValue
=
QByteArray
(
"UTF-8"
);
}
//qDebug() << " codecValue ******************************************: " << codecValue;
if
(
data
().
contains
(
"<meta charset=
\"
utf-8
\"
>"
))
{
codecValue
=
QByteArray
(
"UTF-8"
);
}
const
QByteArray
codecValue
=
Util
::
htmlCodec
(
data
(),
codec
());
stream
.
setCodec
(
codecValue
.
constData
());
stream
<<
data
();
...
...
messageviewer/src/utils/messageviewerutil.cpp
View file @
e2658eef
...
...
@@ -735,3 +735,17 @@ QString Util::processHtml(const QString &htmlSource, QString &extraHead)
s
=
textBeforeDoctype
+
s
;
return
s
;
}
QByteArray
Util
::
htmlCodec
(
const
QByteArray
&
data
,
const
QByteArray
&
codec
)
{
QByteArray
currentCodec
=
codec
;
if
(
currentCodec
.
isEmpty
())
{
currentCodec
=
QByteArray
(
"UTF-8"
);
}
//qDebug() << " codecValue ******************************************: " << codecValue;
if
(
data
.
contains
(
"<meta charset=
\"
utf-8
\"
>"
))
{
currentCodec
=
QByteArray
(
"UTF-8"
);
}
return
currentCodec
;
}
messageviewer/src/utils/messageviewerutil.h
View file @
e2658eef
...
...
@@ -73,6 +73,7 @@ Q_REQUIRED_RESULT MESSAGEVIEWER_EXPORT bool excludeExtraHeader(const QString &s)
MESSAGEVIEWER_EXPORT
const
QTextCodec
*
codecForName
(
const
QByteArray
&
_str
);
Q_REQUIRED_RESULT
MESSAGEVIEWER_EXPORT
QString
processHtml
(
const
QString
&
htmlSource
,
QString
&
extraHead
);
Q_REQUIRED_RESULT
MESSAGEVIEWER_EXPORT
QByteArray
htmlCodec
(
const
QByteArray
&
data
,
const
QByteArray
&
currentCodec
);
}
}
Q_DECLARE_METATYPE
(
KService
::
Ptr
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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