Skip to content

Cleanup: dead code removal, bug fix, and deduplication#2

Merged
imakris merged 5 commits intomasterfrom
claude/cleanup-source-code-BL2L8
Mar 25, 2026
Merged

Cleanup: dead code removal, bug fix, and deduplication#2
imakris merged 5 commits intomasterfrom
claude/cleanup-source-code-BL2L8

Conversation

@imakris
Copy link
Copy Markdown
Owner

@imakris imakris commented Mar 25, 2026

Summary

Commit 1: Deduplication, bug fix, and macro cleanup

  • Fix bug in NodeGraphicsObject::hoverMoveEvent where | (bitwise OR) was used instead of & (bitwise AND) for testing NodeFlag::Resizable, making the condition always true
  • Deduplicate ~80 lines of JSON style macros across NodeStyle, ConnectionStyle, and GraphicsViewStyle by extracting shared readColor/writeColor/readFloat/writeFloat/readBool/writeBool helpers into Style.hpp
  • Extract portCountRole() helper into ConnectionIdUtils.hpp to replace repeated ternary expressions across 7 source files
  • Extract DataFlowGraphModel::connectDelegateModel() to deduplicate ~30 lines of identical signal connection setup between addNode() and loadNode()
  • Remove dead code: unused hash specializations in ConnectionIdHash.hpp, unused NODE_EDITOR_DEMANGLED macro, commented-out code in 4 files, unused PySide2/Shiboken2 cmake modules
  • Simplify oppositePort() switch statement

Commit 2: Dead code, unused includes, stale forward declarations

  • Remove phantom forward declarations for non-existent classes (NodeDataModel, ConnectionGeometry, GraphModel, NodeGeometry) — leftovers from a previous API version
  • Remove dead methods: connectionRequiredPort(), nodePortScenePosition(), connectionEndScenePosition() in NodeConnectionInteraction; addGraphicsEffect() in ConnectionGraphicsObject
  • Remove #if 0 blocks in NodeDelegateModelRegistry.hpp (~26 lines of old type converter API)
  • Remove unused includes: QUuid (3 headers), QUuidStdHash, iostream, QFile, QMessageBox, QMargins, QIcon, QJsonObject, NodeConnectionInteraction.hpp, NodeState.hpp, ConnectionGraphicsObject.hpp
  • Remove duplicate includes: NodeState.hpp in NodeGraphicsObject.hpp, QColor in NodeDelegateModel.hpp
  • Remove unused using declarations and variables

Commit 3: Fix broken forwarding header, minor include cleanup

  • Fix include/QtNodes/NodeGeometry forwarding header: was pointing to non-existent internal/NodeGeometry.hpp, now correctly points to internal/AbstractNodeGeometry.hpp
  • Remove unused QVariant includes from QUuidStdHash.hpp and QStringStdHash.hpp
  • Remove unused QObject include from Style.hpp

Commit 4: Structural refactors

  • Extract DefaultNodeGeometryBase intermediate class: DefaultHorizontalNodeGeometry and DefaultVerticalNodeGeometry shared ~120 lines of identical code (constructor, boundingRect, size, captionRect, portTextRect, maxPortsTextAdvance, maxPortsExtent, and 4 member variables). These are now in a shared base class.
  • Unify pointsC1C2Horizontal/pointsC1C2Vertical into a single computeControlPoints(Qt::Orientation) method — identical structure with X/Y swapped, now parameterized by axis.
  • Extract selectedItemsOfType<T> template helper to deduplicate selectedNodes() / selectedGroups() iteration pattern.

Total net reduction: ~960 lines across 45+ files.

Test plan

  • Verify all existing unit tests pass
  • Verify node resizing correctly checks the Resizable flag (bug fix)
  • Verify style loading/saving works correctly with the new shared helpers
  • Verify DataFlowGraphModel node creation and loading still connects all delegate signals
  • Verify horizontal and vertical node geometry rendering is unchanged
  • Verify connection Bezier curves render identically in both orientations
  • Verify no compilation regressions from removed includes/forward declarations

https://claude.ai/code/session_015aZAxLSpakeTpF7zaq6D2F

claude added 4 commits March 25, 2026 05:34
- Fix bug in NodeGraphicsObject::hoverMoveEvent: `|` -> `&` for flag test
  (line 466 was always true due to bitwise OR with Resizable)
- Replace triplicated JSON style read/write macros across NodeStyle,
  ConnectionStyle, and GraphicsViewStyle with shared helpers in Style.hpp
- Extract portCountRole() helper to eliminate repeated ternary expressions
  across 7 files
- Extract DataFlowGraphModel::connectDelegateModel() to deduplicate ~30
  lines of identical signal connection setup in addNode/loadNode
- Remove unused hash specializations (pair/tuple) from ConnectionIdHash.hpp
- Remove commented-out code from NodeGraphicsObject, ConnectionGraphicsObject,
  ConnectionState, and Style.hpp
- Remove unused NODE_EDITOR_DEMANGLED macro from Export.hpp
- Remove unused PySide2/Shiboken2 cmake modules (never referenced)
- Simplify oppositePort() switch with direct returns

Net reduction: ~715 lines across 20 files.

https://claude.ai/code/session_015aZAxLSpakeTpF7zaq6D2F
- Remove phantom forward declarations for non-existent classes:
  NodeDataModel, ConnectionGeometry, GraphModel, NodeGeometry
- Remove redundant forward declarations where the header is already
  included (QPainter, ConnectionId, DataFlowGraphModel, etc.)
- Remove unused forward declarations (NodeStyle, NodeState,
  StyleCollection, NodeDelegateModel, NodeConnectionInteraction, etc.)
- Remove dead methods: connectionRequiredPort(), nodePortScenePosition(),
  connectionEndScenePosition() in NodeConnectionInteraction;
  addGraphicsEffect() in ConnectionGraphicsObject
- Remove #if 0 blocks in NodeDelegateModelRegistry.hpp (old registerModel
  overloads, type converter API)
- Remove unused includes: QUuid (3 headers), QUuidStdHash, iostream,
  QFile, QMessageBox, QMargins, QPointF, QIcon, QJsonObject,
  NodeConnectionInteraction, NodeState, ConnectionGraphicsObject
- Remove duplicate includes: NodeState.hpp (NodeGraphicsObject.hpp),
  QColor (NodeDelegateModel.hpp)
- Remove unused using declarations and variables: DataFlowGraphModel,
  NodeConnectionInteraction, NodeDataType, QVariant result in setPortData

https://claude.ai/code/session_015aZAxLSpakeTpF7zaq6D2F
- Fix include/QtNodes/NodeGeometry: was pointing to non-existent
  internal/NodeGeometry.hpp, now correctly points to
  internal/AbstractNodeGeometry.hpp
- Remove unused QVariant includes from QUuidStdHash.hpp and
  QStringStdHash.hpp
- Remove unused QObject include from Style.hpp

https://claude.ai/code/session_015aZAxLSpakeTpF7zaq6D2F
1. Extract DefaultNodeGeometryBase from duplicated geometry classes

   DefaultHorizontalNodeGeometry and DefaultVerticalNodeGeometry shared
   ~120 lines of identical code (constructor, boundingRect, size,
   captionRect, portTextRect, maxPortsTextAdvance, maxPortsExtent, and
   all 4 member variables). Extract these into a new intermediate base
   class DefaultNodeGeometryBase, leaving only orientation-specific
   methods in the subclasses.

2. Unify pointsC1C2Horizontal/pointsC1C2Vertical

   These two methods had identical algorithmic structure with X/Y axes
   swapped. Replace with a single computeControlPoints(Qt::Orientation)
   method that parameterizes by axis.

3. Extract selectedItemsOfType<T> template helper

   selectedNodes() and selectedGroups() shared the same iteration
   pattern over QGraphicsScene::selectedItems() with qgraphicsitem_cast.
   Extract into a local template function.

https://claude.ai/code/session_015aZAxLSpakeTpF7zaq6D2F
@imakris imakris force-pushed the claude/cleanup-source-code-BL2L8 branch from 2efe5c6 to 864769b Compare March 25, 2026 05:35
@imakris imakris merged commit 5d6a05b into master Mar 25, 2026
@imakris imakris deleted the claude/cleanup-source-code-BL2L8 branch March 25, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants