mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-19 20:44:16 +02:00
015811d243
A spare (reserved) terminal is a terminal of a strip which is drawn on no
folio. RealTerminal already foresaw it ("a terminal set by user but not
present on any folio") but every terminal needed an element.
- RealTerminal::createSpare(): a terminal without element, with its own
data (label, type, function, led, informations: section, width, catalog
terminal, color, manufacturer...). Saved in the strip:
<real_terminal spare_uuid="..." type="..." function="..."><informations>
Older versions ignore these terminals.
- TerminalStrip::insertSpareTerminals() / insertTerminals(): insert at a
position of the strip. Undoable commands AddSpareTerminalsCommand and
ChangeSpareTerminalDataCommand.
- Terminal strip editor: "Add spare terminals..." button. The terminals
are inserted after the selected terminal (at the end if none), numbered
from its label ("X1:12" -> "X1:13", "X1:14", leading zeros kept), with
its properties if asked. The labels can be changed or removed in the
table, like the other cells; the Xref column shows "Spare". Moving a
spare terminal to the independent terminals removes it (undoable).
- Nomenclature: the spare terminals are in the new spare_terminal table,
added to element_nomenclature_view (UNION ALL, same columns), after the
folios, in the order of their strip. exclude_from_bom is honoured.
- The modified cells of the editor model are kept by real terminal, not by
element, since a spare terminal has none.
136 lines
4.1 KiB
C++
136 lines
4.1 KiB
C++
/*
|
|
Copyright 2006-2026 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>
|
|
#include <QVector>
|
|
#include <QSharedPointer>
|
|
#include "../../properties/elementdata.h"
|
|
|
|
class TerminalElement;
|
|
class TerminalStrip;
|
|
class RealTerminal;
|
|
class PhysicalTerminal;
|
|
|
|
/**
|
|
* @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(QSharedPointer<RealTerminal> terminal, TerminalStrip *strip, QUndoCommand *parent = nullptr);
|
|
AddTerminalToStripCommand(QVector<QSharedPointer<RealTerminal>> terminals, TerminalStrip *strip, QUndoCommand *parent = nullptr);
|
|
~AddTerminalToStripCommand() override;
|
|
|
|
void undo() override;
|
|
void redo() override;
|
|
|
|
private:
|
|
QVector<QSharedPointer<RealTerminal>> m_terminal;
|
|
QPointer<TerminalStrip> m_new_strip;
|
|
};
|
|
|
|
/**
|
|
* @brief The RemoveTerminalFromStripCommand class
|
|
* Remove a terminal from a terminal strip.
|
|
* The removed terminal become free.
|
|
*/
|
|
class RemoveTerminalFromStripCommand : public QUndoCommand
|
|
{
|
|
public:
|
|
RemoveTerminalFromStripCommand (QSharedPointer<PhysicalTerminal> terminal, TerminalStrip *strip, QUndoCommand *parent = nullptr);
|
|
RemoveTerminalFromStripCommand (const QVector<QSharedPointer<PhysicalTerminal>> &phy_t_vector, TerminalStrip *strip, QUndoCommand *parent = nullptr);
|
|
~RemoveTerminalFromStripCommand() override {}
|
|
|
|
void undo() override;
|
|
void redo() override;
|
|
|
|
private:
|
|
void setCommandTitle();
|
|
|
|
private:
|
|
QVector<QVector<QSharedPointer<RealTerminal>>> m_terminals;
|
|
QPointer<TerminalStrip> m_strip;
|
|
};
|
|
|
|
class MoveTerminalCommand : public QUndoCommand
|
|
{
|
|
public:
|
|
MoveTerminalCommand (QSharedPointer<PhysicalTerminal> terminal, TerminalStrip *old_strip,
|
|
TerminalStrip *new_strip, QUndoCommand *parent = nullptr);
|
|
MoveTerminalCommand (QVector<QSharedPointer<PhysicalTerminal>> terminals, TerminalStrip *old_strip,
|
|
TerminalStrip *new_strip, QUndoCommand *parent = nullptr);
|
|
|
|
void undo() override;
|
|
void redo() override;
|
|
|
|
private:
|
|
const QVector<QSharedPointer<PhysicalTerminal>> m_terminal;
|
|
QPointer<TerminalStrip> m_old_strip, m_new_strip;
|
|
|
|
};
|
|
|
|
/**
|
|
* @brief The AddSpareTerminalsCommand class
|
|
* Insert spare terminals (on no folio) in a terminal strip,
|
|
* at a position of the strip.
|
|
*/
|
|
class AddSpareTerminalsCommand : public QUndoCommand
|
|
{
|
|
public:
|
|
AddSpareTerminalsCommand(TerminalStrip *strip, int pos,
|
|
const QVector<QSharedPointer<RealTerminal>> &spare_terminals,
|
|
QUndoCommand *parent = nullptr);
|
|
|
|
void undo() override;
|
|
void redo() override;
|
|
|
|
private:
|
|
QPointer<TerminalStrip> m_strip;
|
|
int m_pos = -1;
|
|
QVector<QSharedPointer<RealTerminal>> m_spare_terminals;
|
|
QVector<QSharedPointer<PhysicalTerminal>> m_physical_terminals;
|
|
};
|
|
|
|
/**
|
|
* @brief The ChangeSpareTerminalDataCommand class
|
|
* Change the data (label, type, section...) of a spare terminal
|
|
*/
|
|
class ChangeSpareTerminalDataCommand : public QUndoCommand
|
|
{
|
|
public:
|
|
ChangeSpareTerminalDataCommand(const QSharedPointer<RealTerminal> &spare_terminal,
|
|
const ElementData &new_data,
|
|
QUndoCommand *parent = nullptr);
|
|
|
|
void undo() override;
|
|
void redo() override;
|
|
|
|
private:
|
|
QSharedPointer<RealTerminal> m_spare_terminal;
|
|
ElementData m_old_data, m_new_data;
|
|
};
|
|
|
|
#endif // ADDTERMINALTOSTRIPCOMMAND_H
|