37
37
// QuickQanava headers
38
38
#include " ./qanGraph.h"
39
39
#include " ./qanGroup.h"
40
- #include " ./qanNavigable.h"
40
+ // #include "./qanNavigable.h"
41
41
#include " ./qanPortItem.h"
42
42
43
43
// Qt headers
@@ -50,7 +50,7 @@ namespace qan { // ::qan
50
50
*
51
51
* \nosubgrouping
52
52
*/
53
- class GraphView : public qan ::Navigable
53
+ class GraphView : public QQuickItem
54
54
{
55
55
Q_OBJECT
56
56
/* ! \name GraphView Object Management */ // ---------------------------------
@@ -60,7 +60,48 @@ class GraphView : public qan::Navigable
60
60
explicit GraphView (QQuickItem* parent = nullptr );
61
61
virtual ~GraphView () override = default ;
62
62
GraphView (const GraphView&) = delete ;
63
+ // @}
64
+ // -------------------------------------------------------------------------
65
+
63
66
67
+ /* ! \name View Flickable Management */ // ---------------------------------
68
+ // @{
69
+ public:
70
+ /* ! \brief Parent container for area child items.
71
+ *
72
+ * Items added as child of the area must manually update their parents property to \c containerItem
73
+ *
74
+ * Example code for navigating an image:
75
+ * \code
76
+ * // Don't forget to register the component:
77
+ * // C++: qmlRegisterType< qan::Navigable >( "Qanava", 1, 0, "Navigable");
78
+ * // QML: import QuickQanava 2.0
79
+ * Qan.Navigable {
80
+ * anchors.fill: parent
81
+ * clip: true // Don't set clipping if Navigable is anchored directly to your main window
82
+ * Image {
83
+ * parent: imageView.containerItem // Any direct child must manually set its parent item
84
+ * id: image
85
+ * source: "qrc:/myimage.png"
86
+ * Component.onCompleted: {
87
+ * // Eventually, fit the image in view: navigable.fitContentInView(), where navigable is Navigable id
88
+ * }
89
+ * }
90
+ * }
91
+ * \endcode
92
+ *
93
+ */
94
+ Q_PROPERTY (QQuickItem* containerItem READ getContainerItem CONSTANT FINAL)
95
+ // ! \sa containerItem
96
+ inline QQuickItem* getContainerItem () noexcept { return _containerItem.data (); }
97
+ private:
98
+ QPointer<QQuickItem> _containerItem = nullptr ;
99
+ // @}
100
+ // -------------------------------------------------------------------------
101
+
102
+
103
+ /* ! \name Graph Interactions */ // ------------------------------------------
104
+ // @{
64
105
public:
65
106
// ! Graph that should be displayed in this graph view.
66
107
Q_PROPERTY (qan::Graph* graph READ getGraph WRITE setGraph NOTIFY graphChanged FINAL)
@@ -73,8 +114,9 @@ class GraphView : public qan::Navigable
73
114
74
115
protected:
75
116
// ! Called when the mouse is clicked in the container (base implementation empty).
76
- virtual void navigableClicked (QPointF pos, QPointF globalPos) override ;
77
- virtual void navigableRightClicked (QPointF pos, QPointF globalPos) override ;
117
+ // FIXME #232 probably rename that...
118
+ virtual void navigableClicked (QPointF pos, QPointF globalPos);
119
+ virtual void navigableRightClicked (QPointF pos, QPointF globalPos);
78
120
79
121
// ! Utilisty method to convert a given \c url to a local file path (if possible, otherwise return an empty string).
80
122
Q_INVOKABLE QString urlToLocalFile (QUrl url) const noexcept ;
@@ -106,10 +148,12 @@ class GraphView : public qan::Navigable
106
148
// @{
107
149
protected:
108
150
// ! \copydoc qan::Navigable::selectionRectActivated()
109
- virtual void selectionRectActivated (const QRectF& rect) override ;
151
+ // FIXME #232 probably rename that...
152
+ virtual void selectionRectActivated (const QRectF& rect);
110
153
111
154
// ! \copydoc qan::Navigable::selectionRectEnd()
112
- virtual void selectionRectEnd () override ;
155
+ // FIXME #232 probably rename that...
156
+ virtual void selectionRectEnd ();
113
157
private:
114
158
QSet<QQuickItem*> _selectedItems;
115
159
0 commit comments