QElectroTech  0.8-dev
qpropertyundocommand.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 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 
24 class QObject;
25 
33 class 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,
61  m_first_time = true;
62 };
63 
64 #endif // QPROPERTYUNDOCOMMAND_H
QPropertyUndoCommand::enableAnimation
void enableAnimation(bool animate=true)
QPropertyUndoCommand::enableAnimation True to enable animation.
Definition: qpropertyundocommand.cpp:92
QPropertyUndoCommand::QPropertyUndoCommand
QPropertyUndoCommand(QObject *object, const char *property_name, const QVariant &old_value, const QVariant &new_value, QUndoCommand *parent=nullptr)
QPropertyUndoCommand::QPropertyUndoCommand Default constructor with old and new value This command do...
Definition: qpropertyundocommand.cpp:31
QPropertyUndoCommand::m_new_value
QVariant m_new_value
Definition: qpropertyundocommand.h:59
QPropertyUndoCommand::mergeWith
bool mergeWith(const QUndoCommand *other) override
QPropertyUndoCommand::mergeWith Try to merge this command with other command.
Definition: qpropertyundocommand.cpp:115
QPropertyUndoCommand::redo
void redo() override
QPropertyUndoCommand::redo Redo this command.
Definition: qpropertyundocommand.cpp:129
QPropertyUndoCommand::setNewValue
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
QPropertyUndoCommand::m_first_time
bool m_first_time
Definition: qpropertyundocommand.h:61
QPropertyUndoCommand::m_object
QObject * m_object
Definition: qpropertyundocommand.h:57
qpropertyundocommand.h
QPropertyUndoCommand::m_property_name
const char * m_property_name
Definition: qpropertyundocommand.h:58
QPropertyUndoCommand::setAnimated
void setAnimated(bool animate=true, bool first_time=true)
QPropertyUndoCommand::setAnimated.
Definition: qpropertyundocommand.cpp:103
QPropertyUndoCommand::undo
void undo() override
QPropertyUndoCommand::undo Undo this command.
Definition: qpropertyundocommand.cpp:154
QPropertyUndoCommand::m_old_value
QVariant m_old_value
Definition: qpropertyundocommand.h:59
QPropertyUndoCommand::m_animate
bool m_animate
Definition: qpropertyundocommand.h:60
QPropertyUndoCommand
The QPropertyUndoCommand class This undo command manage QProperty of a QObject. This undo command can...
Definition: qpropertyundocommand.h:34
QPropertyUndoCommand::id
int id() const override
Definition: qpropertyundocommand.h:51