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"
29#include "cmdlistelementsswap.h"
30
32
33#include <QtCore>
34
35/*******************************************************************************
36 * Namespace / Forward Declarations
37 ******************************************************************************/
38namespace librepcb {
39namespace editor {
40
41/*******************************************************************************
42 * Class CmdAttributeEdit
43 ******************************************************************************/
44
48class CmdAttributeEdit final : public UndoCommand {
49public:
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
65private:
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
99 Attribute::Event>;
102 Attribute::Event>;
105
106/*******************************************************************************
107 * End of File
108 ******************************************************************************/
109
110} // namespace editor
111} // namespace librepcb
112
113#endif
The Attribute class.
Definition: attribute.h:46
The AttributeType class.
Definition: attributetype.h:42
The AttributeUnit class.
Definition: attributeunit.h:40
The CmdAttributeEdit class.
Definition: cmdattributeedit.h:48
void performRedo() override
Redo the command.
Definition: cmdattributeedit.cpp:99
AttributeKey mNewKey
Definition: cmdattributeedit.h:84
void setType(const AttributeType &type) noexcept
Definition: cmdattributeedit.cpp:62
const AttributeUnit * mOldUnit
Definition: cmdattributeedit.h:89
CmdAttributeEdit(const CmdAttributeEdit &other)=delete
void setValue(const QString &value) noexcept
Definition: cmdattributeedit.cpp:67
Attribute & mAttribute
Definition: cmdattributeedit.h:80
const AttributeType * mOldType
Definition: cmdattributeedit.h:85
void performUndo() override
Undo the command.
Definition: cmdattributeedit.cpp:94
void setKey(const AttributeKey &key) noexcept
Definition: cmdattributeedit.cpp:57
const AttributeUnit * mNewUnit
Definition: cmdattributeedit.h:90
QString mNewValue
Definition: cmdattributeedit.h:88
AttributeKey mOldKey
Definition: cmdattributeedit.h:83
QString mOldValue
Definition: cmdattributeedit.h:87
~CmdAttributeEdit() noexcept
Definition: cmdattributeedit.cpp:50
const AttributeType * mNewType
Definition: cmdattributeedit.h:86
bool performExecute() override
Execute the command the first time.
Definition: cmdattributeedit.cpp:81
void setUnit(const AttributeUnit *unit) noexcept
Definition: cmdattributeedit.cpp:72
The CmdListElementInsert class.
Definition: cmdlistelementinsert.h:46
The CmdListElementRemove class.
Definition: cmdlistelementremove.h:46
The CmdListElementsSwap class.
Definition: cmdlistelementsswap.h:46
The UndoCommand class represents a command which you can undo/redo.
Definition: undocommand.h:46
Definition: occmodel.cpp:77
type_safe::constrained_type< QString, AttributeKeyConstraint, AttributeKeyVerifier > AttributeKey
Definition: attributekey.h:84
Definition: attribute.h:111