From: Joel Holdsworth Date: Sun, 8 Sep 2013 14:03:10 +0000 (+0100) Subject: Added decoder delete context menu item X-Git-Tag: pulseview-0.2.0~282 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c51482b339fbb76e0de042ac3f136a6e5b752b9a;p=pulseview.git Added decoder delete context menu item --- diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index d8976a14..dacf65e5 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -223,6 +223,20 @@ vector< shared_ptr > SigSession::get_decode_signals() const return _decode_traces; } +void SigSession::remove_decode_signal(view::DecodeSignal *signal) +{ + for (vector< shared_ptr >::iterator i = + _decode_traces.begin(); + i != _decode_traces.end(); + i++) + if ((*i).get() == signal) + { + _decode_traces.erase(i); + signals_changed(); + return; + } +} + void SigSession::set_capture_state(capture_state state) { lock_guard lock(_sampling_mutex); diff --git a/pv/sigsession.h b/pv/sigsession.h index 75ecff68..e0eb4938 100644 --- a/pv/sigsession.h +++ b/pv/sigsession.h @@ -101,6 +101,8 @@ public: std::vector< boost::shared_ptr > get_decode_signals() const; + void remove_decode_signal(view::DecodeSignal *signal); + private: void set_capture_state(capture_state state); diff --git a/pv/view/decodesignal.cpp b/pv/view/decodesignal.cpp index 89d2c321..afc465b9 100644 --- a/pv/view/decodesignal.cpp +++ b/pv/view/decodesignal.cpp @@ -24,6 +24,8 @@ extern "C" { #include +#include + #include "decodesignal.h" #include @@ -114,11 +116,29 @@ const list DecodeSignal::get_context_bar_actions() return actions; } +QMenu* DecodeSignal::create_context_menu(QWidget *parent) +{ + QMenu *const menu = Trace::create_context_menu(parent); + + menu->addSeparator(); + + QAction *const del = new QAction(tr("Delete"), this); + connect(del, SIGNAL(triggered()), this, SLOT(on_delete())); + menu->addAction(del); + + return menu; +} + void DecodeSignal::on_new_decode_data() { if (_view) _view->update_viewport(); } +void DecodeSignal::on_delete() +{ + _session.remove_decode_signal(this); +} + } // namespace view } // namespace pv diff --git a/pv/view/decodesignal.h b/pv/view/decodesignal.h index 673d6549..b9fbb24d 100644 --- a/pv/view/decodesignal.h +++ b/pv/view/decodesignal.h @@ -68,6 +68,8 @@ public: const std::list get_context_bar_actions(); + QMenu* create_context_menu(QWidget *parent); + private: /** @@ -79,6 +81,8 @@ private: private slots: void on_new_decode_data(); + void on_delete(); + private: boost::shared_ptr _decoder;