LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
packagechooserdialog.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_PACKAGECHOOSERDIALOG_H
21 #define LIBREPCB_LIBRARY_EDITOR_PACKAGECHOOSERDIALOG_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 GraphicsScene;
38 class IF_GraphicsLayerProvider;
39 
40 namespace workspace {
41 class Workspace;
42 }
43 
44 namespace library {
45 
46 class Package;
47 class FootprintPreviewGraphicsItem;
48 
49 namespace editor {
50 
51 namespace Ui {
52 class PackageChooserDialog;
53 }
54 
55 /*******************************************************************************
56  * Class PackageChooserDialog
57  ******************************************************************************/
58 
65 class PackageChooserDialog final : public QDialog {
66  Q_OBJECT
67 
68 public:
69  // Constructors / Destructor
70  PackageChooserDialog() = delete;
71  PackageChooserDialog(const PackageChooserDialog& other) = delete;
73  const IF_GraphicsLayerProvider* layerProvider,
74  QWidget* parent = nullptr) noexcept;
75  ~PackageChooserDialog() noexcept;
76 
77  // Getters
78  const tl::optional<Uuid>& getSelectedPackageUuid() const noexcept {
79  return mSelectedPackageUuid;
80  }
81 
82  // Operator Overloadings
84 
85 private: // Methods
86  void treeCategories_currentItemChanged(const QModelIndex& current,
87  const QModelIndex& previous) noexcept;
88  void listPackages_currentItemChanged(QListWidgetItem* current,
89  QListWidgetItem* previous) noexcept;
90  void listPackages_itemDoubleClicked(QListWidgetItem* item) noexcept;
91  void setSelectedCategory(const tl::optional<Uuid>& uuid) noexcept;
92  void setSelectedPackage(const tl::optional<Uuid>& uuid) noexcept;
93  void updatePreview() noexcept;
94  void accept() noexcept override;
95  const QStringList& localeOrder() const noexcept;
96 
97 private: // Data
98  const workspace::Workspace& mWorkspace;
100  QScopedPointer<Ui::PackageChooserDialog> mUi;
101  QScopedPointer<QAbstractItemModel> mCategoryTreeModel;
103  tl::optional<Uuid> mSelectedPackageUuid;
104 
105  // preview
107  QScopedPointer<Package> mPackage;
108  QScopedPointer<GraphicsScene> mGraphicsScene;
110 };
111 
112 /*******************************************************************************
113  * End of File
114  ******************************************************************************/
115 
116 } // namespace editor
117 } // namespace library
118 } // namespace librepcb
119 
120 #endif // LIBREPCB_LIBRARY_EDITOR_PACKAGECHOOSERDIALOG_H
The Workspace class represents a workspace with all its data (library, projects, settings, ...)
Definition: workspace.h:65
void listPackages_itemDoubleClicked(QListWidgetItem *item) noexcept
Definition: packagechooserdialog.cpp:104
FilePath mPackageFilePath
Definition: packagechooserdialog.h:106
void accept() noexceptoverride
Definition: packagechooserdialog.cpp:191
tl::optional< Uuid > mSelectedCategoryUuid
Definition: packagechooserdialog.h:102
void updatePreview() noexcept
Definition: packagechooserdialog.cpp:169
The Package class represents a package of a component (including footprint and 3D model) ...
Definition: package.h:56
tl::optional< Uuid > mSelectedPackageUuid
Definition: packagechooserdialog.h:103
The PackageChooserDialog class.
Definition: packagechooserdialog.h:65
PackageChooserDialog & operator=(const PackageChooserDialog &rhs)=delete
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers...
Definition: graphicslayer.h:250
void listPackages_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous) noexcept
Definition: packagechooserdialog.cpp:93
The FootprintPreviewGraphicsItem class.
Definition: footprintpreviewgraphicsitem.h:58
void setSelectedPackage(const tl::optional< Uuid > &uuid) noexcept
Definition: packagechooserdialog.cpp:145
const tl::optional< Uuid > & getSelectedPackageUuid() const noexcept
Definition: packagechooserdialog.h:78
QScopedPointer< QAbstractItemModel > mCategoryTreeModel
Definition: packagechooserdialog.h:101
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:130
QScopedPointer< FootprintPreviewGraphicsItem > mGraphicsItem
Definition: packagechooserdialog.h:109
QScopedPointer< Package > mPackage
Definition: packagechooserdialog.h:107
const workspace::Workspace & mWorkspace
Definition: packagechooserdialog.h:98
void setSelectedCategory(const tl::optional< Uuid > &uuid) noexcept
Definition: packagechooserdialog.cpp:113
void treeCategories_currentItemChanged(const QModelIndex &current, const QModelIndex &previous) noexcept
Definition: packagechooserdialog.cpp:86
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:58
The GraphicsScene class.
Definition: graphicsscene.h:43
QScopedPointer< Ui::PackageChooserDialog > mUi
Definition: packagechooserdialog.h:100
~PackageChooserDialog() noexcept
Definition: packagechooserdialog.cpp:78
const QStringList & localeOrder() const noexcept
Definition: packagechooserdialog.cpp:200
const IF_GraphicsLayerProvider * mLayerProvider
Definition: packagechooserdialog.h:99
QScopedPointer< GraphicsScene > mGraphicsScene
Definition: packagechooserdialog.h:108