Commit b38a9545 authored by Tobias Hunger's avatar Tobias Hunger

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's avatarOrgad Shaneh <orgads@gmail.com>
parent bd5becfe
......@@ -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
......
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