X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fsignal.cpp;h=47e91f4b9a67f9a904d0b059e3da5cee543a35ab;hp=3312c5924576b9517c5aa6425de4f935cbf95e63;hb=f1626bb80080435e306c9a6c5d6ff20dd6dc9e57;hpb=4871ed92f2d9e6e514223383ba16e6ad78c81161 diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index 3312c592..47e91f4b 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -21,32 +21,35 @@ #include #include -#include +#include #include #include +#include +#include #include -#include +#include -#include "signal.h" -#include "view.h" +#include "signal.hpp" +#include "view.hpp" -#include +using std::shared_ptr; +using std::make_shared; -using boost::shared_ptr; +using sigrok::Channel; namespace pv { namespace view { -const char *const ProbeNames[] = { +const char *const ChannelNames[] = { "CLK", "DATA", "IN", "OUT", "RST", - "Tx", - "Rx", + "TX", + "RX", "EN", "SCLK", "MOSI", @@ -56,54 +59,76 @@ const char *const ProbeNames[] = { "SCL" }; -Signal::Signal(shared_ptr dev_inst, - const sr_channel *const probe) : - Trace(probe->name), - _dev_inst(dev_inst), - _probe(probe), - _name_widget(NULL), - _updating_name_widget(false) +Signal::Signal(pv::Session &session, + std::shared_ptr channel) : + Trace(QString::fromUtf8(channel->name().c_str())), + session_(session), + channel_(channel), + scale_handle_(make_shared(*this)), + items_({scale_handle_}), + name_widget_(nullptr), + updating_name_widget_(false) { - assert(_probe); + assert(channel_); } void Signal::set_name(QString name) { Trace::set_name(name); - _updating_name_widget = true; - _name_widget->setEditText(name); - _updating_name_widget = false; + updating_name_widget_ = true; + name_widget_->setEditText(name); + updating_name_widget_ = false; + + // Store the channel name in sigrok::Channel so that it + // will end up in the .sr file upon save. + channel_->set_name(name.toUtf8().constData()); } bool Signal::enabled() const { - return _probe->enabled; + return channel_->enabled(); } void Signal::enable(bool enable) { - _dev_inst->enable_probe(_probe, enable); - visibility_changed(); + channel_->set_enabled(enable); + + if (owner_) + owner_->extents_changed(true, true); } -const sr_channel* Signal::probe() const +shared_ptr Signal::channel() const { - return _probe; + return channel_; +} + +const ViewItemOwner::item_list& Signal::child_items() const +{ + return items_; } void Signal::populate_popup_form(QWidget *parent, QFormLayout *form) { - _name_widget = new QComboBox(parent); - _name_widget->setEditable(true); + name_widget_ = new QComboBox(parent); + name_widget_->setEditable(true); + name_widget_->setCompleter(0); + + for (unsigned int i = 0; i < countof(ChannelNames); i++) + name_widget_->insertItem(i, ChannelNames[i]); + + const int index = name_widget_->findText(name_, Qt::MatchExactly); - for(unsigned int i = 0; i < countof(ProbeNames); i++) - _name_widget->insertItem(i, ProbeNames[i]); - _name_widget->setEditText(_probe->name); + if (index == -1) { + name_widget_->insertItem(0, name_); + name_widget_->setCurrentIndex(0); + } else { + name_widget_->setCurrentIndex(index); + } - connect(_name_widget, SIGNAL(editTextChanged(const QString&)), + connect(name_widget_, SIGNAL(editTextChanged(const QString&)), this, SLOT(on_text_changed(const QString&))); - form->addRow(tr("Name"), _name_widget); + form->addRow(tr("Name"), name_widget_); add_colour_option(parent, form); }