LibrePCB Developers Documentation
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_EDITOR_PACKAGECHOOSERDIALOG_H
21#define LIBREPCB_EDITOR_PACKAGECHOOSERDIALOG_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 Package;
40class Workspace;
41
42namespace editor {
43
44class FootprintGraphicsItem;
45class GraphicsScene;
46class IF_GraphicsLayerProvider;
47
48namespace Ui {
49class PackageChooserDialog;
50}
51
52/*******************************************************************************
53 * Class PackageChooserDialog
54 ******************************************************************************/
55
59class PackageChooserDialog final : public QDialog {
60 Q_OBJECT
61
62public:
63 // Constructors / Destructor
67 const IF_GraphicsLayerProvider* layerProvider,
68 QWidget* parent = nullptr) noexcept;
69 ~PackageChooserDialog() noexcept;
70
71 // Getters
72 const tl::optional<Uuid>& getSelectedPackageUuid() const noexcept {
74 }
75
76 // Operator Overloadings
78
79private: // Methods
80 void searchEditTextChanged(const QString& text) noexcept;
81 void treeCategories_currentItemChanged(const QModelIndex& current,
82 const QModelIndex& previous) noexcept;
83 void listPackages_currentItemChanged(QListWidgetItem* current,
84 QListWidgetItem* previous) noexcept;
85 void listPackages_itemDoubleClicked(QListWidgetItem* item) noexcept;
86 void searchPackages(const QString& input);
87 void setSelectedCategory(const tl::optional<Uuid>& uuid) noexcept;
88 void setSelectedPackage(const tl::optional<Uuid>& uuid) noexcept;
89 void updatePreview(const FilePath& fp) noexcept;
90 void accept() noexcept override;
91 const QStringList& localeOrder() const noexcept;
92
93private: // Data
96 QScopedPointer<Ui::PackageChooserDialog> mUi;
97 QScopedPointer<QAbstractItemModel> mCategoryTreeModel;
101
102 // preview
103 std::unique_ptr<Package> mPackage;
106};
107
108/*******************************************************************************
109 * End of File
110 ******************************************************************************/
111
112} // namespace editor
113} // namespace librepcb
114
115#endif
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:129
The Package class represents a package of a component (including footprint and 3D model)
Definition: package.h:59
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 FootprintGraphicsItem class.
Definition: footprintgraphicsitem.h:66
The GraphicsScene class.
Definition: graphicsscene.h:45
The IF_GraphicsLayerProvider class defines an interface for classes which provide layers.
Definition: graphicslayer.h:111
The PackageChooserDialog class.
Definition: packagechooserdialog.h:59
const QStringList & localeOrder() const noexcept
Definition: packagechooserdialog.cpp:261
PackageChooserDialog(const PackageChooserDialog &other)=delete
PackageChooserDialog & operator=(const PackageChooserDialog &rhs)=delete
void setSelectedPackage(const tl::optional< Uuid > &uuid) noexcept
Definition: packagechooserdialog.cpp:206
tl::optional< Uuid > mSelectedPackageUuid
Definition: packagechooserdialog.h:100
const tl::optional< Uuid > & getSelectedPackageUuid() const noexcept
Definition: packagechooserdialog.h:72
void listPackages_itemDoubleClicked(QListWidgetItem *item) noexcept
Definition: packagechooserdialog.cpp:137
QScopedPointer< GraphicsScene > mGraphicsScene
Definition: packagechooserdialog.h:104
QScopedPointer< FootprintGraphicsItem > mGraphicsItem
Definition: packagechooserdialog.h:105
tl::optional< Uuid > mSelectedCategoryUuid
Definition: packagechooserdialog.h:99
QScopedPointer< QAbstractItemModel > mCategoryTreeModel
Definition: packagechooserdialog.h:97
void treeCategories_currentItemChanged(const QModelIndex &current, const QModelIndex &previous) noexcept
Definition: packagechooserdialog.cpp:119
const Workspace & mWorkspace
Definition: packagechooserdialog.h:94
void setSelectedCategory(const tl::optional< Uuid > &uuid) noexcept
Definition: packagechooserdialog.cpp:171
void updatePreview(const FilePath &fp) noexcept
Definition: packagechooserdialog.cpp:229
void searchPackages(const QString &input)
Definition: packagechooserdialog.cpp:146
void searchEditTextChanged(const QString &text) noexcept
Definition: packagechooserdialog.cpp:105
std::unique_ptr< Package > mPackage
Definition: packagechooserdialog.h:103
QScopedPointer< Ui::PackageChooserDialog > mUi
Definition: packagechooserdialog.h:96
bool mCategorySelected
Definition: packagechooserdialog.h:98
const IF_GraphicsLayerProvider * mLayerProvider
Definition: packagechooserdialog.h:95
void listPackages_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous) noexcept
Definition: packagechooserdialog.cpp:126
void accept() noexcept override
Definition: packagechooserdialog.cpp:252
Definition: occmodel.cpp:77
Definition: uuid.h:183