X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fsignal.cpp;h=5cd5b183590af45dcd783dd948f3a0d81af84582;hp=16ebc74d24a890f70f8ca3f5bf0d8b1335506f5b;hb=8c09273b13a10399e7f7d18dd446c2d13813e239;hpb=e8d009288de28cb194bc7964f96677c2baf900c9 diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index 16ebc74d..5cd5b183 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -29,12 +29,13 @@ #include #include -#include +#include -#include "signal.h" -#include "view.h" +#include "signal.hpp" +#include "view.hpp" using std::shared_ptr; +using std::make_shared; using sigrok::Channel; @@ -47,8 +48,8 @@ const char *const ChannelNames[] = { "IN", "OUT", "RST", - "Tx", - "Rx", + "TX", + "RX", "EN", "SCLK", "MOSI", @@ -58,62 +59,81 @@ const char *const ChannelNames[] = { "SCL" }; -Signal::Signal(shared_ptr channel) : - Trace(channel->name().c_str()), - _channel(channel), - _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) { - assert(_channel); + assert(channel_); } void Signal::set_name(QString name) { Trace::set_name(name); - _updating_name_widget = true; - _name_widget->setEditText(name); - _updating_name_widget = false; + + if (name != name_widget_->currentText()) + name_widget_->setEditText(name); + + // 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 _channel->enabled(); + return channel_->enabled(); } void Signal::enable(bool enable) { - _channel->set_enabled(enable); - visibility_changed(); + channel_->set_enabled(enable); + + if (owner_) + owner_->extents_changed(true, true); } shared_ptr Signal::channel() const { - return _channel; + return channel_; } -void Signal::populate_popup_form(QWidget *parent, QFormLayout *form) +const ViewItemOwner::item_list& Signal::child_items() const +{ + return items_; +} + +void Signal::paint_back(QPainter &p, const ViewItemPaintParams &pp) { - int index; + if (channel_->enabled()) + Trace::paint_back(p, pp); +} - _name_widget = new QComboBox(parent); - _name_widget->setEditable(true); +void Signal::populate_popup_form(QWidget *parent, QFormLayout *form) +{ + name_widget_ = new QComboBox(parent); + name_widget_->setEditable(true); + name_widget_->setCompleter(nullptr); - for(unsigned int i = 0; i < countof(ChannelNames); i++) - _name_widget->insertItem(i, ChannelNames[i]); + for (unsigned int i = 0; i < countof(ChannelNames); i++) + name_widget_->insertItem(i, ChannelNames[i]); - index = _name_widget->findText(_name, Qt::MatchExactly); + const int index = name_widget_->findText(name_, Qt::MatchExactly); if (index == -1) { - _name_widget->insertItem(0, _name); - _name_widget->setCurrentIndex(0); + name_widget_->insertItem(0, name_); + name_widget_->setCurrentIndex(0); } else { - _name_widget->setCurrentIndex(index); + 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); }