Files
qelectrotech-source-mirror/sources/TerminalStrip/terminalstrip.h
T
Laurent Trinques 015811d243 Terminal strip editor: add spare terminals, numbered, counted in the nomenclature
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.
2026-10-18 16:34:41 +02:00

140 lines
6.2 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 TERMINALSTRIP_H
#define TERMINALSTRIP_H
#include <QObject>
#include <QPointer>
#include <QColor>
#include "terminalstripdata.h"
#include "../properties/elementdata.h"
class Element;
class RealTerminal;
class QETProject;
class PhysicalTerminal;
class TerminalStripIndex;
class TerminalElement;
class TerminalStrip;
class TerminalStripBridge;
/**
* @brief The TerminalStrip class
* This class hold all the datas and configurations
* of a terminal strip (but the not the visual aspect).
* A terminal strip have some informations (name comment etc...)
* and is composed by one or several PhysicalTerminal.
*/
class TerminalStrip : public QObject
{
friend class TerminalStripModel;
friend class RealTerminalData;
Q_OBJECT
public:
signals:
void orderChanged(); //Emitted when the order of the physical terminal is changed
void bridgeChanged();
void bridgeColorChanged(QSharedPointer<TerminalStripBridge> bridge);
//Emitted when the data of the strip (name...) or of one of its
//terminals (width, color, type...) is changed : what is drawn changes
void dataChanged();
public:
TerminalStrip(QETProject *project);
TerminalStrip(const QString &installation,
const QString &location,
const QString &name,
QETProject *project);
void setInstallation(const QString &installation);
QString installation() const {return m_data.m_installation;}
void setLocation(const QString &location);
QString location() const {return m_data.m_location;}
void setName(const QString &name);
QString name() const {return m_data.m_name;}
void setComment(const QString &comment);
QString comment() const {return m_data.m_comment;}
void setDescription(const QString &description);
QString description() const {return m_data.m_description;}
///Manufacturer of the terminals proposed by the editor, empty = all
QString manufacturer() const {return m_data.m_manufacturer;}
QUuid uuid() const {return m_data.m_uuid;}
QETProject *project() const;
TerminalStripData data() const;
void setData(const TerminalStripData &data);
void terminalDataChanged();
bool addTerminal (QSharedPointer<RealTerminal> real_t);
void addTerminals (QVector<QSharedPointer<RealTerminal>> real_t_vector);
void addAndGroupTerminals (const QVector<QVector<QSharedPointer<RealTerminal>>> &real_t_vector);
bool removeTerminal (QSharedPointer<RealTerminal> real_t);
void removeTerminals (QVector<QSharedPointer<RealTerminal>> real_t_vector);
bool addTerminal (Element *terminal);
bool removeTerminal (Element *terminal);
bool addTerminal (QSharedPointer<PhysicalTerminal> phy_t);
void addTerminals (QVector<QSharedPointer<PhysicalTerminal>> phy_t_vector);
bool removeTerminal (QSharedPointer<PhysicalTerminal> phy_t);
void removeTerminals (QVector<QSharedPointer<PhysicalTerminal>> phy_t_vector);
QVector<QSharedPointer<PhysicalTerminal>> insertSpareTerminals(int pos, const QVector<QSharedPointer<RealTerminal>> &spare_terminals);
void insertTerminals(int pos, const QVector<QSharedPointer<PhysicalTerminal>> &phy_t_vector);
int pos(const QSharedPointer<PhysicalTerminal> &terminal) const;
int physicalTerminalCount() const;
QSharedPointer<PhysicalTerminal> physicalTerminal(int index) const;
QSharedPointer<PhysicalTerminal> physicalTerminal(const QUuid &uuid) const;
QVector<QSharedPointer<PhysicalTerminal>> physicalTerminal() const;
QSharedPointer<RealTerminal> realTerminalForUuid(const QUuid &uuid) const;
QVector<QSharedPointer<RealTerminal>> realTerminals() const;
bool setOrderTo(const QVector<QSharedPointer<PhysicalTerminal>> &sorted_vector);
bool groupTerminals(const QSharedPointer<PhysicalTerminal> &receiver_terminal, const QVector<QSharedPointer<RealTerminal>> &added_terminals);
void unGroupTerminals(const QVector<QSharedPointer<RealTerminal>> &terminals_to_ungroup);
bool setLevel(const QSharedPointer<RealTerminal> &real_terminal, int level);
bool isBridgeable(const QVector<QSharedPointer<RealTerminal>> &real_terminals) const;
bool isBridgeable(QSharedPointer<TerminalStripBridge> bridge, const QVector<QSharedPointer<RealTerminal>> &real_terminals) const;
bool setBridge(const QVector<QSharedPointer<RealTerminal>> &real_terminals);
bool setBridge(const QSharedPointer<TerminalStripBridge> &bridge, const QVector<QSharedPointer<RealTerminal>> &real_terminals);
void unBridge(const QVector<QSharedPointer<RealTerminal>> &real_terminals);
bool canUnBridge(const QVector <QSharedPointer<RealTerminal>> &real_terminals) const;
QSharedPointer<TerminalStripBridge> isBridged(const QSharedPointer<RealTerminal> real_terminal) const;
QSharedPointer<TerminalStripBridge> bridgeFor (const QVector<QSharedPointer<RealTerminal>> &terminal_vector) const;
QSharedPointer<RealTerminal> previousTerminalInLevel(const QSharedPointer<RealTerminal> &real_terminal) const;
QSharedPointer<RealTerminal> nextTerminalInLevel(const QSharedPointer<RealTerminal> &real_terminal) const;
QSharedPointer<RealTerminal> previousRealTerminal(const QSharedPointer<RealTerminal> &real_terminal) const;
QSharedPointer<RealTerminal> nextRealTerminal(const QSharedPointer<RealTerminal> &real_terminal) const;
static QString xmlTagName() {return QStringLiteral("terminal_strip");}
QDomElement toXml(QDomDocument &parent_document);
bool fromXml(QDomElement &xml_element);
private:
TerminalStripData m_data;
QPointer<QETProject> m_project;
QVector<QSharedPointer<PhysicalTerminal>> m_physical_terminals;
QVector<QSharedPointer<TerminalStripBridge>> m_bridge;
};
#endif // TERMINALSTRIP_H