diff options
-rw-r--r-- | rbutil/rbutilqt/base/autodetection.cpp | 6 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbsettings.cpp | 64 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbsettings.h | 10 |
3 files changed, 23 insertions, 57 deletions
diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp index aa74419ce0..ee42a8c09e 100644 --- a/rbutil/rbutilqt/base/autodetection.cpp +++ b/rbutil/rbutilqt/base/autodetection.cpp | |||
@@ -333,9 +333,9 @@ bool Autodetection::detectUsb() | |||
333 | // usbids holds the mapping in the form | 333 | // usbids holds the mapping in the form |
334 | // ((VID<<16)|(PID)), targetname | 334 | // ((VID<<16)|(PID)), targetname |
335 | // the ini file needs to hold the IDs as hex values. | 335 | // the ini file needs to hold the IDs as hex values. |
336 | QMap<int, QString> usbids = settings->usbIdMap(); | 336 | QMap<int, QString> usbids = settings->usbIdMap(RbSettings::MapDevice); |
337 | QMap<int, QString> usberror = settings->usbIdErrorMap(); | 337 | QMap<int, QString> usberror = settings->usbIdMap(RbSettings::MapError); |
338 | QMap<int, QString> usbincompat = settings->usbIdIncompatMap(); | 338 | QMap<int, QString> usbincompat = settings->usbIdMap(RbSettings::MapIncompatible); |
339 | 339 | ||
340 | // usb pid detection | 340 | // usb pid detection |
341 | QList<uint32_t> attached; | 341 | QList<uint32_t> attached; |
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) | |||
388 | return brand; | 388 | return brand; |
389 | } | 389 | } |
390 | 390 | ||
391 | QMap<int, QString> RbSettings::usbIdMap() | 391 | QMap<int, QString> RbSettings::usbIdMap(enum MapType type) |
392 | { | 392 | { |
393 | QMap<int, QString> map; | 393 | QMap<int, QString> map; |
394 | // get a list of ID -> target name | 394 | // get a list of ID -> target name |
@@ -397,31 +397,18 @@ QMap<int, QString> RbSettings::usbIdMap() | |||
397 | platforms = devices->childKeys(); | 397 | platforms = devices->childKeys(); |
398 | devices->endGroup(); | 398 | devices->endGroup(); |
399 | 399 | ||
400 | for(int i = 0; i < platforms.size(); i++) | 400 | QString t; |
401 | { | 401 | switch(type) { |
402 | devices->beginGroup("platforms"); | 402 | case MapDevice: |
403 | QString target = devices->value(platforms.at(i)).toString(); | 403 | t = "usbid"; |
404 | devices->endGroup(); | 404 | break; |
405 | devices->beginGroup(target); | 405 | case MapError: |
406 | QStringList ids = devices->value("usbid").toStringList(); | 406 | t = "usberror"; |
407 | int j = ids.size(); | 407 | break; |
408 | while(j--) | 408 | case MapIncompatible: |
409 | map.insert(ids.at(j).toInt(0, 16), target); | 409 | t = "usbincompat"; |
410 | 410 | break; | |
411 | devices->endGroup(); | ||
412 | } | 411 | } |
413 | return map; | ||
414 | } | ||
415 | |||
416 | QMap<int, QString> RbSettings::usbIdErrorMap() | ||
417 | { | ||
418 | |||
419 | QMap<int, QString> map; | ||
420 | // get a list of ID -> target name | ||
421 | QStringList platforms; | ||
422 | devices->beginGroup("platforms"); | ||
423 | platforms = devices->childKeys(); | ||
424 | devices->endGroup(); | ||
425 | 412 | ||
426 | for(int i = 0; i < platforms.size(); i++) | 413 | for(int i = 0; i < platforms.size(); i++) |
427 | { | 414 | { |
@@ -429,36 +416,11 @@ QMap<int, QString> RbSettings::usbIdErrorMap() | |||
429 | QString target = devices->value(platforms.at(i)).toString(); | 416 | QString target = devices->value(platforms.at(i)).toString(); |
430 | devices->endGroup(); | 417 | devices->endGroup(); |
431 | devices->beginGroup(target); | 418 | devices->beginGroup(target); |
432 | QStringList ids = devices->value("usberror").toStringList(); | 419 | QStringList ids = devices->value(t).toStringList(); |
433 | int j = ids.size(); | 420 | int j = ids.size(); |
434 | while(j--) | 421 | while(j--) |
435 | map.insert(ids.at(j).toInt(0, 16), target); | 422 | map.insert(ids.at(j).toInt(0, 16), target); |
436 | devices->endGroup(); | ||
437 | } | ||
438 | return map; | ||
439 | } | ||
440 | |||
441 | |||
442 | QMap<int, QString> RbSettings::usbIdIncompatMap() | ||
443 | { | ||
444 | |||
445 | QMap<int, QString> map; | ||
446 | // get a list of ID -> target name | ||
447 | QStringList platforms; | ||
448 | devices->beginGroup("platforms"); | ||
449 | platforms = devices->childKeys(); | ||
450 | devices->endGroup(); | ||
451 | 423 | ||
452 | for(int i = 0; i < platforms.size(); i++) | ||
453 | { | ||
454 | devices->beginGroup("platforms"); | ||
455 | QString target = devices->value(platforms.at(i)).toString(); | ||
456 | devices->endGroup(); | ||
457 | devices->beginGroup(target); | ||
458 | QStringList ids = devices->value("usbincompat").toStringList(); | ||
459 | int j = ids.size(); | ||
460 | while(j--) | ||
461 | map.insert(ids.at(j).toInt(0, 16), target); | ||
462 | devices->endGroup(); | 424 | devices->endGroup(); |
463 | } | 425 | } |
464 | return map; | 426 | return map; |
diff --git a/rbutil/rbutilqt/rbsettings.h b/rbutil/rbutilqt/rbsettings.h index c785061ee8..339c835d4a 100644 --- a/rbutil/rbutilqt/rbsettings.h +++ b/rbutil/rbutilqt/rbsettings.h | |||
@@ -41,6 +41,12 @@ class RbSettings : public QObject | |||
41 | // returns the filename of the usersettings file | 41 | // returns the filename of the usersettings file |
42 | QString userSettingFilename(); | 42 | QString userSettingFilename(); |
43 | 43 | ||
44 | enum MapType { | ||
45 | MapDevice, | ||
46 | MapError, | ||
47 | MapIncompatible, | ||
48 | }; | ||
49 | |||
44 | //! access functions for the settings | 50 | //! access functions for the settings |
45 | QString curVersion(); | 51 | QString curVersion(); |
46 | bool cacheOffline(); | 52 | bool cacheOffline(); |
@@ -86,9 +92,7 @@ class RbSettings : public QObject | |||
86 | QString name(QString plattform); | 92 | QString name(QString plattform); |
87 | QString brand(QString plattform); | 93 | QString brand(QString plattform); |
88 | 94 | ||
89 | QMap<int, QString> usbIdMap(); | 95 | QMap<int, QString> usbIdMap(enum MapType); |
90 | QMap<int, QString> usbIdErrorMap(); | ||
91 | QMap<int, QString> usbIdIncompatMap(); | ||
92 | 96 | ||
93 | QString curBrand(); | 97 | QString curBrand(); |
94 | QString curName(); | 98 | QString curName(); |