wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ElementLabel Class Reference

Icon and name widget shown in the left-panel element palette. More...

#include <ElementLabel.h>

Inheritance diagram for ElementLabel:
[legend]

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 ElementTypeelementType () 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

Detailed Description

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.

Constructor & Destructor Documentation

◆ ElementLabel()

ElementLabel::ElementLabel ( const QPixmap & pixmap,
ElementType type,
const QString & icFileName,
QWidget * parent = nullptr,
bool isEmbedded = false )
explicit

Constructs an ElementLabel from a pixmap.

Parameters
pixmapIcon image.
typeElement type identifier.
icFileNameIC file path or blob name (for embedded ICs).
parentOptional parent widget.
isEmbeddedTrue if this label represents an embedded IC.

Definition at line 17 of file ElementLabel.cpp.

References ElementFactory::description(), icFileName(), isEmbedded(), pixmap(), and ElementFactory::translatedName().

Member Function Documentation

◆ addToSceneRequested()

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().

◆ elementType()

const ElementType & ElementLabel::elementType ( ) const

Returns the element type identifier for this label.

Definition at line 101 of file ElementLabel.cpp.

◆ icFileName()

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().

◆ isEmbedded()

bool ElementLabel::isEmbedded ( ) const

Returns true if this label represents an embedded IC.

Definition at line 121 of file ElementLabel.cpp.

Referenced by ElementLabel().

◆ mimeData()

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().

◆ mouseDoubleClickEvent()

void ElementLabel::mouseDoubleClickEvent ( QMouseEvent * event)
overrideprotected

Requests adding this element to the active scene (drag-free shortcut).

Definition at line 93 of file ElementLabel.cpp.

References addToSceneRequested(), and mimeData().

◆ mouseMoveEvent()

void ElementLabel::mouseMoveEvent ( QMouseEvent * event)
overrideprotected

Starts the drag once the pointer moves past the platform drag threshold.

Definition at line 82 of file ElementLabel.cpp.

References startDrag().

◆ mousePressEvent()

void ElementLabel::mousePressEvent ( QMouseEvent * event)
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.

◆ name()

QString ElementLabel::name ( ) const

Returns the displayed element name.

Definition at line 111 of file ElementLabel.cpp.

◆ pixmap()

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().

◆ 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().

◆ updateName()

void ElementLabel::updateName ( )

Updates the displayed name to match the current application locale.

Definition at line 65 of file ElementLabel.cpp.

References ElementFactory::translatedName().

◆ updateTheme()

void ElementLabel::updateTheme ( )

Updates colors to match the current application theme.

Definition at line 155 of file ElementLabel.cpp.

References ElementFactory::pixmap().


The documentation for this class was generated from the following files: