X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fsignal.cpp;h=fc90eba1fcd11cf6f5b5d0e132895304b8cbc9f9;hp=916801c97eceb17c67ec8c54c423065b0f73ab42;hb=bf0edd2b0cbb5f4bd5d69b0f00bcea7d037e2287;hpb=8dbbc7f0b9ea59d0f0d62225772f8a56eee125f5 diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index 916801c..fc90eba 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include @@ -29,14 +29,15 @@ #include #include -#include +#include -#include "signal.h" -#include "view.h" +#include "pv/data/signalbase.hpp" -using std::shared_ptr; +#include "signal.hpp" +#include "view.hpp" -using sigrok::Channel; +using std::shared_ptr; +using std::make_shared; namespace pv { namespace view { @@ -47,8 +48,8 @@ const char *const ChannelNames[] = { "IN", "OUT", "RST", - "Tx", - "Rx", + "TX", + "RX", "EN", "SCLK", "MOSI", @@ -58,13 +59,13 @@ const char *const ChannelNames[] = { "SCL" }; -Signal::Signal(pv::SigSession &session, - std::shared_ptr channel) : - Trace(channel->name().c_str()), +Signal::Signal(pv::Session &session, + std::shared_ptr channel) : + Trace(channel), session_(session), - channel_(channel), - name_widget_(NULL), - updating_name_widget_(false) + scale_handle_(make_shared(*this)), + items_({scale_handle_}), + name_widget_(nullptr) { assert(channel_); } @@ -72,9 +73,9 @@ Signal::Signal(pv::SigSession &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); } bool Signal::enabled() const @@ -90,32 +91,42 @@ void Signal::enable(bool enable) owner_->extents_changed(true, true); } -shared_ptr Signal::channel() const +shared_ptr 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(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]); - index = name_widget_->findText(name_, Qt::MatchExactly); + const int index = name_widget_->findText(channel_->name(), Qt::MatchExactly); if (index == -1) { - name_widget_->insertItem(0, name_); + name_widget_->insertItem(0, channel_->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_); @@ -141,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);