LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
numbereditbase.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_NUMBEREDITBASE_H
21 #define LIBREPCB_NUMBEREDITBASE_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include <optional/tl/optional.hpp>
27 
28 #include <QtCore>
29 #include <QtWidgets>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 
36 class DoubleSpinBox;
37 
38 /*******************************************************************************
39  * Class NumberEditBase
40  ******************************************************************************/
41 
48 class NumberEditBase : public QWidget {
49  Q_OBJECT
50 
51 public:
52  // Constructors / Destructor
53  explicit NumberEditBase(QWidget* parent = nullptr) noexcept;
54  NumberEditBase(const NumberEditBase& other) = delete;
55  virtual ~NumberEditBase() noexcept;
56 
57  // General Methods
58  void setSingleStep(tl::optional<double> step) noexcept;
59  void setFrame(bool frame) noexcept;
60  void selectAll() noexcept;
61 
62  // Operator Overloadings
63  NumberEditBase& operator=(const NumberEditBase& rhs) = delete;
64 
65 signals:
66  void editingFinished();
67 
68 protected: // Methods
69  virtual void updateSpinBox() noexcept = 0;
70  virtual void spinBoxValueChanged(double value) noexcept = 0;
71 
72 protected: // Data
73  QScopedPointer<DoubleSpinBox> mSpinBox;
74 };
75 
76 /*******************************************************************************
77  * End of File
78  ******************************************************************************/
79 
80 } // namespace librepcb
81 
82 #endif // LIBREPCB_NUMBEREDITBASE_H
QScopedPointer< DoubleSpinBox > mSpinBox
Definition: numbereditbase.h:73
virtual ~NumberEditBase() noexcept
Definition: numbereditbase.cpp:57
void selectAll() noexcept
Definition: numbereditbase.cpp:78
NumberEditBase & operator=(const NumberEditBase &rhs)=delete
The NumberEditBase class is a widget base class to edit various kinds of numbers. ...
Definition: numbereditbase.h:48
NumberEditBase(QWidget *parent=nullptr) noexcept
Definition: numbereditbase.cpp:36
void setSingleStep(tl::optional< double > step) noexcept
Definition: numbereditbase.cpp:64
virtual void updateSpinBox() noexcept=0
virtual void spinBoxValueChanged(double value) noexcept=0
void setFrame(bool frame) noexcept
Definition: numbereditbase.cpp:74