QElectroTech  0.70
qpropertyundocommand.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 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, const char *property_name, const QVariant &old_value, const QVariant &new_value, QUndoCommand *parent = nullptr);
37  QPropertyUndoCommand(QObject *object, const char *property_name, const QVariant &old_value, QUndoCommand *parent = nullptr);
39 
40  void setNewValue(const QVariant &new_value);
41  void enableAnimation (bool animate = true);
42  void setAnimated(bool animate = true, bool first_time = true);
43 
44  int id() const override{return 10000;}
45  bool mergeWith(const QUndoCommand *other) override;
46  void redo() override;
47  void undo() override;
48 
49  private:
50  QObject *m_object = nullptr;
51  const char *m_property_name;
53  bool m_animate = false,
54  m_first_time = true;
55 };
56 
57 #endif // QPROPERTYUNDOCOMMAND_H
The QPropertyUndoCommand class This undo command manage QProperty of a QObject. This undo command can...
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...
void enableAnimation(bool animate=true)
QPropertyUndoCommand::enableAnimation True to enable animation.
void undo() override
QPropertyUndoCommand::undo Undo this command.
int id() const override
bool mergeWith(const QUndoCommand *other) override
QPropertyUndoCommand::mergeWith Try to merge this command with other command.
void redo() override
QPropertyUndoCommand::redo Redo this command.
void setAnimated(bool animate=true, bool first_time=true)
QPropertyUndoCommand::setAnimated.
void setNewValue(const QVariant &new_value)
QPropertyUndoCommand::setNewValue Set the new value of the property (set with redo) to ...