X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fdialogs%2Fconnect.cpp;h=52530beb5d391815233f8a11140bde1c2d5ad20b;hb=819f4c25391a9c74d3d2f528d462142d5c4aad4d;hp=e205c45047c8c07b97bdaa944577b8add97bdf10;hpb=2b82262fa05427247b583bc1a7fd802e6dfef387;p=pulseview.git diff --git a/pv/dialogs/connect.cpp b/pv/dialogs/connect.cpp index e205c45..52530be 100644 --- a/pv/dialogs/connect.cpp +++ b/pv/dialogs/connect.cpp @@ -18,8 +18,12 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "connect.h" +#include "pv/devicemanager.h" + extern "C" { /* __STDC_FORMAT_MACROS is required for PRIu64 and friends (in C++). */ #define __STDC_FORMAT_MACROS @@ -27,13 +31,17 @@ extern "C" { #include } +using std::list; +using std::string; + extern sr_context *sr_ctx; namespace pv { namespace dialogs { -Connect::Connect(QWidget *parent) : +Connect::Connect(QWidget *parent, pv::DeviceManager &device_manager) : QDialog(parent), + _device_manager(device_manager), _layout(this), _form(this), _form_layout(&_form), @@ -95,8 +103,8 @@ void Connect::populate_drivers() * and sensors. */ bool supported_device = false; - if ((sr_config_list(drivers[i], SR_CONF_DEVICE_OPTIONS, - &gvar_opts, NULL) == SR_OK)) + if ((sr_config_list(drivers[i], NULL, NULL, + SR_CONF_DEVICE_OPTIONS, &gvar_opts) == SR_OK)) { hwopts = (const int32_t *)g_variant_get_fixed_array(gvar_opts, &num_opts, sizeof(int32_t)); for (unsigned int j = 0; j < num_opts; j++) @@ -104,6 +112,7 @@ void Connect::populate_drivers() supported_device = true; break; } + } if (supported_device) _drivers.addItem(QString("%1 (%2)").arg( @@ -147,21 +156,17 @@ void Connect::scan_pressed() drvopts = g_slist_append(drvopts, src); } - GSList *const devices = sr_driver_scan(driver, drvopts); + const list devices = _device_manager.driver_scan( + driver, drvopts); - for (GSList *l = devices; l; l = l->next) { - - sr_dev_inst *const sdi = (sr_dev_inst*)l->data; + g_slist_free_full(drvopts, (GDestroyNotify)free_drvopts); - QString text; - if (sdi->vendor && sdi->vendor[0]) - text += QString("%1 ").arg(sdi->vendor); - if (sdi->model && sdi->model[0]) - text += QString("%1 ").arg(sdi->model); - if (sdi->version && sdi->version[0]) - text += QString("%1 ").arg(sdi->version); + BOOST_FOREACH(sr_dev_inst *const sdi, devices) + { + const string title = DeviceManager::format_device_title(sdi); + QString text = QString::fromUtf8(title.c_str()); if (sdi->probes) { - text += QString("with %1 probes").arg( + text += QString(" with %1 probes").arg( g_slist_length(sdi->probes)); } @@ -171,9 +176,6 @@ void Connect::scan_pressed() _device_list.addItem(item); } - g_slist_free(devices); - g_slist_free_full(drvopts, (GDestroyNotify)free_drvopts); - _device_list.setCurrentRow(0); _button_box.button(QDialogButtonBox::Ok)->setDisabled(false); } @@ -188,8 +190,8 @@ void Connect::device_selected(int index) unset_connection(); - if ((sr_config_list(driver, SR_CONF_SCAN_OPTIONS, - &gvar_list, NULL) == SR_OK)) { + if ((sr_config_list(driver, NULL, NULL, + SR_CONF_SCAN_OPTIONS, &gvar_list) == SR_OK)) { hwopts = (const int32_t *)g_variant_get_fixed_array(gvar_list, &num_opts, sizeof(int32_t));