From: Joel Holdsworth Date: Mon, 27 Oct 2014 20:33:27 +0000 (+0000) Subject: Header: Allow RowItems to have no popup X-Git-Tag: pulseview-0.3.0~475 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=8b4802fb79f2af703a8e140daf3f8aacb19644c9;p=pulseview.git Header: Allow RowItems to have no popup --- diff --git a/pv/view/header.cpp b/pv/view/header.cpp index 5e978a70..8377cb2c 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -108,6 +108,19 @@ void Header::clear_selection() update(); } +void Header::show_popup(const shared_ptr &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 @@ -187,8 +200,6 @@ void Header::mousePressEvent(QMouseEvent *event) void Header::mouseReleaseEvent(QMouseEvent *event) { - using pv::widgets::Popup; - assert(event); if (event->button() == Qt::LeftButton) { if (_dragging) @@ -197,15 +208,8 @@ void Header::mouseReleaseEvent(QMouseEvent *event) { const shared_ptr 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; diff --git a/pv/view/header.h b/pv/view/header.h index f4e7ef4a..319f234e 100644 --- a/pv/view/header.h +++ b/pv/view/header.h @@ -57,6 +57,8 @@ private: void clear_selection(); + void show_popup(const std::shared_ptr &item); + private: void paintEvent(QPaintEvent *event);