mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-08 20:55:17 -05:00
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
|
|
@ -66,6 +66,8 @@ const static struct {
|
||||||
{ PlayerBuildInfo::Encoder, ":target:/encoder" },
|
{ PlayerBuildInfo::Encoder, ":target:/encoder" },
|
||||||
{ PlayerBuildInfo::Brand, ":target:/brand" },
|
{ PlayerBuildInfo::Brand, ":target:/brand" },
|
||||||
{ PlayerBuildInfo::PlayerPicture, ":target:/playerpic" },
|
{ PlayerBuildInfo::PlayerPicture, ":target:/playerpic" },
|
||||||
|
{ PlayerBuildInfo::TargetNamesAll, "" },
|
||||||
|
{ PlayerBuildInfo::TargetNamesEnabled, "" },
|
||||||
};
|
};
|
||||||
|
|
||||||
const static struct {
|
const static struct {
|
||||||
|
|
@ -216,6 +218,14 @@ QVariant PlayerBuildInfo::value(DeviceInfo item, QString target)
|
||||||
result = -1;
|
result = -1;
|
||||||
break;
|
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:
|
default:
|
||||||
result = playerInfo.value(s);
|
result = playerInfo.value(s);
|
||||||
|
|
@ -263,3 +273,22 @@ QString PlayerBuildInfo::statusAsString(QString platform)
|
||||||
|
|
||||||
return result;
|
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,
|
Encoder,
|
||||||
Brand,
|
Brand,
|
||||||
PlayerPicture,
|
PlayerPicture,
|
||||||
|
|
||||||
|
TargetNamesAll,
|
||||||
|
TargetNamesEnabled,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SystemUrl {
|
enum SystemUrl {
|
||||||
|
|
@ -97,6 +100,10 @@ protected:
|
||||||
explicit PlayerBuildInfo();
|
explicit PlayerBuildInfo();
|
||||||
|
|
||||||
private:
|
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;
|
static PlayerBuildInfo* infoInstance;
|
||||||
QSettings* serverInfo;
|
QSettings* serverInfo;
|
||||||
QSettings playerInfo;
|
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)
|
QMap<QString, QStringList> SystemInfo::languages(bool namesOnly)
|
||||||
{
|
{
|
||||||
ensureSystemInfoExists();
|
ensureSystemInfoExists();
|
||||||
|
|
|
||||||
|
|
@ -34,18 +34,6 @@ class SystemInfo : public QObject
|
||||||
MapIncompatible,
|
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.
|
//! returns a map of all languages.
|
||||||
//! Maps <language code> to (<language name>, <display name>)
|
//! Maps <language code> to (<language name>, <display name>)
|
||||||
static QMap<QString, QStringList> languages(bool namesOnly = false);
|
static QMap<QString, QStringList> languages(bool namesOnly = false);
|
||||||
|
|
|
||||||
|
|
@ -346,18 +346,20 @@ void Config::setDevices()
|
||||||
// setup devices table
|
// setup devices table
|
||||||
LOG_INFO() << "setting up devices list";
|
LOG_INFO() << "setting up devices list";
|
||||||
|
|
||||||
QStringList platformList;
|
QStringList targets;
|
||||||
if(ui.showDisabled->isChecked())
|
if(ui.showDisabled->isChecked())
|
||||||
platformList = SystemInfo::platforms(SystemInfo::PlatformAllDisabled);
|
targets = PlayerBuildInfo::instance()->value(
|
||||||
|
PlayerBuildInfo::TargetNamesAll).toStringList();
|
||||||
else
|
else
|
||||||
platformList = SystemInfo::platforms(SystemInfo::PlatformAll);
|
targets = PlayerBuildInfo::instance()->value(
|
||||||
|
PlayerBuildInfo::TargetNamesEnabled).toStringList();
|
||||||
|
|
||||||
QMultiMap <QString, QString> manuf;
|
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(
|
QString curbrand = PlayerBuildInfo::instance()->value(
|
||||||
PlayerBuildInfo::Brand, platformList.at(it)).toString();
|
PlayerBuildInfo::Brand, targets.at(it)).toString();
|
||||||
manuf.insert(curbrand, platformList.at(it));
|
manuf.insert(curbrand, targets.at(it));
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up devices table
|
// set up devices table
|
||||||
|
|
@ -379,20 +381,20 @@ void Config::setDevices()
|
||||||
w->setText(0, brands.at(c));
|
w->setText(0, brands.at(c));
|
||||||
items.append(w);
|
items.append(w);
|
||||||
// go through platforms and add all players matching the current brand
|
// 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
|
// 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;
|
continue;
|
||||||
// construct display name
|
// construct display name
|
||||||
QString curname = QString("%1 (%2)").arg(
|
QString curname = QString("%1 (%2)").arg(
|
||||||
PlayerBuildInfo::instance()->value(PlayerBuildInfo::DisplayName,
|
PlayerBuildInfo::instance()->value(PlayerBuildInfo::DisplayName,
|
||||||
platformList.at(it)).toString(),
|
targets.at(it)).toString(),
|
||||||
PlayerBuildInfo::instance()->statusAsString(platformList.at(it)));
|
PlayerBuildInfo::instance()->statusAsString(targets.at(it)));
|
||||||
LOG_INFO() << "add supported device:" << brands.at(c) << curname;
|
LOG_INFO() << "add supported device:" << brands.at(c) << curname;
|
||||||
w2 = new QTreeWidgetItem(w, QStringList(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);
|
w2->setSelected(true);
|
||||||
w->setExpanded(true);
|
w->setExpanded(true);
|
||||||
w3 = w2; // save pointer to hilight old selection
|
w3 = w2; // save pointer to hilight old selection
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue