LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
graphicslayercombobox.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_GRAPHICSLAYERCOMBOBOX_H
21 #define LIBREPCB_GRAPHICSLAYERCOMBOBOX_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../graphics/graphicslayername.h"
27 
28 #include <optional/tl/optional.hpp>
29 
30 #include <QtCore>
31 #include <QtWidgets>
32 
33 /*******************************************************************************
34  * Namespace / Forward Declarations
35  ******************************************************************************/
36 namespace librepcb {
37 
38 class GraphicsLayer;
39 
40 /*******************************************************************************
41  * Class GraphicsLayerComboBox
42  ******************************************************************************/
43 
47 class GraphicsLayerComboBox final : public QWidget {
48  Q_OBJECT
49 
50 public:
51  // Constructors / Destructor
52  explicit GraphicsLayerComboBox(QWidget* parent = nullptr) noexcept;
53  GraphicsLayerComboBox(const GraphicsLayerComboBox& other) = delete;
54  ~GraphicsLayerComboBox() noexcept;
55 
56  // Getters
57  tl::optional<GraphicsLayerName> getCurrentLayerName() const noexcept;
58 
59  // Setters
60  void setLayers(const QList<GraphicsLayer*>& layers) noexcept;
61  void setCurrentLayer(const GraphicsLayerName& name) noexcept;
62 
63  // Operator Overloadings
65 
66 signals:
67  void currentLayerChanged(const GraphicsLayerName& name);
68 
69 private: // Methods
70  void currentIndexChanged(int index) noexcept;
71 
72 private: // Data
73  QScopedPointer<QComboBox> mComboBox;
74 };
75 
76 /*******************************************************************************
77  * End of File
78  ******************************************************************************/
79 
80 } // namespace librepcb
81 
82 #endif // LIBREPCB_GRAPHICSLAYERCOMBOBOX_H
void setLayers(const QList< GraphicsLayer * > &layers) noexcept
Definition: graphicslayercombobox.cpp:79
GraphicsLayerComboBox(QWidget *parent=nullptr) noexcept
Definition: graphicslayercombobox.cpp:39
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
QScopedPointer< QComboBox > mComboBox
Definition: graphicslayercombobox.h:73
GraphicsLayerComboBox & operator=(const GraphicsLayerComboBox &rhs)=delete
void setCurrentLayer(const GraphicsLayerName &name) noexcept
Definition: graphicslayercombobox.cpp:98
~GraphicsLayerComboBox() noexcept
Definition: graphicslayercombobox.cpp:54
tl::optional< GraphicsLayerName > getCurrentLayerName() const noexcept
Definition: graphicslayercombobox.cpp:61
void currentLayerChanged(const GraphicsLayerName &name)
void currentIndexChanged(int index) noexcept
Definition: graphicslayercombobox.cpp:107
The GraphicsLayerComboBox class.
Definition: graphicslayercombobox.h:47