]> sigrok.org Git - pulseview.git/commitdiff
Header: Allow RowItems to have no popup
authorJoel Holdsworth <redacted>
Mon, 27 Oct 2014 20:33:27 +0000 (20:33 +0000)
committerJoel Holdsworth <redacted>
Wed, 19 Nov 2014 10:23:02 +0000 (10:23 +0000)
pv/view/header.cpp
pv/view/header.h

index 5e978a70252565cf47f4a3bb95712707a813842d..8377cb2cfc481e76d932b68c47e35cc14bd5edec 100644 (file)
@@ -108,6 +108,19 @@ void Header::clear_selection()
        update();
 }
 
        update();
 }
 
+void Header::show_popup(const shared_ptr<RowItem> &item)
+{
+       using pv::widgets::Popup;
+
+       Popup *const p = item->create_popup(&_view);
+       if (!p)
+               return;
+
+       const QPoint pt(width() - BaselineOffset, item->get_y());
+       p->set_position(mapToGlobal(pt), Popup::Right);
+       p->show();
+}
+
 void Header::paintEvent(QPaintEvent*)
 {
        // The trace labels are not drawn with the arrows exactly on the
 void Header::paintEvent(QPaintEvent*)
 {
        // The trace labels are not drawn with the arrows exactly on the
@@ -187,8 +200,6 @@ void Header::mousePressEvent(QMouseEvent *event)
 
 void Header::mouseReleaseEvent(QMouseEvent *event)
 {
 
 void Header::mouseReleaseEvent(QMouseEvent *event)
 {
-       using pv::widgets::Popup;
-
        assert(event);
        if (event->button() == Qt::LeftButton) {
                if (_dragging)
        assert(event);
        if (event->button() == Qt::LeftButton) {
                if (_dragging)
@@ -197,15 +208,8 @@ void Header::mouseReleaseEvent(QMouseEvent *event)
                {
                        const shared_ptr<RowItem> mouse_over_row_item =
                                get_mouse_over_row_item(event->pos());
                {
                        const shared_ptr<RowItem> mouse_over_row_item =
                                get_mouse_over_row_item(event->pos());
-                       if (mouse_over_row_item) {
-                               const int w = width() - BaselineOffset;
-                               Popup *const p =
-                                       mouse_over_row_item->create_popup(&_view);
-                               p->set_position(mapToGlobal(QPoint(w,
-                                       mouse_over_row_item->get_y())),
-                                       Popup::Right);
-                               p->show();
-                       }
+                       if (mouse_over_row_item)
+                               show_popup(mouse_over_row_item);
                }
 
                _dragging = false;
                }
 
                _dragging = false;
index f4e7ef4a6bd832eedc69c78a879f0d4f8cbfa674..319f234e255e532f4f3a016c1c78bb6c40d1c821 100644 (file)
@@ -57,6 +57,8 @@ private:
 
        void clear_selection();
 
 
        void clear_selection();
 
+       void show_popup(const std::shared_ptr<RowItem> &item);
+
 private:
        void paintEvent(QPaintEvent *event);
 
 private:
        void paintEvent(QPaintEvent *event);