LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cmdtextedit.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_CMDTEXTEDIT_H
21 #define LIBREPCB_CMDTEXTEDIT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../../undocommand.h"
27 #include "../text.h"
28 
29 #include <QtCore>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 
36 /*******************************************************************************
37  * Class CmdTextEdit
38  ******************************************************************************/
39 
43 class CmdTextEdit final : public UndoCommand {
44 public:
45  // Constructors / Destructor
46  CmdTextEdit() = delete;
47  CmdTextEdit(const CmdTextEdit& other) = delete;
48  explicit CmdTextEdit(Text& text) noexcept;
49  ~CmdTextEdit() noexcept;
50 
51  // Setters
52  void setLayerName(const GraphicsLayerName& name, bool immediate) noexcept;
53  void setText(const QString& text, bool immediate) noexcept;
54  void setHeight(const PositiveLength& height, bool immediate) noexcept;
55  void setAlignment(const Alignment& align, bool immediate) noexcept;
56  void setPosition(const Point& pos, bool immediate) noexcept;
57  void translate(const Point& deltaPos, bool immediate) noexcept;
58  void setRotation(const Angle& angle, bool immediate) noexcept;
59  void rotate(const Angle& angle, const Point& center, bool immediate) noexcept;
60 
61  // Operator Overloadings
62  CmdTextEdit& operator=(const CmdTextEdit& rhs) = delete;
63 
64 private:
65  // Private Methods
66 
68  bool performExecute() override;
69 
71  void performUndo() override;
72 
74  void performRedo() override;
75 
76  // Private Member Variables
77 
78  // Attributes from the constructor
80 
81  // General Attributes
84  QString mOldText;
85  QString mNewText;
94 };
95 
96 /*******************************************************************************
97  * End of File
98  ******************************************************************************/
99 
100 } // namespace librepcb
101 
102 #endif // LIBREPCB_CMDTEXTEDIT_H
void setHeight(const PositiveLength &height, bool immediate) noexcept
Definition: cmdtextedit.cpp:76
Alignment mNewAlign
Definition: cmdtextedit.h:93
The Alignment class.
Definition: alignment.h:184
void setAlignment(const Alignment &align, bool immediate) noexcept
Definition: cmdtextedit.cpp:83
type_safe::constrained_type< QString, GraphicsLayerNameConstraint, GraphicsLayerNameVerifier > GraphicsLayerName
Definition: graphicslayername.h:78
void setText(const QString &text, bool immediate) noexcept
Definition: cmdtextedit.cpp:70
Angle mOldRotation
Definition: cmdtextedit.h:88
void setRotation(const Angle &angle, bool immediate) noexcept
Definition: cmdtextedit.cpp:102
void setPosition(const Point &pos, bool immediate) noexcept
Definition: cmdtextedit.cpp:90
void performRedo() override
Redo the command.
Definition: cmdtextedit.cpp:144
Alignment mOldAlign
Definition: cmdtextedit.h:92
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition: angle.h:78
void rotate(const Angle &angle, const Point &center, bool immediate) noexcept
Definition: cmdtextedit.cpp:108
QString mOldText
Definition: cmdtextedit.h:84
GraphicsLayerName mOldLayerName
Definition: cmdtextedit.h:82
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5...
Definition: point.h:78
GraphicsLayerName mNewLayerName
Definition: cmdtextedit.h:83
Text & mText
Definition: cmdtextedit.h:79
~CmdTextEdit() noexcept
Definition: cmdtextedit.cpp:53
void setLayerName(const GraphicsLayerName &name, bool immediate) noexcept
Definition: cmdtextedit.cpp:63
Point mOldPosition
Definition: cmdtextedit.h:86
Angle mNewRotation
Definition: cmdtextedit.h:89
Point mNewPosition
Definition: cmdtextedit.h:87
The UndoCommand class represents a command which you can undo/redo.
Definition: undocommand.h:47
PositiveLength mNewHeight
Definition: cmdtextedit.h:91
PositiveLength mOldHeight
Definition: cmdtextedit.h:90
bool performExecute() override
Execute the command the first time.
Definition: cmdtextedit.cpp:123
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition: length.h:780
The Text class.
Definition: text.h:48
The CmdTextEdit class.
Definition: cmdtextedit.h:43
void translate(const Point &deltaPos, bool immediate) noexcept
Definition: cmdtextedit.cpp:96
QString mNewText
Definition: cmdtextedit.h:85
void performUndo() override
Undo the command.
Definition: cmdtextedit.cpp:135
CmdTextEdit & operator=(const CmdTextEdit &rhs)=delete