From 35365c66bf6166c5607f1180016528d996a45b66 Mon Sep 17 00:00:00 2001 From: Soeren Apel Date: Tue, 29 Dec 2015 23:13:18 +0100 Subject: [PATCH] Make traces only selectable in the header area --- pv/view/trace.cpp | 10 ++++++++++ pv/view/trace.hpp | 5 +++++ pv/view/viewitem.hpp | 2 -- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index f7e7ebf2..ee0a4f0e 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -91,6 +91,16 @@ bool Trace::is_draggable() const return (cursor_pos.x() <= view->header_size().width()); } +void Trace::select(bool select) +{ + // Trace can only be selected if the mouse cursor is in the header area; + // as is_draggable() checks the same thing, we re-use it here + if (is_draggable() && select) + selected_ = true; + else + selected_ = false; +} + void Trace::paint_label(QPainter &p, const QRect &rect, bool hover) { const int y = get_visual_y(); diff --git a/pv/view/trace.hpp b/pv/view/trace.hpp index acaa341a..88e54b1a 100644 --- a/pv/view/trace.hpp +++ b/pv/view/trace.hpp @@ -86,6 +86,11 @@ public: */ bool is_draggable() const; + /** + * Selects or deselects the signal. + */ + void select(bool select = true); + /** * Computes the outline rectangle of the viewport hit-box. * @param rect the rectangle of the viewport area. diff --git a/pv/view/viewitem.hpp b/pv/view/viewitem.hpp index a4eb6aef..c9da948e 100644 --- a/pv/view/viewitem.hpp +++ b/pv/view/viewitem.hpp @@ -167,8 +167,6 @@ protected: protected: QWidget *context_parent_; QPoint drag_point_; - -private: bool selected_; }; -- 2.30.2