BareMetal: Remove qualifiers from setting keys

They're pure noise, since there should be no conflicts between base and
derived classes, and there can't be multiple classes for the same provider.

This maintains compatibility when upgrading from earlier versions, but not
for downgrades.

Change-Id: I02655410172ff170fca4893f7b37c2fb1f316aff
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Orgad Shaneh
2020-10-26 10:38:59 +02:00
committed by Orgad Shaneh
parent 0a4a1693ec
commit f487e471aa
18 changed files with 101 additions and 109 deletions

View File

@@ -117,7 +117,13 @@ void DebugServerProviderManager::restoreProviders()
if (!data.contains(key))
break;
const QVariantMap map = data.value(key).toMap();
QVariantMap map = data.value(key).toMap();
const QStringList keys = map.keys();
for (const QString &key : keys) {
const int lastDot = key.lastIndexOf('.');
if (lastDot != -1)
map[key.mid(lastDot + 1)] = map[key];
}
bool restored = false;
for (IDebugServerProviderFactory *f : qAsConst(m_factories)) {
if (f->canRestore(map)) {

View File

@@ -46,17 +46,17 @@ using namespace Utils;
namespace BareMetal {
namespace Internal {
const char executableFileKeyC[] = "BareMetal.EBlinkGdbServerProvider.ExecutableFile";
const char verboseLevelKeyC[] = "BareMetal.EBlinkGdbServerProvider.VerboseLevel";
const char deviceScriptC[] = "BareMetal.EBlinkGdbServerProvider.DeviceScript";
const char interfaceTypeC[] = "BareMetal.EBlinkGdbServerProvider.InterfaceType";
const char interfaceResetOnConnectC[] = "BareMetal.EBlinkGdbServerProvider.interfaceResetOnConnect";
const char interfaceSpeedC[] = "BareMetal.EBlinkGdbServerProvider.InterfaceSpeed";
const char interfaceExplicidDeviceC[] = "BareMetal.EBlinkGdbServerProvider.InterfaceExplicidDevice";
const char targetNameC[] = "BareMetal.EBlinkGdbServerProvider.TargetName";
const char targetDisableStackC[] = "BareMetal.EBlinkGdbServerProvider.TargetDisableStack";
const char gdbShutDownAfterDisconnectC[] = "BareMetal.EBlinkGdbServerProvider.GdbShutDownAfterDisconnect";
const char gdbNotUseCacheC[] = "BareMetal.EBlinkGdbServerProvider.GdbNotUseCache";
const char executableFileKeyC[] = "ExecutableFile";
const char verboseLevelKeyC[] = "VerboseLevel";
const char deviceScriptC[] = "DeviceScript";
const char interfaceTypeC[] = "InterfaceType";
const char interfaceResetOnConnectC[] = "interfaceResetOnConnect";
const char interfaceSpeedC[] = "InterfaceSpeed";
const char interfaceExplicidDeviceC[] = "InterfaceExplicidDevice";
const char targetNameC[] = "TargetName";
const char targetDisableStackC[] = "TargetDisableStack";
const char gdbShutDownAfterDisconnectC[] = "GdbShutDownAfterDisconnect";
const char gdbNotUseCacheC[] = "GdbNotUseCache";
// EBlinkGdbServerProvider
@@ -66,7 +66,6 @@ EBlinkGdbServerProvider::EBlinkGdbServerProvider()
setInitCommands(defaultInitCommands());
setResetCommands(defaultResetCommands());
setChannel("127.0.0.1", 2331);
setSettingsKeyBase("BareMetal.EBlinkGdbServerProvider");
setTypeDisplayName(GdbServerProvider::tr("EBlink"));
setConfigurationWidgetCreator([this] { return new EBlinkGdbServerProviderConfigWidget(this); });
}

View File

@@ -49,11 +49,11 @@ using namespace Utils;
namespace BareMetal {
namespace Internal {
const char startupModeKeyC[] = "BareMetal.GdbServerProvider.Mode";
const char peripheralDescriptionFileKeyC[] = "BareMetal.GdbServerProvider.PeripheralDescriptionFile";
const char initCommandsKeyC[] = "BareMetal.GdbServerProvider.InitCommands";
const char resetCommandsKeyC[] = "BareMetal.GdbServerProvider.ResetCommands";
const char useExtendedRemoteKeyC[] = "BareMetal.GdbServerProvider.UseExtendedRemote";
const char startupModeKeyC[] = "Mode";
const char peripheralDescriptionFileKeyC[] = "PeripheralDescriptionFile";
const char initCommandsKeyC[] = "InitCommands";
const char resetCommandsKeyC[] = "ResetCommands";
const char useExtendedRemoteKeyC[] = "UseExtendedRemote";
// GdbServerProvider

View File

@@ -44,7 +44,6 @@ GenericGdbServerProvider::GenericGdbServerProvider()
: GdbServerProvider(Constants::GDBSERVER_GENERIC_PROVIDER_ID)
{
setChannel("localhost", 3333);
setSettingsKeyBase("BareMetal.GenericGdbServerProvider");
setTypeDisplayName(GdbServerProvider::tr("Generic"));
setConfigurationWidgetCreator([this] { return new GenericGdbServerProviderConfigWidget(this); });
}

View File

@@ -46,13 +46,13 @@ using namespace Utils;
namespace BareMetal {
namespace Internal {
const char executableFileKeyC[] = "BareMetal.JLinkGdbServerProvider.ExecutableFile";
const char jlinkDeviceKeyC[] = "BareMetal.JLinkGdbServerProvider.JLinkDevice";
const char jlinkHostInterfaceKeyC[] = "BareMetal.JLinkGdbServerProvider.JLinkHostInterface";
const char jlinkHostInterfaceIPAddressKeyC[] = "BareMetal.JLinkGdbServerProvider.JLinkHostInterfaceIPAddress";
const char jlinkTargetInterfaceKeyC[] = "BareMetal.JLinkGdbServerProvider.JLinkTargetInterface";
const char jlinkTargetInterfaceSpeedKeyC[] = "BareMetal.JLinkGdbServerProvider.JLinkTargetInterfaceSpeed";
const char additionalArgumentsKeyC[] = "BareMetal.JLinkGdbServerProvider.AdditionalArguments";
const char executableFileKeyC[] = "ExecutableFile";
const char jlinkDeviceKeyC[] = "JLinkDevice";
const char jlinkHostInterfaceKeyC[] = "JLinkHostInterface";
const char jlinkHostInterfaceIPAddressKeyC[] = "JLinkHostInterfaceIPAddress";
const char jlinkTargetInterfaceKeyC[] = "JLinkTargetInterface";
const char jlinkTargetInterfaceSpeedKeyC[] = "JLinkTargetInterfaceSpeed";
const char additionalArgumentsKeyC[] = "AdditionalArguments";
// JLinkGdbServerProvider
@@ -62,7 +62,6 @@ JLinkGdbServerProvider::JLinkGdbServerProvider()
setInitCommands(defaultInitCommands());
setResetCommands(defaultResetCommands());
setChannel("localhost", 2331);
setSettingsKeyBase("BareMetal.JLinkGdbServerProvider");
setTypeDisplayName(GdbServerProvider::tr("JLink"));
setConfigurationWidgetCreator([this] { return new JLinkGdbServerProviderConfigWidget(this); });
}

View File

@@ -44,10 +44,10 @@ using namespace Utils;
namespace BareMetal {
namespace Internal {
const char executableFileKeyC[] = "BareMetal.OpenOcdGdbServerProvider.ExecutableFile";
const char rootScriptsDirKeyC[] = "BareMetal.OpenOcdGdbServerProvider.RootScriptsDir";
const char configurationFileKeyC[] = "BareMetal.OpenOcdGdbServerProvider.ConfigurationPath";
const char additionalArgumentsKeyC[] = "BareMetal.OpenOcdGdbServerProvider.AdditionalArguments";
const char executableFileKeyC[] = "ExecutableFile";
const char rootScriptsDirKeyC[] = "RootScriptsDir";
const char configurationFileKeyC[] = "ConfigurationPath";
const char additionalArgumentsKeyC[] = "AdditionalArguments";
// OpenOcdGdbServerProvider
@@ -57,7 +57,6 @@ OpenOcdGdbServerProvider::OpenOcdGdbServerProvider()
setInitCommands(defaultInitCommands());
setResetCommands(defaultResetCommands());
setChannel("localhost", 3333);
setSettingsKeyBase("BareMetal.OpenOcdGdbServerProvider");
setTypeDisplayName(GdbServerProvider::tr("OpenOCD"));
setConfigurationWidgetCreator([this] { return new OpenOcdGdbServerProviderConfigWidget(this); });
}

View File

@@ -44,11 +44,11 @@ using namespace Utils;
namespace BareMetal {
namespace Internal {
const char executableFileKeyC[] = "BareMetal.StLinkUtilGdbServerProvider.ExecutableFile";
const char verboseLevelKeyC[] = "BareMetal.StLinkUtilGdbServerProvider.VerboseLevel";
const char extendedModeKeyC[] = "BareMetal.StLinkUtilGdbServerProvider.ExtendedMode";
const char resetBoardKeyC[] = "BareMetal.StLinkUtilGdbServerProvider.ResetBoard";
const char transportLayerKeyC[] = "BareMetal.StLinkUtilGdbServerProvider.TransportLayer";
const char executableFileKeyC[] = "ExecutableFile";
const char verboseLevelKeyC[] = "VerboseLevel";
const char extendedModeKeyC[] = "ExtendedMode";
const char resetBoardKeyC[] = "ResetBoard";
const char transportLayerKeyC[] = "TransportLayer";
// StLinkUtilGdbServerProvider
@@ -58,7 +58,6 @@ StLinkUtilGdbServerProvider::StLinkUtilGdbServerProvider()
setInitCommands(defaultInitCommands());
setResetCommands(defaultResetCommands());
setChannel("localhost", 4242);
setSettingsKeyBase("BareMetal.StLinkUtilGdbServerProvider");
setTypeDisplayName(GdbServerProvider::tr("ST-LINK Utility"));
setConfigurationWidgetCreator([this] { return new StLinkUtilGdbServerProviderConfigWidget(this); });
}

View File

@@ -52,9 +52,9 @@ namespace Internal {
using namespace Uv;
constexpr char adapterOptionsKeyC[] = "BareMetal.JLinkUvscServerProvider.AdapterOptions";
constexpr char adapterPortKeyC[] = "BareMetal.JLinkUvscServerProvider.AdapterPort";
constexpr char adapterSpeedKeyC[] = "BareMetal.JLinkUvscServerProvider.AdapterSpeed";
constexpr char adapterOptionsKeyC[] = "AdapterOptions";
constexpr char adapterPortKeyC[] = "AdapterPort";
constexpr char adapterSpeedKeyC[] = "AdapterSpeed";
static int decodeSpeedCode(JLinkUvscAdapterOptions::Speed speed)
{

View File

@@ -50,7 +50,7 @@ namespace Internal {
using namespace Uv;
const char limitSpeedKeyC[] = "BareMetal.SimulatorUvscServerProvider.LimitSpeed";
const char limitSpeedKeyC[] = "LimitSpeed";
static DriverSelection defaultSimulatorDriverSelection()
{

View File

@@ -52,9 +52,9 @@ namespace Internal {
using namespace Uv;
constexpr char adapterOptionsKeyC[] = "BareMetal.StLinkUvscServerProvider.AdapterOptions";
constexpr char adapterPortKeyC[] = "BareMetal.StLinkUvscServerProvider.AdapterPort";
constexpr char adapterSpeedKeyC[] = "BareMetal.StLinkUvscServerProvider.AdapterSpeed";
constexpr char adapterOptionsKeyC[] = "AdapterOptions";
constexpr char adapterPortKeyC[] = "AdapterPort";
constexpr char adapterSpeedKeyC[] = "AdapterSpeed";
static QString buildAdapterOptions(const StLinkUvscAdapterOptions &opts)
{

View File

@@ -58,9 +58,9 @@ namespace Internal {
using namespace Uv;
// Whole software package selection keys.
constexpr char toolsIniKeyC[] = "BareMetal.UvscServerProvider.ToolsIni";
constexpr char deviceSelectionKeyC[] = "BareMetal.UvscServerProvider.DeviceSelection";
constexpr char driverSelectionKeyC[] = "BareMetal.UvscServerProvider.DriverSelection";
constexpr char toolsIniKeyC[] = "ToolsIni";
constexpr char deviceSelectionKeyC[] = "DeviceSelection";
constexpr char driverSelectionKeyC[] = "DriverSelection";
constexpr int defaultPortNumber = 5101;

View File

@@ -38,39 +38,39 @@ namespace Internal {
namespace Uv {
// Software package data keys.
constexpr char packageDescrKeyC[] = "BareMetal.UvscServerProvider.PackageDescription";
constexpr char packageFileKeyC[] = "BareMetal.UvscServerProvider.PackageFile";
constexpr char packageNameKeyC[] = "BareMetal.UvscServerProvider.PackageName";
constexpr char packageUrlKeyC[] = "BareMetal.UvscServerProvider.PackageUrl";
constexpr char packageVendorNameKeyC[] = "BareMetal.UvscServerProvider.PackageVendorName";
constexpr char packageVendorIdKeyC[] = "BareMetal.UvscServerProvider.PackageVendorId";
constexpr char packageVersionKeyC[] = "BareMetal.UvscServerProvider.PackageVersion";
constexpr char packageDescrKeyC[] = "PackageDescription";
constexpr char packageFileKeyC[] = "PackageFile";
constexpr char packageNameKeyC[] = "PackageName";
constexpr char packageUrlKeyC[] = "PackageUrl";
constexpr char packageVendorNameKeyC[] = "PackageVendorName";
constexpr char packageVendorIdKeyC[] = "PackageVendorId";
constexpr char packageVersionKeyC[] = "PackageVersion";
// Device data keys.
constexpr char deviceNameKeyC[] = "BareMetal.UvscServerProvider.DeviceName";
constexpr char deviceDescrKeyC[] = "BareMetal.UvscServerProvider.DeviceDescription";
constexpr char deviceFamilyKeyC[] = "BareMetal.UvscServerProvider.DeviceFamily";
constexpr char deviceSubFamilyKeyC[] = "BareMetal.UvscServerProvider.DeviceSubFamily";
constexpr char deviceVendorNameKeyC[] = "BareMetal.UvscServerProvider.DeviceVendorName";
constexpr char deviceVendorIdKeyC[] = "BareMetal.UvscServerProvider.DeviceVendorId";
constexpr char deviceSvdKeyC[] = "BareMetal.UvscServerProvider.DeviceSVD";
constexpr char deviceNameKeyC[] = "DeviceName";
constexpr char deviceDescrKeyC[] = "DeviceDescription";
constexpr char deviceFamilyKeyC[] = "DeviceFamily";
constexpr char deviceSubFamilyKeyC[] = "DeviceSubFamily";
constexpr char deviceVendorNameKeyC[] = "DeviceVendorName";
constexpr char deviceVendorIdKeyC[] = "DeviceVendorId";
constexpr char deviceSvdKeyC[] = "DeviceSVD";
// Device CPU data keys.
constexpr char deviceClockKeyC[] = "BareMetal.UvscServerProvider.DeviceClock";
constexpr char deviceCoreKeyC[] = "BareMetal.UvscServerProvider.DeviceCore";
constexpr char deviceFpuKeyC[] = "BareMetal.UvscServerProvider.DeviceFPU";
constexpr char deviceMpuKeyC[] = "BareMetal.UvscServerProvider.DeviceMPU";
constexpr char deviceClockKeyC[] = "DeviceClock";
constexpr char deviceCoreKeyC[] = "DeviceCore";
constexpr char deviceFpuKeyC[] = "DeviceFPU";
constexpr char deviceMpuKeyC[] = "DeviceMPU";
// Device MEMORY data keys.
constexpr char deviceMemoryKeyC[] = "BareMetal.UvscServerProvider.DeviceMemory";
constexpr char deviceMemoryIdKeyC[] = "BareMetal.UvscServerProvider.DeviceMemoryId";
constexpr char deviceMemoryStartKeyC[] = "BareMetal.UvscServerProvider.DeviceMemoryStart";
constexpr char deviceMemorySizeKeyC[] = "BareMetal.UvscServerProvider.DeviceMemorySize";
constexpr char deviceMemoryKeyC[] = "DeviceMemory";
constexpr char deviceMemoryIdKeyC[] = "DeviceMemoryId";
constexpr char deviceMemoryStartKeyC[] = "DeviceMemoryStart";
constexpr char deviceMemorySizeKeyC[] = "DeviceMemorySize";
// Device ALGORITHM data keys.
constexpr char deviceAlgorithmKeyC[] = "BareMetal.UvscServerProvider.DeviceAlgorithm";
constexpr char deviceAlgorithmPathKeyC[] = "BareMetal.UvscServerProvider.DeviceAlgorithmPath";
constexpr char deviceAlgorithmFlashStartKeyC[] = "BareMetal.UvscServerProvider.DeviceAlgorithmStart";
constexpr char deviceAlgorithmFlashSizeKeyC[] = "BareMetal.UvscServerProvider.DeviceAlgorithmSize";
constexpr char deviceAlgorithmRamStartKeyC[] = "BareMetal.UvscServerProvider.DeviceAlgorithmRamStart";
constexpr char deviceAlgorithmRamSizeKeyC[] = "BareMetal.UvscServerProvider.DeviceAlgorithmRamSize";
constexpr char deviceAlgorithmIndexKeyC[] = "BareMetal.UvscServerProvider.DeviceAlgorithmIndex";
constexpr char deviceAlgorithmKeyC[] = "DeviceAlgorithm";
constexpr char deviceAlgorithmPathKeyC[] = "DeviceAlgorithmPath";
constexpr char deviceAlgorithmFlashStartKeyC[] = "DeviceAlgorithmStart";
constexpr char deviceAlgorithmFlashSizeKeyC[] = "DeviceAlgorithmSize";
constexpr char deviceAlgorithmRamStartKeyC[] = "DeviceAlgorithmRamStart";
constexpr char deviceAlgorithmRamSizeKeyC[] = "DeviceAlgorithmRamSize";
constexpr char deviceAlgorithmIndexKeyC[] = "DeviceAlgorithmIndex";
// DeviceSelection

View File

@@ -36,11 +36,11 @@ namespace Internal {
namespace Uv {
// Driver data keys.
constexpr char driverIndexKeyC[] = "BareMetal.UvscServerProvider.DriverIndex";
constexpr char driverCpuDllIndexKeyC[] = "BareMetal.UvscServerProvider.DriverCpuDllIndex";
constexpr char driverDllKeyC[] = "BareMetal.UvscServerProvider.DriverDll";
constexpr char driverCpuDllsKeyC[] = "BareMetal.UvscServerProvider.DriverCpuDlls";
constexpr char driverNameKeyC[] = "BareMetal.UvscServerProvider.DriverName";
constexpr char driverIndexKeyC[] = "DriverIndex";
constexpr char driverCpuDllIndexKeyC[] = "DriverCpuDllIndex";
constexpr char driverDllKeyC[] = "DriverDll";
constexpr char driverCpuDllsKeyC[] = "DriverCpuDlls";
constexpr char driverNameKeyC[] = "DriverName";
// DriverSelection

View File

@@ -58,9 +58,9 @@ namespace Internal {
// Helpers:
static const char compilerCommandKeyC[] = "BareMetal.IarToolChain.CompilerPath";
static const char compilerPlatformCodeGenFlagsKeyC[] = "BareMetal.IarToolChain.PlatformCodeGenFlags";
static const char targetAbiKeyC[] = "BareMetal.IarToolChain.TargetAbi";
static const char compilerCommandKeyC[] = "CompilerPath";
static const char compilerPlatformCodeGenFlagsKeyC[] = "PlatformCodeGenFlags";
static const char targetAbiKeyC[] = "TargetAbi";
static bool compilerExists(const FilePath &compilerPath)
{

View File

@@ -43,12 +43,12 @@ using namespace ProjectExplorer;
namespace BareMetal {
namespace Internal {
const char idKeyC[] = "BareMetal.IDebugServerProvider.Id";
const char displayNameKeyC[] = "BareMetal.IDebugServerProvider.DisplayName";
const char engineTypeKeyC[] = "BareMetal.IDebugServerProvider.EngineType";
const char idKeyC[] = "Id";
const char displayNameKeyC[] = "DisplayName";
const char engineTypeKeyC[] = "EngineType";
const char hostKeySuffixC[] = ".Host";
const char portKeySuffixC[] = ".Port";
const char hostKeyC[] = "Host";
const char portKeyC[] = "Port";
static QString createId(const QString &id)
{
@@ -139,11 +139,6 @@ void IDebugServerProvider::setEngineType(DebuggerEngineType engineType)
providerUpdated();
}
void IDebugServerProvider::setSettingsKeyBase(const QString &settingsBase)
{
m_settingsBase = settingsBase;
}
bool IDebugServerProvider::operator==(const IDebugServerProvider &other) const
{
if (this == &other)
@@ -170,8 +165,8 @@ QVariantMap IDebugServerProvider::toMap() const
{idKeyC, m_id},
{displayNameKeyC, m_displayName},
{engineTypeKeyC, m_engineType},
{m_settingsBase + hostKeySuffixC, m_channel.host()},
{m_settingsBase + portKeySuffixC, m_channel.port()},
{hostKeyC, m_channel.host()},
{portKeyC, m_channel.port()},
};
}
@@ -201,8 +196,8 @@ bool IDebugServerProvider::fromMap(const QVariantMap &data)
m_displayName = data.value(displayNameKeyC).toString();
m_engineType = static_cast<DebuggerEngineType>(
data.value(engineTypeKeyC, NoEngineType).toInt());
m_channel.setHost(data.value(m_settingsBase + hostKeySuffixC).toString());
m_channel.setPort(data.value(m_settingsBase + portKeySuffixC).toInt());
m_channel.setHost(data.value(hostKeyC).toString());
m_channel.setPort(data.value(portKeyC).toInt());
return true;
}
@@ -238,9 +233,7 @@ IDebugServerProvider *IDebugServerProviderFactory::create() const
IDebugServerProvider *IDebugServerProviderFactory::restore(const QVariantMap &data) const
{
IDebugServerProvider *p = m_creator();
const auto updated = data;
if (p->fromMap(updated))
if (p->fromMap(data))
return p;
delete p;
return nullptr;

View File

@@ -104,7 +104,6 @@ public:
protected:
void setTypeDisplayName(const QString &typeDisplayName);
void setEngineType(Debugger::DebuggerEngineType engineType);
void setSettingsKeyBase(const QString &settingsBase);
void providerUpdated();
void resetId();
@@ -112,7 +111,6 @@ protected:
QString m_id;
mutable QString m_displayName;
QString m_typeDisplayName;
QString m_settingsBase;
QUrl m_channel;
Debugger::DebuggerEngineType m_engineType = Debugger::NoEngineType;
QSet<BareMetalDevice *> m_devices;

View File

@@ -60,9 +60,9 @@ namespace Internal {
// Helpers:
static const char compilerCommandKeyC[] = "BareMetal.KeilToolchain.CompilerPath";
static const char compilerPlatformCodeGenFlagsKeyC[] = "BareMetal.KeilToolchain.PlatformCodeGenFlags";
static const char targetAbiKeyC[] = "BareMetal.KeilToolchain.TargetAbi";
static const char compilerCommandKeyC[] = "CompilerPath";
static const char compilerPlatformCodeGenFlagsKeyC[] = "PlatformCodeGenFlags";
static const char targetAbiKeyC[] = "TargetAbi";
static bool compilerExists(const FilePath &compilerPath)
{

View File

@@ -58,8 +58,8 @@ namespace Internal {
// Helpers:
static const char compilerCommandKeyC[] = "BareMetal.SdccToolChain.CompilerPath";
static const char targetAbiKeyC[] = "BareMetal.SdccToolChain.TargetAbi";
static const char compilerCommandKeyC[] = "CompilerPath";
static const char targetAbiKeyC[] = "TargetAbi";
static bool compilerExists(const FilePath &compilerPath)
{