rbutil: Make target list part of new player info.
Also remove the unused cases. Change-Id: Ic53c12c68f9d62d9c3e4406641355893e137bcf7
This commit is contained in:
parent
c51c6c1eb3
commit
ac5fc26085
5 changed files with 59 additions and 66 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue