From: Joel Holdsworth Date: Sun, 13 Oct 2013 22:44:33 +0000 (+0100) Subject: Added Header delete key X-Git-Tag: pulseview-0.2.0~247 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=5ed1adf555e0f0fb36d5b4b36f2be17745b5c8ae;p=pulseview.git Added Header delete key --- diff --git a/pv/view/decodesignal.cpp b/pv/view/decodesignal.cpp index bce58a19..5f6bfffc 100644 --- a/pv/view/decodesignal.cpp +++ b/pv/view/decodesignal.cpp @@ -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); diff --git a/pv/view/decodesignal.h b/pv/view/decodesignal.h index ab1a1608..f9113f5b 100644 --- a/pv/view/decodesignal.h +++ b/pv/view/decodesignal.h @@ -66,6 +66,8 @@ public: QMenu* create_context_menu(QWidget *parent); + void delete_pressed(); + private: /** diff --git a/pv/view/header.cpp b/pv/view/header.cpp index 77a887f9..dec5c20c 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -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 > traces(_view.get_traces()); + BOOST_FOREACH(const shared_ptr t, traces) + if (t->selected()) + t->delete_pressed(); + break; + } + } +} + void Header::on_signals_changed() { const vector< shared_ptr > traces(_view.get_traces()); diff --git a/pv/view/header.h b/pv/view/header.h index 02422782..806cc985 100644 --- a/pv/view/header.h +++ b/pv/view/header.h @@ -62,6 +62,8 @@ private: void contextMenuEvent(QContextMenuEvent *event); + void keyPressEvent(QKeyEvent *e); + private slots: void on_signals_changed(); diff --git a/pv/view/selectableitem.cpp b/pv/view/selectableitem.cpp index 31c45ef3..3f4f6da9 100644 --- a/pv/view/selectableitem.cpp +++ b/pv/view/selectableitem.cpp @@ -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( diff --git a/pv/view/selectableitem.h b/pv/view/selectableitem.h index fa728c72..d3217752 100644 --- a/pv/view/selectableitem.h +++ b/pv/view/selectableitem.h @@ -63,6 +63,8 @@ public: virtual pv::widgets::Popup* create_popup(QWidget *parent) = 0; + virtual void delete_pressed(); + protected: static QPen highlight_pen(); diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index 44341aea..8ca55900 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -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); diff --git a/pv/view/signal.h b/pv/view/signal.h index ecd13dc9..e5e91954 100644 --- a/pv/view/signal.h +++ b/pv/view/signal.h @@ -64,6 +64,8 @@ public: QMenu* create_context_menu(QWidget *parent); + void delete_pressed(); + private slots: void on_disable();