QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
qpropertyundocommand.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef QPROPERTYUNDOCOMMAND_H
19#define QPROPERTYUNDOCOMMAND_H
20
21#include <QUndoCommand>
22#include <QVariant>
23
24class QObject;
25
33class QPropertyUndoCommand : public QUndoCommand
34{
35 public:
36 QPropertyUndoCommand(QObject *object,
37 const char *property_name,
38 const QVariant &old_value,
39 const QVariant &new_value,
40 QUndoCommand *parent = nullptr);
41 QPropertyUndoCommand(QObject *object,
42 const char *property_name,
43 const QVariant &old_value,
44 QUndoCommand *parent = nullptr);
46
47 void setNewValue(const QVariant &new_value);
48 void enableAnimation (bool animate = true);
49 void setAnimated(bool animate = true, bool first_time = true);
50
51 int id() const override{return 10000;}
52 bool mergeWith(const QUndoCommand *other) override;
53 void redo() override;
54 void undo() override;
55
56 private:
57 QObject *m_object = nullptr;
58 const char *m_property_name;
60 bool m_animate = false,
62};
63
64#endif // QPROPERTYUNDOCOMMAND_H
The QPropertyUndoCommand class This undo command manage QProperty of a QObject. This undo command can...
Definition qpropertyundocommand.h:34
int id() const override
Definition qpropertyundocommand.h:51
void undo() override
QPropertyUndoCommand::undo Undo this command.
Definition qpropertyundocommand.cpp:154
bool m_animate
Definition qpropertyundocommand.h:60
bool m_first_time
Definition qpropertyundocommand.h:61
QVariant m_old_value
Definition qpropertyundocommand.h:59
void enableAnimation(bool animate=true)
QPropertyUndoCommand::enableAnimation True to enable animation.
Definition qpropertyundocommand.cpp:92
QObject * m_object
Definition qpropertyundocommand.h:57
void setAnimated(bool animate=true, bool first_time=true)
QPropertyUndoCommand::setAnimated.
Definition qpropertyundocommand.cpp:103
QVariant m_new_value
Definition qpropertyundocommand.h:59
void redo() override
QPropertyUndoCommand::redo Redo this command.
Definition qpropertyundocommand.cpp:129
const char * m_property_name
Definition qpropertyundocommand.h:58
bool mergeWith(const QUndoCommand *other) override
QPropertyUndoCommand::mergeWith Try to merge this command with other command.
Definition qpropertyundocommand.cpp:115
void setNewValue(const QVariant &new_value)
QPropertyUndoCommand::setNewValue Set the new value of the property (set with redo) to new_value.
Definition qpropertyundocommand.cpp:83