]> sigrok.org Git - pulseview.git/blobdiff - pv/dialogs/connect.cpp
Connect dialog: Make button caption more clear
[pulseview.git] / pv / dialogs / connect.cpp
index fcb2103bedf77737d23f1c5e48b09f4af8199ef6..997234be76dc1815f229dd54ae56a7559eab730d 100644 (file)
 
 #include <cassert>
 
-#include <libsigrok/libsigrok.hpp>
+#include <libsigrokcxx/libsigrokcxx.hpp>
 
 #include "connect.hpp"
 
-#include "pv/devicemanager.hpp"
+#include <pv/devicemanager.hpp>
+#include <pv/devices/hardwaredevice.hpp>
 
 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> 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<HardwareDevice> > devices =
+       const list< shared_ptr<HardwareDevice> > devices =
                device_manager_.driver_scan(driver, drvopts);
 
-       for (shared_ptr<HardwareDevice> device : devices)
-       {
+       for (shared_ptr<HardwareDevice> 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);
 }