LibrePCB Developers Documentation
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 GraphicsScene;
46class IF_GraphicsLayerProvider;
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
68 const IF_GraphicsLayerProvider* layerProvider,
69 QWidget* parent = nullptr) noexcept;
70 ~ComponentChooserDialog() noexcept;
71
72 // Getters
73 const tl::optional<Uuid>& getSelectedComponentUuid() const noexcept {
75 }
76
77 // Operator Overloadings
79
80private: // Methods
81 void searchEditTextChanged(const QString& text) noexcept;
82 void treeCategories_currentItemChanged(const QModelIndex& current,
83 const QModelIndex& previous) noexcept;
84 void listComponents_currentItemChanged(QListWidgetItem* current,
85 QListWidgetItem* previous) noexcept;
86 void listComponents_itemDoubleClicked(QListWidgetItem* item) noexcept;
87 void searchComponents(const QString& input);
88 void setSelectedCategory(const tl::optional<Uuid>& uuid) noexcept;
89 void setSelectedComponent(const tl::optional<Uuid>& uuid) noexcept;
90 void updatePreview(const FilePath& fp) noexcept;
91 void accept() noexcept override;
92 const QStringList& localeOrder() const noexcept;
93
94private: // Data
97 QScopedPointer<Ui::ComponentChooserDialog> mUi;
98 QScopedPointer<QAbstractItemModel> mCategoryTreeModel;
102
103 // preview
104 std::shared_ptr<Component> mComponent;
106 QList<std::shared_ptr<Symbol>> mSymbols;
108};
109
110/*******************************************************************************
111 * End of File
112 ******************************************************************************/
113
114} // namespace editor
115} // namespace librepcb
116
117#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:129
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:58
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:289
ComponentChooserDialog(const ComponentChooserDialog &other)=delete
void listComponents_itemDoubleClicked(QListWidgetItem *item) noexcept
Definition: componentchooserdialog.cpp:139
void listComponents_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous) noexcept
Definition: componentchooserdialog.cpp:128
QList< std::shared_ptr< SymbolGraphicsItem > > mSymbolGraphicsItems
Definition: componentchooserdialog.h:107
QScopedPointer< GraphicsScene > mGraphicsScene
Definition: componentchooserdialog.h:105
ComponentChooserDialog & operator=(const ComponentChooserDialog &rhs)=delete
tl::optional< Uuid > mSelectedComponentUuid
Definition: componentchooserdialog.h:101
tl::optional< Uuid > mSelectedCategoryUuid
Definition: componentchooserdialog.h:100
QScopedPointer< QAbstractItemModel > mCategoryTreeModel
Definition: componentchooserdialog.h:98
void treeCategories_currentItemChanged(const QModelIndex &current, const QModelIndex &previous) noexcept
Definition: componentchooserdialog.cpp:121
void searchComponents(const QString &input)
Definition: componentchooserdialog.cpp:148
const Workspace & mWorkspace
Definition: componentchooserdialog.h:95
void setSelectedComponent(const tl::optional< Uuid > &uuid) noexcept
Definition: componentchooserdialog.cpp:209
void setSelectedCategory(const tl::optional< Uuid > &uuid) noexcept
Definition: componentchooserdialog.cpp:173
const tl::optional< Uuid > & getSelectedComponentUuid() const noexcept
Definition: componentchooserdialog.h:73
void updatePreview(const FilePath &fp) noexcept
Definition: componentchooserdialog.cpp:232
std::shared_ptr< Component > mComponent
Definition: componentchooserdialog.h:104
void searchEditTextChanged(const QString &text) noexcept
Definition: componentchooserdialog.cpp:106
QList< std::shared_ptr< Symbol > > mSymbols
Definition: componentchooserdialog.h:106
bool mCategorySelected
Definition: componentchooserdialog.h:99
const IF_GraphicsLayerProvider * mLayerProvider
Definition: componentchooserdialog.h:96
QScopedPointer< Ui::ComponentChooserDialog > mUi
Definition: componentchooserdialog.h:97
void accept() noexcept override
Definition: componentchooserdialog.cpp:280
The GraphicsScene class.
Definition: graphicsscene.h:45
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers.
Definition: graphicslayer.h:111
The SymbolGraphicsItem class.
Definition: symbolgraphicsitem.h:56
Definition: occmodel.cpp:77
Definition: uuid.h:183