8#include <QGraphicsSceneDragDropEvent>
32 const auto &formats = mimeData->formats();
52 QDataStream stream(&itemData, QIODevice::ReadOnly);
58 QPointF pos =
event->scenePos() - payload.offset;
59 qCDebug(zero) << payload.type <<
" at position: " << pos.x() <<
", " << pos.y() <<
", label: " << payload.icFileName;
62 qCDebug(zero) <<
"Valid element.";
64 if (payload.isEmbedded && payload.type == ElementType::IC) {
65 if (!m_scene->icRegistry()->initEmbeddedIC(
static_cast<IC *
>(element.get()), payload.
blobName)) {
71 element->loadFromDrop(payload.icFileName, m_scene->contextDir());
74 qCDebug(zero) <<
"Adding the element to the scene.";
75 auto *raw = element.release();
78 qCDebug(zero) <<
"Cleaning the selection.";
79 m_scene->clearSelection();
81 qCDebug(zero) <<
"Setting created element as selected.";
82 raw->setSelected(
true);
84 qCDebug(zero) <<
"Adjusting the position of the element.";
100 QDataStream stream(&itemData, QIODevice::ReadOnly);
104 QPointF offset; stream >> offset;
105 QPointF ctr; stream >> ctr;
106 offset =
event->scenePos() - offset;
108 QHash<quint64, Port *> portMap;
113 m_scene->clearSelection();
115 for (
auto *item : itemList) {
117 item->setPos((item->pos() + offset));
118 item->setSelected(
true);
122 m_scene->resizeScene();
130 QDataStream stream(&itemData, QIODevice::ReadOnly);
136 qCDebug(zero) <<
"Valid element.";
141 auto mimeGuard = qScopeGuard([mimeData]() { mimeData->deleteLater(); });
143 if (payload.isEmbedded && payload.type == ElementType::IC) {
144 if (!m_scene->icRegistry()->initEmbeddedIC(
static_cast<IC *
>(element.get()), payload.
blobName)) {
148 element->loadFromDrop(payload.icFileName, m_scene->contextDir());
151 qCDebug(zero) <<
"Adding the element to the scene.";
152 auto *raw = element.release();
155 qCDebug(zero) <<
"Cleaning the selection.";
156 m_scene->clearSelection();
158 qCDebug(zero) <<
"Setting created element as selected.";
159 raw->setSelected(
true);
165 raw->setPos(*scenePos);
All QUndoCommand subclasses and the CommandUtils helper namespace.
Common logging utilities, the Pandaception error type, and helper macros.
#define qCDebug(category)
DragDropPayload readDragDropPayload(QDataStream &stream)
Reads a drag-and-drop payload from stream.
Shared reader for wiRedPanda's drag-and-drop MIME payload format.
Singleton factory for all circuit element types.
Central enumeration types for element types, groups, and signal status.
Abstract base class for all graphical circuit elements.
IC definition registry with file watching and embedded blob storage.
Integrated Circuit (IC) graphic element that encapsulates a sub-circuit file.
MIME type string constants for drag-and-drop operations.
SceneDropHandler: decodes drag-and-drop payloads into scene elements.
Main circuit editing scene with undo/redo and user interaction.
Deserialization/serialization context structs passed through load()/save() call chains.
Circuit and waveform file serialization/deserialization utilities.
Undo command that adds a list of graphic elements to the scene.
static GraphicElement * buildElement(const ElementType type)
Constructs and returns a new graphic element of the given type.
Graphic element representing an Integrated Circuit (sub-circuit) box.
const QString & blobName() const override
Returns the blob name for embedded ICs, empty if file-backed.
SceneDropHandler(Scene *scene)
static bool isSupportedDropFormat(const QMimeData *mimeData)
Returns true if mimeData carries any recognised wiRedPanda drop format.
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.
void addFromMimeData(QMimeData *mimeData, std::optional< QPointF > scenePos=std::nullopt)
Main circuit editing scene.
static QList< QGraphicsItem * > deserialize(QDataStream &stream, SerializationContext &context)
Deserializes items from stream until the stream is exhausted.
static QVersionNumber readPandaHeader(QDataStream &stream)
Reads and validates the .panda circuit file header; returns the stored version number.
constexpr const char * CloneDragLegacy
Legacy clone-drag MIME type retained for backward compatibility.
constexpr const char * CloneDrag
Current MIME type for clone-drag (Ctrl+drag within the scene).
constexpr const char * DragDropLegacy
Legacy drag-and-drop MIME type retained for backward compatibility.
constexpr const char * DragDrop
Current drag-and-drop MIME type for element palette → scene drops.