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 
62 class SymbolChooserDialog final : public QDialog {
63  Q_OBJECT
64 
65 public:
66  // Constructors / Destructor
67  SymbolChooserDialog() = delete;
68  SymbolChooserDialog(const SymbolChooserDialog& other) = delete;
70  const IF_GraphicsLayerProvider& layerProvider,
71  QWidget* parent = nullptr) noexcept;
72  ~SymbolChooserDialog() noexcept;
73 
74  // Getters
75  tl::optional<Uuid> getSelectedSymbolUuid() const noexcept;
76  QString getSelectedSymbolNameTr() const noexcept;
77  QString getSelectedSymbolDescriptionTr() const noexcept;
78 
79  // Operator Overloadings
81 
82 private: // Methods
83  void searchEditTextChanged(const QString& text) noexcept;
84  void treeCategories_currentItemChanged(const QModelIndex& current,
85  const QModelIndex& previous) noexcept;
86  void listSymbols_currentItemChanged(QListWidgetItem* current,
87  QListWidgetItem* previous) noexcept;
88  void listSymbols_itemDoubleClicked(QListWidgetItem* item) noexcept;
89  void searchSymbols(const QString& input);
90  void setSelectedCategory(const tl::optional<Uuid>& uuid) noexcept;
91  void setSelectedSymbol(const FilePath& fp) noexcept;
92  void accept() noexcept override;
93  const QStringList& localeOrder() const noexcept;
94 
95 private: // Data
98  QScopedPointer<Ui::SymbolChooserDialog> mUi;
99  QScopedPointer<QAbstractItemModel> mCategoryTreeModel;
100  QScopedPointer<GraphicsScene> mPreviewScene;
101  tl::optional<Uuid> mSelectedCategoryUuid;
102  QScopedPointer<Symbol> mSelectedSymbol;
103  QScopedPointer<SymbolGraphicsItem> mGraphicsItem;
104 };
105 
106 /*******************************************************************************
107  * End of File
108  ******************************************************************************/
109 
110 } // namespace editor
111 } // namespace library
112 } // namespace librepcb
113 
114 #endif // LIBREPCB_LIBRARY_EDITOR_SYMBOLCHOOSERDIALOG_H
tl::optional< Uuid > mSelectedCategoryUuid
Definition: symbolchooserdialog.h:101
QScopedPointer< Ui::SymbolChooserDialog > mUi
Definition: symbolchooserdialog.h:98
const IF_GraphicsLayerProvider & mLayerProvider
Definition: symbolchooserdialog.h:97
The Workspace class represents a workspace with all its data (library, projects, settings, ...)
Definition: workspace.h:62
void accept() noexceptoverride
Definition: symbolchooserdialog.cpp:226
const QStringList & localeOrder() const noexcept
Definition: symbolchooserdialog.cpp:235
void listSymbols_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous) noexcept
Definition: symbolchooserdialog.cpp:128
void listSymbols_itemDoubleClicked(QListWidgetItem *item) noexcept
Definition: symbolchooserdialog.cpp:138
QScopedPointer< QAbstractItemModel > mCategoryTreeModel
Definition: symbolchooserdialog.h:99
void setSelectedSymbol(const FilePath &fp) noexcept
Definition: symbolchooserdialog.cpp:198
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers...
Definition: graphicslayer.h:227
QScopedPointer< Symbol > mSelectedSymbol
Definition: symbolchooserdialog.h:102
~SymbolChooserDialog() noexcept
Definition: symbolchooserdialog.cpp:79
void searchSymbols(const QString &input)
Definition: symbolchooserdialog.cpp:146
QScopedPointer< GraphicsScene > mPreviewScene
Definition: symbolchooserdialog.h:100
QScopedPointer< SymbolGraphicsItem > mGraphicsItem
Definition: symbolchooserdialog.h:103
QString getSelectedSymbolNameTr() const noexcept
Definition: symbolchooserdialog.cpp:92
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
QString getSelectedSymbolDescriptionTr() const noexcept
Definition: symbolchooserdialog.cpp:97
SymbolChooserDialog & operator=(const SymbolChooserDialog &rhs)=delete
const workspace::Workspace & mWorkspace
Definition: symbolchooserdialog.h:96
void searchEditTextChanged(const QString &text) noexcept
Definition: symbolchooserdialog.cpp:107
tl::optional< Uuid > getSelectedSymbolUuid() const noexcept
Definition: symbolchooserdialog.cpp:87
The SymbolChooserDialog class.
Definition: symbolchooserdialog.h:62
void setSelectedCategory(const tl::optional< Uuid > &uuid) noexcept
Definition: symbolchooserdialog.cpp:167
void treeCategories_currentItemChanged(const QModelIndex &current, const QModelIndex &previous) noexcept
Definition: symbolchooserdialog.cpp:121