X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fsignal.cpp;h=fc90eba1fcd11cf6f5b5d0e132895304b8cbc9f9;hp=5cd5b183590af45dcd783dd948f3a0d81af84582;hb=bf0edd2b0cbb5f4bd5d69b0f00bcea7d037e2287;hpb=14f9d4a1f4472d29366ed8333b20f4041cf1b443 diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index 5cd5b18..fc90eba 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -31,14 +31,14 @@ #include +#include "pv/data/signalbase.hpp" + #include "signal.hpp" #include "view.hpp" using std::shared_ptr; using std::make_shared; -using sigrok::Channel; - namespace pv { namespace view { @@ -60,10 +60,9 @@ 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), scale_handle_(make_shared(*this)), items_({scale_handle_}), name_widget_(nullptr) @@ -77,10 +76,6 @@ void Signal::set_name(QString name) 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 @@ -96,7 +91,7 @@ void Signal::enable(bool enable) owner_->extents_changed(true, true); } -shared_ptr Signal::channel() const +shared_ptr Signal::channel() const { return channel_; } @@ -121,17 +116,17 @@ void Signal::populate_popup_form(QWidget *parent, QFormLayout *form) 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(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_); @@ -157,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);