LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_LIBRARY_EDITOR_COMPONENTCHOOSERDIALOG_H
21 #define LIBREPCB_LIBRARY_EDITOR_COMPONENTCHOOSERDIALOG_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
27 #include <librepcb/common/uuid.h>
28 
29 #include <QtCore>
30 #include <QtWidgets>
31 
32 #include <memory>
33 
34 /*******************************************************************************
35  * Namespace / Forward Declarations
36  ******************************************************************************/
37 namespace librepcb {
38 
39 class GraphicsScene;
40 class IF_GraphicsLayerProvider;
41 
42 namespace workspace {
43 class Workspace;
44 }
45 
46 namespace library {
47 
48 class Component;
49 class Symbol;
50 class SymbolPreviewGraphicsItem;
51 
52 namespace editor {
53 
54 namespace Ui {
55 class ComponentChooserDialog;
56 }
57 
58 /*******************************************************************************
59  * Class ComponentChooserDialog
60  ******************************************************************************/
61 
68 class ComponentChooserDialog final : public QDialog {
69  Q_OBJECT
70 
71 public:
72  // Constructors / Destructor
73  ComponentChooserDialog() = delete;
74  ComponentChooserDialog(const ComponentChooserDialog& other) = delete;
76  const IF_GraphicsLayerProvider* layerProvider,
77  QWidget* parent = nullptr) noexcept;
78  ~ComponentChooserDialog() noexcept;
79 
80  // Getters
81  const tl::optional<Uuid>& getSelectedComponentUuid() const noexcept {
83  }
84 
85  // Operator Overloadings
87 
88 private: // Methods
89  void treeCategories_currentItemChanged(const QModelIndex& current,
90  const QModelIndex& previous) noexcept;
91  void listComponents_currentItemChanged(QListWidgetItem* current,
92  QListWidgetItem* previous) noexcept;
93  void listComponents_itemDoubleClicked(QListWidgetItem* item) noexcept;
94  void setSelectedCategory(const tl::optional<Uuid>& uuid) noexcept;
95  void setSelectedComponent(const tl::optional<Uuid>& uuid) noexcept;
96  void updatePreview() noexcept;
97  void accept() noexcept override;
98  const QStringList& localeOrder() const noexcept;
99 
100 private: // Data
101  const workspace::Workspace& mWorkspace;
103  QScopedPointer<Ui::ComponentChooserDialog> mUi;
104  QScopedPointer<QAbstractItemModel> mCategoryTreeModel;
107 
108  // preview
110  QScopedPointer<Component> mComponent;
111  QScopedPointer<GraphicsScene> mGraphicsScene;
112  QList<std::shared_ptr<Symbol>> mSymbols;
114 };
115 
116 /*******************************************************************************
117  * End of File
118  ******************************************************************************/
119 
120 } // namespace editor
121 } // namespace library
122 } // namespace librepcb
123 
124 #endif // LIBREPCB_LIBRARY_EDITOR_COMPONENTCHOOSERDIALOG_H
void setSelectedCategory(const tl::optional< Uuid > &uuid) noexcept
Definition: componentchooserdialog.cpp:110
void setSelectedComponent(const tl::optional< Uuid > &uuid) noexcept
Definition: componentchooserdialog.cpp:141
The Workspace class represents a workspace with all its data (library, projects, settings, ...)
Definition: workspace.h:65
The SymbolPreviewGraphicsItem class.
Definition: symbolpreviewgraphicsitem.h:57
QScopedPointer< Component > mComponent
Definition: componentchooserdialog.h:110
const QStringList & localeOrder() const noexcept
Definition: componentchooserdialog.cpp:214
void listComponents_itemDoubleClicked(QListWidgetItem *item) noexcept
Definition: componentchooserdialog.cpp:101
~ComponentChooserDialog() noexcept
Definition: componentchooserdialog.cpp:75
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers...
Definition: graphicslayer.h:250
The ComponentChooserDialog class.
Definition: componentchooserdialog.h:68
const tl::optional< Uuid > & getSelectedComponentUuid() const noexcept
Definition: componentchooserdialog.h:81
The Symbol class represents the part of a component which is added to schematics. ...
Definition: symbol.h:57
FilePath mComponentFilePath
Definition: componentchooserdialog.h:109
tl::optional< Uuid > mSelectedComponentUuid
Definition: componentchooserdialog.h:106
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:130
QScopedPointer< QAbstractItemModel > mCategoryTreeModel
Definition: componentchooserdialog.h:104
tl::optional< Uuid > mSelectedCategoryUuid
Definition: componentchooserdialog.h:105
void updatePreview() noexcept
Definition: componentchooserdialog.cpp:166
void accept() noexceptoverride
Definition: componentchooserdialog.cpp:205
void treeCategories_currentItemChanged(const QModelIndex &current, const QModelIndex &previous) noexcept
Definition: componentchooserdialog.cpp:83
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
QScopedPointer< GraphicsScene > mGraphicsScene
Definition: componentchooserdialog.h:111
QScopedPointer< Ui::ComponentChooserDialog > mUi
Definition: componentchooserdialog.h:103
The GraphicsScene class.
Definition: graphicsscene.h:43
const workspace::Workspace & mWorkspace
Definition: componentchooserdialog.h:101
void listComponents_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous) noexcept
Definition: componentchooserdialog.cpp:90
The Component class represents a "generic" device in the library.
Definition: component.h:73
ComponentChooserDialog & operator=(const ComponentChooserDialog &rhs)=delete
QList< std::shared_ptr< SymbolPreviewGraphicsItem > > mSymbolGraphicsItems
Definition: componentchooserdialog.h:113
QList< std::shared_ptr< Symbol > > mSymbols
Definition: componentchooserdialog.h:112
const IF_GraphicsLayerProvider * mLayerProvider
Definition: componentchooserdialog.h:102