From: Joel Holdsworth Date: Sun, 21 Dec 2014 11:36:46 +0000 (+0000) Subject: Header: Make get_mouse_over_item return shared_ptr X-Git-Tag: pulseview-0.3.0~316 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=bc01bb31fb03f69c8ceef57676b3399d7a08dcd9;p=pulseview.git Header: Make get_mouse_over_item return shared_ptr --- diff --git a/pv/view/header.cpp b/pv/view/header.cpp index 04e4c764..a2a7c505 100644 --- a/pv/view/header.cpp +++ b/pv/view/header.cpp @@ -80,7 +80,7 @@ QSize Header::extended_size_hint() const return sizeHint() + QSize(ViewItem::HighlightRadius, 0); } -shared_ptr Header::get_mouse_over_item(const QPoint &pt) +shared_ptr Header::get_mouse_over_item(const QPoint &pt) { const QRect r(0, 0, width() - BaselineOffset, height()); for (auto &i : view_) @@ -174,7 +174,7 @@ void Header::mouseLeftReleaseEvent(QMouseEvent *event) QApplication::keyboardModifiers() & Qt::ControlModifier; // Unselect everything if control is not pressed - const shared_ptr mouse_over = + const shared_ptr mouse_over = get_mouse_over_item(event->pos()); for (auto &r : view_) @@ -254,7 +254,7 @@ void Header::mouseMoveEvent(QMouseEvent *event) void Header::contextMenuEvent(QContextMenuEvent *event) { - const shared_ptr r = get_mouse_over_item(mouse_point_); + const shared_ptr r = get_mouse_over_item(mouse_point_); if (!r) return; diff --git a/pv/view/header.hpp b/pv/view/header.hpp index 3c94f791..e2492643 100644 --- a/pv/view/header.hpp +++ b/pv/view/header.hpp @@ -32,6 +32,7 @@ namespace view { class RowItem; class View; +class ViewItem; class Header : public MarginWidget { @@ -59,7 +60,13 @@ public: static const int BaselineOffset; private: - std::shared_ptr get_mouse_over_item( + /** + * Gets the first view item which has a label that contains @c pt . + * @param pt the point to search with. + * @return the view item that has been found, or and empty + * @c shared_ptr if no item was found. + */ + std::shared_ptr get_mouse_over_item( const QPoint &pt); void clear_selection();