wiRedPanda
Logic Circuit Simulator
Loading...
Searching...
No Matches
ElementLabel.h
Go to the documentation of this file.
1// Copyright 2015 - 2026, GIBIS-UNIFESP and the wiRedPanda contributors
2// SPDX-License-Identifier: GPL-3.0-or-later
3
7
8#pragma once
9
10#include <QFrame>
11#include <QLabel>
12#include <QMimeData>
13#include <QPoint>
14
15#include "App/Core/Enums.h"
16
25class ElementLabel : public QFrame
26{
27 Q_OBJECT
28
29public:
38 explicit ElementLabel(const QPixmap &pixmap, ElementType type, const QString &icFileName, QWidget *parent = nullptr, bool isEmbedded = false);
39
40 // --- Queries ---
41
43 const ElementType &elementType() const;
44
46 QString icFileName() const;
47
49 bool isEmbedded() const;
50
52 QString name() const;
53
55 const QPixmap &pixmap() const;
56
57 // --- Drag support ---
58
60 QMimeData *mimeData() const;
61
63 void startDrag();
64
65 // --- Display updates ---
66
68 void updateName();
69
71 void updateTheme();
72
73signals:
76 void addToSceneRequested(QMimeData *mimeData);
77
78protected:
81 void mousePressEvent(QMouseEvent *event) override;
82
84 void mouseMoveEvent(QMouseEvent *event) override;
85
87 void mouseDoubleClickEvent(QMouseEvent *event) override;
88
89private:
90 // --- Members ---
91
92 QPoint m_dragStartPos;
93 ElementType m_elementType = ElementType::Unknown;
94 QLabel m_iconLabel;
95 QLabel m_nameLabel;
96 QPixmap m_pixmap;
97 QString m_icFileName;
98 bool m_isEmbedded = false;
99};
Central enumeration types for element types, groups, and signal status.
Enums::ElementType ElementType
Definition Enums.h:107
void startDrag()
Initiates a drag operation carrying this label's element type.
void mouseMoveEvent(QMouseEvent *event) override
Starts the drag once the pointer moves past the platform drag threshold.
void addToSceneRequested(QMimeData *mimeData)
QString name() const
Returns the displayed element name.
bool isEmbedded() const
Returns true if this label represents an embedded IC.
void mousePressEvent(QMouseEvent *event) override
const QPixmap & pixmap() const
Returns the icon pixmap shown in this label.
void updateName()
Updates the displayed name to match the current application locale.
QMimeData * mimeData() const
Creates and returns the MIME data payload used for drag-and-drop.
QString icFileName() const
Returns the IC file path, or an empty string for built-in elements.
void mouseDoubleClickEvent(QMouseEvent *event) override
Requests adding this element to the active scene (drag-free shortcut).
void updateTheme()
Updates colors to match the current application theme.
const ElementType & elementType() const
Returns the element type identifier for this label.
ElementLabel(const QPixmap &pixmap, ElementType type, const QString &icFileName, QWidget *parent=nullptr, bool isEmbedded=false)
Constructs an ElementLabel from a pixmap.