LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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_CMDATTRIBUTEEDIT_H
21 #define LIBREPCB_CMDATTRIBUTEEDIT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "../../undocommand.h"
27 #include "../attribute.h"
28 
29 #include <QtCore>
30 
31 /*******************************************************************************
32  * Namespace / Forward Declarations
33  ******************************************************************************/
34 namespace librepcb {
35 
36 /*******************************************************************************
37  * Class CmdAttributeEdit
38  ******************************************************************************/
39 
43 class CmdAttributeEdit final : public UndoCommand {
44 public:
45  // Constructors / Destructor
46  CmdAttributeEdit() = delete;
47  CmdAttributeEdit(const CmdAttributeEdit& other) = delete;
48  explicit CmdAttributeEdit(Attribute& attribute) noexcept;
49  ~CmdAttributeEdit() noexcept;
50 
51  // Setters
52  void setKey(const AttributeKey& key) noexcept;
53  void setType(const AttributeType& type) noexcept;
54  void setValue(const QString& value) noexcept;
55  void setUnit(const AttributeUnit* unit) noexcept;
56 
57  // Operator Overloadings
58  CmdAttributeEdit& operator=(const CmdAttributeEdit& rhs) = delete;
59 
60 private:
61  // Private Methods
62 
64  bool performExecute() override;
65 
67  void performUndo() override;
68 
70  void performRedo() override;
71 
72  // Private Member Variables
73 
74  // Attributes from the constructor
76 
77  // General Attributes
82  QString mOldValue;
83  QString mNewValue;
86 };
87 
88 /*******************************************************************************
89  * End of File
90  ******************************************************************************/
91 
92 } // namespace librepcb
93 
94 #endif // LIBREPCB_CMDATTRIBUTEEDIT_H
The CmdAttributeEdit class.
Definition: cmdattributeedit.h:43
Attribute & mAttribute
Definition: cmdattributeedit.h:75
void setValue(const QString &value) noexcept
Definition: cmdattributeedit.cpp:66
type_safe::constrained_type< QString, AttributeKeyConstraint, AttributeKeyVerifier > AttributeKey
Definition: attributekey.h:83
void setKey(const AttributeKey &key) noexcept
Definition: cmdattributeedit.cpp:56
The AttributeUnit class.
Definition: attributeunit.h:42
void setUnit(const AttributeUnit *unit) noexcept
Definition: cmdattributeedit.cpp:71
const AttributeType * mNewType
Definition: cmdattributeedit.h:81
CmdAttributeEdit & operator=(const CmdAttributeEdit &rhs)=delete
bool performExecute() override
Execute the command the first time.
Definition: cmdattributeedit.cpp:80
~CmdAttributeEdit() noexcept
Definition: cmdattributeedit.cpp:49
QString mOldValue
Definition: cmdattributeedit.h:82
AttributeKey mNewKey
Definition: cmdattributeedit.h:79
const AttributeUnit * mNewUnit
Definition: cmdattributeedit.h:85
void performRedo() override
Redo the command.
Definition: cmdattributeedit.cpp:98
The Attribute class.
Definition: attribute.h:49
void setType(const AttributeType &type) noexcept
Definition: cmdattributeedit.cpp:61
const AttributeType * mOldType
Definition: cmdattributeedit.h:80
The UndoCommand class represents a command which you can undo/redo.
Definition: undocommand.h:47
void performUndo() override
Undo the command.
Definition: cmdattributeedit.cpp:93
const AttributeUnit * mOldUnit
Definition: cmdattributeedit.h:84
QString mNewValue
Definition: cmdattributeedit.h:83
AttributeKey mOldKey
Definition: cmdattributeedit.h:78
The AttributeType class.
Definition: attributetype.h:44