mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-19 16:31:21 +00:00
make backslashes escapable
BUG: 199005 FIXED-IN: 4.9
This commit is contained in:
parent
84dc11954c
commit
03e91d5242
|
@ -307,12 +307,7 @@ static int directCommand(KCmdLineArgs *args)
|
|||
}
|
||||
int ret;
|
||||
|
||||
QString text = args->getOption( option );
|
||||
int pos;
|
||||
while ((pos = text.indexOf( QLatin1String("\\n") )) >= 0)
|
||||
{
|
||||
text.replace(pos, 2, QLatin1String("\n"));
|
||||
}
|
||||
QString text = Widgets::parseString(args->getOption(option));
|
||||
|
||||
if ( type == KMessageBox::WarningContinueCancel ) {
|
||||
ret = KMessageBox::messageBox( 0, type, text, title, continueButton,
|
||||
|
|
|
@ -368,3 +368,35 @@ bool Widgets::calendar( QWidget *parent, const QString &title, const QString &te
|
|||
return retcode;
|
||||
}
|
||||
|
||||
QString Widgets::parseString(const QString &str)
|
||||
{
|
||||
QString ret;
|
||||
ret.reserve(str.size());
|
||||
bool escaped = false;
|
||||
for (int i = 0; i < str.size(); i++) {
|
||||
QChar c = str.at(i);
|
||||
if (escaped) {
|
||||
escaped = false;
|
||||
if (c == '\\') {
|
||||
ret += c;
|
||||
} else if (c == 'n') {
|
||||
ret += '\n';
|
||||
} else {
|
||||
kWarning() << qPrintable(QString::fromLatin1("Unrecognized escape sequence \\%1").arg(c));
|
||||
ret += '\\';
|
||||
ret += c;
|
||||
}
|
||||
} else {
|
||||
if (c == '\\') {
|
||||
escaped = true;
|
||||
} else {
|
||||
ret += c;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (escaped) {
|
||||
kWarning() << "Unterminated escape sequence";
|
||||
ret += '\\';
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ namespace Widgets
|
|||
|
||||
void handleXGeometry(QWidget * dlg);
|
||||
|
||||
QString parseString(const QString &str);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue