SILICON
Loading...
Searching...
No Matches
componentCatalogOverlay.hpp
Go to the documentation of this file.
1/*
2 Copyright (c) 2026. Giulio Cocconi
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include <string>
21#include <vector>
22
23#include <QStringList>
24#include <QWidget>
25
26#include <ui/lifetime.hpp>
27
28#include <core/component.hpp>
30
31namespace SILICON::project {
32class DocumentStore;
33}
34namespace SILICON::core {
35class CircuitResolver;
36}
37
38class QLineEdit;
39class QTableWidget;
40
41namespace SILICON::ui {
42 using namespace SILICON::core;
43
44 class DiagramScene;
45
46 class ComponentCatalogOverlay : public QWidget {
47 public:
53
57 QWidget* parent = nullptr);
58
59 void open();
60 void dismiss();
61
62 protected:
63 void keyPressEvent(QKeyEvent* event) override;
64
65 private:
66 void rebuildRows();
68 void addComponentRow(const CatalogRow& rowData);
69 void activateRow(int row);
72 [[nodiscard]] static QStringList searchableFields(const CatalogRow& rowData);
73
77 QLineEdit* searchInput = nullptr;
78 QTableWidget* table = nullptr;
79 std::vector<CatalogRow> catalogRows;
81 };
82
83} // namespace SILICON::ui
SILICON::core::ComponentCategory ComponentCategory
SILICON::core::ComponentMetadata ComponentMetadata
ComponentCatalogOverlay(DiagramScene *scene, const SILICON::project::DocumentStore &documents, const CircuitResolver *resolver, QWidget *parent=nullptr)
static QStringList searchableFields(const CatalogRow &rowData)
void addComponentRow(const CatalogRow &rowData)
void keyPressEvent(QKeyEvent *event) override
void addCategoryRow(ComponentRegistry::ComponentCategory category)
const SILICON::project::DocumentStore & documents
Graphics scene for the circuit diagram editor.
std::unordered_map< std::string, PropertyValue, TransparentStringHash, TransparentStringEqual > PropertyMap
Map from property names to their values.