From: Joel Holdsworth Date: Sun, 21 Dec 2014 11:38:25 +0000 (+0000) Subject: Ruler: Make get_mouse_over_item return shared_ptr X-Git-Tag: pulseview-0.3.0~315 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6871ee9fc6c4a87cfa3796b893b91fc5b16c2673;p=pulseview.git Ruler: Make get_mouse_over_item return shared_ptr --- diff --git a/pv/view/ruler.cpp b/pv/view/ruler.cpp index 0c4dcb0b..5b84d6d3 100644 --- a/pv/view/ruler.cpp +++ b/pv/view/ruler.cpp @@ -76,7 +76,7 @@ QSize Ruler::extended_size_hint() const ViewItem::HighlightRadius); } -shared_ptr Ruler::get_mouse_over_item(const QPoint &pt) +shared_ptr Ruler::get_mouse_over_item(const QPoint &pt) { const vector< shared_ptr > items(view_.time_items()); for (auto i = items.rbegin(); i != items.rend(); i++) @@ -216,7 +216,7 @@ void Ruler::mouseDoubleClickEvent(QMouseEvent *e) void Ruler::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/ruler.hpp b/pv/view/ruler.hpp index 5720c9a9..68e7eb58 100644 --- a/pv/view/ruler.hpp +++ b/pv/view/ruler.hpp @@ -29,6 +29,7 @@ namespace pv { namespace view { class TimeItem; +class ViewItem; class Ruler : public MarginWidget { @@ -61,7 +62,13 @@ public: QSize extended_size_hint() const; 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); private: