X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fsignal.cpp;h=51af899ee4d814d8703e92c33ebfe135142cd6ad;hp=1f00477a2012d9cb5a3a8e11f6cd046ff62f8682;hb=0715fb8c638b53ac25590841fcbf3a1da3546b68;hpb=b213ef0991a13af0c74ffe5c54382c5c455c5496 diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index 1f00477a..51af899e 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -25,15 +25,23 @@ #include #include +#include +#include #include +#include + #include "signal.h" #include "view.h" +#include + +using std::shared_ptr; + namespace pv { namespace view { -const char *const ProbeNames[] = { +const char *const ChannelNames[] = { "CLK", "DATA", "IN", @@ -50,13 +58,15 @@ const char *const ProbeNames[] = { "SCL" }; -Signal::Signal(pv::SigSession &session, sr_probe *const probe) : - Trace(session, probe->name), - _probe(probe), +Signal::Signal(shared_ptr dev_inst, + const sr_channel *const channel) : + Trace(channel->name), + _dev_inst(dev_inst), + _channel(channel), _name_widget(NULL), _updating_name_widget(false) { - assert(_probe); + assert(_channel); } void Signal::set_name(QString name) @@ -69,28 +79,41 @@ void Signal::set_name(QString name) bool Signal::enabled() const { - return _probe->enabled; + return _channel->enabled; } void Signal::enable(bool enable) { - _probe->enabled = enable; + _dev_inst->enable_channel(_channel, enable); visibility_changed(); } -const sr_probe* Signal::probe() const +const sr_channel* Signal::channel() const { - return _probe; + return _channel; } void Signal::populate_popup_form(QWidget *parent, QFormLayout *form) { + int index; + _name_widget = new QComboBox(parent); _name_widget->setEditable(true); - for(unsigned int i = 0; i < countof(ProbeNames); i++) - _name_widget->insertItem(i, ProbeNames[i]); - _name_widget->setEditText(_probe->name); + for(unsigned int i = 0; i < countof(ChannelNames); i++) + _name_widget->insertItem(i, ChannelNames[i]); + + index = _name_widget->findText(_name, Qt::MatchExactly); + + if (index == -1) { + _name_widget->insertItem(0, _name); + _name_widget->setCurrentIndex(0); + } else { + _name_widget->setCurrentIndex(index); + } + + _name_widget->lineEdit()->selectAll(); + _name_widget->setFocus(); connect(_name_widget, SIGNAL(editTextChanged(const QString&)), this, SLOT(on_text_changed(const QString&)));