aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/fakevim
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2023-09-05 15:25:26 +0200
committerhjk <hjk@qt.io>2023-09-27 09:41:44 +0000
commitd6fe357d81da96475c02eb3c73f660d8121381e4 (patch)
treebd260d5b3e69f83e9fd31293ee2b44f4b307576f /src/plugins/fakevim
parentd3b9b9b2d14eebf932a8c94e57a584fac06e486d (diff)
Utils: Use a proper class as Key
The Key encapsulates now a QByteArray. Plan is to use QByteArray::fromRawData on literals, but that's not active yet due to an unclear ASAN report, see the gerrit discussion. For now we also paddle back when interfacing QSettings, instead of mimicing writing a QVariantMap (and fail in some corners), always convert the Store. This is meant to go away in the future when code paths are better controled. Change-Id: Id1206a434d511f8003903d5322c7c9bd5f5fb859 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Diffstat (limited to 'src/plugins/fakevim')
-rw-r--r--src/plugins/fakevim/fakevimactions.cpp8
-rw-r--r--src/plugins/fakevim/fakevimactions.h10
-rw-r--r--src/plugins/fakevim/fakevimhandler.cpp8
3 files changed, 12 insertions, 14 deletions
diff --git a/src/plugins/fakevim/fakevimactions.cpp b/src/plugins/fakevim/fakevimactions.cpp
index 7440257eea..b4d568c7f0 100644
--- a/src/plugins/fakevim/fakevimactions.cpp
+++ b/src/plugins/fakevim/fakevimactions.cpp
@@ -244,7 +244,7 @@ FakeVimSettings::FakeVimSettings()
FakeVimSettings::~FakeVimSettings() = default;
-FvBaseAspect *FakeVimSettings::item(const Key &name)
+FvBaseAspect *FakeVimSettings::item(const Utils::Key &name)
{
return m_nameToAspect.value(name, nullptr);
}
@@ -265,8 +265,8 @@ QString FakeVimSettings::trySetValue(const QString &name, const QString &value)
void FakeVimSettings::setup(FvBaseAspect *aspect,
const QVariant &value,
- const Key &settingsKey,
- const Key &shortName,
+ const Utils::Key &settingsKey,
+ const Utils::Key &shortName,
const QString &labelText)
{
aspect->setSettingsKey("FakeVim", settingsKey);
@@ -282,7 +282,7 @@ void FakeVimSettings::setup(FvBaseAspect *aspect,
Q_UNUSED(labelText)
#endif
- const Key longName = settingsKey.toLower();
+ const Key longName = settingsKey.toByteArray().toLower();
if (!longName.isEmpty()) {
m_nameToAspect[longName] = aspect;
m_aspectToName[aspect] = longName;
diff --git a/src/plugins/fakevim/fakevimactions.h b/src/plugins/fakevim/fakevimactions.h
index ac4256eca0..1ad91bb968 100644
--- a/src/plugins/fakevim/fakevimactions.h
+++ b/src/plugins/fakevim/fakevimactions.h
@@ -25,8 +25,6 @@ namespace FakeVim::Internal {
#ifdef FAKEVIM_STANDALONE
-using Key = QByteArray;
-
class FvBaseAspect
{
public:
@@ -37,15 +35,15 @@ public:
virtual void setDefaultVariantValue(const QVariant &) {}
virtual QVariant variantValue() const { return {}; }
virtual QVariant defaultVariantValue() const { return {}; }
- void setSettingsKey(const Key &group, const Key &key);
- Key settingsKey() const;
+ void setSettingsKey(const Utils::Key &group, const Utils::Key &key);
+ Utils::Key settingsKey() const;
void setCheckable(bool) {}
void setDisplayName(const QString &) {}
void setToolTip(const QString &) {}
private:
- Key m_settingsGroup;
- Key m_settingsKey;
+ Utils::Key m_settingsGroup;
+ Utils::Key m_settingsKey;
};
template <class ValueType>
diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index 4a5d8e0415..a1bee53b6a 100644
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -6125,7 +6125,7 @@ bool FakeVimHandler::Private::handleExSetCommand(const ExCommand &cmd)
if (!error.isEmpty())
showMessage(MessageError, error);
} else {
- Utils::Key optionName = Utils::keyFromString(cmd.args);
+ QString optionName = cmd.args;
bool toggleOption = optionName.endsWith('!');
bool printOption = !toggleOption && optionName.endsWith('?');
@@ -6136,14 +6136,14 @@ bool FakeVimHandler::Private::handleExSetCommand(const ExCommand &cmd)
if (negateOption)
optionName.remove(0, 2);
- FvBaseAspect *act = s.item(optionName);
+ FvBaseAspect *act = s.item(Utils::keyFromString(optionName));
if (!act) {
showMessage(MessageError, Tr::tr("Unknown option:") + ' ' + cmd.args);
} else if (act->defaultVariantValue().type() == QVariant::Bool) {
bool oldValue = act->variantValue().toBool();
if (printOption) {
showMessage(MessageInfo, QLatin1String(oldValue ? "" : "no")
- + act->settingsKey().toLower());
+ + act->settingsKey().toByteArray().toLower());
} else if (toggleOption || negateOption == oldValue) {
act->setVariantValue(!oldValue);
}
@@ -6152,7 +6152,7 @@ bool FakeVimHandler::Private::handleExSetCommand(const ExCommand &cmd)
} else if (toggleOption) {
showMessage(MessageError, Tr::tr("Trailing characters:") + ' ' + cmd.args);
} else {
- showMessage(MessageInfo, act->settingsKey().toLower() + "="
+ showMessage(MessageInfo, act->settingsKey().toByteArray().toLower() + "="
+ act->variantValue().toString());
}
}