From: Soeren Apel Date: Tue, 29 Dec 2015 22:13:18 +0000 (+0100) Subject: Make traces only selectable in the header area X-Git-Tag: pulseview-0.3.0~16 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=35365c66bf6166c5607f1180016528d996a45b66;p=pulseview.git Make traces only selectable in the header area --- 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_; };