From 8c8703038be3f9bbb80742816045e18d3aa8c465 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Mon, 1 Mar 2010 22:45:17 +0000 Subject: Refactor device tree setup a bit. - reorder value retrieval (display names etc) to cut down the number of necessary accesses. While this is not critical it cuts down the noise generated in the trace noticably. - match the old target by its internal name instead of the display name. - remove two access functions in SystemInfo that are not really needed anymore. Accessing the values via platformValue() is much more logical and in line with the rest of the value accesses. - try to scroll to the selected item in the device list after setup and detection. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24988 a1c6a512-1295-4272-9138-f99709370657 --- rbutil/rbutilqt/base/systeminfo.cpp | 12 ----------- rbutil/rbutilqt/base/systeminfo.h | 4 ---- rbutil/rbutilqt/configure.cpp | 40 ++++++++++++++++++------------------- 3 files changed, 20 insertions(+), 36 deletions(-) (limited to 'rbutil') diff --git a/rbutil/rbutilqt/base/systeminfo.cpp b/rbutil/rbutilqt/base/systeminfo.cpp index a941f43078..72a62ac2fb 100644 --- a/rbutil/rbutilqt/base/systeminfo.cpp +++ b/rbutil/rbutilqt/base/systeminfo.cpp @@ -156,18 +156,6 @@ QStringList SystemInfo::languages() } -QString SystemInfo::name(QString platform) -{ - ensureSystemInfoExists(); - return systemInfos->value(platform + "/name").toString(); -} - -QString SystemInfo::brand(QString platform) -{ - ensureSystemInfoExists(); - return systemInfos->value(platform + "/brand").toString(); -} - QMap SystemInfo::usbIdMap(enum MapType type) { ensureSystemInfoExists(); diff --git a/rbutil/rbutilqt/base/systeminfo.h b/rbutil/rbutilqt/base/systeminfo.h index 76d00d4949..fb5fa9e1ac 100644 --- a/rbutil/rbutilqt/base/systeminfo.h +++ b/rbutil/rbutilqt/base/systeminfo.h @@ -77,10 +77,6 @@ class SystemInfo : public QObject QString variant=""); //! returns a list of all languages static QStringList languages(void); - //! maps a platform to its name - static QString name(QString platform); - //! maps a platform to its brand - static QString brand(QString platform); //! returns a map of usb-ids and their targets static QMap usbIdMap(enum MapType); //! get a value from system settings diff --git a/rbutil/rbutilqt/configure.cpp b/rbutil/rbutilqt/configure.cpp index 7507833297..c57554aef3 100644 --- a/rbutil/rbutilqt/configure.cpp +++ b/rbutil/rbutilqt/configure.cpp @@ -309,20 +309,13 @@ void Config::setDevices() platformList = SystemInfo::platforms(SystemInfo::PlatformAll); QMap manuf; - QMap devcs; for(int it = 0; it < platformList.size(); it++) { - QString curname = SystemInfo::name(platformList.at(it)) + - " (" +ServerInfo::platformValue(platformList.at(it), - ServerInfo::CurStatus).toString() + ")"; - QString curbrand = SystemInfo::brand(platformList.at(it)); + QString curbrand = SystemInfo::platformValue(platformList.at(it), + SystemInfo::CurBrand).toString(); manuf.insertMulti(curbrand, platformList.at(it)); - devcs.insert(platformList.at(it), curname); } - QString platform; - platform = devcs.value(RbSettings::value(RbSettings::Platform).toString()); - // set up devices table ui.treeDevices->header()->hide(); ui.treeDevices->expandAll(); @@ -334,25 +327,28 @@ void Config::setDevices() QTreeWidgetItem *w; QTreeWidgetItem *w2; QTreeWidgetItem *w3 = 0; + + QString selected = RbSettings::value(RbSettings::Platform).toString(); for(int c = 0; c < brands.size(); c++) { w = new QTreeWidgetItem(); w->setFlags(Qt::ItemIsEnabled); w->setText(0, brands.at(c)); items.append(w); - - // go through platforms again for sake of order + // go through platforms and add all players matching the current brand for(int it = 0; it < platformList.size(); it++) { - - QString curname = SystemInfo::name(platformList.at(it)) + - " (" +ServerInfo::platformValue(platformList.at(it),ServerInfo::CurStatus).toString() +")"; - QString curbrand = SystemInfo::brand(platformList.at(it)); - - if(curbrand != brands.at(c)) continue; + // skip if not current brand + if(!manuf.values(brands.at(c)).contains(platformList.at(it))) + continue; + // construct display name + QString curname = SystemInfo::platformValue(platformList.at(it), + SystemInfo::CurName).toString() + + " (" +ServerInfo::platformValue(platformList.at(it), + ServerInfo::CurStatus).toString() +")"; qDebug() << "[Config] add supported device:" << brands.at(c) << curname; w2 = new QTreeWidgetItem(w, QStringList(curname)); w2->setData(0, Qt::UserRole, platformList.at(it)); - if(platform.contains(curname)) { + if(platformList.at(it) == selected) { w2->setSelected(true); w->setExpanded(true); w3 = w2; // save pointer to hilight old selection @@ -369,8 +365,10 @@ void Config::setDevices() while(widgetitem); // add new items ui.treeDevices->insertTopLevelItems(0, items); - if(w3 != 0) + if(w3 != 0) { ui.treeDevices->setCurrentItem(w3); // hilight old selection + ui.treeDevices->scrollToItem(w3); + } // tts / encoder tab @@ -589,7 +587,8 @@ void Config::autodetect() // find the new item // enumerate all platform items - QList itmList= ui.treeDevices->findItems("*",Qt::MatchWildcard); + QList itmList + = ui.treeDevices->findItems("*",Qt::MatchWildcard); for(int i=0; i< itmList.size();i++) { //enumerate device items @@ -602,6 +601,7 @@ void Config::autodetect() itmList.at(i)->child(j)->setSelected(true); //select the item itmList.at(i)->setExpanded(true); //expand the platform item //ui.treeDevices->indexOfTopLevelItem(itmList.at(i)->child(j)); + ui.treeDevices->scrollToItem(itmList.at(i)->child(j)); break; } } -- cgit v1.2.3