Commit 9cd07bac authored by Kurt Hindenburg's avatar Kurt Hindenburg

Use QLatin1*/QStringLiteral to handle casts from ascii

parent fef096b5
...@@ -163,7 +163,7 @@ void TerminalImageFilterChain::setImage(const Character* const image , int lines ...@@ -163,7 +163,7 @@ void TerminalImageFilterChain::setImage(const Character* const image , int lines
// terminal image to avoid adding this imaginary character for wrapped // terminal image to avoid adding this imaginary character for wrapped
// lines // lines
if ((lineProperties.value(i, LINE_DEFAULT) & LINE_WRAPPED) == 0) if ((lineProperties.value(i, LINE_DEFAULT) & LINE_WRAPPED) == 0)
lineStream << QChar('\n'); lineStream << QLatin1Char('\n');
} }
decoder.end(); decoder.end();
} }
...@@ -435,16 +435,16 @@ void UrlFilter::HotSpot::activate(QObject* object) ...@@ -435,16 +435,16 @@ void UrlFilter::HotSpot::activate(QObject* object)
//regexp matches: //regexp matches:
// full url: // full url:
// protocolname:// or www. followed by anything other than whitespaces, <, >, ' or ", and ends before whitespaces, <, >, ', ", ], !, ), :, comma and dot // protocolname:// or www. followed by anything other than whitespaces, <, >, ' or ", and ends before whitespaces, <, >, ', ", ], !, ), :, comma and dot
const QRegularExpression UrlFilter::FullUrlRegExp("(www\\.(?!\\.)|[a-z][a-z0-9+.-]*://)[^\\s<>'\"]+[^!,\\.\\s<>'\"\\]\\)\\:]", const QRegularExpression UrlFilter::FullUrlRegExp(QStringLiteral("(www\\.(?!\\.)|[a-z][a-z0-9+.-]*://)[^\\s<>'\"]+[^!,\\.\\s<>'\"\\]\\)\\:]"),
QRegularExpression::OptimizeOnFirstUsageOption); QRegularExpression::OptimizeOnFirstUsageOption);
// email address: // email address:
// [word chars, dots or dashes]@[word chars, dots or dashes].[word chars] // [word chars, dots or dashes]@[word chars, dots or dashes].[word chars]
const QRegularExpression UrlFilter::EmailAddressRegExp("\\b(\\w|\\.|-)+@(\\w|\\.|-)+\\.\\w+\\b", const QRegularExpression UrlFilter::EmailAddressRegExp(QStringLiteral("\\b(\\w|\\.|-)+@(\\w|\\.|-)+\\.\\w+\\b"),
QRegularExpression::OptimizeOnFirstUsageOption); QRegularExpression::OptimizeOnFirstUsageOption);
// matches full url or email address // matches full url or email address
const QRegularExpression UrlFilter::CompleteUrlRegExp('(' + FullUrlRegExp.pattern() + '|' + const QRegularExpression UrlFilter::CompleteUrlRegExp(QLatin1Char('(') + FullUrlRegExp.pattern() + QLatin1Char('|') +
EmailAddressRegExp.pattern() + ')', EmailAddressRegExp.pattern() + QLatin1Char(')'),
QRegularExpression::OptimizeOnFirstUsageOption); QRegularExpression::OptimizeOnFirstUsageOption);
UrlFilter::UrlFilter() UrlFilter::UrlFilter()
...@@ -539,13 +539,13 @@ FileFilter::FileFilter(Session* session) ...@@ -539,13 +539,13 @@ FileFilter::FileFilter(Session* session)
} }
patterns.removeDuplicates(); patterns.removeDuplicates();
patterns.replaceInStrings("*", ""); patterns.replaceInStrings(QLatin1String("*"), QLatin1String(""));
patterns = patterns.filter(QRegularExpression("^[A-Za-z0-9\\._-]+$")); patterns = patterns.filter(QRegularExpression(QStringLiteral("^[A-Za-z0-9\\._-]+$")));
patterns.replaceInStrings(".", "\\."); patterns.replaceInStrings(QLatin1String("."), QLatin1String("\\."));
QString regex("(\\b|/)+[A-Za-z0-9\\._\\-/]+("); QString regex(QStringLiteral("(\\b|/)+[A-Za-z0-9\\._\\-/]+("));
regex.append(patterns.join("|")); regex.append(patterns.join(QLatin1String("|")));
regex.append("){1}\\b"); regex.append(QLatin1String("){1}\\b"));
setRegExp(QRegularExpression(regex)); setRegExp(QRegularExpression(regex));
} }
......
...@@ -61,7 +61,7 @@ void KeyboardTranslatorWriter::writeEntry(const KeyboardTranslator::Entry& entry ...@@ -61,7 +61,7 @@ void KeyboardTranslatorWriter::writeEntry(const KeyboardTranslator::Entry& entry
if (entry.command() != KeyboardTranslator::NoCommand) if (entry.command() != KeyboardTranslator::NoCommand)
result = entry.resultToString(); result = entry.resultToString();
else else
result = '\"' + entry.resultToString() + '\"'; result = QLatin1Char('\"') + entry.resultToString() + QLatin1Char('\"');
*_writer << "key " << entry.conditionToString() << " : " << result << '\n'; *_writer << "key " << entry.conditionToString() << " : " << result << '\n';
} }
...@@ -230,9 +230,9 @@ bool KeyboardTranslatorReader::decodeSequence(const QString& text, ...@@ -230,9 +230,9 @@ bool KeyboardTranslatorReader::decodeSequence(const QString& text,
// check if this is a wanted / not-wanted flag and update the // check if this is a wanted / not-wanted flag and update the
// state ready for the next item // state ready for the next item
if (ch == '+') if (ch == QLatin1Char('+'))
isWanted = true; isWanted = true;
else if (ch == '-') else if (ch == QLatin1Char('-'))
isWanted = false; isWanted = false;
} }
...@@ -309,7 +309,7 @@ KeyboardTranslator::Entry KeyboardTranslatorReader::createEntry(const QString& c ...@@ -309,7 +309,7 @@ KeyboardTranslator::Entry KeyboardTranslatorReader::createEntry(const QString& c
{ {
QString entryString(QStringLiteral("keyboard \"temporary\"\nkey ")); QString entryString(QStringLiteral("keyboard \"temporary\"\nkey "));
entryString.append(condition); entryString.append(condition);
entryString.append(" : "); entryString.append(QLatin1String(" : "));
// if 'result' is the name of a command then the entry result will be that command, // if 'result' is the name of a command then the entry result will be that command,
// otherwise the result will be treated as a string to echo when the key sequence // otherwise the result will be treated as a string to echo when the key sequence
...@@ -318,7 +318,7 @@ KeyboardTranslator::Entry KeyboardTranslatorReader::createEntry(const QString& c ...@@ -318,7 +318,7 @@ KeyboardTranslator::Entry KeyboardTranslatorReader::createEntry(const QString& c
if (parseAsCommand(result, command)) if (parseAsCommand(result, command))
entryString.append(result); entryString.append(result);
else else
entryString.append('\"' + result + '\"'); entryString.append(QLatin1Char('\"') + result + QLatin1Char('\"'));
QByteArray array = entryString.toUtf8(); QByteArray array = entryString.toUtf8();
QBuffer buffer(&array); QBuffer buffer(&array);
...@@ -352,9 +352,9 @@ QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const ...@@ -352,9 +352,9 @@ QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const
int commentPos = -1; int commentPos = -1;
for (int i = text.length() - 1; i >= 0; i--) { for (int i = text.length() - 1; i >= 0; i--) {
QChar ch = text[i]; QChar ch = text[i];
if (ch == '\"') if (ch == QLatin1Char('\"'))
inQuotes = !inQuotes; inQuotes = !inQuotes;
else if (ch == '#' && !inQuotes) else if (ch == QLatin1Char('#') && !inQuotes)
commentPos = i; commentPos = i;
} }
if (commentPos != -1) if (commentPos != -1)
...@@ -363,10 +363,10 @@ QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const ...@@ -363,10 +363,10 @@ QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const
text = text.simplified(); text = text.simplified();
// title line: keyboard "title" // title line: keyboard "title"
static const QRegularExpression title("keyboard\\s+\"(.*)\"", QRegularExpression::OptimizeOnFirstUsageOption); static const QRegularExpression title(QStringLiteral("keyboard\\s+\"(.*)\""), QRegularExpression::OptimizeOnFirstUsageOption);
// key line: key KeySequence : "output" // key line: key KeySequence : "output"
// key line: key KeySequence : command // key line: key KeySequence : command
static const QRegularExpression key("key\\s+([\\w\\+\\s\\-\\*\\.]+)\\s*:\\s*(\"(.*)\"|\\w+)", QRegularExpression::OptimizeOnFirstUsageOption); static const QRegularExpression key(QStringLiteral("key\\s+([\\w\\+\\s\\-\\*\\.]+)\\s*:\\s*(\"(.*)\"|\\w+)"), QRegularExpression::OptimizeOnFirstUsageOption);
QList<Token> list; QList<Token> list;
if (text.isEmpty()) { if (text.isEmpty()) {
...@@ -391,7 +391,7 @@ QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const ...@@ -391,7 +391,7 @@ QList<KeyboardTranslatorReader::Token> KeyboardTranslatorReader::tokenize(const
Token keyToken = { Token::KeyKeyword , QString() }; Token keyToken = { Token::KeyKeyword , QString() };
QString sequenceTokenString = keyMatch.captured(1); QString sequenceTokenString = keyMatch.captured(1);
Token sequenceToken = { Token::KeySequence , sequenceTokenString.remove(QChar(' ')) }; Token sequenceToken = { Token::KeySequence , sequenceTokenString.remove(QLatin1Char(' ')) };
list << keyToken << sequenceToken; list << keyToken << sequenceToken;
...@@ -478,7 +478,7 @@ QByteArray KeyboardTranslator::Entry::escapedText(bool expandWildCards, ...@@ -478,7 +478,7 @@ QByteArray KeyboardTranslator::Entry::escapedText(bool expandWildCards,
default: default:
// any character which is not printable is replaced by an equivalent // any character which is not printable is replaced by an equivalent
// \xhh escape sequence (where 'hh' are the corresponding hex digits) // \xhh escape sequence (where 'hh' are the corresponding hex digits)
if (!QChar(ch).isPrint()) if (!QChar(QLatin1Char(ch)).isPrint())
replacement = 'x'; replacement = 'x';
} }
...@@ -547,9 +547,9 @@ void KeyboardTranslator::Entry::insertModifier(QString& item , int modifier) con ...@@ -547,9 +547,9 @@ void KeyboardTranslator::Entry::insertModifier(QString& item , int modifier) con
return; return;
if ((modifier & _modifiers) != 0u) if ((modifier & _modifiers) != 0u)
item += '+'; item += QLatin1Char('+');
else else
item += '-'; item += QLatin1Char('-');
if (modifier == Qt::ShiftModifier) if (modifier == Qt::ShiftModifier)
item += QLatin1String("Shift"); item += QLatin1String("Shift");
...@@ -568,9 +568,9 @@ void KeyboardTranslator::Entry::insertState(QString& item, int aState) const ...@@ -568,9 +568,9 @@ void KeyboardTranslator::Entry::insertState(QString& item, int aState) const
return; return;
if ((aState & _state) != 0) if ((aState & _state) != 0)
item += '+'; item += QLatin1Char('+');
else else
item += '-'; item += QLatin1Char('-');
if (aState == KeyboardTranslator::AlternateScreenState) if (aState == KeyboardTranslator::AlternateScreenState)
item += QLatin1String("AppScreen"); item += QLatin1String("AppScreen");
...@@ -589,7 +589,7 @@ QString KeyboardTranslator::Entry::resultToString(bool expandWildCards, ...@@ -589,7 +589,7 @@ QString KeyboardTranslator::Entry::resultToString(bool expandWildCards,
Qt::KeyboardModifiers keyboardModifiers) const Qt::KeyboardModifiers keyboardModifiers) const
{ {
if (!_text.isEmpty()) if (!_text.isEmpty())
return escapedText(expandWildCards, keyboardModifiers); return QString::fromLatin1(escapedText(expandWildCards, keyboardModifiers));
else if (_command == EraseCommand) else if (_command == EraseCommand)
return QStringLiteral("Erase"); return QStringLiteral("Erase");
else if (_command == ScrollPageUpCommand) else if (_command == ScrollPageUpCommand)
......
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