From: Tilman Sauerbeck Date: Sat, 7 Nov 2015 14:31:08 +0000 (+0100) Subject: Add a mechanism to make ViewItem classes immovable. X-Git-Tag: pulseview-0.3.0~47 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=a009d21992db132679e27030736ed614522245ea;p=pulseview.git Add a mechanism to make ViewItem classes immovable. This adds a new method ViewItem::is_draggable(), which returns true iff the view item is supposed to be draggable/movable. Also, ViewItem::drag() is turned into a nop if the item is not draggable. --- diff --git a/pv/view/viewitem.cpp b/pv/view/viewitem.cpp index a63d4d38..e9602f87 100644 --- a/pv/view/viewitem.cpp +++ b/pv/view/viewitem.cpp @@ -49,6 +49,11 @@ void ViewItem::select(bool select) selected_ = select; } +bool ViewItem::is_draggable() const +{ + return true; +} + bool ViewItem::dragging() const { return drag_point_.x() != INT_MIN && drag_point_.y() != INT_MIN; @@ -56,7 +61,8 @@ bool ViewItem::dragging() const void ViewItem::drag() { - drag_point_ = point(QRect()); + if (is_draggable()) + drag_point_ = point(QRect()); } void ViewItem::drag_release() diff --git a/pv/view/viewitem.hpp b/pv/view/viewitem.hpp index 648be84e..16b34cb0 100644 --- a/pv/view/viewitem.hpp +++ b/pv/view/viewitem.hpp @@ -68,6 +68,11 @@ public: */ virtual void select(bool select = true); + /** + Returns true if the item may be dragged/moved. + */ + virtual bool is_draggable() const; + /** * Returns true if the item is being dragged. */