diff --git a/src/libs/utils/CMakeLists.txt b/src/libs/utils/CMakeLists.txt index 5d9a8ffd442..72c18e3346f 100644 --- a/src/libs/utils/CMakeLists.txt +++ b/src/libs/utils/CMakeLists.txt @@ -162,6 +162,7 @@ add_qtc_library(Utils span.h statuslabel.cpp statuslabel.h store.cpp store.h + storekey.h stringtable.cpp stringtable.h stringutils.cpp stringutils.h styleanimator.cpp styleanimator.h diff --git a/src/libs/utils/aspects.cpp b/src/libs/utils/aspects.cpp index a0b7cf6754b..33eedd561d3 100644 --- a/src/libs/utils/aspects.cpp +++ b/src/libs/utils/aspects.cpp @@ -63,7 +63,7 @@ public: std::function m_fromSettings; QString m_displayName; - QString m_settingsKey; // Name of data in settings. + Key m_settingsKey; // Name of data in settings. QString m_tooltip; QString m_labelText; QPixmap m_labelPixmap; @@ -390,7 +390,7 @@ void BaseAspect::setConfigWidgetCreator(const ConfigWidgetCreator &configWidgetC \sa setSettingsKey() */ -QString BaseAspect::settingsKey() const +Key BaseAspect::settingsKey() const { return d->m_settingsKey; } @@ -400,7 +400,7 @@ QString BaseAspect::settingsKey() const \sa settingsKey() */ -void BaseAspect::setSettingsKey(const QString &key) +void BaseAspect::setSettingsKey(const Key &key) { d->m_settingsKey = key; } @@ -410,7 +410,7 @@ void BaseAspect::setSettingsKey(const QString &key) \sa settingsKey() */ -void BaseAspect::setSettingsKey(const QString &group, const QString &key) +void BaseAspect::setSettingsKey(const Key &group, const Key &key) { d->m_settingsKey = group + "/" + key; } @@ -569,8 +569,8 @@ void BaseAspect::registerSubWidget(QWidget *widget) widget->setVisible(d->m_visible); } -void BaseAspect::saveToMap(QVariantMap &data, const QVariant &value, - const QVariant &defaultValue, const QString &key) +void BaseAspect::saveToMap(Store &data, const QVariant &value, + const QVariant &defaultValue, const Key &key) { if (key.isEmpty()) return; @@ -581,7 +581,7 @@ void BaseAspect::saveToMap(QVariantMap &data, const QVariant &value, } /*! - Retrieves the internal value of this BaseAspect from the QVariantMap \a map. + Retrieves the internal value of this BaseAspect from the Store \a map. */ void BaseAspect::fromMap(const Store &map) { @@ -592,7 +592,7 @@ void BaseAspect::fromMap(const Store &map) } /*! - Stores the internal value of this BaseAspect into the QVariantMap \a map. + Stores the internal value of this BaseAspect into the Store \a map. */ void BaseAspect::toMap(Store &map) const { @@ -732,7 +732,7 @@ public: } void makeCheckable(CheckBoxPlacement checkBoxPlacement, const QString &checkerLabel, - const QString &checkerKey, BaseAspect *aspect) + const Key &checkerKey, BaseAspect *aspect) { QTC_ASSERT(!m_checked, return); m_checkBoxPlacement = checkBoxPlacement; @@ -788,7 +788,7 @@ public: Qt::TextElideMode m_elideMode = Qt::ElideNone; QString m_placeHolderText; - QString m_historyCompleterKey; + Key m_historyCompleterKey; QPointer m_labelDisplay; QPointer m_lineEditDisplay; QPointer m_showPasswordButton; @@ -996,7 +996,7 @@ void StringAspect::setElideMode(Qt::TextElideMode elideMode) \sa Utils::PathChooser::setExpectedKind() */ -void StringAspect::setHistoryCompleter(const QString &historyCompleterKey) +void StringAspect::setHistoryCompleter(const Key &historyCompleterKey) { d->m_historyCompleterKey = historyCompleterKey; if (d->m_lineEditDisplay) @@ -1202,7 +1202,7 @@ void StringAspect::bufferToGui() \a checkerKey. */ void StringAspect::makeCheckable(CheckBoxPlacement checkBoxPlacement, - const QString &checkerLabel, const QString &checkerKey) + const QString &checkerLabel, const Key &checkerKey) { d->m_checkerImpl.makeCheckable(checkBoxPlacement, checkerLabel, checkerKey, this); } @@ -1242,7 +1242,7 @@ public: QString m_prompDialogFilter; QString m_prompDialogTitle; QStringList m_commandVersionArguments; - QString m_historyCompleterKey; + Key m_historyCompleterKey; PathChooser::Kind m_expectedKind = PathChooser::File; Environment m_environment; QPointer m_pathChooserDisplay; @@ -1325,7 +1325,8 @@ void FilePathAspect::setDefaultValue(const QString &filePath) \a checkerKey. */ void FilePathAspect::makeCheckable(CheckBoxPlacement checkBoxPlacement, - const QString &checkerLabel, const QString &checkerKey) + const QString &checkerLabel, + const Key &checkerKey) { d->m_checkerImpl.makeCheckable(checkBoxPlacement, checkerLabel, checkerKey, this); } @@ -1545,7 +1546,7 @@ void FilePathAspect::setDisplayFilter(const std::functionm_displayFilter = displayFilter; } -void FilePathAspect::setHistoryCompleter(const QString &historyCompleterKey) +void FilePathAspect::setHistoryCompleter(const Key &historyCompleterKey) { d->m_historyCompleterKey = historyCompleterKey; if (d->m_pathChooserDisplay) @@ -2608,7 +2609,7 @@ bool AspectContainer::isDirty() bool AspectContainer::equals(const AspectContainer &other) const { // FIXME: Expensive, but should not really be needed in a fully aspectified world. - QVariantMap thisMap, thatMap; + Store thisMap, thatMap; toMap(thisMap); other.toMap(thatMap); return thisMap == thatMap; @@ -2616,7 +2617,7 @@ bool AspectContainer::equals(const AspectContainer &other) const void AspectContainer::copyFrom(const AspectContainer &other) { - QVariantMap map; + Store map; other.toMap(map); fromMap(map); } diff --git a/src/libs/utils/aspects.h b/src/libs/utils/aspects.h index 00e452e3015..b2b98937c7f 100644 --- a/src/libs/utils/aspects.h +++ b/src/libs/utils/aspects.h @@ -63,9 +63,9 @@ public: virtual void setDefaultVariantValue(const QVariant &value); virtual bool isDefaultValue() const; - QString settingsKey() const; - void setSettingsKey(const QString &settingsKey); - void setSettingsKey(const QString &group, const QString &key); + Key settingsKey() const; + void setSettingsKey(const Key &settingsKey); + void setSettingsKey(const Key &group, const Key &key); QString displayName() const; void setDisplayName(const QString &displayName); @@ -230,8 +230,8 @@ protected: } void registerSubWidget(QWidget *widget); - static void saveToMap(QVariantMap &data, const QVariant &value, - const QVariant &defaultValue, const QString &key); + static void saveToMap(Store &data, const QVariant &value, + const QVariant &defaultValue, const Key &key); protected: template @@ -534,7 +534,7 @@ public: void setShowToolTipOnLabel(bool show); void setDisplayFilter(const std::function &displayFilter); void setPlaceHolderText(const QString &placeHolderText); - void setHistoryCompleter(const QString &historyCompleterKey); + void setHistoryCompleter(const Key &historyCompleterKey); void setUndoRedoEnabled(bool readOnly); void setAcceptRichText(bool acceptRichText); void setMacroExpanderProvider(const MacroExpanderProvider &expanderProvider); @@ -544,7 +544,7 @@ public: void setAutoApplyOnEditingFinished(bool applyOnEditingFinished); void setElideMode(Qt::TextElideMode elideMode); - void makeCheckable(CheckBoxPlacement checkBoxPlacement, const QString &optionalLabel, const QString &optionalBaseKey); + void makeCheckable(CheckBoxPlacement checkBoxPlacement, const QString &optionalLabel, const Key &optionalBaseKey); bool isChecked() const; void setChecked(bool checked); @@ -608,14 +608,14 @@ public: void setPlaceHolderText(const QString &placeHolderText); void setValidationFunction(const FancyLineEdit::ValidationFunction &validator); void setDisplayFilter(const std::function &displayFilter); - void setHistoryCompleter(const QString &historyCompleterKey); + void setHistoryCompleter(const Key &historyCompleterKey); void setMacroExpanderProvider(const MacroExpanderProvider &expanderProvider); void setShowToolTipOnLabel(bool show); void setAutoApplyOnEditingFinished(bool applyOnEditingFinished); void validateInput(); - void makeCheckable(CheckBoxPlacement checkBoxPlacement, const QString &optionalLabel, const QString &optionalBaseKey); + void makeCheckable(CheckBoxPlacement checkBoxPlacement, const QString &optionalLabel, const Key &optionalBaseKey); bool isChecked() const; void setChecked(bool checked); diff --git a/src/libs/utils/delegates.cpp b/src/libs/utils/delegates.cpp index 3b0623027b6..b384faba571 100644 --- a/src/libs/utils/delegates.cpp +++ b/src/libs/utils/delegates.cpp @@ -151,7 +151,7 @@ void PathChooserDelegate::updateEditorGeometry(QWidget *editor, const QStyleOpti editor->setGeometry(option.rect); } -void PathChooserDelegate::setHistoryCompleter(const QString &key) +void PathChooserDelegate::setHistoryCompleter(const Key &key) { m_historyKey = key; } diff --git a/src/libs/utils/delegates.h b/src/libs/utils/delegates.h index ff012152f5f..328798b4b8d 100644 --- a/src/libs/utils/delegates.h +++ b/src/libs/utils/delegates.h @@ -52,12 +52,12 @@ public: void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const override; - void setHistoryCompleter(const QString &key); + void setHistoryCompleter(const Key &key); private: PathChooser::Kind m_kind = PathChooser::ExistingDirectory; QString m_filter; - QString m_historyKey; + Key m_historyKey; }; class QTCREATOR_UTILS_EXPORT CompleterDelegate : public QStyledItemDelegate diff --git a/src/libs/utils/displayname.cpp b/src/libs/utils/displayname.cpp index 0046b50ae9e..a2f622143c6 100644 --- a/src/libs/utils/displayname.cpp +++ b/src/libs/utils/displayname.cpp @@ -35,13 +35,13 @@ bool DisplayName::usesDefaultValue() const return m_value.isEmpty(); } -void DisplayName::toMap(Store &map, const QString &key) const +void DisplayName::toMap(Store &map, const Key &key) const { if (m_forceSerialization || !usesDefaultValue()) map.insert(key, m_value); } -void DisplayName::fromMap(const Store &map, const QString &key) +void DisplayName::fromMap(const Store &map, const Key &key) { m_value = map.value(key).toString(); } diff --git a/src/libs/utils/fancylineedit.cpp b/src/libs/utils/fancylineedit.cpp index 2ed8beabc5e..e5de16e3e84 100644 --- a/src/libs/utils/fancylineedit.cpp +++ b/src/libs/utils/fancylineedit.cpp @@ -346,7 +346,7 @@ bool FancyLineEdit::hasAutoHideButton(Side side) const return d->m_iconbutton[side]->hasAutoHide(); } -void FancyLineEdit::setHistoryCompleter(const QString &historyKey, bool restoreLastItemFromHistory) +void FancyLineEdit::setHistoryCompleter(const Key &historyKey, bool restoreLastItemFromHistory) { QTC_ASSERT(!d->m_historyCompleter, return); d->m_historyCompleter = new HistoryCompleter(historyKey, this); diff --git a/src/libs/utils/fancylineedit.h b/src/libs/utils/fancylineedit.h index 9f1e1693984..c5212aa6392 100644 --- a/src/libs/utils/fancylineedit.h +++ b/src/libs/utils/fancylineedit.h @@ -7,6 +7,7 @@ #include "completinglineedit.h" #include "expected.h" +#include "storekey.h" #include #include @@ -86,7 +87,7 @@ public: // Completion // Enable a history completer with a history of entries. - void setHistoryCompleter(const QString &historyKey, bool restoreLastItemFromHistory = false); + void setHistoryCompleter(const Utils::Key &historyKey, bool restoreLastItemFromHistory = false); // Sets a completer that is not a history completer. void setSpecialCompleter(QCompleter *completer); diff --git a/src/libs/utils/historycompleter.cpp b/src/libs/utils/historycompleter.cpp index f8c93b9fbef..7f299af1372 100644 --- a/src/libs/utils/historycompleter.cpp +++ b/src/libs/utils/historycompleter.cpp @@ -30,8 +30,8 @@ public: void addEntry(const QString &str); QStringList list; - QString historyKey; - QString historyKeyIsLastItemEmpty; + Key historyKey; + Key historyKeyIsLastItemEmpty; int maxLines = 6; bool isLastItemEmpty = isLastItemEmptyDefault; }; @@ -174,17 +174,16 @@ void HistoryCompleterPrivate::addEntry(const QString &str) isLastItemEmptyDefault); } -HistoryCompleter::HistoryCompleter(const QString &historyKey, QObject *parent) +HistoryCompleter::HistoryCompleter(const Key &historyKey, QObject *parent) : QCompleter(parent), d(new HistoryCompleterPrivate) { QTC_ASSERT(!historyKey.isEmpty(), return); QTC_ASSERT(theSettings, return); - d->historyKey = QLatin1String("CompleterHistory/") + historyKey; + d->historyKey = "CompleterHistory/" + historyKey; d->list = theSettings->value(d->historyKey).toStringList(); - d->historyKeyIsLastItemEmpty = QLatin1String("CompleterHistory/") - + historyKey + QLatin1String(".IsLastItemEmpty"); + d->historyKeyIsLastItemEmpty = "CompleterHistory/" + historyKey + ".IsLastItemEmpty"; d->isLastItemEmpty = theSettings->value(d->historyKeyIsLastItemEmpty, isLastItemEmptyDefault) .toBool(); diff --git a/src/libs/utils/historycompleter.h b/src/libs/utils/historycompleter.h index 7a1fd2a4993..b0842549fef 100644 --- a/src/libs/utils/historycompleter.h +++ b/src/libs/utils/historycompleter.h @@ -5,6 +5,8 @@ #include "utils_global.h" +#include "storekey.h" + #include namespace Utils { @@ -17,7 +19,7 @@ class QTCREATOR_UTILS_EXPORT HistoryCompleter : public QCompleter { public: static void setSettings(QtcSettings *settings); - HistoryCompleter(const QString &historyKey, QObject *parent = nullptr); + HistoryCompleter(const Key &historyKey, QObject *parent = nullptr); bool removeHistoryItem(int index); QString historyItem() const; bool hasHistory() const { return historySize() > 0; } diff --git a/src/libs/utils/minimizableinfobars.cpp b/src/libs/utils/minimizableinfobars.cpp index a4fcd478118..c3775bdf899 100644 --- a/src/libs/utils/minimizableinfobars.cpp +++ b/src/libs/utils/minimizableinfobars.cpp @@ -33,7 +33,7 @@ void MinimizableInfoBars::setPossibleInfoBarEntries(const QList #include @@ -27,7 +28,7 @@ public: public: explicit MinimizableInfoBars(InfoBar &infoBar); - void setSettingsGroup(const QString &settingsGroup); + void setSettingsGroup(const Key &settingsGroup); void setPossibleInfoBarEntries(const QList &entries); void createShowInfoBarActions(const ActionCreator &actionCreator) const; @@ -37,7 +38,7 @@ public: private: void createActions(); - QString settingsKey(const Id &id) const; + Key settingsKey(const Id &id) const; bool showInInfoBar(const Id &id) const; void setShowInInfoBar(const Id &id, bool show); @@ -46,7 +47,7 @@ private: void showInfoBar(const Id &id); InfoBar &m_infoBar; - QString m_settingsGroup; + Key m_settingsGroup; QHash m_actions; QHash m_isInfoVisible; QHash m_infoEntries; diff --git a/src/libs/utils/pathchooser.cpp b/src/libs/utils/pathchooser.cpp index 848e5619593..048fb57ddb7 100644 --- a/src/libs/utils/pathchooser.cpp +++ b/src/libs/utils/pathchooser.cpp @@ -735,7 +735,7 @@ void PathChooser::installLineEditVersionToolTip(QLineEdit *le, const QStringList ef->setArguments(arguments); } -void PathChooser::setHistoryCompleter(const QString &historyKey, bool restoreLastItemFromHistory) +void PathChooser::setHistoryCompleter(const Key &historyKey, bool restoreLastItemFromHistory) { d->m_lineEdit->setHistoryCompleter(historyKey, restoreLastItemFromHistory); } diff --git a/src/libs/utils/pathchooser.h b/src/libs/utils/pathchooser.h index 45930a61270..b7b4a040f31 100644 --- a/src/libs/utils/pathchooser.h +++ b/src/libs/utils/pathchooser.h @@ -105,7 +105,7 @@ public: static void installLineEditVersionToolTip(QLineEdit *le, const QStringList &arguments); // Enable a history completer with a history of entries. - void setHistoryCompleter(const QString &historyKey, bool restoreLastItemFromHistory = false); + void setHistoryCompleter(const Key &historyKey, bool restoreLastItemFromHistory = false); // Sets a macro expander that is used when producing path and fileName. // By default, the global expander is used. diff --git a/src/libs/utils/qtcsettings.h b/src/libs/utils/qtcsettings.h index 13e5ef4c3cb..05d44ef2ffd 100644 --- a/src/libs/utils/qtcsettings.h +++ b/src/libs/utils/qtcsettings.h @@ -5,6 +5,8 @@ #include "utils_global.h" +#include "store.h" + #include namespace Utils { @@ -15,34 +17,34 @@ public: using QSettings::QSettings; template - void setValueWithDefault(const QString &key, const T &val, const T &defaultValue); + void setValueWithDefault(const Key &key, const T &val, const T &defaultValue); template - void setValueWithDefault(const QString &key, const T &val); + void setValueWithDefault(const Key &key, const T &val); template static void setValueWithDefault(QSettings *settings, - const QString &key, + const Key &key, const T &val, const T &defaultValue); template - static void setValueWithDefault(QSettings *settings, const QString &key, const T &val); + static void setValueWithDefault(QSettings *settings, const Key &key, const T &val); }; template -void QtcSettings::setValueWithDefault(const QString &key, const T &val, const T &defaultValue) +void QtcSettings::setValueWithDefault(const Key &key, const T &val, const T &defaultValue) { setValueWithDefault(this, key, val, defaultValue); } template -void QtcSettings::setValueWithDefault(const QString &key, const T &val) +void QtcSettings::setValueWithDefault(const Key &key, const T &val) { setValueWithDefault(this, key, val); } template void QtcSettings::setValueWithDefault(QSettings *settings, - const QString &key, + const Key &key, const T &val, const T &defaultValue) { @@ -53,7 +55,7 @@ void QtcSettings::setValueWithDefault(QSettings *settings, } template -void QtcSettings::setValueWithDefault(QSettings *settings, const QString &key, const T &val) +void QtcSettings::setValueWithDefault(QSettings *settings, const Key &key, const T &val) { if (val == T()) settings->remove(key); diff --git a/src/libs/utils/settingsutils.h b/src/libs/utils/settingsutils.h index 2feb62380d1..97d8f285a98 100644 --- a/src/libs/utils/settingsutils.h +++ b/src/libs/utils/settingsutils.h @@ -3,38 +3,39 @@ #pragma once +#include "store.h" + #include -#include #include #include namespace Utils { template -void fromSettings(const QString &postFix, - const QString &category, +void fromSettings(const Key &postFix, + const Key &category, QSettings *s, SettingsClassT *obj) { - QVariantMap map; + Store map; s->beginGroup(category + postFix); - const QStringList keys = s->allKeys(); - for (const QString &key : keys) + const KeyList keys = s->allKeys(); + for (const Key &key : keys) map.insert(key, s->value(key)); s->endGroup(); obj->fromMap(map); } template -void toSettings(const QString &postFix, - const QString &category, +void toSettings(const Key &postFix, + const Key &category, QSettings *s, const SettingsClassT *obj) { - QString group = postFix; + Key group = postFix; if (!category.isEmpty()) group.insert(0, category); - const QVariantMap map = obj->toMap(); + const Store map = obj->toMap(); s->beginGroup(group); for (auto it = map.constBegin(), end = map.constEnd(); it != end; ++it) diff --git a/src/libs/utils/store.h b/src/libs/utils/store.h index d692216c301..7037f5b4a4e 100644 --- a/src/libs/utils/store.h +++ b/src/libs/utils/store.h @@ -3,12 +3,14 @@ #pragma once -#include +#include "storekey.h" + +#include +#include namespace Utils { -using Key = QString; -using Data = QVariant; -using Store = QMap; +using KeyList = QList; +using Store = QMap; } // Utils diff --git a/src/libs/utils/storekey.h b/src/libs/utils/storekey.h new file mode 100644 index 00000000000..550bcda10cd --- /dev/null +++ b/src/libs/utils/storekey.h @@ -0,0 +1,12 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#pragma once + +#include + +namespace Utils { + +using Key = QString; + +} // Utils diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs index 9e59cc2b86a..021c1d37f26 100644 --- a/src/libs/utils/utils.qbs +++ b/src/libs/utils/utils.qbs @@ -295,6 +295,7 @@ Project { "statuslabel.h", "store.cpp", "store.h", + "storekey.h", "stringtable.cpp", "stringtable.h", "stringutils.cpp", diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.cpp b/src/plugins/coreplugin/dialogs/settingsdialog.cpp index c1410bf130f..79cd816e368 100644 --- a/src/plugins/coreplugin/dialogs/settingsdialog.cpp +++ b/src/plugins/coreplugin/dialogs/settingsdialog.cpp @@ -769,7 +769,7 @@ bool SettingsDialog::execDialog() if (!m_running) { m_running = true; m_finished = false; - static const QLatin1String kPreferenceDialogSize("Core/PreferenceDialogSize"); + static const char kPreferenceDialogSize[] = "Core/PreferenceDialogSize"; const QSize initialSize(kInitialWidth, kInitialHeight); resize(ICore::settings()->value(kPreferenceDialogSize, initialSize).toSize()); exec(); diff --git a/src/plugins/coreplugin/foldernavigationwidget.cpp b/src/plugins/coreplugin/foldernavigationwidget.cpp index 7460f427b5c..3bf45137557 100644 --- a/src/plugins/coreplugin/foldernavigationwidget.cpp +++ b/src/plugins/coreplugin/foldernavigationwidget.cpp @@ -841,7 +841,7 @@ void FolderNavigationWidgetFactory::saveSettings(Utils::QtcSettings *settings, { auto fnw = qobject_cast(widget); QTC_ASSERT(fnw, return); - const QString base = kSettingsBase + QString::number(position); + const Key base = kSettingsBase + Key::number(position); settings->setValueWithDefault(base + kHiddenFilesKey, fnw->hiddenFilesFilter(), kHiddenFilesDefault); diff --git a/src/plugins/coreplugin/generalsettings.cpp b/src/plugins/coreplugin/generalsettings.cpp index 1f7da60d157..13f853e7592 100644 --- a/src/plugins/coreplugin/generalsettings.cpp +++ b/src/plugins/coreplugin/generalsettings.cpp @@ -269,7 +269,7 @@ void GeneralSettingsWidget::setLanguage(const QString &locale) dialog.exec(); } - settings->setValueWithDefault(QLatin1String("General/OverrideLanguage"), locale, {}); + settings->setValueWithDefault("General/OverrideLanguage", locale, {}); } void GeneralSettingsWidget::fillCodecBox() const diff --git a/src/plugins/coreplugin/ioutputpane.h b/src/plugins/coreplugin/ioutputpane.h index 9193699ca4a..1b65bad61e9 100644 --- a/src/plugins/coreplugin/ioutputpane.h +++ b/src/plugins/coreplugin/ioutputpane.h @@ -81,7 +81,7 @@ signals: void fontChanged(const QFont &font); protected: - void setupFilterUi(const QString &historyKey); + void setupFilterUi(const Utils::Key &historyKey); QString filterText() const; bool filterUsesRegexp() const { return m_filterRegexp; } bool filterIsInverted() const { return m_invertFilter; } diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp index 2c2634d9478..90b667b0500 100644 --- a/src/plugins/coreplugin/navigationwidget.cpp +++ b/src/plugins/coreplugin/navigationwidget.cpp @@ -249,11 +249,9 @@ void NavigationWidget::setFactories(const QList &fac updateToggleText(); } -QString NavigationWidget::settingsGroup() const +Key NavigationWidget::settingsGroup() const { - const QString side(d->m_side == Side::Left ? QStringLiteral("Left") - : QStringLiteral("Right")); - return QStringLiteral("Navigation%1").arg(side); + return d->m_side == Side::Left ? Key("NavigationLeft") : Key("NavigationRight"); } int NavigationWidget::storedWidth() @@ -400,12 +398,12 @@ void NavigationWidget::saveSettings(QtcSettings *settings) settings->setValue(settingsKey("VerticalPosition"), saveState()); settings->setValue(settingsKey("Width"), d->m_width); - const QString activationKey = QStringLiteral("ActivationPosition."); + const Key activationKey = "ActivationPosition."; const auto keys = NavigationWidgetPrivate::s_activationsMap.keys(); for (const auto &factoryId : keys) { const auto &info = NavigationWidgetPrivate::s_activationsMap[factoryId]; if (info.side == d->m_side) - settings->setValue(settingsKey(activationKey + factoryId.toString()), info.position); + settings->setValue(settingsKey(activationKey + factoryId.name()), info.position); } } @@ -524,9 +522,9 @@ int NavigationWidget::factoryIndex(Id id) return -1; } -QString NavigationWidget::settingsKey(const QString &key) const +Key NavigationWidget::settingsKey(const Key &key) const { - return QStringLiteral("%1/%2").arg(settingsGroup(), key); + return settingsGroup() + '/' + key; } QHash NavigationWidget::commandMap() const diff --git a/src/plugins/coreplugin/navigationwidget.h b/src/plugins/coreplugin/navigationwidget.h index 776fd682d49..bf5fceff880 100644 --- a/src/plugins/coreplugin/navigationwidget.h +++ b/src/plugins/coreplugin/navigationwidget.h @@ -6,6 +6,7 @@ #include #include +#include #include @@ -69,7 +70,7 @@ public: void setFactories(const QList &factories); - QString settingsGroup() const; + Utils::Key settingsGroup() const; void saveSettings(Utils::QtcSettings *settings); void restoreSettings(QSettings *settings); @@ -98,7 +99,7 @@ private: void updateToggleText(); Internal::NavigationSubWidget *insertSubItem(int position, int factoryIndex); int factoryIndex(Utils::Id id); - QString settingsKey(const QString &key) const; + Utils::Key settingsKey(const Utils::Key &key) const; NavigationWidgetPrivate *d; }; diff --git a/src/plugins/coreplugin/outputpanemanager.cpp b/src/plugins/coreplugin/outputpanemanager.cpp index 7f46e63f29c..04c61e35b61 100644 --- a/src/plugins/coreplugin/outputpanemanager.cpp +++ b/src/plugins/coreplugin/outputpanemanager.cpp @@ -117,7 +117,7 @@ void IOutputPane::setWheelZoomEnabled(bool enabled) emit wheelZoomEnabledChanged(enabled); } -void IOutputPane::setupFilterUi(const QString &historyKey) +void IOutputPane::setupFilterUi(const Key &historyKey) { m_filterOutputLineEdit = new FancyLineEdit; m_filterActionRegexp = new QAction(this); diff --git a/src/plugins/coreplugin/outputwindow.cpp b/src/plugins/coreplugin/outputwindow.cpp index 2de95d1b0ba..dfc7e0c9d87 100644 --- a/src/plugins/coreplugin/outputwindow.cpp +++ b/src/plugins/coreplugin/outputwindow.cpp @@ -50,7 +50,7 @@ public: { } - QString settingsKey; + Key settingsKey; OutputFormatter formatter; QList> queuedOutput; QTimer queueTimer; @@ -77,7 +77,7 @@ public: /*******************/ -OutputWindow::OutputWindow(Context context, const QString &settingsKey, QWidget *parent) +OutputWindow::OutputWindow(Context context, const Key &settingsKey, QWidget *parent) : QPlainTextEdit(parent) , d(new Internal::OutputWindowPrivate(document())) { diff --git a/src/plugins/coreplugin/outputwindow.h b/src/plugins/coreplugin/outputwindow.h index baf58cc22c4..83681a988e4 100644 --- a/src/plugins/coreplugin/outputwindow.h +++ b/src/plugins/coreplugin/outputwindow.h @@ -6,6 +6,7 @@ #include "core_global.h" #include "icontext.h" +#include #include #include @@ -32,7 +33,7 @@ public: }; Q_DECLARE_FLAGS(FilterModeFlags, FilterModeFlag) - OutputWindow(Context context, const QString &settingsKey, QWidget *parent = nullptr); + OutputWindow(Context context, const Utils::Key &settingsKey, QWidget *parent = nullptr); ~OutputWindow() override; void setLineParsers(const QList &parsers); diff --git a/src/plugins/texteditor/behaviorsettings.cpp b/src/plugins/texteditor/behaviorsettings.cpp index f8356d6916e..0a638867165 100644 --- a/src/plugins/texteditor/behaviorsettings.cpp +++ b/src/plugins/texteditor/behaviorsettings.cpp @@ -33,18 +33,18 @@ BehaviorSettings::BehaviorSettings() : { } -void BehaviorSettings::toSettings(const QString &category) const +void BehaviorSettings::toSettings(const Key &category) const { - Utils::toSettings(QLatin1String(groupPostfix), category, Core::ICore::settings(), this); + Utils::toSettings(groupPostfix, category, Core::ICore::settings(), this); } -void BehaviorSettings::fromSettings(const QString &category) +void BehaviorSettings::fromSettings(const Key &category) { *this = BehaviorSettings(); - Utils::fromSettings(QLatin1String(groupPostfix), category, Core::ICore::settings(), this); + Utils::fromSettings(groupPostfix, category, Core::ICore::settings(), this); } -QVariantMap BehaviorSettings::toMap() const +Store BehaviorSettings::toMap() const { return { {mouseHidingKey, m_mouseHiding}, diff --git a/src/plugins/texteditor/behaviorsettings.h b/src/plugins/texteditor/behaviorsettings.h index a4a1f60fce7..e33fe5a2573 100644 --- a/src/plugins/texteditor/behaviorsettings.h +++ b/src/plugins/texteditor/behaviorsettings.h @@ -18,8 +18,8 @@ class TEXTEDITOR_EXPORT BehaviorSettings public: BehaviorSettings(); - void toSettings(const QString &category) const; - void fromSettings(const QString &category); + void toSettings(const Utils::Key &category) const; + void fromSettings(const Utils::Key &category); Utils::Store toMap() const; void fromMap(const Utils::Store &map); diff --git a/src/plugins/texteditor/behaviorsettingspage.cpp b/src/plugins/texteditor/behaviorsettingspage.cpp index 2fcbdab4ccb..705f8ba8d20 100644 --- a/src/plugins/texteditor/behaviorsettingspage.cpp +++ b/src/plugins/texteditor/behaviorsettingspage.cpp @@ -33,6 +33,8 @@ #include #include +using namespace Utils; + namespace TextEditor { class BehaviorSettingsPagePrivate : public QObject @@ -40,7 +42,7 @@ class BehaviorSettingsPagePrivate : public QObject public: BehaviorSettingsPagePrivate(); - const QString m_settingsPrefix{"text"}; + const Key m_settingsPrefix{"text"}; TextEditor::BehaviorSettingsWidget *m_behaviorWidget = nullptr; CodeStylePool *m_defaultCodeStylePool = nullptr; diff --git a/src/plugins/texteditor/extraencodingsettings.cpp b/src/plugins/texteditor/extraencodingsettings.cpp index 34c46e8cf62..91587f19464 100644 --- a/src/plugins/texteditor/extraencodingsettings.cpp +++ b/src/plugins/texteditor/extraencodingsettings.cpp @@ -23,19 +23,19 @@ ExtraEncodingSettings::ExtraEncodingSettings() : m_utf8BomSetting(OnlyKeep) ExtraEncodingSettings::~ExtraEncodingSettings() = default; -void ExtraEncodingSettings::toSettings(const QString &category) const +void ExtraEncodingSettings::toSettings(const Key &category) const { Q_UNUSED(category) - Utils::toSettings(QLatin1String(kGroupPostfix), QString(), Core::ICore::settings(), this); + Utils::toSettings(kGroupPostfix, Key(), Core::ICore::settings(), this); } -void ExtraEncodingSettings::fromSettings(const QString &category) +void ExtraEncodingSettings::fromSettings(const Key &category) { Q_UNUSED(category) *this = ExtraEncodingSettings(); - Utils::fromSettings(QLatin1String(kGroupPostfix), QString(), Core::ICore::settings(), this); + Utils::fromSettings(kGroupPostfix, Key(), Core::ICore::settings(), this); } QVariantMap ExtraEncodingSettings::toMap() const diff --git a/src/plugins/texteditor/extraencodingsettings.h b/src/plugins/texteditor/extraencodingsettings.h index 1104bd0354b..7f64dd09938 100644 --- a/src/plugins/texteditor/extraencodingsettings.h +++ b/src/plugins/texteditor/extraencodingsettings.h @@ -16,7 +16,7 @@ public: ~ExtraEncodingSettings(); void toSettings(const QString &category) const; - void fromSettings(const QString &category); + void fromSettings(const Utils::Key &category); Utils::Store toMap() const; void fromMap(const Utils::Store &map); diff --git a/src/plugins/texteditor/findinfiles.cpp b/src/plugins/texteditor/findinfiles.cpp index 64b2a78fb76..8156c10b18c 100644 --- a/src/plugins/texteditor/findinfiles.cpp +++ b/src/plugins/texteditor/findinfiles.cpp @@ -142,8 +142,7 @@ QWidget *FindInFiles::createConfigWidget() connect(m_directory.data(), &PathChooser::textChanged, this, [this] { setSearchDir(m_directory->filePath()); }); connect(this, &BaseFileFind::searchDirChanged, m_directory, &PathChooser::setFilePath); - m_directory->setHistoryCompleter(QLatin1String(HistoryKey), - /*restoreLastItemFromHistory=*/ true); + m_directory->setHistoryCompleter(HistoryKey, /*restoreLastItemFromHistory=*/ true); if (!HistoryCompleter::historyExistsFor(QLatin1String(HistoryKey))) { auto completer = static_cast(m_directory->lineEdit()->completer()); const QStringList legacyHistory = ICore::settings()->value( diff --git a/src/plugins/texteditor/icodestylepreferences.cpp b/src/plugins/texteditor/icodestylepreferences.cpp index 1f98062712c..3fffa8401a3 100644 --- a/src/plugins/texteditor/icodestylepreferences.cpp +++ b/src/plugins/texteditor/icodestylepreferences.cpp @@ -27,7 +27,7 @@ public: bool m_readOnly = false; bool m_temporarilyReadOnly = false; bool m_isAdditionalTabDisabled = false; - QString m_settingsSuffix; + Key m_settingsSuffix; }; } @@ -207,17 +207,17 @@ void ICodeStylePreferences::setCurrentDelegate(const QByteArray &id) setCurrentDelegate(d->m_pool->codeStyle(id)); } -void ICodeStylePreferences::setSettingsSuffix(const QString &suffix) +void ICodeStylePreferences::setSettingsSuffix(const Key &suffix) { d->m_settingsSuffix = suffix; } -void ICodeStylePreferences::toSettings(const QString &category) const +void ICodeStylePreferences::toSettings(const Key &category) const { Utils::toSettings(d->m_settingsSuffix, category, Core::ICore::settings(), this); } -void ICodeStylePreferences::fromSettings(const QString &category) +void ICodeStylePreferences::fromSettings(const Key &category) { Utils::fromSettings(d->m_settingsSuffix, category, Core::ICore::settings(), this); } diff --git a/src/plugins/texteditor/icodestylepreferences.h b/src/plugins/texteditor/icodestylepreferences.h index a3eedfb5c57..1305e0679a6 100644 --- a/src/plugins/texteditor/icodestylepreferences.h +++ b/src/plugins/texteditor/icodestylepreferences.h @@ -64,9 +64,9 @@ public: QByteArray currentDelegateId() const; void setCurrentDelegate(const QByteArray &id); - void setSettingsSuffix(const QString &suffix); + void setSettingsSuffix(const Utils::Key &suffix); void toSettings(const QString &category) const; - void fromSettings(const QString &category); + void fromSettings(const Utils::Key &category); // make below 2 protected? virtual Utils::Store toMap() const; diff --git a/src/plugins/texteditor/storagesettings.cpp b/src/plugins/texteditor/storagesettings.cpp index b70eb3ec144..6352bf3e566 100644 --- a/src/plugins/texteditor/storagesettings.cpp +++ b/src/plugins/texteditor/storagesettings.cpp @@ -9,7 +9,6 @@ #include #include -#include using namespace Utils; @@ -34,15 +33,15 @@ StorageSettings::StorageSettings() { } -void StorageSettings::toSettings(const QString &category) const +void StorageSettings::toSettings(const Key &category) const { - Utils::toSettings(QLatin1String(groupPostfix), category, Core::ICore::settings(), this); + Utils::toSettings(groupPostfix, category, Core::ICore::settings(), this); } -void StorageSettings::fromSettings(const QString &category) +void StorageSettings::fromSettings(const Key &category) { *this = StorageSettings(); - Utils::fromSettings(QLatin1String(groupPostfix), category, Core::ICore::settings(), this); + Utils::fromSettings(groupPostfix, category, Core::ICore::settings(), this); } Store StorageSettings::toMap() const diff --git a/src/plugins/texteditor/storagesettings.h b/src/plugins/texteditor/storagesettings.h index bff84b6fc00..bf3ac1ba32a 100644 --- a/src/plugins/texteditor/storagesettings.h +++ b/src/plugins/texteditor/storagesettings.h @@ -14,8 +14,8 @@ class TEXTEDITOR_EXPORT StorageSettings public: StorageSettings(); - void toSettings(const QString &category) const; - void fromSettings(const QString &category); + void toSettings(const Utils::Key &category) const; + void fromSettings(const Utils::Key &category); Utils::Store toMap() const; void fromMap(const Utils::Store &map); diff --git a/src/plugins/texteditor/tabsettings.cpp b/src/plugins/texteditor/tabsettings.cpp index a11b564994c..2668d4f88f6 100644 --- a/src/plugins/texteditor/tabsettings.cpp +++ b/src/plugins/texteditor/tabsettings.cpp @@ -7,7 +7,6 @@ #include #include -#include #include #include @@ -34,18 +33,18 @@ TabSettings::TabSettings(TabSettings::TabPolicy tabPolicy, } -void TabSettings::toSettings(const QString &category, QSettings *s) const +void TabSettings::toSettings(const Key &category, QSettings *s) const { - Utils::toSettings(QLatin1String(groupPostfix), category, s, this); + Utils::toSettings(groupPostfix, category, s, this); } -void TabSettings::fromSettings(const QString &category, QSettings *s) +void TabSettings::fromSettings(const Key &category, QSettings *s) { *this = TabSettings(); // Assign defaults - Utils::fromSettings(QLatin1String(groupPostfix), category, s, this); + Utils::fromSettings(groupPostfix, category, s, this); } -QVariantMap TabSettings::toMap() const +Store TabSettings::toMap() const { return { {spacesForTabsKey, m_tabPolicy != TabsOnlyTabPolicy}, diff --git a/src/plugins/texteditor/tabsettings.h b/src/plugins/texteditor/tabsettings.h index 57adca91a05..a4a6f1c3f27 100644 --- a/src/plugins/texteditor/tabsettings.h +++ b/src/plugins/texteditor/tabsettings.h @@ -38,8 +38,8 @@ public: TabSettings(TabPolicy tabPolicy, int tabSize, int indentSize, ContinuationAlignBehavior continuationAlignBehavior); - void toSettings(const QString &category, QSettings *s) const; - void fromSettings(const QString &category, QSettings *s); + void toSettings(const Utils::Key &category, QSettings *s) const; + void fromSettings(const Utils::Key &category, QSettings *s); Utils::Store toMap() const; void fromMap(const Utils::Store &map); diff --git a/src/plugins/texteditor/typingsettings.cpp b/src/plugins/texteditor/typingsettings.cpp index 7fa6b84c7e9..402d472848c 100644 --- a/src/plugins/texteditor/typingsettings.cpp +++ b/src/plugins/texteditor/typingsettings.cpp @@ -28,15 +28,15 @@ TypingSettings::TypingSettings(): { } -void TypingSettings::toSettings(const QString &category) const +void TypingSettings::toSettings(const Key &category) const { - Utils::toSettings(QLatin1String(groupPostfix), category, Core::ICore::settings(), this); + Utils::toSettings(groupPostfix, category, Core::ICore::settings(), this); } -void TypingSettings::fromSettings(const QString &category) +void TypingSettings::fromSettings(const Key &category) { *this = TypingSettings(); // Assign defaults - Utils::fromSettings(QLatin1String(groupPostfix), category, Core::ICore::settings(), this); + Utils::fromSettings(groupPostfix, category, Core::ICore::settings(), this); } Store TypingSettings::toMap() const diff --git a/src/plugins/texteditor/typingsettings.h b/src/plugins/texteditor/typingsettings.h index 8cb9eee8d13..63b1e6bea18 100644 --- a/src/plugins/texteditor/typingsettings.h +++ b/src/plugins/texteditor/typingsettings.h @@ -35,8 +35,8 @@ public: bool tabShouldIndent(const QTextDocument *document, const QTextCursor &cursor, int *suggestedPosition) const; - void toSettings(const QString &category) const; - void fromSettings(const QString &category); + void toSettings(const Utils::Key &category) const; + void fromSettings(const Utils::Key &category); Utils::Store toMap() const; void fromMap(const Utils::Store &map);