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
74 // Operator Overloadings
75 CmdTextEdit& operator=(const CmdTextEdit& rhs) = delete;
76
77private:
78 // Private Methods
79
81 bool performExecute() override;
82
84 void performUndo() override;
85
87 void performRedo() override;
88
89 // Private Member Variables
90
91 // Attributes from the constructor
93
94 // General Attributes
97 QString mOldText;
98 QString mNewText;
107};
108
109/*******************************************************************************
110 * Undo Commands
111 ******************************************************************************/
112
119
120/*******************************************************************************
121 * End of File
122 ******************************************************************************/
123
124} // namespace editor
125} // namespace librepcb
126
127#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:162
void setHeight(const PositiveLength &height, bool immediate) noexcept
Definition cmdtextedit.cpp:76
void setPosition(const Point &pos, bool immediate) noexcept
Definition cmdtextedit.cpp:90
void setLayer(const Layer &layer, bool immediate) noexcept
Definition cmdtextedit.cpp:64
void translate(const Point &deltaPos, bool immediate) noexcept
Definition cmdtextedit.cpp:96
Point mOldPosition
Definition cmdtextedit.h:99
Angle mNewRotation
Definition cmdtextedit.h:102
void performUndo() override
Undo the command.
Definition cmdtextedit.cpp:153
Text & mText
Definition cmdtextedit.h:92
PositiveLength mNewHeight
Definition cmdtextedit.h:104
void setAlignment(const Alignment &align, bool immediate) noexcept
Definition cmdtextedit.cpp:83
void setText(const QString &text, bool immediate) noexcept
Definition cmdtextedit.cpp:70
Alignment mNewAlign
Definition cmdtextedit.h:106
PositiveLength mOldHeight
Definition cmdtextedit.h:103
Alignment mOldAlign
Definition cmdtextedit.h:105
CmdTextEdit(const CmdTextEdit &other)=delete
void snapToGrid(const PositiveLength &gridInterval, bool immediate) noexcept
Definition cmdtextedit.cpp:102
QString mNewText
Definition cmdtextedit.h:98
const Layer * mNewLayer
Definition cmdtextedit.h:96
Point mNewPosition
Definition cmdtextedit.h:100
void mirror(Qt::Orientation orientation, const Point &center, bool immediate) noexcept
Definition cmdtextedit.cpp:119
~CmdTextEdit() noexcept
Definition cmdtextedit.cpp:54
bool performExecute() override
Execute the command the first time.
Definition cmdtextedit.cpp:141
void rotate(const Angle &angle, const Point &center, bool immediate) noexcept
Definition cmdtextedit.cpp:113
Angle mOldRotation
Definition cmdtextedit.h:101
const Layer * mOldLayer
Definition cmdtextedit.h:95
QString mOldText
Definition cmdtextedit.h:97
void setRotation(const Angle &angle, bool immediate) noexcept
Definition cmdtextedit.cpp:107
The UndoCommand class represents a command which you can undo/redo.
Definition undocommand.h:46
CmdListElementRemove< Text, TextListNameProvider, Text::Event > CmdTextRemove
Definition cmdtextedit.h:116
CmdListElementsSwap< Text, TextListNameProvider, Text::Event > CmdTextsSwap
Definition cmdtextedit.h:118
CmdListElementInsert< Text, TextListNameProvider, Text::Event > CmdTextInsert
Definition cmdtextedit.h:114
Definition occmodel.cpp:76
type_safe::constrained_type< Length, PositiveLengthConstraint, PositiveLengthVerifier > PositiveLength
Definition length.h:810
Definition text.h:120