]> sigrok.org Git - pulseview.git/commitdiff
Added decoder delete context menu item
authorJoel Holdsworth <redacted>
Sun, 8 Sep 2013 14:03:10 +0000 (15:03 +0100)
committerJoel Holdsworth <redacted>
Sun, 29 Sep 2013 14:56:13 +0000 (23:56 +0900)
pv/sigsession.cpp
pv/sigsession.h
pv/view/decodesignal.cpp
pv/view/decodesignal.h

index d8976a1483c1c7ab47708f7fa285d84789b21c80..dacf65e56b55df4c8266d603928c86c0ce02a6fc 100644 (file)
@@ -223,6 +223,20 @@ vector< shared_ptr<view::DecodeSignal> > SigSession::get_decode_signals() const
        return _decode_traces;
 }
 
+void SigSession::remove_decode_signal(view::DecodeSignal *signal)
+{
+       for (vector< shared_ptr<view::DecodeSignal> >::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<mutex> lock(_sampling_mutex);
index 75ecff683fab00f1aad317fc5cbb178da17cce76..e0eb493853cb54d871f2aafc5e8e15b21376a232 100644 (file)
@@ -101,6 +101,8 @@ public:
        std::vector< boost::shared_ptr<view::DecodeSignal> >
                get_decode_signals() const;
 
+       void remove_decode_signal(view::DecodeSignal *signal);
+
 private:
        void set_capture_state(capture_state state);
 
index 89d2c3212774cd229d72666a32cdd73f72e5ae8f..afc465b9e7a1fe4ff39ce10f4a8acac14e8d1264 100644 (file)
@@ -24,6 +24,8 @@ extern "C" {
 
 #include <extdef.h>
 
+#include <QAction>
+
 #include "decodesignal.h"
 
 #include <pv/sigsession.h>
@@ -114,11 +116,29 @@ const list<QAction*> 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
index 673d65499509a409ca1266c5fbcd693ed4d97cd4..b9fbb24d15bc3ee3d18c0646799818f08159f884 100644 (file)
@@ -68,6 +68,8 @@ public:
 
        const std::list<QAction*> 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<pv::data::Decoder> _decoder;