]> sigrok.org Git - pulseview.git/commitdiff
Added Header delete key
authorJoel Holdsworth <redacted>
Sun, 13 Oct 2013 22:44:33 +0000 (23:44 +0100)
committerJoel Holdsworth <redacted>
Mon, 14 Oct 2013 12:00:26 +0000 (13:00 +0100)
pv/view/decodesignal.cpp
pv/view/decodesignal.h
pv/view/header.cpp
pv/view/header.h
pv/view/selectableitem.cpp
pv/view/selectableitem.h
pv/view/signal.cpp
pv/view/signal.h

index bce58a1922751f145313bef0d53a39a992e92d61..5f6bfffcac63a95a5f3e45518405ddd5b1bf5353 100644 (file)
@@ -123,6 +123,11 @@ void DecodeSignal::on_new_decode_data()
                _view->update_viewport();
 }
 
+void DecodeSignal::delete_pressed()
+{
+       on_delete();
+}
+
 void DecodeSignal::on_delete()
 {
        _session.remove_decode_signal(this);
index ab1a1608c692e52976c5caaa982eab19340095f6..f9113f5bee99298ef5951aafc97657d59d0d7c58 100644 (file)
@@ -66,6 +66,8 @@ public:
 
        QMenu* create_context_menu(QWidget *parent);
 
+       void delete_pressed();
+
 private:
 
        /**
index 77a887f9fe4c9b6b232fa78aaf31cd11b3b5ecd3..dec5c20cbabfad042ec785886a2a2be9ca747e40 100644 (file)
@@ -46,6 +46,7 @@ Header::Header(View &parent) :
        MarginWidget(parent),
        _dragging(false)
 {
+       setFocusPolicy(Qt::ClickFocus);
        setMouseTracking(true);
 
        connect(&_view.session(), SIGNAL(signals_changed()),
@@ -235,6 +236,23 @@ void Header::contextMenuEvent(QContextMenuEvent *event)
                t->create_context_menu(this)->exec(event->globalPos());
 }
 
+void Header::keyPressEvent(QKeyEvent *e)
+{
+       assert(e);
+
+       switch (e->key())
+       {
+       case Qt::Key_Delete:
+       {
+               const vector< shared_ptr<Trace> > traces(_view.get_traces());
+               BOOST_FOREACH(const shared_ptr<Trace> t, traces)
+                       if (t->selected())
+                               t->delete_pressed();    
+               break;
+       }
+       }
+}
+
 void Header::on_signals_changed()
 {
        const vector< shared_ptr<Trace> > traces(_view.get_traces());
index 024227820b6635008216b38b290ec230fce528d8..806cc985c3d482877539cc07d6f90ee77c22cea5 100644 (file)
@@ -62,6 +62,8 @@ private:
 
        void contextMenuEvent(QContextMenuEvent *event);
 
+       void keyPressEvent(QKeyEvent *e);
+
 private slots:
        void on_signals_changed();
 
index 31c45ef3b166fa9ff4f85894edc304d761b1ad72..3f4f6da92dbef767611c404c753210888b7247fe 100644 (file)
@@ -51,6 +51,10 @@ QMenu* SelectableItem::create_context_menu(QWidget *parent)
        return new QMenu(parent);
 }
 
+void SelectableItem::delete_pressed()
+{
+}
+
 QPen SelectableItem::highlight_pen()
 {
        return QPen(QApplication::palette().brush(
index fa728c72745924f764c692a88b5fdb91c868aff0..d3217752289e4cea7ceffdc16b59482ddd862471 100644 (file)
@@ -63,6 +63,8 @@ public:
 
        virtual pv::widgets::Popup* create_popup(QWidget *parent) = 0;
 
+       virtual void delete_pressed();
+
 protected:
        static QPen highlight_pen();
 
index 44341aeab5cfa406dd3fa65390169907e2089248..8ca55900b47c8002861a8bacbafdba403e366a9c 100644 (file)
@@ -111,6 +111,11 @@ QMenu* Signal::create_context_menu(QWidget *parent)
        return menu;
 }
 
+void Signal::delete_pressed()
+{
+       on_disable();
+}
+
 void Signal::on_disable()
 {
        enable(false);
index ecd13dc92a17493d79f7f84a02a141fc5d6d30cf..e5e919548be0679147730823eaf113785c3871fe 100644 (file)
@@ -64,6 +64,8 @@ public:
 
        QMenu* create_context_menu(QWidget *parent);
 
+       void delete_pressed();
+
 private slots:
        void on_disable();