Plugins: A bit more Keys and Store

Change-Id: Iee55eeaa881dd9f2047fdbe95ad8d827f4ba34e0
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-08-24 16:14:26 +02:00
parent e1e1af36d2
commit 8d0aa34bfc
53 changed files with 243 additions and 239 deletions

View File

@@ -30,7 +30,7 @@ public:
CMakeToolSettingsUpgraderV0() : VersionUpgrader(0, "4.6") { }
// NOOP
QVariantMap upgrade(const QVariantMap &data) final { return data; }
Store upgrade(const Store &data) final { return data; }
};
// --------------------------------------------------------------------
@@ -170,8 +170,8 @@ void CMakeToolSettingsAccessor::saveCMakeTools(const QList<CMakeTool *> &cmakeTo
const Id &defaultId,
QWidget *parent)
{
QVariantMap data;
data.insert(QLatin1String(CMAKE_TOOL_DEFAULT_KEY), defaultId.toSetting());
Store data;
data.insert(CMAKE_TOOL_DEFAULT_KEY, defaultId.toSetting());
int count = 0;
const bool autoRun = settings().autorunCMake();
@@ -183,30 +183,30 @@ void CMakeToolSettingsAccessor::saveCMakeTools(const QList<CMakeTool *> &cmakeTo
item->setAutorun(autoRun);
if (fi.needsDevice() || fi.isExecutableFile()) { // be graceful for device related stuff
QVariantMap tmp = item->toMap();
Store tmp = item->toMap();
if (tmp.isEmpty())
continue;
data.insert(QString::fromLatin1(CMAKE_TOOL_DATA_KEY) + QString::number(count), tmp);
data.insert(CMAKE_TOOL_DATA_KEY + Key::number(count), QVariant::fromValue(tmp));
++count;
}
}
data.insert(QLatin1String(CMAKE_TOOL_COUNT_KEY), count);
data.insert(CMAKE_TOOL_COUNT_KEY, count);
saveSettings(data, parent);
}
CMakeToolSettingsAccessor::CMakeTools
CMakeToolSettingsAccessor::cmakeTools(const QVariantMap &data, bool fromSdk) const
CMakeToolSettingsAccessor::cmakeTools(const Store &data, bool fromSdk) const
{
CMakeTools result;
int count = data.value(QLatin1String(CMAKE_TOOL_COUNT_KEY), 0).toInt();
int count = data.value(CMAKE_TOOL_COUNT_KEY, 0).toInt();
for (int i = 0; i < count; ++i) {
const QString key = QString::fromLatin1(CMAKE_TOOL_DATA_KEY) + QString::number(i);
const Key key = CMAKE_TOOL_DATA_KEY + Key::number(i);
if (!data.contains(key))
continue;
const QVariantMap dbMap = data.value(key).toMap();
const Store dbMap = data.value(key).value<Store>();
auto item = std::make_unique<CMakeTool>(dbMap, fromSdk);
const FilePath cmakeExecutable = item->cmakeExecutable();
if (item->isAutoDetected() && !cmakeExecutable.needsDevice() && !cmakeExecutable.isExecutableFile()) {