summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/rbsettings.cpp
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2009-04-16 20:49:43 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2009-04-16 20:49:43 +0000
commitbfce7eea5c0d43c9f2cd84cd325bbcc1949102e3 (patch)
treeac926f8a844d2706cb01323d80fb42b2a8f24898 /rbutil/rbutilqt/rbsettings.cpp
parent2995c2d265e4e6b2c07a88023bbd7635ae7cb9e9 (diff)
downloadrockbox-bfce7eea5c0d43c9f2cd84cd325bbcc1949102e3.tar.gz
rockbox-bfce7eea5c0d43c9f2cd84cd325bbcc1949102e3.tar.bz2
rockbox-bfce7eea5c0d43c9f2cd84cd325bbcc1949102e3.zip
Refactor USB ID map retrieval from device settings file and minimize duplicated code.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20716 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/rbutilqt/rbsettings.cpp')
-rw-r--r--rbutil/rbutilqt/rbsettings.cpp64
1 files changed, 13 insertions, 51 deletions
diff --git a/rbutil/rbutilqt/rbsettings.cpp b/rbutil/rbutilqt/rbsettings.cpp
index 909dba4951..560b9ab5fc 100644
--- a/rbutil/rbutilqt/rbsettings.cpp
+++ b/rbutil/rbutilqt/rbsettings.cpp
@@ -388,7 +388,7 @@ QString RbSettings::brand(QString plattform)
return brand;
}
-QMap<int, QString> RbSettings::usbIdMap()
+QMap<int, QString> RbSettings::usbIdMap(enum MapType type)
{
QMap<int, QString> map;
// get a list of ID -> target name
@@ -397,31 +397,18 @@ QMap<int, QString> RbSettings::usbIdMap()
platforms = devices->childKeys();
devices->endGroup();
- for(int i = 0; i < platforms.size(); i++)
- {
- devices->beginGroup("platforms");
- QString target = devices->value(platforms.at(i)).toString();
- devices->endGroup();
- devices->beginGroup(target);
- QStringList ids = devices->value("usbid").toStringList();
- int j = ids.size();
- while(j--)
- map.insert(ids.at(j).toInt(0, 16), target);
-
- devices->endGroup();
+ QString t;
+ switch(type) {
+ case MapDevice:
+ t = "usbid";
+ break;
+ case MapError:
+ t = "usberror";
+ break;
+ case MapIncompatible:
+ t = "usbincompat";
+ break;
}
- return map;
-}
-
-QMap<int, QString> RbSettings::usbIdErrorMap()
-{
-
- QMap<int, QString> map;
- // get a list of ID -> target name
- QStringList platforms;
- devices->beginGroup("platforms");
- platforms = devices->childKeys();
- devices->endGroup();
for(int i = 0; i < platforms.size(); i++)
{
@@ -429,36 +416,11 @@ QMap<int, QString> RbSettings::usbIdErrorMap()
QString target = devices->value(platforms.at(i)).toString();
devices->endGroup();
devices->beginGroup(target);
- QStringList ids = devices->value("usberror").toStringList();
+ QStringList ids = devices->value(t).toStringList();
int j = ids.size();
while(j--)
map.insert(ids.at(j).toInt(0, 16), target);
- devices->endGroup();
- }
- return map;
-}
-
-
-QMap<int, QString> RbSettings::usbIdIncompatMap()
-{
-
- QMap<int, QString> map;
- // get a list of ID -> target name
- QStringList platforms;
- devices->beginGroup("platforms");
- platforms = devices->childKeys();
- devices->endGroup();
- for(int i = 0; i < platforms.size(); i++)
- {
- devices->beginGroup("platforms");
- QString target = devices->value(platforms.at(i)).toString();
- devices->endGroup();
- devices->beginGroup(target);
- QStringList ids = devices->value("usbincompat").toStringList();
- int j = ids.size();
- while(j--)
- map.insert(ids.at(j).toInt(0, 16), target);
devices->endGroup();
}
return map;