Revert "Merge branch 'master' of ssh://git.tuxfamily.org/gitroot/qet/qet into terminal_strip"

This reverts commit 364bce618c, reversing
changes made to efb4a8dd71.
This commit is contained in:
joshua
2021-06-07 20:00:52 +02:00
parent 4615e6d060
commit bb26954bd4
27 changed files with 12 additions and 2814 deletions

View File

@@ -1,87 +0,0 @@
/*
Copyright 2006-2021 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 "addterminalstripcommand.h"
#include "../../qetproject.h"
#include "../terminalstrip.h"
#include "../qetgraphicsitem/element.h"
#include <QObject>
/**
* @brief AddTerminalStripCommand::AddTerminalStripCommand
* @param strip
* @param parent
*/
AddTerminalStripCommand::AddTerminalStripCommand(TerminalStrip *strip,
QETProject *project,
QUndoCommand *parent) :
QUndoCommand(parent),
m_strip(strip),
m_project(project)
{
setText(QObject::tr("Ajouter un groupe de bornes"));
}
AddTerminalStripCommand::~AddTerminalStripCommand()
{}
void AddTerminalStripCommand::undo() {
if (m_project && m_strip) {
m_project->removeTerminalStrip(m_strip);
}
}
void AddTerminalStripCommand::redo() {
if (m_project && m_strip) {
m_project->addTerminalStrip(m_strip);
}
}
RemoveTerminalStripCommand::RemoveTerminalStripCommand(TerminalStrip *strip,
QETProject *project,
QUndoCommand *parent) :
QUndoCommand(parent),
m_strip(strip),
m_project(project),
m_elements(strip->terminalElement())
{
setText(QObject::tr("Supprimer un groupe de bornes"));
}
RemoveTerminalStripCommand::~RemoveTerminalStripCommand()
{}
void RemoveTerminalStripCommand::undo()
{
if (m_project && m_strip) {
for (auto elmt : m_elements) {
m_strip->addTerminal(elmt);
}
m_project->addTerminalStrip(m_strip);
}
}
void RemoveTerminalStripCommand::redo()
{
if (m_project && m_strip) {
for (auto elmt : m_elements) {
m_strip->removeTerminal(elmt);
}
m_project->removeTerminalStrip(m_strip);
}
}

View File

@@ -1,57 +0,0 @@
/*
Copyright 2006-2021 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/>.
*/
#ifndef ADDTERMINALSTRIPCOMMAND_H
#define ADDTERMINALSTRIPCOMMAND_H
#include <QUndoCommand>
#include <QPointer>
class TerminalStrip;
class QETProject;
class Element;
class AddTerminalStripCommand : public QUndoCommand
{
public:
AddTerminalStripCommand(TerminalStrip *strip, QETProject *project, QUndoCommand *parent = nullptr);
~AddTerminalStripCommand() override;
void undo() override;
void redo() override;
private:
QPointer<TerminalStrip> m_strip;
QPointer<QETProject> m_project;
};
class RemoveTerminalStripCommand : public QUndoCommand
{
public:
RemoveTerminalStripCommand(TerminalStrip *strip, QETProject *project, QUndoCommand *parent = nullptr);
~RemoveTerminalStripCommand() override;
void undo() override;
void redo() override;
private:
QPointer<TerminalStrip> m_strip;
QPointer<QETProject> m_project;
QVector<QPointer<Element>> m_elements;
};
#endif // ADDTERMINALSTRIPCOMMAND_H

View File

@@ -1,156 +0,0 @@
/*
Copyright 2006-2021 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 "addterminaltostripcommand.h"
#include "../../qetgraphicsitem/terminalelement.h"
/**
* @brief AddTerminalToStripCommand::AddTerminalToStripCommand
* Add \p terminal to \p strip
* @param terminal : terminal to add to strip
* @param strip : terminal strip where terminal must be added
* @param parent : parent undo command
*/
AddTerminalToStripCommand::AddTerminalToStripCommand(TerminalElement *terminal, TerminalStrip *strip, QUndoCommand *parent) :
QUndoCommand(parent),
m_terminal(terminal),
m_new_strip(strip),
m_operation(Operation::add)
{
auto t_label = terminal->actualLabel();
auto ts_name = strip->name();
auto str_1 = t_label.isEmpty() ? QObject::tr("Ajouter une borne") :
QObject::tr("Ajouter la borne %1").arg(t_label);
auto str_2 = ts_name.isEmpty() ? QObject::tr("à un groupe de bornes") :
QObject::tr("au groupe de bornes %1").arg(ts_name);
setText(str_1 + " " + str_2);
}
/**
* @brief AddTerminalToStripCommand::AddTerminalToStripCommand
* Move \p terminal from \p old_strip to \p new_strip
* @param terminal : terminal to move
* @param old_strip : terminal where start the move
* @param new_strip : terminal where finish the move
* @param parent : parent undo command
*/
AddTerminalToStripCommand::AddTerminalToStripCommand(TerminalElement *terminal, TerminalStrip *old_strip,
TerminalStrip *new_strip, QUndoCommand *parent) :
QUndoCommand(parent),
m_terminal(terminal),
m_old_strip(old_strip),
m_new_strip(new_strip),
m_operation(Operation::move)
{
auto t_label = terminal->actualLabel();
auto old_ts_name = old_strip->name();
auto new_ts_name = new_strip->name();
auto str_1 = t_label.isEmpty() ? QObject::tr("Déplacer une borne") :
QObject::tr("Déplacer la borne %1").arg(t_label);
auto str_2 = old_ts_name.isEmpty() ? QObject::tr("d'un groupe de bornes") :
QObject::tr("du groupe de bornes %1").arg(old_ts_name);
auto str_3 = new_ts_name.isEmpty() ? QObject::tr("à un autre groupe de bornes") :
QObject::tr("au groupe de bornes %1").arg(new_ts_name);
setText(str_1 + " " + str_2 + " " + str_3);
}
AddTerminalToStripCommand::~AddTerminalToStripCommand()
{}
/**
* @brief AddTerminalToStripCommand::undo
* Reimplemented from QUndoCommand
*/
void AddTerminalToStripCommand::undo()
{
if (!m_terminal ||
!m_new_strip) {
return;
}
m_new_strip->removeTerminal(m_terminal);
if ( m_operation == Operation::move &&
m_old_strip) {
m_old_strip->addTerminal(m_terminal);
}
}
/**
* @brief AddTerminalToStripCommand::redo
* Reimplemented from QUndoCommand
*/
void AddTerminalToStripCommand::redo()
{
if (!m_terminal ||
!m_new_strip) {
return;
}
if (m_operation == Operation::move &&
m_old_strip) {
m_old_strip->removeTerminal(m_terminal);
}
m_new_strip->addTerminal(m_terminal);
}
/**
* @brief RemoveTerminalFromStripCommand::RemoveTerminalFromStripCommand
* @param terminal
* @param strip
* @param parent
*/
RemoveTerminalFromStripCommand::RemoveTerminalFromStripCommand(TerminalElement *terminal,
TerminalStrip *strip,
QUndoCommand *parent) :
QUndoCommand(parent),
m_terminal(terminal),
m_strip(strip)
{
auto t_label = terminal->actualLabel();
auto strip_name = strip->name();
auto str_1 = t_label.isEmpty() ? QObject::tr("Enlever une borne") :
QObject::tr("Enlever la borne %1").arg(t_label);
auto str_2 = strip_name.isEmpty() ? QObject::tr("d'un groupe de bornes") :
QObject::tr("du groupe de bornes %1").arg(strip_name);
setText(str_1 + " " + str_2);
}
void RemoveTerminalFromStripCommand::undo()
{
if (m_terminal && m_strip) {
m_strip->addTerminal(m_terminal);
}
}
void RemoveTerminalFromStripCommand::redo()
{
if (m_terminal && m_strip) {
m_strip->removeTerminal(m_terminal);
}
}

View File

@@ -1,79 +0,0 @@
/*
Copyright 2006-2021 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/>.
*/
#ifndef ADDTERMINALTOSTRIPCOMMAND_H
#define ADDTERMINALTOSTRIPCOMMAND_H
#include <QUndoCommand>
#include <QPointer>
class TerminalElement;
class TerminalStrip;
/**
* @brief The AddTerminalToStripCommand class
* Add a terminal element to a terminal strip
* Two cases are handled :
* Add free terminal to strip,
* Move terminal from strip to another strip
*/
class AddTerminalToStripCommand : public QUndoCommand
{
public:
AddTerminalToStripCommand(TerminalElement *terminal, TerminalStrip *strip, QUndoCommand *parent = nullptr);
AddTerminalToStripCommand(TerminalElement *terminal, TerminalStrip *old_strip,
TerminalStrip *new_strip, QUndoCommand *parent = nullptr);
~AddTerminalToStripCommand() override;
void undo() override;
void redo() override;
private:
enum Operation{
none,
add,
move,
};
QPointer<TerminalElement> m_terminal;
QPointer<TerminalStrip> m_old_strip;
QPointer<TerminalStrip> m_new_strip;
Operation m_operation = Operation::none;
};
/**
* @brief The RemoveTerminalFromStripCommand class
* Remove a terminal from a terminal strip.
* The removed terminal become free.
*/
class RemoveTerminalFromStripCommand : public QUndoCommand
{
public:
RemoveTerminalFromStripCommand (TerminalElement *terminal, TerminalStrip *strip, QUndoCommand *parent = nullptr);
~RemoveTerminalFromStripCommand() override {}
void undo() override;
void redo() override;
private:
QPointer<TerminalElement> m_terminal;
QPointer<TerminalStrip> m_strip;
};
#endif // ADDTERMINALTOSTRIPCOMMAND_H

View File

@@ -1,43 +0,0 @@
/*
Copyright 2006-2021 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 "changeterminalstripdata.h"
ChangeTerminalStripData::ChangeTerminalStripData(TerminalStrip *strip,
const TerminalStripData &data,
QUndoCommand *parent) :
QUndoCommand(parent),
m_strip(strip),
m_new_data(data)
{
setText(QObject::tr("Modifier les proriétés d'un groupe de bornes"));
m_old_data = strip->data();
}
void ChangeTerminalStripData::undo()
{
if (m_strip) {
m_strip->setData(m_old_data);
}
}
void ChangeTerminalStripData::redo()
{
if (m_strip) {
m_strip->setData(m_new_data);
}
}

View File

@@ -1,41 +0,0 @@
/*
Copyright 2006-2021 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/>.
*/
#ifndef CHANGETERMINALSTRIPDATA_H
#define CHANGETERMINALSTRIPDATA_H
#include <QUndoCommand>
#include "../terminalstripdata.h"
#include "../terminalstrip.h"
/**
* @brief The ChangeTerminalStripData class
*/
class ChangeTerminalStripData : public QUndoCommand
{
public:
ChangeTerminalStripData(TerminalStrip *strip, const TerminalStripData &data, QUndoCommand *parent = nullptr);
void undo() override;
void redo() override;
private:
QPointer<TerminalStrip> m_strip;
TerminalStripData m_old_data, m_new_data;
};
#endif // CHANGETERMINALSTRIPDATA_H