LibrePCB Developers Documentation
Loading...
Searching...
No Matches
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_EDITOR_CMDTEXTEDIT_H
21#define LIBREPCB_EDITOR_CMDTEXTEDIT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "../undocommand.h"
29#include "cmdlistelementsswap.h"
30
32
33#include <QtCore>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39
40class Layer;
41
42namespace editor {
43
44/*******************************************************************************
45 * Class CmdTextEdit
46 ******************************************************************************/
47
51class CmdTextEdit final : public UndoCommand {
52public:
53 // Constructors / Destructor
54 CmdTextEdit() = delete;
55 CmdTextEdit(const CmdTextEdit& other) = delete;
56 explicit CmdTextEdit(Text& text) noexcept;
57 ~CmdTextEdit() noexcept;
58
59 // Setters
60 void setLayer(const Layer& layer, bool immediate) noexcept;
61 void setText(const QString& text, bool immediate) noexcept;
62 void setHeight(const PositiveLength& height, bool immediate) noexcept;
63 void setAlignment(const Alignment& align, bool immediate) noexcept;
64 void setPosition(const Point& pos, bool immediate) noexcept;
65 void translate(const Point& deltaPos, bool immediate) noexcept;
66 void snapToGrid(const PositiveLength& gridInterval, bool immediate) noexcept;
67 void setRotation(const Angle& angle, bool immediate) noexcept;
68 void rotate(const Angle& angle, const Point& center, bool immediate) noexcept;
69 void mirror(Qt::Orientation orientation, const Point& center,
70 bool immediate) noexcept;
71 void mirror(const Angle& rotation, const Point& center,
72 bool immediate) noexcept;
73 void setLocked(bool locked, bool immediate) noexcept;
74
75 // Operator Overloadings
76 CmdTextEdit& operator=(const CmdTextEdit& rhs) = delete;
77
78private:
79 // Private Methods
80
82 bool performExecute() override;
83
85 void performUndo() override;
86
88 void performRedo() override;
89
90 // Private Member Variables
91
92 // Attributes from the constructor
94
95 // General Attributes
98 QString mOldText;
99 QString mNewText;
110};
111
112/*******************************************************************************
113 * Undo Commands
114 ******************************************************************************/
115
122
123/*******************************************************************************
124 * End of File
125 ******************************************************************************/
126
127} // namespace editor
128} // namespace librepcb
129
130#endif
The Alignment class.
Definition alignment.h:115
The Angle class is used to represent an angle (for example 12.75 degrees)
Definition angle.h:76
The Layer class provides all supported geometry layers.
Definition layer.h:42
The Point class is used to represent a point/coordinate/vector, for example (1.2mm; 5....
Definition point.h:78
The Text class.
Definition text.h:48
The CmdListElementInsert class.
Definition cmdlistelementinsert.h:46
The CmdListElementRemove class.
Definition cmdlistelementremove.h:46
The CmdListElementsSwap class.
Definition cmdlistelementsswap.h:46
The CmdTextEdit class.
Definition cmdtextedit.h:51
void performRedo() override
Redo the command.
Definition cmdtextedit.cpp:172
bool mOldLocked
Definition cmdtextedit.h:108
void setHeight(const PositiveLength &height, bool immediate) noexcept
Definition cmdtextedit.cpp:78
void setPosition(const Point &pos, bool immediate) noexcept
Definition cmdtextedit.cpp:92
void setLayer(const Layer &layer, bool immediate) noexcept
Definition cmdtextedit.cpp:66
void translate(const Point &deltaPos, bool immediate) noexcept
Definition cmdtextedit.cpp:98
Point mOldPosition
Definition cmdtextedit.h:100
void setLocked(bool locked, bool immediate) noexcept
Definition cmdtextedit.cpp:139
Angle mNewRotation
Definition cmdtextedit.h:103
void performUndo() override
Undo the command.
Definition cmdtextedit.cpp:162
Text & mText
Definition cmdtextedit.h:93
PositiveLength mNewHeight
Definition cmdtextedit.h:105
void setAlignment(const Alignment &align, bool immediate) noexcept
Definition cmdtextedit.cpp:85
void setText(const QString &text, bool immediate) noexcept
Definition cmdtextedit.cpp:72
Alignment mNewAlign
Definition cmdtextedit.h:107
PositiveLength mOldHeight
Definition cmdtextedit.h:104
Alignment mOldAlign
Definition cmdtextedit.h:106
CmdTextEdit(const CmdTextEdit &other)=delete
void snapToGrid(const PositiveLength &gridInterval, bool immediate) noexcept
Definition cmdtextedit.cpp:104
QString mNewText
Definition cmdtextedit.h:99
const Layer * mNewLayer
Definition cmdtextedit.h:97
Point mNewPosition
Definition cmdtextedit.h:101
void mirror(Qt::Orientation orientation, const Point &center, bool immediate) noexcept
Definition cmdtextedit.cpp:121
~CmdTextEdit() noexcept
Definition cmdtextedit.cpp:56
bool performExecute() override
Execute the command the first time.
Definition cmdtextedit.cpp:149
void rotate(const Angle &angle, const Point &center, bool immediate) noexcept
Definition cmdtextedit.cpp:115
Angle mOldRotation
Definition cmdtextedit.h:102
const Layer * mOldLayer
Definition cmdtextedit.h:96
bool mNewLocked
Definition cmdtextedit.h:109
QString mOldText
Definition cmdtextedit.h:98
void setRotation(const Angle &angle, bool immediate) noexcept
Definition cmdtextedit.cpp:109
The UndoCommand class represents a command which you can undo/redo.
Definition undocommand.h:46
CmdListElementRemove< Text, TextListNameProvider, Text::Event > CmdTextRemove
Definition cmdtextedit.h:119
CmdListElementsSwap< Text, TextListNameProvider, Text::Event > CmdTextsSwap
Definition cmdtextedit.h:121
CmdListElementInsert< Text, TextListNameProvider, Text::Event > CmdTextInsert
Definition cmdtextedit.h:117
Definition occmodel.cpp:77
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
Definition text.h:124