X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fdialogs%2Fconnect.cpp;h=997234be76dc1815f229dd54ae56a7559eab730d;hp=fcb2103bedf77737d23f1c5e48b09f4af8199ef6;hb=be7645e8d02d1865f9bc1a4a9bb397812ea3c380;hpb=34750abe0a89c4b5184daf6dc117adfafa74a84e diff --git a/pv/dialogs/connect.cpp b/pv/dialogs/connect.cpp index fcb2103b..997234be 100644 --- a/pv/dialogs/connect.cpp +++ b/pv/dialogs/connect.cpp @@ -20,11 +20,12 @@ #include -#include +#include #include "connect.hpp" -#include "pv/devicemanager.hpp" +#include +#include using std::list; using std::map; @@ -38,7 +39,8 @@ using Glib::VariantBase; using sigrok::ConfigKey; using sigrok::Driver; using sigrok::Error; -using sigrok::HardwareDevice; + +using pv::devices::HardwareDevice; namespace pv { namespace dialogs { @@ -51,7 +53,7 @@ Connect::Connect(QWidget *parent, pv::DeviceManager &device_manager) : form_layout_(&form_), drivers_(&form_), serial_devices_(&form_), - scan_button_(tr("&Scan for Devices"), this), + scan_button_(tr("&Scan for devices using driver above"), this), device_list_(this), button_box_(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this) @@ -104,14 +106,14 @@ void Connect::populate_drivers() * @todo Add support for non-monotonic devices i.e. DMMs * and sensors. */ - bool supported_device = driver->config_check( - ConfigKey::LOGIC_ANALYZER, ConfigKey::DEVICE_OPTIONS) | - driver->config_check( - ConfigKey::OSCILLOSCOPE, ConfigKey::DEVICE_OPTIONS); + const auto keys = driver->config_keys(); + + bool supported_device = keys.count(ConfigKey::LOGIC_ANALYZER) | + keys.count(ConfigKey::OSCILLOSCOPE); if (supported_device) drivers_.addItem(QString("%1 (%2)").arg( - driver->long_name().c_str()).arg(name.c_str()), + driver->long_name().c_str(), name.c_str()), qVariantFromValue(driver)); } } @@ -121,7 +123,7 @@ void Connect::populate_serials(shared_ptr driver) serial_devices_.clear(); for (auto serial : device_manager_.context()->serials(driver)) serial_devices_.addItem(QString("%1 (%2)").arg( - serial.first.c_str()).arg(serial.second.c_str()), + serial.first.c_str(), serial.second.c_str()), QString::fromStdString(serial.first)); } @@ -167,16 +169,16 @@ void Connect::scan_pressed() serial.toUtf8().constData()); } - list< shared_ptr > devices = + const list< shared_ptr > devices = device_manager_.driver_scan(driver, drvopts); - for (shared_ptr device : devices) - { + for (shared_ptr device : devices) { assert(device); QString text = QString::fromStdString( - device_manager_.get_display_name(device)); - text += QString(" with %1 channels").arg(device->channels().size()); + device->display_name(device_manager_)); + text += QString(" with %1 channels").arg( + device->device()->channels().size()); QListWidgetItem *const item = new QListWidgetItem(text, &device_list_); @@ -195,7 +197,7 @@ void Connect::device_selected(int index) unset_connection(); - if (driver->config_check(ConfigKey::SERIALCOMM, ConfigKey::SCAN_OPTIONS)) + if (driver->scan_options().count(ConfigKey::SERIALCOMM)) set_serial_connection(driver); }