LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
symbolchooserdialog.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_SYMBOLCHOOSERDIALOG_H
21 #define LIBREPCB_LIBRARY_EDITOR_SYMBOLCHOOSERDIALOG_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
27 #include <librepcb/common/uuid.h>
28 
29 #include <QtCore>
30 #include <QtWidgets>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 class IF_GraphicsLayerProvider;
38 class GraphicsScene;
39 
40 namespace workspace {
41 class Workspace;
42 }
43 
44 namespace library {
45 
46 class Symbol;
47 class SymbolGraphicsItem;
48 
49 namespace editor {
50 
51 namespace Ui {
52 class SymbolChooserDialog;
53 }
54 
55 /*******************************************************************************
56  * Class SymbolChooserDialog
57  ******************************************************************************/
58 
65 class SymbolChooserDialog final : public QDialog {
66  Q_OBJECT
67 
68 public:
69  // Constructors / Destructor
70  SymbolChooserDialog() = delete;
71  SymbolChooserDialog(const SymbolChooserDialog& other) = delete;
73  const IF_GraphicsLayerProvider& layerProvider,
74  QWidget* parent = nullptr) noexcept;
75  ~SymbolChooserDialog() noexcept;
76 
77  // Getters
78  tl::optional<Uuid> getSelectedSymbolUuid() const noexcept;
79  QString getSelectedSymbolNameTr() const noexcept;
80  QString getSelectedSymbolDescriptionTr() const noexcept;
81 
82  // Operator Overloadings
84 
85 private: // Methods
86  void treeCategories_currentItemChanged(const QModelIndex& current,
87  const QModelIndex& previous) noexcept;
88  void listSymbols_currentItemChanged(QListWidgetItem* current,
89  QListWidgetItem* previous) noexcept;
90  void listSymbols_itemDoubleClicked(QListWidgetItem* item) noexcept;
91  void setSelectedCategory(const tl::optional<Uuid>& uuid) noexcept;
92  void setSelectedSymbol(const FilePath& fp) noexcept;
93  void accept() noexcept override;
94  const QStringList& localeOrder() const noexcept;
95 
96 private: // Data
99  QScopedPointer<Ui::SymbolChooserDialog> mUi;
100  QScopedPointer<QAbstractItemModel> mCategoryTreeModel;
101  QScopedPointer<GraphicsScene> mPreviewScene;
102  tl::optional<Uuid> mSelectedCategoryUuid;
103  QScopedPointer<Symbol> mSelectedSymbol;
104  QScopedPointer<SymbolGraphicsItem> mGraphicsItem;
105 };
106 
107 /*******************************************************************************
108  * End of File
109  ******************************************************************************/
110 
111 } // namespace editor
112 } // namespace library
113 } // namespace librepcb
114 
115 #endif // LIBREPCB_LIBRARY_EDITOR_SYMBOLCHOOSERDIALOG_H
tl::optional< Uuid > mSelectedCategoryUuid
Definition: symbolchooserdialog.h:102
QScopedPointer< Ui::SymbolChooserDialog > mUi
Definition: symbolchooserdialog.h:99
const IF_GraphicsLayerProvider & mLayerProvider
Definition: symbolchooserdialog.h:98
The Workspace class represents a workspace with all its data (library, projects, settings, ...)
Definition: workspace.h:65
void accept() noexceptoverride
Definition: symbolchooserdialog.cpp:184
const QStringList & localeOrder() const noexcept
Definition: symbolchooserdialog.cpp:193
void listSymbols_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous) noexcept
Definition: symbolchooserdialog.cpp:110
void listSymbols_itemDoubleClicked(QListWidgetItem *item) noexcept
Definition: symbolchooserdialog.cpp:120
QScopedPointer< QAbstractItemModel > mCategoryTreeModel
Definition: symbolchooserdialog.h:100
void setSelectedSymbol(const FilePath &fp) noexcept
Definition: symbolchooserdialog.cpp:159
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers...
Definition: graphicslayer.h:250
QScopedPointer< Symbol > mSelectedSymbol
Definition: symbolchooserdialog.h:103
~SymbolChooserDialog() noexcept
Definition: symbolchooserdialog.cpp:75
QScopedPointer< GraphicsScene > mPreviewScene
Definition: symbolchooserdialog.h:101
QScopedPointer< SymbolGraphicsItem > mGraphicsItem
Definition: symbolchooserdialog.h:104
QString getSelectedSymbolNameTr() const noexcept
Definition: symbolchooserdialog.cpp:88
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:130
QString getSelectedSymbolDescriptionTr() const noexcept
Definition: symbolchooserdialog.cpp:93
SymbolChooserDialog & operator=(const SymbolChooserDialog &rhs)=delete
const workspace::Workspace & mWorkspace
Definition: symbolchooserdialog.h:97
tl::optional< Uuid > getSelectedSymbolUuid() const noexcept
Definition: symbolchooserdialog.cpp:83
The SymbolChooserDialog class.
Definition: symbolchooserdialog.h:65
void setSelectedCategory(const tl::optional< Uuid > &uuid) noexcept
Definition: symbolchooserdialog.cpp:128
void treeCategories_currentItemChanged(const QModelIndex &current, const QModelIndex &previous) noexcept
Definition: symbolchooserdialog.cpp:103