Skip to content

Commit 33e2cb1

Browse files
committed
#232 Testing replacement of qan::Navigable by a regular QML Flickable.
Signed-off-by: cneben <[email protected]>
1 parent 63deb2e commit 33e2cb1

File tree

3 files changed

+62
-10
lines changed

3 files changed

+62
-10
lines changed

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ if (${QUICK_QANAVA_BUILD_SAMPLES})
2323
#add_subdirectory(samples/edges)
2424
add_subdirectory(samples/groups)
2525
#add_subdirectory(samples/navigable)
26-
add_subdirectory(samples/nodes)
27-
add_subdirectory(samples/layouts)
26+
#add_subdirectory(samples/nodes)
27+
#add_subdirectory(samples/layouts)
2828
#add_subdirectory(samples/selection)
2929
#add_subdirectory(samples/style)
3030
#add_subdirectory(samples/topology)

src/qanGraphView.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,27 @@
3737
#include <QQuickItem>
3838

3939
// QuickQanava headers
40-
#include "./qanNavigable.h"
40+
//#include "./qanNavigable.h"
4141
#include "./qanGraphView.h"
4242
#include "./qanGraph.h"
4343

4444
namespace qan { // ::qan
4545

4646
/* GraphView Object Management *///--------------------------------------------
4747
GraphView::GraphView(QQuickItem* parent) :
48-
qan::Navigable{parent}
48+
QQuickItem{parent}
4949
{
5050
setFocus(true);
5151
}
52+
//-----------------------------------------------------------------------------
53+
54+
55+
/* View Flickable Management *///----------------------------------------------
56+
57+
//-----------------------------------------------------------------------------
58+
5259

60+
/* raph Interactions *///------------------------------------------------------
5361
void GraphView::setGraph(qan::Graph* graph)
5462
{
5563
if (graph == nullptr) {

src/qanGraphView.h

+50-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
// QuickQanava headers
3838
#include "./qanGraph.h"
3939
#include "./qanGroup.h"
40-
#include "./qanNavigable.h"
40+
//#include "./qanNavigable.h"
4141
#include "./qanPortItem.h"
4242

4343
// Qt headers
@@ -50,7 +50,7 @@ namespace qan { // ::qan
5050
*
5151
* \nosubgrouping
5252
*/
53-
class GraphView : public qan::Navigable
53+
class GraphView : public QQuickItem
5454
{
5555
Q_OBJECT
5656
/*! \name GraphView Object Management *///---------------------------------
@@ -60,7 +60,48 @@ class GraphView : public qan::Navigable
6060
explicit GraphView(QQuickItem* parent = nullptr);
6161
virtual ~GraphView() override = default;
6262
GraphView(const GraphView&) = delete;
63+
//@}
64+
//-------------------------------------------------------------------------
65+
6366

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+
//@{
64105
public:
65106
//! Graph that should be displayed in this graph view.
66107
Q_PROPERTY(qan::Graph* graph READ getGraph WRITE setGraph NOTIFY graphChanged FINAL)
@@ -73,8 +114,9 @@ class GraphView : public qan::Navigable
73114

74115
protected:
75116
//! 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);
78120

79121
//! Utilisty method to convert a given \c url to a local file path (if possible, otherwise return an empty string).
80122
Q_INVOKABLE QString urlToLocalFile(QUrl url) const noexcept;
@@ -106,10 +148,12 @@ class GraphView : public qan::Navigable
106148
//@{
107149
protected:
108150
//! \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);
110153

111154
//! \copydoc qan::Navigable::selectionRectEnd()
112-
virtual void selectionRectEnd() override;
155+
// FIXME #232 probably rename that...
156+
virtual void selectionRectEnd();
113157
private:
114158
QSet<QQuickItem*> _selectedItems;
115159

0 commit comments

Comments
 (0)