LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cmdcomponentinstanceedit.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_PROJECT_CMDCOMPONENTINSTANCEEDIT_H
21 #define LIBREPCB_PROJECT_CMDCOMPONENTINSTANCEEDIT_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
29 
30 #include <QtCore>
31 
32 /*******************************************************************************
33  * Namespace / Forward Declarations
34  ******************************************************************************/
35 namespace librepcb {
36 
37 namespace library {
38 class Component;
39 class ComponentSymbolVariant;
40 } // namespace library
41 
42 namespace project {
43 
44 class Circuit;
45 class ComponentInstance;
46 
47 /*******************************************************************************
48  * Class CmdComponentInstanceEdit
49  ******************************************************************************/
50 
54 class CmdComponentInstanceEdit final : public UndoCommand {
55 public:
56  // Constructors / Destructor
57  CmdComponentInstanceEdit(Circuit& circuit, ComponentInstance& cmp) noexcept;
58  ~CmdComponentInstanceEdit() noexcept;
59 
60  // Setters
61  void setName(const CircuitIdentifier& name) noexcept;
62  void setValue(const QString& value) noexcept;
63  void setAttributes(const AttributeList& attributes) noexcept;
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
82 
83  // Misc
86  QString mOldValue;
87  QString mNewValue;
90 };
91 
92 /*******************************************************************************
93  * End of File
94  ******************************************************************************/
95 
96 } // namespace project
97 } // namespace librepcb
98 
99 #endif // LIBREPCB_PROJECT_CMDCOMPONENTINSTANCEEDIT_H
The Circuit class represents all electrical connections in a project (drawed in the schematics) ...
Definition: circuit.h:75
CircuitIdentifier mNewName
Definition: cmdcomponentinstanceedit.h:85
void performUndo() override
Undo the command.
Definition: cmdcomponentinstanceedit.cpp:89
The CmdComponentInstanceEdit class.
Definition: cmdcomponentinstanceedit.h:54
AttributeList mOldAttributes
Definition: cmdcomponentinstanceedit.h:88
CircuitIdentifier mOldName
Definition: cmdcomponentinstanceedit.h:84
CmdComponentInstanceEdit(Circuit &circuit, ComponentInstance &cmp) noexcept
Definition: cmdcomponentinstanceedit.cpp:40
~CmdComponentInstanceEdit() noexcept
Definition: cmdcomponentinstanceedit.cpp:53
bool performExecute() override
Execute the command the first time.
Definition: cmdcomponentinstanceedit.cpp:80
void performRedo() override
Redo the command.
Definition: cmdcomponentinstanceedit.cpp:95
void setValue(const QString &value) noexcept
Definition: cmdcomponentinstanceedit.cpp:65
ComponentInstance & mComponentInstance
Definition: cmdcomponentinstanceedit.h:81
Circuit & mCircuit
Definition: cmdcomponentinstanceedit.h:80
type_safe::constrained_type< QString, CircuitIdentifierConstraint, CircuitIdentifierVerifier > CircuitIdentifier
Definition: circuitidentifier.h:89
void setAttributes(const AttributeList &attributes) noexcept
Definition: cmdcomponentinstanceedit.cpp:70
AttributeList mNewAttributes
Definition: cmdcomponentinstanceedit.h:89
void setName(const CircuitIdentifier &name) noexcept
Definition: cmdcomponentinstanceedit.cpp:60
The UndoCommand class represents a command which you can undo/redo.
Definition: undocommand.h:52
The ComponentInstance class.
Definition: componentinstance.h:64
QString mNewValue
Definition: cmdcomponentinstanceedit.h:87
QString mOldValue
Definition: cmdcomponentinstanceedit.h:86