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 ******************************************************************************/
37namespace librepcb {
38
39class Symbol;
40class Workspace;
41
42namespace editor {
43
44class GraphicsScene;
45class IF_GraphicsLayerProvider;
46class SymbolGraphicsItem;
47
48namespace Ui {
49class SymbolChooserDialog;
50}
51
52/*******************************************************************************
53 * Class SymbolChooserDialog
54 ******************************************************************************/
55
59class SymbolChooserDialog final : public QDialog {
60 Q_OBJECT
61
62public:
63 // Constructors / Destructor
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
79private: // 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
92private: // Data
95 QScopedPointer<Ui::SymbolChooserDialog> mUi;
96 QScopedPointer<QAbstractItemModel> mCategoryTreeModel;
100 std::unique_ptr<Symbol> mSelectedSymbol;
102};
103
104/*******************************************************************************
105 * End of File
106 ******************************************************************************/
107
108} // namespace editor
109} // namespace librepcb
110
111#endif
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 GraphicsScene class.
Definition: graphicsscene.h:45
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers.
Definition: graphicslayer.h:111
The SymbolChooserDialog class.
Definition: symbolchooserdialog.h:59
const QStringList & localeOrder() const noexcept
Definition: symbolchooserdialog.cpp:262
QString getSelectedSymbolNameTr() const noexcept
Definition: symbolchooserdialog.cpp:110
std::unique_ptr< Symbol > mSelectedSymbol
Definition: symbolchooserdialog.h:100
void setSelectedSymbol(const FilePath &fp) noexcept
Definition: symbolchooserdialog.cpp:225
void searchSymbols(const QString &input)
Definition: symbolchooserdialog.cpp:164
tl::optional< Uuid > mSelectedCategoryUuid
Definition: symbolchooserdialog.h:99
QScopedPointer< QAbstractItemModel > mCategoryTreeModel
Definition: symbolchooserdialog.h:96
void treeCategories_currentItemChanged(const QModelIndex &current, const QModelIndex &previous) noexcept
Definition: symbolchooserdialog.cpp:139
QScopedPointer< SymbolGraphicsItem > mGraphicsItem
Definition: symbolchooserdialog.h:101
const Workspace & mWorkspace
Definition: symbolchooserdialog.h:93
QScopedPointer< Ui::SymbolChooserDialog > mUi
Definition: symbolchooserdialog.h:95
const IF_GraphicsLayerProvider & mLayerProvider
Definition: symbolchooserdialog.h:94
void setSelectedCategory(const tl::optional< Uuid > &uuid) noexcept
Definition: symbolchooserdialog.cpp:189
void searchEditTextChanged(const QString &text) noexcept
Definition: symbolchooserdialog.cpp:125
SymbolChooserDialog(const SymbolChooserDialog &other)=delete
QScopedPointer< GraphicsScene > mPreviewScene
Definition: symbolchooserdialog.h:97
tl::optional< Uuid > getSelectedSymbolUuid() const noexcept
Definition: symbolchooserdialog.cpp:105
void listSymbols_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous) noexcept
Definition: symbolchooserdialog.cpp:146
QString getSelectedSymbolDescriptionTr() const noexcept
Definition: symbolchooserdialog.cpp:115
bool mCategorySelected
Definition: symbolchooserdialog.h:98
void listSymbols_itemDoubleClicked(QListWidgetItem *item) noexcept
Definition: symbolchooserdialog.cpp:156
void accept() noexcept override
Definition: symbolchooserdialog.cpp:253
The SymbolGraphicsItem class.
Definition: symbolgraphicsitem.h:56
Definition: occmodel.cpp:77
Definition: uuid.h:183