QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
movegraphicsitemcommand.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2022 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 MOVEGRAPHICSITEMCOMMAND_H
19#define MOVEGRAPHICSITEMCOMMAND_H
20
21#include <QUndoCommand>
22#include <QParallelAnimationGroup>
23#include <QPointer>
24
25#include "../diagramcontent.h"
26
27class Diagram;
28
33class MoveGraphicsItemCommand : public QUndoCommand
34{
35 public:
37 const DiagramContent &content,
38 const QPointF &movement,
39 QUndoCommand *parent = nullptr);
40
42
43 private:
45
46 public:
47 void undo() override;
48 void redo() override;
49
50 private:
51 void move(const QPointF &movement);
52 void setupAnimation(QObject *target,
53 const QByteArray &property_name,
54 const QVariant &start,
55 const QVariant &end);
56
57 private:
58 QPointer<Diagram> m_diagram;
60 const QPointF m_movement;
61 QParallelAnimationGroup m_anim_group;
62 bool m_first_redo{true};
63};
64
65#endif // MOVEGRAPHICSITEMCOMMAND_H
Definition diagramcontent.h:47
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition diagram.h:56
The MoveGraphicsItemCommand class An undo command used for move item(s) in a diagram.
Definition movegraphicsitemcommand.h:34
void setupAnimation(QObject *target, const QByteArray &property_name, const QVariant &start, const QVariant &end)
MoveGraphicsItemCommand::setupAnimation Create the animation used for the movement.
Definition movegraphicsitemcommand.cpp:164
~MoveGraphicsItemCommand()
Definition movegraphicsitemcommand.h:41
QParallelAnimationGroup m_anim_group
Definition movegraphicsitemcommand.h:61
bool m_first_redo
Definition movegraphicsitemcommand.h:62
void undo() override
MoveGraphicsItemCommand::undo Reimplemented from QUndoCommand::undo()
Definition movegraphicsitemcommand.cpp:61
void redo() override
MoveGraphicsItemCommand::redo Reimplemented from QUndoCommand::redo()
Definition movegraphicsitemcommand.cpp:76
QPointer< Diagram > m_diagram
Definition movegraphicsitemcommand.h:58
MoveGraphicsItemCommand(const MoveGraphicsItemCommand &)
const QPointF m_movement
Definition movegraphicsitemcommand.h:60
DiagramContent m_content
Definition movegraphicsitemcommand.h:59
void move(const QPointF &movement)
MoveGraphicsItemCommand::move Apply movement to items of m_content.
Definition movegraphicsitemcommand.cpp:100