Extract a pure virtual IShape interface from AbstractShapeType<T> so
selectors and Document use dynamic_cast<IShape *> instead of
qgraphicsitem_cast<AbstractShape *>. This decouples the selector
system from the template hierarchy, enabling GraphicsTextItem (backed
by QGraphicsTextItem) to work uniformly with all existing selectors.
GraphicsTextItem supports inline text editing (double-click to edit,
focus-out to finish), font/color properties via PropertyEditor, resize
with proportional font scaling, move, rotate, and full serialization.
Adds CM_place creation mode for single-click placement.
Move per-type serialization logic out of Document's monolithic
serializeItem()/deserializeItem() into each item class:
- Add virtual serialize() to AbstractShapeType template, overridden by
GraphicsRectItem, GraphicPolygonItem, and GraphicsItemGroup
- Add static createFromJson() factory + self-registration to each item
- Extract shared pen/brush/common helpers into serializationUtils
- Add type registry (serializationRegistry) for factory-based deserialization
- Document::saveAs()/load() now delegate to item->serialize() and
createItemFromJson() — no longer owns per-type dispatch
- Adding a new shape type no longer requires touching Document
Introduce a Document QObject that composes DesignerScene + QUndoStack,
following "composition over inheritance" and unidirectional signal-slot
communication per Qt Graphics View Framework conventions.
New files:
- include/document.h — Document class declaration
- source/document.cpp — full implementation (~450 lines)
Core capabilities:
- JSON serialization/deserialization for rect, roundRect, polygon, group
(uses dynamic_cast dispatch since subclasses don't override type())
- Two-path dirty tracking:
1. QUndoStack::indexChanged for undoable ops (add/delete/group/ungroup)
2. Explicit markDirty() via DesignerScene::notifyDocumentModified()
called by selectors after successful move/scale/rotate/edit
- save()/saveAs()/load()/clear() with maybeSave() prompt on close
- File actions (New/Open/Save/Save As) wired to toolbar and File menu;
window title tracks filename + modified indicator
Integration changes:
- DrawingPanel now receives scene via setScene() instead of creating it
- CMainWindow routes all modifications through Document::execute()
- DesignerScene gains notifyDocumentModified() for selector dirty marking
- GraphicsRectItem gains isRound()/ratioX()/ratioY() accessors
- CreatingSelector: fix missing signalAddItem emit for polygon completion
- Scene lifecycle uses clear() instead of delete+recreate to avoid
dangling view pointer
Moved QUndoStack ownership from CMainWindow into Document.