]> sigrok.org Git - pulseview.git/commitdiff
Added a probe selector
authorJoel Holdsworth <redacted>
Mon, 11 Mar 2013 20:41:04 +0000 (20:41 +0000)
committerJoel Holdsworth <redacted>
Mon, 11 Mar 2013 20:41:35 +0000 (20:41 +0000)
pv/dialogs/deviceoptions.cpp
pv/dialogs/deviceoptions.h

index b8f4cabf2542af7175ac6819bdac77a86fe80488..232e6f6f834e90aac50aad4824c150c77597f9d4 100644 (file)
 
 #include "deviceoptions.h"
 
+#include <QListWidget>
+
 namespace pv {
 namespace dialogs {
 
 DeviceOptions::DeviceOptions(QWidget *parent, struct sr_dev_inst *sdi) :
        QDialog(parent),
+       _sdi(sdi),
        _layout(this),
+       _probes_box(tr("Probes"), this),
+       _probes(this),
+       _props_box(tr("Configuration"), this),
        _button_box(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
                Qt::Horizontal, this),
        _device_options_binding(sdi)
@@ -37,17 +43,55 @@ DeviceOptions::DeviceOptions(QWidget *parent, struct sr_dev_inst *sdi) :
 
        setLayout(&_layout);
 
-       QWidget *const form = _device_options_binding.get_form(this);
-       _layout.addWidget(form);
+       setup_probes();
+       _probes_box.setLayout(&_probes_box_layout);
+       _probes_box_layout.addWidget(&_probes);
+       _layout.addWidget(&_probes_box);
+
+       _props_box.setLayout(&_props_box_layout);
+       _props_box_layout.addWidget(_device_options_binding.get_form(this));
+       _layout.addWidget(&_props_box);
 
        _layout.addWidget(&_button_box);
 }
 
 void DeviceOptions::accept()
 {
+       using namespace Qt;
+
        QDialog::accept();
+
+       // Commit the probes
+       for (int i = 0; i < _probes.count(); i++) {
+               const QListWidgetItem *const item = _probes.item(i);
+               assert(item);
+               sr_probe *const probe = (sr_probe*)
+                       item->data(UserRole).value<void*>();
+               assert(probe);
+               probe->enabled = item->checkState() == Checked;
+       }
+
+       // Commit the properties
        _device_options_binding.commit();
 }
 
+void DeviceOptions::setup_probes()
+{
+       using namespace Qt;
+
+       for (const GSList *l = _sdi->probes; l; l = l->next) {
+               sr_probe *const probe = (sr_probe*)l->data;
+               assert(probe);
+               QListWidgetItem *const item = new QListWidgetItem(
+                       probe->name, &_probes);
+               assert(item);
+               item->setCheckState(probe->enabled ?
+                       Checked : Unchecked);
+               item->setData(UserRole,
+                       qVariantFromValue((void*)probe));
+               _probes.addItem(item);
+       }
+}
+
 } // namespace dialogs
 } // namespace pv
index 20f6b6b65205a67d61c88c43851898d12cff8fb1..2e1b7bfb23c9c3999873c00995461266b49ade2c 100644 (file)
@@ -23,6 +23,8 @@
 
 #include <QDialog>
 #include <QDialogButtonBox>
+#include <QGroupBox>
+#include <QListWidget>
 #include <QVBoxLayout>
 
 #include <pv/prop/binding/deviceoptions.h>
@@ -39,7 +41,20 @@ protected:
        void accept();
 
 private:
+       void setup_probes();
+
+private:
+       struct sr_dev_inst *const _sdi;
+
        QVBoxLayout _layout;
+
+       QGroupBox _probes_box;
+       QVBoxLayout _probes_box_layout;
+       QListWidget _probes;
+
+       QGroupBox _props_box;
+       QVBoxLayout _props_box_layout;
+
        QDialogButtonBox _button_box;
 
        pv::prop::binding::DeviceOptions _device_options_binding;