From: Joel Holdsworth Date: Sun, 21 Dec 2014 14:07:53 +0000 (+0000) Subject: MarginWidget: Moved in keyPressEvent X-Git-Tag: pulseview-0.3.0~309 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=bb4a0e8e0b337988264e43a368b6ce5950d2d6cd;p=pulseview.git MarginWidget: Moved in keyPressEvent --- diff --git a/pv/view/header.cpp b/pv/view/header.cpp index 2a732f25..766347d5 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -238,13 +238,9 @@ void Header::keyPressEvent(QKeyEvent *e) { assert(e); - if (e->key() == Qt::Key_Delete) - { - for (const shared_ptr r : view_) - if (r->selected()) - r->delete_pressed(); - } - else if (e->key() == Qt::Key_G && e->modifiers() == Qt::ControlModifier) + MarginWidget::keyPressEvent(e); + + if (e->key() == Qt::Key_G && e->modifiers() == Qt::ControlModifier) on_group(); else if (e->key() == Qt::Key_U && e->modifiers() == Qt::ControlModifier) on_ungroup(); diff --git a/pv/view/marginwidget.cpp b/pv/view/marginwidget.cpp index e20e7b9f..5a81c459 100644 --- a/pv/view/marginwidget.cpp +++ b/pv/view/marginwidget.cpp @@ -108,6 +108,19 @@ void MarginWidget::contextMenuEvent(QContextMenuEvent *event) menu->exec(event->globalPos()); } +void MarginWidget::keyPressEvent(QKeyEvent *e) +{ + assert(e); + + if (e->key() == Qt::Key_Delete) + { + const auto items = this->items(); + for (auto &i : items) + if (i->selected()) + i->delete_pressed(); + } +} + void MarginWidget::clear_selection() { const auto items = this->items(); diff --git a/pv/view/marginwidget.hpp b/pv/view/marginwidget.hpp index 77a10a22..11946965 100644 --- a/pv/view/marginwidget.hpp +++ b/pv/view/marginwidget.hpp @@ -73,13 +73,15 @@ protected: */ void mouse_left_press_event(QMouseEvent *event); -private: +protected: void mousePressEvent(QMouseEvent * event); void leaveEvent(QEvent *event); virtual void contextMenuEvent(QContextMenuEvent *event); + virtual void keyPressEvent(QKeyEvent *e); + public Q_SLOTS: void clear_selection(); diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index b847d2c8..f4bffd4c 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -195,19 +195,6 @@ void Ruler::mouseDoubleClickEvent(QMouseEvent *e) view_.add_flag(view_.offset() + ((double)e->x() + 0.5) * view_.scale()); } -void Ruler::keyPressEvent(QKeyEvent *e) -{ - assert(e); - - if (e->key() == Qt::Key_Delete) - { - const vector< shared_ptr > items(view_.time_items()); - for (auto &i : items) - if (i->selected()) - i->delete_pressed(); - } -} - void Ruler::draw_hover_mark(QPainter &p, int text_height) { const int x = view_.hover_point().x(); diff --git a/pv/view/ruler.hpp b/pv/view/ruler.hpp index 7fa58452..d13a31b8 100644 --- a/pv/view/ruler.hpp +++ b/pv/view/ruler.hpp @@ -81,8 +81,6 @@ private: void mouseDoubleClickEvent(QMouseEvent *e); - void keyPressEvent(QKeyEvent *e); - private: /** * Draw a hover arrow under the cursor position.