chore(cpn): Switch from component names to ids (#2602)

* cpn(fix): Switch from component names to ids

* Fix Win compile

* Sound packs list entries should not be editable
This commit is contained in:
Neil Horne
2022-10-27 21:52:05 +10:00
committed by GitHub
parent 56617dc209
commit 6b01a0c673
17 changed files with 441 additions and 350 deletions
+13 -10
View File
@@ -346,7 +346,7 @@ bool ComponentData::existsOnDisk()
void ComponentData::clearRelease()
{
releaseReset();
idReset();
releaseIdReset();
prereleaseReset();
dateReset();
versionReset();
@@ -516,15 +516,6 @@ QMap<int, QString> AppData::getActiveProfiles() const
return active;
}
int AppData::getComponentIndex(QString name) const
{
for (int i=0; i<MAX_COMPONENTS; i++) {
if (g.component[i].existsOnDisk() && g.component[i].name() == name)
return i;
}
return -1;
}
void AppData::convertSettings(QSettings & settings)
{
quint32 savedVer = settings.value(SETTINGS_VERSION_KEY, 0).toUInt();
@@ -567,6 +558,18 @@ void AppData::convertSettings(QSettings & settings)
}
}
if (savedMajMin < 0x209) {
// 2.9 component id renamed releaseId - copy value before calling clearUnusedSettings
qInfo().noquote() << "Converting components - moving id to releaseId";
static const QString path = QStringLiteral("Components/component%1/%2");
for (int i = 0; i < MAX_COMPONENTS; i++) {
if (settings.contains(path.arg(i).arg("id"))) {
const QVariant id = settings.value(path.arg(i).arg("id"));
settings.setValue(path.arg(i).arg("releaseId"), id);
}
}
}
if (removeUnused)
clearUnusedSettings(settings);
+2 -5
View File
@@ -39,7 +39,7 @@
//! CPN_SETTINGS_REVISION is used to track settings changes independently of EdgeTX version. It should be reset to zero whenever settings are migrated to new COMPANY or PRODUCT.
//! \note !! Increment this value if properties are removed or refactored. It will trigger a conversion/cleanup of any stored settings. \sa AppData::convertSettings()
#define CPN_SETTINGS_REVISION 1 // Note: bumped to ensure 2.7 Nightly version users also get upgraded
#define CPN_SETTINGS_REVISION 2 // Note: bumped for fix during 2.8 RCs
//! CPN_SETTINGS_VERSION is used for settings data version tracking.
#define CPN_SETTINGS_VERSION ((VERSION_NUMBER << 8) | CPN_SETTINGS_REVISION)
@@ -495,11 +495,10 @@ class ComponentData: public CompStoreObj
friend class AppData;
private:
PROPERTYSTR (name)
PROPERTY (bool, checkForUpdate, false)
PROPERTY (ReleaseChannel, releaseChannel, RELEASE_CHANNEL_STABLE)
PROPERTYSTRD( release, "unknown")
PROPERTY (int, id, 0)
PROPERTY (int, releaseId, 0)
PROPERTY (bool, prerelease, false)
PROPERTYSTRD( version, "0")
PROPERTYSTRD( date, "")
@@ -574,8 +573,6 @@ class AppData: public CompStoreObj
//! List of all active profiles mapped by index.
QMap<int, QString> getActiveProfiles() const;
//! Get a modifiable (non-const) index to ComponentData for \a name. Returns -1 if \a name not found.
int getComponentIndex(QString name) const;
//! Get a modifiable (non-const) reference to the ComponentData at \a index. Returns component[0] if \a index is invalid.
ComponentData & getComponent(int index);
//! Get a non-modifiable (const) reference to the ComponentData at \a index. Returns component[0] if \a index is invalid.