aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cpptools/abstracteditorsupport.cpp
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@theqtcompany.com>2015-09-15 16:37:54 +0200
committerTobias Hunger <tobias.hunger@theqtcompany.com>2015-09-22 09:17:02 +0000
commitb38a954521358b35bbb3ca371513e80c7469ee2d (patch)
treed15bbce941434e5baa70264d62e7fa350b3d80a7 /src/plugins/cpptools/abstracteditorsupport.cpp
parentbd5becfe1830408d52a58af0b750190786ad2ad3 (diff)
Old-style wizards: Handle line continuation in license templates
This is necessary to have the same template work in the old-style wizards and the JSON wizard, which supports inserting \n, \t as well as line continuation for everything. Change-Id: I11c310998b92650003206484de8f1ecfc6000034 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src/plugins/cpptools/abstracteditorsupport.cpp')
-rw-r--r--src/plugins/cpptools/abstracteditorsupport.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/plugins/cpptools/abstracteditorsupport.cpp b/src/plugins/cpptools/abstracteditorsupport.cpp
index c1e49a4a1b..3733f668cc 100644
--- a/src/plugins/cpptools/abstracteditorsupport.cpp
+++ b/src/plugins/cpptools/abstracteditorsupport.cpp
@@ -63,7 +63,30 @@ QString AbstractEditorSupport::licenseTemplate(const QString &file, const QStrin
expander.registerVariable("Cpp:License:ClassName", tr("The class name"),
[className]() { return className; });
- return expander.expand(license);
+ QString out = expander.expand(license);
+ // Expand \n, \t and handle line continuation:
+ QString result;
+ result.reserve(out.count());
+ bool isEscaped = false;
+ for (int i = 0; i < out.count(); ++i) {
+ const QChar c = out.at(i);
+
+ if (isEscaped) {
+ if (c == QLatin1Char('n'))
+ result.append(QLatin1Char('\n'));
+ else if (c == QLatin1Char('t'))
+ result.append(QLatin1Char('\t'));
+ else if (c != QLatin1Char('\n'))
+ result.append(c);
+ isEscaped = false;
+ } else {
+ if (c == QLatin1Char('\\'))
+ isEscaped = true;
+ else
+ result.append(c);
+ }
+ }
+ return result;
}
} // namespace CppTools