Cleanup: dead code removal, bug fix, and deduplication#2
Merged
Conversation
- 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
2efe5c6 to
864769b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Commit 1: Deduplication, bug fix, and macro cleanup
NodeGraphicsObject::hoverMoveEventwhere|(bitwise OR) was used instead of&(bitwise AND) for testingNodeFlag::Resizable, making the condition always trueNodeStyle,ConnectionStyle, andGraphicsViewStyleby extracting sharedreadColor/writeColor/readFloat/writeFloat/readBool/writeBoolhelpers intoStyle.hppportCountRole()helper intoConnectionIdUtils.hppto replace repeated ternary expressions across 7 source filesDataFlowGraphModel::connectDelegateModel()to deduplicate ~30 lines of identical signal connection setup betweenaddNode()andloadNode()ConnectionIdHash.hpp, unusedNODE_EDITOR_DEMANGLEDmacro, commented-out code in 4 files, unused PySide2/Shiboken2 cmake modulesoppositePort()switch statementCommit 2: Dead code, unused includes, stale forward declarations
NodeDataModel,ConnectionGeometry,GraphModel,NodeGeometry) — leftovers from a previous API versionconnectionRequiredPort(),nodePortScenePosition(),connectionEndScenePosition()inNodeConnectionInteraction;addGraphicsEffect()inConnectionGraphicsObject#if 0blocks inNodeDelegateModelRegistry.hpp(~26 lines of old type converter API)QUuid(3 headers),QUuidStdHash,iostream,QFile,QMessageBox,QMargins,QIcon,QJsonObject,NodeConnectionInteraction.hpp,NodeState.hpp,ConnectionGraphicsObject.hppNodeState.hppinNodeGraphicsObject.hpp,QColorinNodeDelegateModel.hppCommit 3: Fix broken forwarding header, minor include cleanup
include/QtNodes/NodeGeometryforwarding header: was pointing to non-existentinternal/NodeGeometry.hpp, now correctly points tointernal/AbstractNodeGeometry.hppQVariantincludes fromQUuidStdHash.hppandQStringStdHash.hppQObjectinclude fromStyle.hppCommit 4: Structural refactors
DefaultNodeGeometryBaseintermediate class:DefaultHorizontalNodeGeometryandDefaultVerticalNodeGeometryshared ~120 lines of identical code (constructor,boundingRect,size,captionRect,portTextRect,maxPortsTextAdvance,maxPortsExtent, and 4 member variables). These are now in a shared base class.pointsC1C2Horizontal/pointsC1C2Verticalinto a singlecomputeControlPoints(Qt::Orientation)method — identical structure with X/Y swapped, now parameterized by axis.selectedItemsOfType<T>template helper to deduplicateselectedNodes()/selectedGroups()iteration pattern.Total net reduction: ~960 lines across 45+ files.
Test plan
Resizableflag (bug fix)DataFlowGraphModelnode creation and loading still connects all delegate signalshttps://claude.ai/code/session_015aZAxLSpakeTpF7zaq6D2F