Skip to content

Commit 9efeb41

Browse files
committed
solve conflicts
2 parents 1c31cfe + f953fca commit 9efeb41

9 files changed

Lines changed: 47 additions & 13 deletions

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,9 @@ target_compile_definitions(QtNodes
165165
QT_NO_KEYWORDS
166166
)
167167

168+
if(MSVC)
169+
string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
170+
endif()
168171

169172
target_compile_options(QtNodes
170173
PRIVATE

README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
QtNodes
22
#######
33

4-
https://github.com/paceholder/nodeeditor/actions/workflows/cmake_build.yml/badge.svg
4+
.. image:: https://github.com/paceholder/nodeeditor/actions/workflows/cmake_build.yml/badge.svg
5+
:target: https://github.com/paceholder/nodeeditor/actions/workflows/cmake_build.yml
56

67
Introduction
78
============

include/QtNodes/internal/AbstractGraphModel.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
#pragma once
22

3-
#include "Export.hpp"
43
#include "ConnectionIdHash.hpp"
54
#include "Definitions.hpp"
5+
#include "Export.hpp"
66

77
#include <QtCore/QJsonObject>
88
#include <QtCore/QObject>
99
#include <QtCore/QVariant>
1010

1111
#include <unordered_set>
1212

13-
1413
namespace QtNodes {
1514

1615
/**
@@ -51,8 +50,7 @@ class NODE_EDITOR_PUBLIC AbstractGraphModel : public QObject
5150
*/
5251
virtual std::unordered_set<ConnectionId> connections(NodeId nodeId,
5352
PortType portType,
54-
PortIndex index) const
55-
= 0;
53+
PortIndex index) const = 0;
5654

5755
/// Checks if two nodes with the given `connectionId` are connected.
5856
virtual bool connectionExists(ConnectionId const connectionId) const = 0;
@@ -132,8 +130,10 @@ class NODE_EDITOR_PUBLIC AbstractGraphModel : public QObject
132130
* @returns Port Data Type, Port Data, Connection Policy, Port
133131
* Caption.
134132
*/
135-
virtual QVariant portData(NodeId nodeId, PortType portType, PortIndex index, PortRole role) const
136-
= 0;
133+
virtual QVariant portData(NodeId nodeId,
134+
PortType portType,
135+
PortIndex index,
136+
PortRole role) const = 0;
137137

138138
/**
139139
* A utility function that unwraps the `QVariant` value returned from the

include/QtNodes/internal/BasicGraphicsScene.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ class NODE_EDITOR_PUBLIC BasicGraphicsScene : public QGraphicsScene
125125

126126
/// Signal allows showing custom context menu upon clicking a node.
127127
void nodeContextMenu(NodeId const nodeId, QPointF const pos);
128+
/// Signals to call Graphics View's zoomFit methods
129+
void zoomFitAllClicked();
130+
void zoomFitSelectedClicked();
128131

129132
private:
130133
/**

include/QtNodes/internal/DataFlowGraphModel.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
namespace QtNodes {
1616

17-
class NODE_EDITOR_PUBLIC DataFlowGraphModel : public AbstractGraphModel, public Serializable
17+
class NODE_EDITOR_PUBLIC DataFlowGraphModel
18+
: public AbstractGraphModel
19+
, public Serializable
1820
{
1921
Q_OBJECT
2022

@@ -43,7 +45,6 @@ class NODE_EDITOR_PUBLIC DataFlowGraphModel : public AbstractGraphModel, public
4345

4446
NodeId addNode(QString const nodeType) override;
4547

46-
4748
bool connectionPossible(ConnectionId const connectionId) const override;
4849

4950
void addConnection(ConnectionId const connectionId) override;
@@ -75,7 +76,6 @@ class NODE_EDITOR_PUBLIC DataFlowGraphModel : public AbstractGraphModel, public
7576

7677
void loadNode(QJsonObject const &nodeJson) override;
7778

78-
7979
// From Serializable
8080
QJsonObject save() const override;
8181

include/QtNodes/internal/GraphicsView.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ public Q_SLOTS:
5858

5959
virtual void onPasteObjects();
6060

61+
void zoomFitAll();
62+
63+
void zoomFitSelected();
64+
6165
Q_SIGNALS:
6266
void scaleChanged(double scale);
6367

src/AbstractGraphModel.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ void AbstractGraphModel::portsAboutToBeDeleted(NodeId const nodeId,
4040
// Erases the information about the port on one side;
4141
auto c = makeIncompleteConnectionId(connectionId, portType);
4242

43-
c = makeCompleteConnectionId(c, nodeId, portIndex - nRemovedPorts);
43+
c = makeCompleteConnectionId(c,
44+
nodeId,
45+
portIndex - static_cast<QtNodes::PortIndex>(nRemovedPorts));
4446

4547
_shiftedByDynamicPortsConnections.push_back(c);
4648

@@ -84,7 +86,9 @@ void AbstractGraphModel::portsAboutToBeInserted(NodeId const nodeId,
8486
// Erases the information about the port on one side;
8587
auto c = makeIncompleteConnectionId(connectionId, portType);
8688

87-
c = makeCompleteConnectionId(c, nodeId, portIndex + nNewPorts);
89+
c = makeCompleteConnectionId(c,
90+
nodeId,
91+
portIndex + static_cast<QtNodes::PortIndex>(nNewPorts));
8892

8993
_shiftedByDynamicPortsConnections.push_back(c);
9094

src/DataFlowGraphModel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ QVariant DataFlowGraphModel::nodeData(NodeId nodeId, NodeRole role) const
268268
break;
269269

270270
case NodeRole::Style: {
271-
auto style = StyleCollection::nodeStyle();
271+
auto style = _models.at(nodeId)->nodeStyle();
272272
result = style.toJson().toVariantMap();
273273
} break;
274274

src/GraphicsView.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,3 +444,22 @@ QPointF GraphicsView::scenePastePosition()
444444

445445
return mapToScene(origin);
446446
}
447+
448+
void GraphicsView::zoomFitAll()
449+
{
450+
fitInView(scene()->itemsBoundingRect(), Qt::KeepAspectRatio);
451+
}
452+
453+
void GraphicsView::zoomFitSelected()
454+
{
455+
if (scene()->selectedItems().count() > 0) {
456+
QRectF unitedBoundingRect{};
457+
458+
for (QGraphicsItem *item : scene()->selectedItems()) {
459+
unitedBoundingRect = unitedBoundingRect.united(
460+
item->mapRectToScene(item->boundingRect()));
461+
}
462+
463+
fitInView(unitedBoundingRect, Qt::KeepAspectRatio);
464+
}
465+
}

0 commit comments

Comments
 (0)