QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
movegraphicsitemcommand.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2026 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 updateConductors(bool is_redo = false);
53 void setupAnimation(QObject *target,
54 const QByteArray &property_name,
55 const QVariant &start,
56 const QVariant &end);
57
58 private:
59 QPointer<Diagram> m_diagram;
61 const QPointF m_movement;
62 QParallelAnimationGroup m_anim_group;
63 bool m_first_redo{true};
64};
65
66#endif // MOVEGRAPHICSITEMCOMMAND_H
Definition diagramcontent.h:49
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition diagram.h:54
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:154
~MoveGraphicsItemCommand()
Definition movegraphicsitemcommand.h:41
MoveGraphicsItemCommand(Diagram *diagram, const DiagramContent &content, const QPointF &movement, QUndoCommand *parent=nullptr)
MoveGraphicsItemCommand::MoveGraphicsItemCommand.
Definition movegraphicsitemcommand.cpp:36
QParallelAnimationGroup m_anim_group
Definition movegraphicsitemcommand.h:62
bool m_first_redo
Definition movegraphicsitemcommand.h:63
void undo() override
MoveGraphicsItemCommand::undo Reimplemented from QUndoCommand::undo().
Definition movegraphicsitemcommand.cpp:62
void redo() override
MoveGraphicsItemCommand::redo Reimplemented from QUndoCommand::redo().
Definition movegraphicsitemcommand.cpp:78
QPointer< Diagram > m_diagram
Definition movegraphicsitemcommand.h:59
MoveGraphicsItemCommand(const MoveGraphicsItemCommand &)
const QPointF m_movement
Definition movegraphicsitemcommand.h:61
void updateConductors(bool is_redo=false)
MoveGraphicsItemCommand::connectConductors.
Definition movegraphicsitemcommand.cpp:172
DiagramContent m_content
Definition movegraphicsitemcommand.h:60
void move(const QPointF &movement)
MoveGraphicsItemCommand::move Apply movement to items of m_content.
Definition movegraphicsitemcommand.cpp:103