LibrePCB Developers Documentation
cmdattributeedit.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_CMDATTRIBUTEEDIT_H
21 #define LIBREPCB_EDITOR_CMDATTRIBUTEEDIT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../undocommand.h"
27 #include "cmdlistelementinsert.h"
28 #include "cmdlistelementremove.h"
29 #include "cmdlistelementsswap.h"
30 
32 
33 #include <QtCore>
34 
35 /*******************************************************************************
36  * Namespace / Forward Declarations
37  ******************************************************************************/
38 namespace librepcb {
39 namespace editor {
40 
41 /*******************************************************************************
42  * Class CmdAttributeEdit
43  ******************************************************************************/
44 
48 class CmdAttributeEdit final : public UndoCommand {
49 public:
50  // Constructors / Destructor
51  CmdAttributeEdit() = delete;
52  CmdAttributeEdit(const CmdAttributeEdit& other) = delete;
53  explicit CmdAttributeEdit(Attribute& attribute) noexcept;
54  ~CmdAttributeEdit() noexcept;
55 
56  // Setters
57  void setKey(const AttributeKey& key) noexcept;
58  void setType(const AttributeType& type) noexcept;
59  void setValue(const QString& value) noexcept;
60  void setUnit(const AttributeUnit* unit) noexcept;
61 
62  // Operator Overloadings
63  CmdAttributeEdit& operator=(const CmdAttributeEdit& rhs) = delete;
64 
65 private:
66  // Private Methods
67 
69  bool performExecute() override;
70 
72  void performUndo() override;
73 
75  void performRedo() override;
76 
77  // Private Member Variables
78 
79  // Attributes from the constructor
81 
82  // General Attributes
87  QString mOldValue;
88  QString mNewValue;
91 };
92 
93 /*******************************************************************************
94  * Undo Commands
95  ******************************************************************************/
96 
97 using CmdAttributeInsert =
100 using CmdAttributeRemove =
101  CmdListElementRemove<Attribute, AttributeListNameProvider,
103 using CmdAttributesSwap =
105 
106 /*******************************************************************************
107  * End of File
108  ******************************************************************************/
109 
110 } // namespace editor
111 } // namespace librepcb
112 
113 #endif
The CmdAttributeEdit class.
Definition: cmdattributeedit.h:48
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:46
AttributeKey mNewKey
Definition: cmdattributeedit.h:84
Definition: occmodel.cpp:77
const AttributeUnit * mOldUnit
Definition: cmdattributeedit.h:89
type_safe::constrained_type< QString, AttributeKeyConstraint, AttributeKeyVerifier > AttributeKey
Definition: attributekey.h:84
Event
Definition: attribute.h:51
const AttributeType * mNewType
Definition: cmdattributeedit.h:86
Definition: attribute.h:111
void setType(const AttributeType &type) noexcept
Definition: cmdattributeedit.cpp:62
The AttributeUnit class.
Definition: attributeunit.h:40
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:46
The UndoCommand class represents a command which you can undo/redo.
Definition: undocommand.h:46
void setValue(const QString &value) noexcept
Definition: cmdattributeedit.cpp:67
const AttributeType * mOldType
Definition: cmdattributeedit.h:85
const AttributeUnit * mNewUnit
Definition: cmdattributeedit.h:90
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:46
The Attribute class.
Definition: attribute.h:46
~CmdAttributeEdit() noexcept
Definition: cmdattributeedit.cpp:50
CmdAttributeEdit & operator=(const CmdAttributeEdit &rhs)=delete
void setKey(const AttributeKey &key) noexcept
Definition: cmdattributeedit.cpp:57
bool performExecute() override
Execute the command the first time.
Definition: cmdattributeedit.cpp:81
AttributeKey mOldKey
Definition: cmdattributeedit.h:83
void performUndo() override
Undo the command.
Definition: cmdattributeedit.cpp:94
The AttributeType class.
Definition: attributetype.h:42
QString mOldValue
Definition: cmdattributeedit.h:87
Attribute & mAttribute
Definition: cmdattributeedit.h:80
void setUnit(const AttributeUnit *unit) noexcept
Definition: cmdattributeedit.cpp:72
void performRedo() override
Redo the command.
Definition: cmdattributeedit.cpp:99
QString mNewValue
Definition: cmdattributeedit.h:88