|
wiRedPanda
Logic Circuit Simulator
|
Icon and name widget shown in the left-panel element palette. More...
#include <ElementLabel.h>
Public Member Functions | |
| void | addToSceneRequested (QMimeData *mimeData) |
| ElementLabel (const QPixmap &pixmap, ElementType type, const QString &icFileName, QWidget *parent=nullptr, bool isEmbedded=false) | |
| Constructs an ElementLabel from a pixmap. | |
| const ElementType & | elementType () const |
| Returns the element type identifier for this label. | |
| QString | icFileName () const |
| Returns the IC file path, or an empty string for built-in elements. | |
| bool | isEmbedded () const |
| Returns true if this label represents an embedded IC. | |
| QMimeData * | mimeData () const |
| Creates and returns the MIME data payload used for drag-and-drop. | |
| QString | name () const |
| Returns the displayed element name. | |
| const QPixmap & | pixmap () const |
| Returns the icon pixmap shown in this label. | |
| void | startDrag () |
| Initiates a drag operation carrying this label's element type. | |
| void | updateName () |
| Updates the displayed name to match the current application locale. | |
| void | updateTheme () |
| Updates colors to match the current application theme. | |
Protected Member Functions | |
| void | mouseDoubleClickEvent (QMouseEvent *event) override |
| Requests adding this element to the active scene (drag-free shortcut). | |
| void | mouseMoveEvent (QMouseEvent *event) override |
| Starts the drag once the pointer moves past the platform drag threshold. | |
| void | mousePressEvent (QMouseEvent *event) override |
Icon and name widget shown in the left-panel element palette.
Displays a small pixmap and the translated element name. When dragged, it produces MIME data that the scene interprets to drop a new element into the circuit.
Definition at line 25 of file ElementLabel.h.
|
explicit |
Constructs an ElementLabel from a pixmap.
| pixmap | Icon image. |
| type | Element type identifier. |
| icFileName | IC file path or blob name (for embedded ICs). |
| parent | Optional parent widget. |
| isEmbedded | True if this label represents an embedded IC. |
Definition at line 17 of file ElementLabel.cpp.
References ElementFactory::description(), icFileName(), isEmbedded(), pixmap(), and ElementFactory::translatedName().
| void ElementLabel::addToSceneRequested | ( | QMimeData * | mimeData | ) |
Emitted on double-click so the palette can add this element to the active scene without a drag. Carries a fresh MIME payload (ownership passes to the receiver).
References mimeData().
Referenced by mouseDoubleClickEvent().
| const ElementType & ElementLabel::elementType | ( | ) | const |
Returns the element type identifier for this label.
Definition at line 101 of file ElementLabel.cpp.
| QString ElementLabel::icFileName | ( | ) | const |
Returns the IC file path, or an empty string for built-in elements.
Definition at line 116 of file ElementLabel.cpp.
Referenced by ElementLabel().
| bool ElementLabel::isEmbedded | ( | ) | const |
Returns true if this label represents an embedded IC.
Definition at line 121 of file ElementLabel.cpp.
Referenced by ElementLabel().
| QMimeData * ElementLabel::mimeData | ( | ) | const |
Creates and returns the MIME data payload used for drag-and-drop.
Definition at line 141 of file ElementLabel.cpp.
References MimeType::DragDrop, mimeData(), and Serialization::writePandaHeader().
Referenced by addToSceneRequested(), mimeData(), mouseDoubleClickEvent(), and startDrag().
|
overrideprotected |
Requests adding this element to the active scene (drag-free shortcut).
Definition at line 93 of file ElementLabel.cpp.
References addToSceneRequested(), and mimeData().
|
overrideprotected |
Starts the drag once the pointer moves past the platform drag threshold.
Definition at line 82 of file ElementLabel.cpp.
References startDrag().
|
overrideprotected |
Records the press position; the drag itself only begins once the pointer moves (see mouseMoveEvent) so a double-click isn't pre-empted by a drag on the press.
Definition at line 72 of file ElementLabel.cpp.
| QString ElementLabel::name | ( | ) | const |
Returns the displayed element name.
Definition at line 111 of file ElementLabel.cpp.
| const QPixmap & ElementLabel::pixmap | ( | ) | const |
Returns the icon pixmap shown in this label.
Definition at line 106 of file ElementLabel.cpp.
Referenced by ElementLabel(), and startDrag().
| void ElementLabel::startDrag | ( | ) |
Initiates a drag operation carrying this label's element type.
Definition at line 126 of file ElementLabel.cpp.
References mimeData(), and pixmap().
Referenced by mouseMoveEvent().
| void ElementLabel::updateName | ( | ) |
Updates the displayed name to match the current application locale.
Definition at line 65 of file ElementLabel.cpp.
References ElementFactory::translatedName().
| void ElementLabel::updateTheme | ( | ) |
Updates colors to match the current application theme.
Definition at line 155 of file ElementLabel.cpp.
References ElementFactory::pixmap().