correct more indentations / whitespace

This commit is contained in:
plc-user
2024-04-24 14:14:40 +02:00
parent 17030aaa80
commit fa68d545d0
46 changed files with 903 additions and 903 deletions

View File

@@ -1,19 +1,19 @@
/*
Copyright 2006-2022 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
Copyright 2006-2022 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QGraphicsItemGroup>
#include <QPropertyAnimation>
@@ -33,25 +33,25 @@
* @param parent : parent undo command
*/
MoveGraphicsItemCommand::MoveGraphicsItemCommand(Diagram *diagram,
const DiagramContent &content,
const QPointF &movement,
QUndoCommand *parent) :
QUndoCommand{parent},
m_diagram{diagram},
m_content{content},
m_movement{movement}
const DiagramContent &content,
const QPointF &movement,
QUndoCommand *parent) :
QUndoCommand{parent},
m_diagram{diagram},
m_content{content},
m_movement{movement}
{
const auto moved_content_sentence = m_content.sentence(DiagramContent::Elements
| DiagramContent::TextFields
| DiagramContent::ConductorsToUpdate
| DiagramContent::ConductorsToMove
| DiagramContent::Images
| DiagramContent::Shapes
| DiagramContent::ElementTextFields
| DiagramContent::TerminalStrip);
const auto moved_content_sentence = m_content.sentence(DiagramContent::Elements
| DiagramContent::TextFields
| DiagramContent::ConductorsToUpdate
| DiagramContent::ConductorsToMove
| DiagramContent::Images
| DiagramContent::Shapes
| DiagramContent::ElementTextFields
| DiagramContent::TerminalStrip);
setText(QString(QObject::tr("déplacer %1",
"undo caption - %1 is a sentence listing the moved content").arg(moved_content_sentence)));
setText(QString(QObject::tr("déplacer %1",
"undo caption - %1 is a sentence listing the moved content").arg(moved_content_sentence)));
}
/**
@@ -60,13 +60,13 @@ MoveGraphicsItemCommand::MoveGraphicsItemCommand(Diagram *diagram,
*/
void MoveGraphicsItemCommand::undo()
{
if (m_diagram)
{
m_diagram->showMe();
m_anim_group.setDirection(QAnimationGroup::Forward);
m_anim_group.start();
}
QUndoCommand::undo();
if (m_diagram)
{
m_diagram->showMe();
m_anim_group.setDirection(QAnimationGroup::Forward);
m_anim_group.start();
}
QUndoCommand::undo();
}
/**
@@ -75,21 +75,21 @@ void MoveGraphicsItemCommand::undo()
*/
void MoveGraphicsItemCommand::redo()
{
if (m_diagram)
{
m_diagram->showMe();
if (m_first_redo)
{
m_first_redo = false;
move(-m_movement);
}
else
{
m_anim_group.setDirection(QAnimationGroup::Backward);
m_anim_group.start();
}
}
QUndoCommand::redo();
if (m_diagram)
{
m_diagram->showMe();
if (m_first_redo)
{
m_first_redo = false;
move(-m_movement);
}
else
{
m_anim_group.setDirection(QAnimationGroup::Backward);
m_anim_group.start();
}
}
QUndoCommand::redo();
}
/**
@@ -99,57 +99,57 @@ void MoveGraphicsItemCommand::redo()
*/
void MoveGraphicsItemCommand::move(const QPointF &movement)
{
for (auto &&qgi : m_content.items(DiagramContent::Elements
| DiagramContent::TextFields
| DiagramContent::Images
| DiagramContent::Shapes
| DiagramContent::TextGroup
| DiagramContent::ElementTextFields
| DiagramContent::Tables
| DiagramContent::TerminalStrip))
{
//If item have a parent and the parent is in m_content,
//we don't apply movement because this item will be moved by his parent
if (const auto parent_ = qgi->parentItem()) {
if (m_content.items().contains(parent_)) {
continue;
}
}
for (auto &&qgi : m_content.items(DiagramContent::Elements
| DiagramContent::TextFields
| DiagramContent::Images
| DiagramContent::Shapes
| DiagramContent::TextGroup
| DiagramContent::ElementTextFields
| DiagramContent::Tables
| DiagramContent::TerminalStrip))
{
//If item have a parent and the parent is in m_content,
//we don't apply movement because this item will be moved by his parent
if (const auto parent_ = qgi->parentItem()) {
if (m_content.items().contains(parent_)) {
continue;
}
}
if (const auto graphics_object = qgi->toGraphicsObject()) {
setupAnimation(graphics_object,
"pos",
graphics_object->pos(),
graphics_object->pos() + movement);
}
else if (qgi->type() == QGraphicsItemGroup::Type)
{
//ElementTextItemGroup is a QObject not a QGraphicsObject
if (ElementTextItemGroup *etig = dynamic_cast<ElementTextItemGroup *>(qgi)) {
setupAnimation(etig,
"pos",
etig->pos(),
etig->pos() + movement);
}
}
else
{
qgi->setPos(qgi->pos() + movement);
}
}
if (const auto graphics_object = qgi->toGraphicsObject()) {
setupAnimation(graphics_object,
"pos",
graphics_object->pos(),
graphics_object->pos() + movement);
}
else if (qgi->type() == QGraphicsItemGroup::Type)
{
//ElementTextItemGroup is a QObject not a QGraphicsObject
if (ElementTextItemGroup *etig = dynamic_cast<ElementTextItemGroup *>(qgi)) {
setupAnimation(etig,
"pos",
etig->pos(),
etig->pos() + movement);
}
}
else
{
qgi->setPos(qgi->pos() + movement);
}
}
//Move some conductors
for (const auto &conductor : qAsConst(m_content.m_conductors_to_move)) {
setupAnimation(conductor,
"pos",
conductor->pos(),
conductor->pos() + movement);
}
//Move some conductors
for (const auto &conductor : qAsConst(m_content.m_conductors_to_move)) {
setupAnimation(conductor,
"pos",
conductor->pos(),
conductor->pos() + movement);
}
//Recalcul the path of other conductors
for (const auto &conductor : qAsConst(m_content.m_conductors_to_update)) {
setupAnimation(conductor, "animPath", 1, 1);
}
//Recalcul the path of other conductors
for (const auto &conductor : qAsConst(m_content.m_conductors_to_update)) {
setupAnimation(conductor, "animPath", 1, 1);
}
}
/**
@@ -162,14 +162,14 @@ void MoveGraphicsItemCommand::move(const QPointF &movement)
* @param end
*/
void MoveGraphicsItemCommand::setupAnimation(QObject *target,
const QByteArray &property_name,
const QVariant &start,
const QVariant &end)
const QByteArray &property_name,
const QVariant &start,
const QVariant &end)
{
QPropertyAnimation *animation{new QPropertyAnimation(target, property_name)};
animation->setDuration(300);
animation->setStartValue(start);
animation->setEndValue(end);
animation->setEasingCurve(QEasingCurve::OutQuad);
m_anim_group.addAnimation(animation);
QPropertyAnimation *animation{new QPropertyAnimation(target, property_name)};
animation->setDuration(300);
animation->setStartValue(start);
animation->setEndValue(end);
animation->setEasingCurve(QEasingCurve::OutQuad);
m_anim_group.addAnimation(animation);
}