summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2016-05-23 06:48:20 +0200
committerMontel Laurent <[email protected]>2016-05-23 06:48:20 +0200
commit1041c55cc015f16264f91e2a8115782bb5cf753e (patch)
treeaaf8ddeff7097e704bbaa4f98ed07aefd5cee292
parent5ad6fcede90453055f91526e0e464ccf4d9a56ed (diff)
Use lamdba
-rw-r--r--blogilo/composereditorwebengine/src/private/composerwebengine_p.cpp29
1 files changed, 10 insertions, 19 deletions
diff --git a/blogilo/composereditorwebengine/src/private/composerwebengine_p.cpp b/blogilo/composereditorwebengine/src/private/composerwebengine_p.cpp
index e510105..b645a1b 100644
--- a/blogilo/composereditorwebengine/src/private/composerwebengine_p.cpp
+++ b/blogilo/composereditorwebengine/src/private/composerwebengine_p.cpp
@@ -894,28 +894,19 @@ void ComposerEditorWebEnginePrivate::_k_slotReplace()
//TODO
}
-struct SetPlainTextFunctor {
- QString fn;
- explicit SetPlainTextFunctor(const QString &filename)
- : fn(filename)
- {
- }
- void operator()(const QString &result)
- {
- QFile file(fn);
- bool success = file.open(QIODevice::WriteOnly);
- if (success) {
- // FIXME: here we always use UTF-8 encoding
- QByteArray data = result.toUtf8();
- const qint64 c = file.write(data);
- }
- }
-};
-
void ComposerEditorWebEnginePrivate::saveHtml(QWebEnginePage *page, const QString &fileName)
{
if (page) {
- page->toHtml(SetPlainTextFunctor(fileName));
+ page->toHtml([fileName](const QString &result) {
+ QFile file(fileName);
+ bool success = file.open(QIODevice::WriteOnly);
+ if (success) {
+ // FIXME: here we always use UTF-8 encoding
+ QByteArray data = result.toUtf8();
+ const qint64 c = file.write(data);
+ }
+ }
+ );
}
}