]> sigrok.org Git - pulseview.git/blobdiff - pv/view/signal.cpp
DecodeTrace: Prevent trace height from jumping
[pulseview.git] / pv / view / signal.cpp
index 7348d25b2d44bea1d974d05bda84d181102dfdbf..67f8dde9c1316c27f17c8830cf234f2285d755d6 100644 (file)
 #include <QLineEdit>
 #include <QMenu>
 
-#include <libsigrok/libsigrok.hpp>
+#include <libsigrokcxx/libsigrokcxx.hpp>
 
 #include "signal.hpp"
 #include "view.hpp"
 
 using std::shared_ptr;
+using std::make_shared;
 
 using sigrok::Channel;
 
@@ -63,8 +64,9 @@ Signal::Signal(pv::Session &session,
        Trace(QString::fromUtf8(channel->name().c_str())),
        session_(session),
        channel_(channel),
-       name_widget_(NULL),
-       updating_name_widget_(false)
+       scale_handle_(make_shared<SignalScaleHandle>(*this)),
+       items_({scale_handle_}),
+       name_widget_(nullptr)
 {
        assert(channel_);
 }
@@ -72,9 +74,9 @@ Signal::Signal(pv::Session &session,
 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.
@@ -99,17 +101,27 @@ shared_ptr<Channel> Signal::channel() const
        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);
+}
 
+void Signal::populate_popup_form(QWidget *parent, QFormLayout *form)
+{
        name_widget_ = new QComboBox(parent);
        name_widget_->setEditable(true);
+       name_widget_->setCompleter(0);
 
-       for(unsigned int i = 0; i < countof(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_);