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