Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
PIM
PIM Messagelib
Commits
acc14b82
Commit
acc14b82
authored
May 22, 2017
by
Sandro Knauß
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor HTMLBlocks so they can be used without HtmlWriter
parent
a675d7f5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
22 deletions
+66
-22
messageviewer/src/messagepartthemes/default/htmlblock.cpp
messageviewer/src/messagepartthemes/default/htmlblock.cpp
+51
-19
messageviewer/src/messagepartthemes/default/htmlblock.h
messageviewer/src/messagepartthemes/default/htmlblock.h
+15
-3
No files found.
messageviewer/src/messagepartthemes/default/htmlblock.cpp
View file @
acc14b82
...
...
@@ -28,6 +28,11 @@
using
namespace
MimeTreeParser
;
HTMLBlock
::
HTMLBlock
()
:
entered
(
false
)
{
}
HTMLBlock
::~
HTMLBlock
()
{
}
...
...
@@ -37,6 +42,24 @@ QString HTMLBlock::dir() const
return
QApplication
::
isRightToLeft
()
?
QStringLiteral
(
"rtl"
)
:
QStringLiteral
(
"ltr"
);
}
QString
HTMLBlock
::
enter
()
{
if
(
!
entered
)
{
entered
=
true
;
return
enterString
();
}
return
QString
();
}
QString
HTMLBlock
::
exit
()
{
if
(
entered
)
{
entered
=
false
;
return
exitString
();
}
return
QString
();
}
AttachmentMarkBlock
::
AttachmentMarkBlock
(
MimeTreeParser
::
HtmlWriter
*
writer
,
KMime
::
Content
*
node
)
:
mNode
(
node
)
,
mWriter
(
writer
)
...
...
@@ -51,22 +74,28 @@ AttachmentMarkBlock::~AttachmentMarkBlock()
void
AttachmentMarkBlock
::
internalEnter
()
{
if
(
mWriter
&&
!
entered
)
{
const
QString
index
=
mNode
->
index
().
toString
();
mWriter
->
queue
(
QStringLiteral
(
"<a name=
\"
att%1
\"
></a>"
).
arg
(
index
));
mWriter
->
queue
(
QStringLiteral
(
"<div id=
\"
attachmentDiv%1
\"
>
\n
"
).
arg
(
index
));
entered
=
true
;
if
(
mWriter
)
{
mWriter
->
queue
(
enter
());
}
}
void
AttachmentMarkBlock
::
internalExit
()
{
if
(
!
en
ter
ed
)
{
return
;
if
(
mWri
ter
)
{
mWriter
->
queue
(
exit
())
;
}
}
QString
AttachmentMarkBlock
::
enterString
()
const
{
const
QString
index
=
mNode
->
index
().
toString
();
return
QStringLiteral
(
"<a name=
\"
att%1
\"
></a>"
).
arg
(
index
)
+
QStringLiteral
(
"<div id=
\"
attachmentDiv%1
\"
>
\n
"
).
arg
(
index
);
}
mWriter
->
queue
(
QStringLiteral
(
"</div>"
));
entered
=
false
;
QString
AttachmentMarkBlock
::
exitString
()
const
{
return
QStringLiteral
(
"</div>"
);
}
RootBlock
::
RootBlock
(
HtmlWriter
*
writer
)
...
...
@@ -83,21 +112,24 @@ RootBlock::~RootBlock()
void
RootBlock
::
internalEnter
()
{
if
(
!
mWriter
||
entered
)
{
return
;
if
(
mWriter
)
{
mWriter
->
queue
(
enter
())
;
}
entered
=
true
;
mWriter
->
queue
(
QStringLiteral
(
"<div style=
\"
position: relative; word-wrap: break-word
\"
>
\n
"
));
}
void
RootBlock
::
internalExit
()
{
if
(
!
en
ter
ed
)
{
return
;
if
(
mWri
ter
)
{
mWriter
->
queue
(
exit
())
;
}
}
entered
=
false
;
QString
RootBlock
::
enterString
()
const
{
return
QStringLiteral
(
"<div style=
\"
position: relative; word-wrap: break-word
\"
>
\n
"
);
}
mWriter
->
queue
(
QStringLiteral
(
"</div>
\n
"
));
}
\ No newline at end of file
QString
RootBlock
::
exitString
()
const
{
return
QStringLiteral
(
"</div>
\n
"
);
}
messageviewer/src/messagepartthemes/default/htmlblock.h
View file @
acc14b82
...
...
@@ -38,14 +38,18 @@ class HTMLBlock
public:
typedef
QSharedPointer
<
HTMLBlock
>
Ptr
;
HTMLBlock
()
:
entered
(
false
)
{
}
HTMLBlock
();
virtual
~
HTMLBlock
();
QString
enter
();
QString
exit
();
protected:
QString
dir
()
const
;
virtual
QString
enterString
()
const
=
0
;
virtual
QString
exitString
()
const
=
0
;
private:
bool
entered
;
};
...
...
@@ -58,6 +62,10 @@ public:
AttachmentMarkBlock
(
MimeTreeParser
::
HtmlWriter
*
writer
,
KMime
::
Content
*
node
);
virtual
~
AttachmentMarkBlock
();
protected:
QString
enterString
()
const
Q_DECL_OVERRIDE
;
QString
exitString
()
const
Q_DECL_OVERRIDE
;
private:
void
internalEnter
();
void
internalExit
();
...
...
@@ -75,6 +83,10 @@ public:
RootBlock
(
MimeTreeParser
::
HtmlWriter
*
writer
);
virtual
~
RootBlock
();
protected:
QString
enterString
()
const
Q_DECL_OVERRIDE
;
QString
exitString
()
const
Q_DECL_OVERRIDE
;
private:
void
internalEnter
();
void
internalExit
();
...
...
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