X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fdialogs%2Fconnect.cpp;h=ea411f156cf33b52f4f86ed61db2ed017a7418f4;hb=404aad0ed6bd90566739af6ecb57475bc02a7c8e;hp=02941f2f6785e02efcff07a80a6520c16d8e36d2;hpb=ef6d8458be34101907f5c45c3de22a10e554e289;p=pulseview.git diff --git a/pv/dialogs/connect.cpp b/pv/dialogs/connect.cpp index 02941f2f..ea411f15 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,16 @@ extern "C" { #include } +using namespace std; + 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), @@ -148,21 +155,17 @@ void Connect::scan_pressed() drvopts = g_slist_append(drvopts, src); } - GSList *const devices = sr_driver_scan(driver, drvopts); - - for (GSList *l = devices; l; l = l->next) { + const list devices = _device_manager.driver_scan( + driver, drvopts); - 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(title.c_str()); if (sdi->probes) { - text += QString("with %1 probes").arg( + text += QString(" with %1 probes").arg( g_slist_length(sdi->probes)); } @@ -172,9 +175,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); }