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

Controller for the left-panel element palette, IC list, and search tab. More...

#include <ElementPalette.h>

Inheritance diagram for ElementPalette:
[legend]

Public Member Functions

void addElementRequested (QMimeData *mimeData)
 Emitted when the user presses Enter in the search box.
 ElementPalette (MainWindowUi *ui, QObject *parent=nullptr)
 Constructs the palette controller.
void populate ()
 Populates all category tabs with ElementLabel widgets and sets tab icons.
void retranslateLabels ()
 Calls updateName() on every ElementLabel in the palette (on language change).
void updateEmbeddedICList (Scene *scene)
 Refreshes the embedded-IC section of the palette from the scene's blob registry.
void updateICList (const QFileInfo &currentFile)
 Refreshes the IC tab to reflect .panda files next to currentFile.
void updateTheme ()
 Updates the memory tab icon and all memory-tab ElementLabel themes.

Static Public Member Functions

static bool nameMatchesSearch (const QString &name, const QString &query)

Detailed Description

Controller for the left-panel element palette, IC list, and search tab.

Owns all state and logic for the left panel: populating element category tabs with ElementLabel widgets, maintaining the IC file list, running the three-pass search, and managing the search-tab lifecycle.

The only cross-boundary action — dropping the first search result into the scene — is exposed as addElementRequested() so MainWindow can route it to the active scene without ElementPalette knowing about Scene.

Definition at line 33 of file ElementPalette.h.

Constructor & Destructor Documentation

◆ ElementPalette()

ElementPalette::ElementPalette ( MainWindowUi * ui,
QObject * parent = nullptr )
explicit

Constructs the palette controller.

Parameters
uiThe host window's UI descriptor (must outlive this object).
parentOptional QObject parent.

Immediately connects lineEditSearch signals to internal slots.

Definition at line 21 of file ElementPalette.cpp.

Member Function Documentation

◆ addElementRequested()

void ElementPalette::addElementRequested ( QMimeData * mimeData)

Emitted when the user presses Enter in the search box.

Parameters
mimeDataMIME data of the first visible search result. MainWindow should pass this to Scene::addItem().

◆ nameMatchesSearch()

bool ElementPalette::nameMatchesSearch ( const QString & name,
const QString & query )
static

Case-insensitive "contains" match of query against name, used by the palette search. query is a raw, user-typed string, so it is regex-escaped: metacharacters (e.g. '(' in an IC named "counter(2)", or a lone '(') match literally instead of forming an invalid pattern that would silently return zero results. Pure/static so the matching can be tested without constructing the palette (which needs a MainWindowUi).

Definition at line 36 of file ElementPalette.cpp.

◆ populate()

void ElementPalette::populate ( )

Populates all category tabs with ElementLabel widgets and sets tab icons.

Must be called once after the host window is fully set up.

Definition at line 46 of file ElementPalette.cpp.

◆ retranslateLabels()

void ElementPalette::retranslateLabels ( )

Calls updateName() on every ElementLabel in the palette (on language change).

Definition at line 153 of file ElementPalette.cpp.

◆ updateEmbeddedICList()

void ElementPalette::updateEmbeddedICList ( Scene * scene)

Refreshes the embedded-IC section of the palette from the scene's blob registry.

Definition at line 110 of file ElementPalette.cpp.

References ICRegistry::blobMap(), and Scene::icRegistry().

◆ updateICList()

void ElementPalette::updateICList ( const QFileInfo & currentFile)

Refreshes the IC tab to reflect .panda files next to currentFile.

Parameters
currentFileThe currently open project file; the IC tab is cleared if this file does not exist.

Definition at line 64 of file ElementPalette.cpp.

◆ updateTheme()

void ElementPalette::updateTheme ( )

Updates the memory tab icon and all memory-tab ElementLabel themes.

Definition at line 161 of file ElementPalette.cpp.

References DFlipFlop::pixmapPath().


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