X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fsignal.cpp;h=a8de4d504aaa36b0fdb9960fb4f5b72c5b2391ae;hp=9f97d5bca7194562f40d4939b77e47f46e19502b;hb=04394ded8776d2163c1e815ccc8170b81d76b028;hpb=0771cc94a8487f1510d0a6751538a39652e9897f diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index 9f97d5bc..a8de4d50 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -31,12 +31,13 @@ #include +#include "pv/data/signalbase.hpp" + #include "signal.hpp" #include "view.hpp" using std::shared_ptr; - -using sigrok::Channel; +using std::make_shared; namespace pv { namespace view { @@ -59,66 +60,73 @@ const char *const ChannelNames[] = { }; Signal::Signal(pv::Session &session, - std::shared_ptr channel) : - Trace(QString::fromUtf8(channel->name().c_str())), + std::shared_ptr channel) : + Trace(channel), session_(session), - channel_(channel), - name_widget_(nullptr), - updating_name_widget_(false) + scale_handle_(make_shared(*this)), + items_({scale_handle_}), + name_widget_(nullptr) { - assert(channel_); + assert(base_); } void Signal::set_name(QString name) { Trace::set_name(name); - 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()); + if (name != name_widget_->currentText()) + name_widget_->setEditText(name); } bool Signal::enabled() const { - return channel_->enabled(); + return base_->enabled(); } void Signal::enable(bool enable) { - channel_->set_enabled(enable); + base_->set_enabled(enable); if (owner_) owner_->extents_changed(true, true); } -shared_ptr Signal::channel() const +shared_ptr Signal::base() const +{ + return base_; +} + +const ViewItemOwner::item_list& Signal::child_items() const +{ + return items_; +} + +void Signal::paint_back(QPainter &p, const ViewItemPaintParams &pp) { - return channel_; + if (base_->enabled()) + Trace::paint_back(p, pp); } void Signal::populate_popup_form(QWidget *parent, QFormLayout *form) { name_widget_ = new QComboBox(parent); name_widget_->setEditable(true); - name_widget_->setCompleter(0); + name_widget_->setCompleter(nullptr); - for(unsigned int i = 0; i < countof(ChannelNames); i++) + for (unsigned int i = 0; i < countof(ChannelNames); i++) name_widget_->insertItem(i, ChannelNames[i]); - const int index = name_widget_->findText(name_, Qt::MatchExactly); + const int index = name_widget_->findText(base_->name(), Qt::MatchExactly); if (index == -1) { - name_widget_->insertItem(0, name_); + name_widget_->insertItem(0, base_->name()); name_widget_->setCurrentIndex(0); } else { name_widget_->setCurrentIndex(index); } connect(name_widget_, SIGNAL(editTextChanged(const QString&)), - this, SLOT(on_text_changed(const QString&))); + this, SLOT(on_nameedit_changed(const QString&))); form->addRow(tr("Name"), name_widget_); @@ -144,6 +152,14 @@ void Signal::delete_pressed() on_disable(); } +void Signal::on_name_changed(const QString &text) +{ + if (text != name_widget_->currentText()) + name_widget_->setEditText(text); + + Trace::on_name_changed(text); +} + void Signal::on_disable() { enable(false);