Commit 5a732c1e authored by Laurent Montel's avatar Laurent Montel 😁

Use directly diffhighlighter

parent 9c6c7344
......@@ -76,3 +76,8 @@ void DiffHighlighter::applyFormat(int offset, int length, const KSyntaxHighlight
mOutputDiff += QStringLiteral("</span>");
}
}
QString DiffHighlighter::outputDiff() const
{
return mOutputDiff;
}
......@@ -32,6 +32,8 @@ public:
void highlightDiff(const QString &str);
QString outputDiff() const;
protected:
void applyFormat(int offset, int length, const KSyntaxHighlighting::Format &format) Q_DECL_OVERRIDE;
private:
......
......@@ -29,6 +29,12 @@
your version.
*/
#define USING_DIFF_HIGHLIGHTER 1
#ifdef USING_DIFF_HIGHLIGHTER
#include "diffhighlighter.h"
#endif
#include <MessageViewer/BodyPartURLHandler>
#include <MimeTreeParser/BodyPartFormatter>
#include <MimeTreeParser/BodyPart>
......@@ -36,6 +42,7 @@
#include <kstringhandler.h>
namespace {
// TODO: Show filename header to make it possible to save the patch.
// FIXME: The box should only be as wide as necessary.
......@@ -58,6 +65,20 @@ public:
return AsIcon;
}
static const QLatin1String tableStyle(
"style=\""
"text-align: left; "
"border: solid black 1px; "
"padding: 0.5em; "
"margin: 0em;\"");
#ifdef USING_DIFF_HIGHLIGHTER
DiffHighlighter highLighter;
highLighter.highlightDiff(diff);
QString html = QStringLiteral("<br><div align=\"center\">");
html += QLatin1String("<pre ") + tableStyle + QLatin1Char('>');
html += highLighter.outputDiff();
html += QLatin1String("</pre></div>");
#else
static const QLatin1String addedLineStyle("style=\"" "color: green;\"");
static const QLatin1String fileAddStyle("style=\"font-weight: bold; " "color: green; \"");
......@@ -65,12 +86,6 @@ public:
static const QLatin1String fileRemoveStyle("style=\"font-weight: bold; "
"color: red ;\"");
static const QLatin1String tableStyle(
"style=\""
"text-align: left; "
"border: solid black 1px; "
"padding: 0.5em; "
"margin: 0em;\"");
static const QLatin1String sepStyle("style=\"color: black; font-weight: bold;\"");
static const QLatin1String chunkStyle("style=\"color: blue;\"");
......@@ -101,7 +116,8 @@ public:
html += QLatin1String("<span ") + style + QLatin1Char('>') + line + QLatin1String("</span><br/>");
}
html += QLatin1String("</pre></div>");
html += QLatin1String("</pre></div>");
#endif
writer->queue(html);
return Ok;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment