]> sigrok.org Git - pulseview.git/commitdiff
Add a mechanism to make ViewItem classes immovable.
authorTilman Sauerbeck <redacted>
Sat, 7 Nov 2015 14:31:08 +0000 (15:31 +0100)
committerTilman Sauerbeck <redacted>
Sat, 7 Nov 2015 14:52:15 +0000 (15:52 +0100)
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.

pv/view/viewitem.cpp
pv/view/viewitem.hpp

index a63d4d38ed7a3c6932f891883ab8918df70097cc..e9602f8790ddcec61767509cd694524cbd3d8cd6 100644 (file)
@@ -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()
index 648be84e64384a6fa382a503ee28f0892a480619..16b34cb0dc59fb880eed69e92a314ec10a00ce53 100644 (file)
@@ -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.
         */