|
wiRedPanda
Logic Circuit Simulator
|
Decodes wiRedPanda drag-and-drop payloads (new element from the palette, and clone-drag of an existing selection) and commits them to the owning Scene. More...
#include <SceneDropHandler.h>
Public Member Functions | |
| void | addFromMimeData (QMimeData *mimeData, std::optional< QPointF > scenePos=std::nullopt) |
| void | handleCloneDrag (QGraphicsSceneDragDropEvent *event) |
| Re-instantiates a clone-dragged selection at the drop position. | |
| void | handleNewElementDrop (QGraphicsSceneDragDropEvent *event) |
| Builds a new element from a palette drag payload and adds it under the cursor. | |
| SceneDropHandler (Scene *scene) | |
Static Public Member Functions | |
| static bool | isSupportedDropFormat (const QMimeData *mimeData) |
Returns true if mimeData carries any recognised wiRedPanda drop format. | |
Decodes wiRedPanda drag-and-drop payloads (new element from the palette, and clone-drag of an existing selection) and commits them to the owning Scene.
Extracted from Scene, following the ConnectionManager pattern: it holds a back-reference to the Scene and delegates element creation, undo commands, and scene resizing back to it. Scene keeps the QGraphicsScene drag/drop event overrides and forwards the payload handling here.
Definition at line 28 of file SceneDropHandler.h.
|
explicit |
Definition at line 25 of file SceneDropHandler.cpp.
| void SceneDropHandler::addFromMimeData | ( | QMimeData * | mimeData, |
| std::optional< QPointF > | scenePos = std::nullopt ) |
Adds a new element from mimeData (palette add-without-drag path); takes ownership of mimeData. If scenePos is set, the element is placed there (snapped to the grid by the scene); otherwise it keeps its default position.
Definition at line 125 of file SceneDropHandler.cpp.
References IC::blobName(), ElementFactory::buildElement(), MimeType::DragDrop, MimeType::DragDropLegacy, qCDebug, readDragDropPayload(), and Serialization::readPandaHeader().
| void SceneDropHandler::handleCloneDrag | ( | QGraphicsSceneDragDropEvent * | event | ) |
Re-instantiates a clone-dragged selection at the drop position.
Definition at line 88 of file SceneDropHandler.cpp.
References MimeType::CloneDrag, MimeType::CloneDragLegacy, Serialization::deserialize(), InMemorySnapshot, Serialization::readPandaHeader(), and GraphicElement::Type.
| void SceneDropHandler::handleNewElementDrop | ( | QGraphicsSceneDragDropEvent * | event | ) |
Builds a new element from a palette drag payload and adds it under the cursor.
Definition at line 39 of file SceneDropHandler.cpp.
References IC::blobName(), ElementFactory::buildElement(), MimeType::DragDrop, MimeType::DragDropLegacy, qCDebug, readDragDropPayload(), and Serialization::readPandaHeader().
|
static |
Returns true if mimeData carries any recognised wiRedPanda drop format.
Definition at line 30 of file SceneDropHandler.cpp.
References MimeType::CloneDrag, MimeType::CloneDragLegacy, MimeType::DragDrop, and MimeType::DragDropLegacy.
Referenced by Scene::dragEnterEvent(), and Scene::dragMoveEvent().