aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cppeditor/cppquickfixes.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2024-02-14 12:48:53 +0100
committerEike Ziller <eike.ziller@qt.io>2024-02-14 12:48:53 +0100
commitbcf0d8c319f1356d8c407fe1335ad58a503e1bd5 (patch)
tree08ef3fce62f5e3ef4519306de145174859a8736d /src/plugins/cppeditor/cppquickfixes.cpp
parent1af555ad09be169bebc7525e4bb7e10ad4de271d (diff)
parent0a1783d656964df60f1ec462f81c56ea38100dc5 (diff)
Merge remote-tracking branch 'origin/13.0'
Diffstat (limited to 'src/plugins/cppeditor/cppquickfixes.cpp')
-rw-r--r--src/plugins/cppeditor/cppquickfixes.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp
index b2f01eaad4..90563ccd33 100644
--- a/src/plugins/cppeditor/cppquickfixes.cpp
+++ b/src/plugins/cppeditor/cppquickfixes.cpp
@@ -141,7 +141,8 @@ enum DefPos {
inline bool isQtStringLiteral(const QByteArray &id)
{
- return id == "QLatin1String" || id == "QLatin1Literal" || id == "QStringLiteral";
+ return id == "QLatin1String" || id == "QLatin1Literal" || id == "QStringLiteral"
+ || id == "QByteArrayLiteral";
}
inline bool isQtStringTranslation(const QByteArray &id)
@@ -1117,21 +1118,20 @@ enum ActionFlags {
EncloseInQLatin1CharAction = 0x1,
EncloseInQLatin1StringAction = 0x2,
EncloseInQStringLiteralAction = 0x4,
- EncloseActionMask = EncloseInQLatin1CharAction
- | EncloseInQLatin1StringAction | EncloseInQStringLiteralAction,
- TranslateTrAction = 0x8,
- TranslateQCoreApplicationAction = 0x10,
- TranslateNoopAction = 0x20,
- TranslationMask = TranslateTrAction
- | TranslateQCoreApplicationAction | TranslateNoopAction,
- RemoveObjectiveCAction = 0x40,
- ConvertEscapeSequencesToCharAction = 0x100,
- ConvertEscapeSequencesToStringAction = 0x200,
- SingleQuoteAction = 0x400,
- DoubleQuoteAction = 0x800
+ EncloseInQByteArrayLiteralAction = 0x8,
+ EncloseActionMask = EncloseInQLatin1CharAction | EncloseInQLatin1StringAction
+ | EncloseInQStringLiteralAction | EncloseInQByteArrayLiteralAction,
+ TranslateTrAction = 0x10,
+ TranslateQCoreApplicationAction = 0x20,
+ TranslateNoopAction = 0x40,
+ TranslationMask = TranslateTrAction | TranslateQCoreApplicationAction | TranslateNoopAction,
+ RemoveObjectiveCAction = 0x100,
+ ConvertEscapeSequencesToCharAction = 0x200,
+ ConvertEscapeSequencesToStringAction = 0x400,
+ SingleQuoteAction = 0x800,
+ DoubleQuoteAction = 0x1000
};
-
/* Convert single-character string literals into character literals with some
* special cases "a" --> 'a', "'" --> '\'', "\n" --> '\n', "\"" --> '"'. */
static QByteArray stringToCharEscapeSequences(const QByteArray &content)
@@ -1167,6 +1167,8 @@ static QString stringLiteralReplacement(unsigned actions)
return QLatin1String("QLatin1String");
if (actions & EncloseInQStringLiteralAction)
return QLatin1String("QStringLiteral");
+ if (actions & EncloseInQByteArrayLiteralAction)
+ return QLatin1String("QByteArrayLiteral");
if (actions & TranslateTrAction)
return QLatin1String("tr");
if (actions & TranslateQCoreApplicationAction)
@@ -1357,6 +1359,9 @@ void WrapStringLiteral::doMatch(const CppQuickFixInterface &interface, QuickFixO
actions = EncloseInQStringLiteralAction | objectiveCActions;
result << new WrapStringLiteralOp(interface, priority, actions,
msgQtStringLiteralDescription(stringLiteralReplacement(actions)), literal);
+ actions = EncloseInQByteArrayLiteralAction | objectiveCActions;
+ result << new WrapStringLiteralOp(interface, priority, actions,
+ msgQtStringLiteralDescription(stringLiteralReplacement(actions)), literal);
}
}