]> sigrok.org Git - pulseview.git/commitdiff
MarginWidget: Moved in keyPressEvent
authorJoel Holdsworth <redacted>
Sun, 21 Dec 2014 14:07:53 +0000 (14:07 +0000)
committerJoel Holdsworth <redacted>
Mon, 29 Dec 2014 11:56:00 +0000 (11:56 +0000)
pv/view/header.cpp
pv/view/marginwidget.cpp
pv/view/marginwidget.hpp
pv/view/ruler.cpp
pv/view/ruler.hpp

index 2a732f25daa3f7f16590c8d8e39310e4acc4a295..766347d5272a09962de138584a57e97cbf479ffa 100644 (file)
@@ -238,13 +238,9 @@ void Header::keyPressEvent(QKeyEvent *e)
 {
        assert(e);
 
-       if (e->key() == Qt::Key_Delete)
-       {
-               for (const shared_ptr<RowItem> 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();
index e20e7b9f00afe664e72439969b73fe5894b6eca7..5a81c45933450b40e5aee63d36116b75eeba6b8b 100644 (file)
@@ -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();
index 77a10a22f5a1240a19d418cb8e297a07492811ad..1194696548e4cd57def831bb05e59efb69daeabf 100644 (file)
@@ -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();
 
index b847d2c82a5c25408f0cc561a9bc35cd20c0e9ea..f4bffd4cf6820449f4818dba3d78e4505fbfe57e 100644 (file)
@@ -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<TimeItem> > 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();
index 7fa58452fe76cd5fa7210d8b35a27420c6f00847..d13a31b8e7a0a0826b50b9244829429ee293e9a9 100644 (file)
@@ -81,8 +81,6 @@ private:
 
        void mouseDoubleClickEvent(QMouseEvent *e);
 
-       void keyPressEvent(QKeyEvent *e);
-
 private:
        /**
         * Draw a hover arrow under the cursor position.