diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-12-04 22:35:44 +0100 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2020-12-05 11:19:32 +0100 |
commit | ac5fc26085e390cb55a3a5fd186a8091adcae2d4 (patch) | |
tree | 02bd09b3978a6345077d732f264f3d52e0845363 /rbutil | |
parent | c51c6c1eb314bb0d5037f3d8f260e9657e62b2f9 (diff) |
rbutil: Make target list part of new player info.
Also remove the unused cases.
Change-Id: Ic53c12c68f9d62d9c3e4406641355893e137bcf7
Diffstat (limited to 'rbutil')
-rw-r--r-- | rbutil/rbutilqt/base/playerbuildinfo.cpp | 47 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/playerbuildinfo.h | 7 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/systeminfo.cpp | 33 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/systeminfo.h | 12 | ||||
-rw-r--r-- | rbutil/rbutilqt/configure.cpp | 26 |
5 files changed, 59 insertions, 66 deletions
diff --git a/rbutil/rbutilqt/base/playerbuildinfo.cpp b/rbutil/rbutilqt/base/playerbuildinfo.cpp index fb8b121e8f..f49917cfef 100644 --- a/rbutil/rbutilqt/base/playerbuildinfo.cpp +++ b/rbutil/rbutilqt/base/playerbuildinfo.cpp @@ -57,15 +57,17 @@ const static struct { PlayerBuildInfo::DeviceInfo item; const char* name; } PlayerInfoList[] = { - { PlayerBuildInfo::BuildStatus, "status/:target:" }, - { PlayerBuildInfo::DisplayName, ":target:/name" }, - { PlayerBuildInfo::BootloaderMethod, ":target:/bootloadermethod" }, - { PlayerBuildInfo::BootloaderName, ":target:/bootloadername" }, - { PlayerBuildInfo::BootloaderFile, ":target:/bootloaderfile" }, - { PlayerBuildInfo::BootloaderFilter, ":target:/bootloaderfilter" }, - { PlayerBuildInfo::Encoder, ":target:/encoder" }, - { PlayerBuildInfo::Brand, ":target:/brand" }, - { PlayerBuildInfo::PlayerPicture, ":target:/playerpic" }, + { PlayerBuildInfo::BuildStatus, "status/:target:" }, + { PlayerBuildInfo::DisplayName, ":target:/name" }, + { PlayerBuildInfo::BootloaderMethod, ":target:/bootloadermethod" }, + { PlayerBuildInfo::BootloaderName, ":target:/bootloadername" }, + { PlayerBuildInfo::BootloaderFile, ":target:/bootloaderfile" }, + { PlayerBuildInfo::BootloaderFilter, ":target:/bootloaderfilter" }, + { PlayerBuildInfo::Encoder, ":target:/encoder" }, + { PlayerBuildInfo::Brand, ":target:/brand" }, + { PlayerBuildInfo::PlayerPicture, ":target:/playerpic" }, + { PlayerBuildInfo::TargetNamesAll, "" }, + { PlayerBuildInfo::TargetNamesEnabled, "" }, }; const static struct { @@ -216,6 +218,14 @@ QVariant PlayerBuildInfo::value(DeviceInfo item, QString target) result = -1; break; } + case TargetNamesAll: + // list of all internal target names. Doesn't depend on the passed target. + result = targetNames(true); + break; + case TargetNamesEnabled: + // list of all non-disabled target names. Doesn't depend on the passed target. + result = targetNames(false); + break; default: result = playerInfo.value(s); @@ -263,3 +273,22 @@ QString PlayerBuildInfo::statusAsString(QString platform) return result; } + + +QStringList PlayerBuildInfo::targetNames(bool all) +{ + QStringList result; + playerInfo.beginGroup("platforms"); + QStringList a = playerInfo.childKeys(); + playerInfo.endGroup(); + for(int i = 0; i < a.size(); i++) + { + QString target = playerInfo.value("platforms/" + a.at(i), "null").toString(); + if(playerInfo.value(target + "/status").toString() != "disabled" || all) { + result.append(target); + } + } + result.removeDuplicates(); + return result; +} + diff --git a/rbutil/rbutilqt/base/playerbuildinfo.h b/rbutil/rbutilqt/base/playerbuildinfo.h index 81d7d97312..5307148ff5 100644 --- a/rbutil/rbutilqt/base/playerbuildinfo.h +++ b/rbutil/rbutilqt/base/playerbuildinfo.h @@ -66,6 +66,9 @@ public: Encoder, Brand, PlayerPicture, + + TargetNamesAll, + TargetNamesEnabled, }; enum SystemUrl { @@ -97,6 +100,10 @@ protected: explicit PlayerBuildInfo(); private: + //! Return a list with all target names (as used internally). + //! @all false filter out all targets with status = disabled. + QStringList targetNames(bool all); + static PlayerBuildInfo* infoInstance; QSettings* serverInfo; QSettings playerInfo; diff --git a/rbutil/rbutilqt/base/systeminfo.cpp b/rbutil/rbutilqt/base/systeminfo.cpp index aa847540b9..6717b120cc 100644 --- a/rbutil/rbutilqt/base/systeminfo.cpp +++ b/rbutil/rbutilqt/base/systeminfo.cpp @@ -38,39 +38,6 @@ void SystemInfo::ensureSystemInfoExists() } -QStringList SystemInfo::platforms(enum SystemInfo::PlatformType type, QString variant) -{ - ensureSystemInfoExists(); - - QStringList result; - systemInfos->beginGroup("platforms"); - QStringList a = systemInfos->childKeys(); - systemInfos->endGroup(); - for(int i = 0; i < a.size(); i++) - { - QString target = systemInfos->value("platforms/"+a.at(i), "null").toString(); - QRegExp regex("\\..*$"); - QString targetbase = target; - targetbase.remove(regex); - // only add target if its not disabled unless Platform*Disabled requested - if(type != PlatformAllDisabled && type != PlatformBaseDisabled - && type != PlatformVariantDisabled - && systemInfos->value(target+"/status").toString() == "disabled") - continue; - // report only matching target if PlatformVariant* is requested - if((type == PlatformVariant || type == PlatformVariantDisabled) - && (targetbase != variant)) - continue; - // report only base targets when PlatformBase* is requested - if((type == PlatformBase || type == PlatformBaseDisabled)) - result.append(targetbase); - else - result.append(target); - } - result.removeDuplicates(); - return result; -} - QMap<QString, QStringList> SystemInfo::languages(bool namesOnly) { ensureSystemInfoExists(); diff --git a/rbutil/rbutilqt/base/systeminfo.h b/rbutil/rbutilqt/base/systeminfo.h index 7b5b68131b..d5a99082aa 100644 --- a/rbutil/rbutilqt/base/systeminfo.h +++ b/rbutil/rbutilqt/base/systeminfo.h @@ -34,18 +34,6 @@ class SystemInfo : public QObject MapIncompatible, }; - enum PlatformType { - PlatformAll, - PlatformAllDisabled, - PlatformBase, - PlatformBaseDisabled, - PlatformVariant, - PlatformVariantDisabled - }; - - //! return a list of all platforms (rbutil internal names) - static QStringList platforms(enum PlatformType type = PlatformAll, - QString variant=""); //! returns a map of all languages. //! Maps <language code> to (<language name>, <display name>) static QMap<QString, QStringList> languages(bool namesOnly = false); diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index 6b784a6383..721727f109 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp @@ -346,18 +346,20 @@ void Config::setDevices() // setup devices table LOG_INFO() << "setting up devices list"; - QStringList platformList; + QStringList targets; if(ui.showDisabled->isChecked()) - platformList = SystemInfo::platforms(SystemInfo::PlatformAllDisabled); + targets = PlayerBuildInfo::instance()->value( + PlayerBuildInfo::TargetNamesAll).toStringList(); else - platformList = SystemInfo::platforms(SystemInfo::PlatformAll); + targets = PlayerBuildInfo::instance()->value( + PlayerBuildInfo::TargetNamesEnabled).toStringList(); QMultiMap <QString, QString> manuf; - for(int it = 0; it < platformList.size(); it++) + for(int it = 0; it < targets.size(); it++) { QString curbrand = PlayerBuildInfo::instance()->value( - PlayerBuildInfo::Brand, platformList.at(it)).toString(); - manuf.insert(curbrand, platformList.at(it)); + PlayerBuildInfo::Brand, targets.at(it)).toString(); + manuf.insert(curbrand, targets.at(it)); } // set up devices table @@ -379,20 +381,20 @@ void Config::setDevices() w->setText(0, brands.at(c)); items.append(w); // go through platforms and add all players matching the current brand - for(int it = 0; it < platformList.size(); it++) { + for(int it = 0; it < targets.size(); it++) { // skip if not current brand - if(!manuf.values(brands.at(c)).contains(platformList.at(it))) + if(!manuf.values(brands.at(c)).contains(targets.at(it))) continue; // construct display name QString curname = QString("%1 (%2)").arg( PlayerBuildInfo::instance()->value(PlayerBuildInfo::DisplayName, - platformList.at(it)).toString(), - PlayerBuildInfo::instance()->statusAsString(platformList.at(it))); + targets.at(it)).toString(), + PlayerBuildInfo::instance()->statusAsString(targets.at(it))); LOG_INFO() << "add supported device:" << brands.at(c) << curname; w2 = new QTreeWidgetItem(w, QStringList(curname)); - w2->setData(0, Qt::UserRole, platformList.at(it)); + w2->setData(0, Qt::UserRole, targets.at(it)); - if(platformList.at(it) == selected) { + if(targets.at(it) == selected) { w2->setSelected(true); w->setExpanded(true); w3 = w2; // save pointer to hilight old selection |