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

index 766347d5272a09962de138584a57e97cbf479ffa..a42becaf366695caeff75440fd4ffff6e6eee18c 100644 (file)
@@ -123,46 +123,6 @@ void Header::paintEvent(QPaintEvent*)
        painter.end();
 }
 
-void Header::mouseLeftReleaseEvent(QMouseEvent *event)
-{
-       assert(event);
-
-       const bool ctrl_pressed =
-               QApplication::keyboardModifiers() & Qt::ControlModifier;
-
-       // Unselect everything if control is not pressed
-       const shared_ptr<ViewItem> mouse_over =
-               get_mouse_over_item(event->pos());
-
-       for (auto &r : view_)
-               r->drag_release();
-
-       if (dragging_)
-               view_.restack_all_row_items();
-       else
-       {
-               if (!ctrl_pressed) {
-                       for (shared_ptr<RowItem> r : view_)
-                               if (mouse_down_item_ != r)
-                                       r->select(false);
-
-                       if (mouse_down_item_)
-                               show_popup(mouse_down_item_);
-               }
-       }
-
-       dragging_ = false;
-}
-
-void Header::mouseReleaseEvent(QMouseEvent *event)
-{
-       assert(event);
-       if (event->button() & Qt::LeftButton)
-               mouseLeftReleaseEvent(event);
-
-       mouse_down_item_ = nullptr;
-}
-
 void Header::mouseMoveEvent(QMouseEvent *event)
 {
        assert(event);
index 704c33451686330012c6a929588872d885210852..758a702d78937d9abbe48b03955a827ec26cde3d 100644 (file)
@@ -78,9 +78,6 @@ private:
        void paintEvent(QPaintEvent *event);
 
 private:
-       void mouseLeftReleaseEvent(QMouseEvent *event);
-       void mouseReleaseEvent(QMouseEvent *event);
-
        void mouseMoveEvent(QMouseEvent *event);
 
        void contextMenuEvent(QContextMenuEvent *event);
index 5a81c45933450b40e5aee63d36116b75eeba6b8b..d96d3aba66f315bf1483f7b4f3045ce96552a7f6 100644 (file)
@@ -80,6 +80,38 @@ void MarginWidget::mouse_left_press_event(QMouseEvent *event)
        update();
 }
 
+void MarginWidget::mouse_left_release_event(QMouseEvent *event)
+{
+       assert(event);
+
+       auto items = this->items();
+       const bool ctrl_pressed =
+               QApplication::keyboardModifiers() & Qt::ControlModifier;
+
+       // Unselect everything if control is not pressed
+       const shared_ptr<ViewItem> mouse_over =
+               get_mouse_over_item(event->pos());
+
+       for (auto &i : items)
+               i->drag_release();
+
+       if (dragging_)
+               view_.restack_all_row_items();
+       else
+       {
+               if (!ctrl_pressed) {
+                       for (shared_ptr<ViewItem> i : items)
+                               if (mouse_down_item_ != i)
+                                       i->select(false);
+
+                       if (mouse_down_item_)
+                               show_popup(mouse_down_item_);
+               }
+       }
+
+       dragging_ = false;
+}
+
 void MarginWidget::mousePressEvent(QMouseEvent *event)
 {
        assert(event);
@@ -91,6 +123,15 @@ void MarginWidget::mousePressEvent(QMouseEvent *event)
                mouse_left_press_event(event);
 }
 
+void MarginWidget::mouseReleaseEvent(QMouseEvent *event)
+{
+       assert(event);
+       if (event->button() & Qt::LeftButton)
+               mouse_left_release_event(event);
+
+       mouse_down_item_ = nullptr;
+}
+
 void MarginWidget::leaveEvent(QEvent*)
 {
        mouse_point_ = QPoint(-1, -1);
index 1194696548e4cd57def831bb05e59efb69daeabf..35d557d10ccab7dcae57f57f6c990bce7c85e9d6 100644 (file)
@@ -73,8 +73,15 @@ protected:
         */
        void mouse_left_press_event(QMouseEvent *event);
 
+       /**
+        * Handles left mouse button release events.
+        * @param event the mouse event that triggered this handler.
+        */
+       void mouse_left_release_event(QMouseEvent *event);
+
 protected:
        void mousePressEvent(QMouseEvent * event);
+       void mouseReleaseEvent(QMouseEvent *event);
 
        void leaveEvent(QEvent *event);
 
index f4bffd4cf6820449f4818dba3d78e4505fbfe57e..0d86efd853202b0bf2753c91eff0344e5848478b 100644 (file)
@@ -175,21 +175,6 @@ void Ruler::mouseMoveEvent(QMouseEvent *e)
                        i->drag_by(delta);
 }
 
-void Ruler::mouseReleaseEvent(QMouseEvent *)
-{
-       using pv::widgets::Popup;
-
-       if (!dragging_ && mouse_down_item_)
-               show_popup(mouse_down_item_);
-
-       dragging_ = false;
-       mouse_down_item_.reset();
-
-       const vector< shared_ptr<TimeItem> > items(view_.time_items());
-       for (auto &i : items)
-               i->drag_release();
-}
-
 void Ruler::mouseDoubleClickEvent(QMouseEvent *e)
 {
        view_.add_flag(view_.offset() + ((double)e->x() + 0.5) * view_.scale());
index d13a31b8e7a0a0826b50b9244829429ee293e9a9..f29075c7868bc052b270135c31667f7b0aa72418 100644 (file)
@@ -77,7 +77,6 @@ private:
        void paintEvent(QPaintEvent *event);
 
        void mouseMoveEvent(QMouseEvent *e);
-       void mouseReleaseEvent(QMouseEvent *);
 
        void mouseDoubleClickEvent(QMouseEvent *e);