From: Joel Holdsworth Date: Mon, 11 Mar 2013 20:41:04 +0000 (+0000) Subject: Added a probe selector X-Git-Tag: pulseview-0.1.0~88 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=0740907f0a3a0908ae71908d8278ef81c7066dcb;p=pulseview.git Added a probe selector --- diff --git a/pv/dialogs/deviceoptions.cpp b/pv/dialogs/deviceoptions.cpp index b8f4cabf..232e6f6f 100644 --- a/pv/dialogs/deviceoptions.cpp +++ b/pv/dialogs/deviceoptions.cpp @@ -20,12 +20,18 @@ #include "deviceoptions.h" +#include + 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(); + 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 diff --git a/pv/dialogs/deviceoptions.h b/pv/dialogs/deviceoptions.h index 20f6b6b6..2e1b7bfb 100644 --- a/pv/dialogs/deviceoptions.h +++ b/pv/dialogs/deviceoptions.h @@ -23,6 +23,8 @@ #include #include +#include +#include #include #include @@ -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;