+ const int index = _device_selector.currentIndex();
+ if(index < 0)
+ return NULL;
+
+ return (sr_dev_inst*)_device_selector.itemData(
+ index).value<void*>();
+}
+
+void SamplingBar::update_device_selector()
+{
+ GSList *devices = NULL;
+
+ /* Scan all drivers for all devices. */
+ struct sr_dev_driver **const drivers = sr_driver_list();
+ for (struct sr_dev_driver **driver = drivers; *driver; driver++) {
+ GSList *tmpdevs = sr_driver_scan(*driver, NULL);
+ for (GSList *l = tmpdevs; l; l = l->next)
+ devices = g_slist_append(devices, l->data);
+ g_slist_free(tmpdevs);
+ }
+
+ for (GSList *l = devices; l; l = l->next) {
+ sr_dev_inst *const sdi = (sr_dev_inst*)l->data;
+
+ QString title;
+ if (sdi->vendor && sdi->vendor[0])
+ title += sdi->vendor + QString(" ");
+ if (sdi->model && sdi->model[0])
+ title += sdi->model + QString(" ");
+ if (sdi->version && sdi->version[0])
+ title += sdi->version + QString(" ");
+
+ _device_selector.addItem(title, qVariantFromValue(
+ (void*)sdi));
+ }
+
+ g_slist_free(devices);