LibrePCB Developers Documentation
Loading...
Searching...
No Matches
componentchooserdialog.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_EDITOR_COMPONENTCHOOSERDIALOG_H
21#define LIBREPCB_EDITOR_COMPONENTCHOOSERDIALOG_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
28
29#include <QtCore>
30#include <QtWidgets>
31
32#include <memory>
33
34/*******************************************************************************
35 * Namespace / Forward Declarations
36 ******************************************************************************/
37namespace librepcb {
38
39class Component;
40class Symbol;
41class Workspace;
42
43namespace editor {
44
45class GraphicsLayerList;
46class GraphicsScene;
47class SymbolGraphicsItem;
48
49namespace Ui {
50class ComponentChooserDialog;
51}
52
53/*******************************************************************************
54 * Class ComponentChooserDialog
55 ******************************************************************************/
56
60class ComponentChooserDialog final : public QDialog {
61 Q_OBJECT
62
63public:
64 // Constructors / Destructor
67 ComponentChooserDialog(const Workspace& ws, const GraphicsLayerList* layers,
68 QWidget* parent = nullptr) noexcept;
69 ~ComponentChooserDialog() noexcept;
70
71 // Getters
72 const std::optional<Uuid>& getSelectedComponentUuid() const noexcept {
74 }
75
76 // Operator Overloadings
78
79private: // Methods
80 void searchEditTextChanged(const QString& text) noexcept;
81 void treeCategories_currentItemChanged(const QModelIndex& current,
82 const QModelIndex& previous) noexcept;
83 void listComponents_currentItemChanged(QListWidgetItem* current,
84 QListWidgetItem* previous) noexcept;
85 void listComponents_itemDoubleClicked(QListWidgetItem* item) noexcept;
86 void searchComponents(const QString& input);
87 void setSelectedCategory(const std::optional<Uuid>& uuid) noexcept;
88 void setSelectedComponent(const std::optional<Uuid>& uuid) noexcept;
89 void updatePreview(const FilePath& fp) noexcept;
90 void accept() noexcept override;
91 const QStringList& localeOrder() const noexcept;
92
93private: // Data
96 QScopedPointer<Ui::ComponentChooserDialog> mUi;
97 QScopedPointer<QAbstractItemModel> mCategoryTreeModel;
101
102 // preview
105 QList<std::shared_ptr<Symbol>> mSymbols;
107};
108
109/*******************************************************************************
110 * End of File
111 ******************************************************************************/
112
113} // namespace editor
114} // namespace librepcb
115
116#endif
The Component class represents a "generic" device in the library.
Definition component.h:73
This class represents absolute, well-formatted paths to files or directories.
Definition filepath.h:127
The Symbol class represents the part of a component which is added to schematics.
Definition symbol.h:55
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition uuid.h:56
The Workspace class represents a workspace with all its data (library, projects, settings,...
Definition workspace.h:54
The ComponentChooserDialog class.
Definition componentchooserdialog.h:60
const QStringList & localeOrder() const noexcept
Definition componentchooserdialog.cpp:292
const GraphicsLayerList * mLayers
Definition componentchooserdialog.h:95
ComponentChooserDialog(const ComponentChooserDialog &other)=delete
void listComponents_itemDoubleClicked(QListWidgetItem *item) noexcept
Definition componentchooserdialog.cpp:142
void listComponents_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous) noexcept
Definition componentchooserdialog.cpp:131
QList< std::shared_ptr< SymbolGraphicsItem > > mSymbolGraphicsItems
Definition componentchooserdialog.h:106
QScopedPointer< GraphicsScene > mGraphicsScene
Definition componentchooserdialog.h:104
ComponentChooserDialog & operator=(const ComponentChooserDialog &rhs)=delete
const std::optional< Uuid > & getSelectedComponentUuid() const noexcept
Definition componentchooserdialog.h:72
std::optional< Uuid > mSelectedCategoryUuid
Definition componentchooserdialog.h:99
std::optional< Uuid > mSelectedComponentUuid
Definition componentchooserdialog.h:100
QScopedPointer< QAbstractItemModel > mCategoryTreeModel
Definition componentchooserdialog.h:97
void treeCategories_currentItemChanged(const QModelIndex &current, const QModelIndex &previous) noexcept
Definition componentchooserdialog.cpp:124
void searchComponents(const QString &input)
Definition componentchooserdialog.cpp:151
const Workspace & mWorkspace
Definition componentchooserdialog.h:94
void setSelectedCategory(const std::optional< Uuid > &uuid) noexcept
Definition componentchooserdialog.cpp:176
void updatePreview(const FilePath &fp) noexcept
Definition componentchooserdialog.cpp:235
std::shared_ptr< Component > mComponent
Definition componentchooserdialog.h:103
void searchEditTextChanged(const QString &text) noexcept
Definition componentchooserdialog.cpp:109
void setSelectedComponent(const std::optional< Uuid > &uuid) noexcept
Definition componentchooserdialog.cpp:212
QList< std::shared_ptr< Symbol > > mSymbols
Definition componentchooserdialog.h:105
bool mCategorySelected
Definition componentchooserdialog.h:98
QScopedPointer< Ui::ComponentChooserDialog > mUi
Definition componentchooserdialog.h:96
void accept() noexcept override
Definition componentchooserdialog.cpp:283
The GraphicsLayerList class.
Definition graphicslayerlist.h:48
The GraphicsScene class.
Definition graphicsscene.h:64
The SymbolGraphicsItem class.
Definition symbolgraphicsitem.h:56
Definition occmodel.cpp:77
Definition uuid.h:186