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.
129 lines
4.3 KiB
C++
129 lines
4.3 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 REALTERMINAL_H
|
|
#define REALTERMINAL_H
|
|
|
|
#include <QSharedPointer>
|
|
#include <QColor>
|
|
#include <QDomElement>
|
|
#include <QUuid>
|
|
#include "../properties/elementdata.h"
|
|
|
|
class TerminalStrip;
|
|
class Element;
|
|
class TerminalElement;
|
|
class PhysicalTerminal;
|
|
class TerminalStripBridge;
|
|
|
|
/**
|
|
* @brief The RealTerminal class
|
|
* Represent a real terminal.
|
|
* A real terminal can be a drawn terminal in a folio
|
|
* or a terminal set by user but not present
|
|
* on any folio (for example a reserved terminal).
|
|
*
|
|
* When create a new instance of RealTerminal you must
|
|
* call sharedRef() and only use the returned QSharedPointer
|
|
* instead of the raw pointer
|
|
*/
|
|
class RealTerminal
|
|
{
|
|
friend class TerminalElement;
|
|
friend class PhysicalTerminal;
|
|
|
|
private:
|
|
RealTerminal(Element *element);
|
|
|
|
QSharedPointer<RealTerminal> sharedRef();
|
|
QSharedPointer<RealTerminal> sharedRef() const;
|
|
QWeakPointer<RealTerminal> weakRef();
|
|
|
|
void setPhysicalTerminal(const QSharedPointer<PhysicalTerminal> &phy_t);
|
|
|
|
public:
|
|
~RealTerminal();
|
|
static QSharedPointer<RealTerminal> createSpare(const ElementData &data, const QUuid &uuid = QUuid());
|
|
static QSharedPointer<RealTerminal> spareFromXml(const QDomElement &xml_element);
|
|
bool isSpare() const;
|
|
ElementData spareData() const;
|
|
void setSpareData(const ElementData &data);
|
|
ElementData terminalData() const;
|
|
TerminalStrip *parentStrip() const noexcept;
|
|
QSharedPointer<PhysicalTerminal> physicalTerminal() const noexcept;
|
|
|
|
QDomElement toXml(QDomDocument &parent_document) const;
|
|
|
|
int level() const;
|
|
QString label() const;
|
|
QString Xref() const;
|
|
QString cable() const;
|
|
QString cableWire() const;
|
|
bool isShield() const;
|
|
QColor color() const;
|
|
QColor stripeColor() const;
|
|
qreal section() const;
|
|
qreal widthMm() const;
|
|
QString catalogEntry() const;
|
|
bool hasSeparatorAfter() const;
|
|
|
|
//Keys used to store the cable data in the element informations
|
|
static QString cableInfoKey() { return QStringLiteral("terminal_cable"); }
|
|
static QString cableWireInfoKey() { return QStringLiteral("terminal_cable_wire"); }
|
|
static QString shieldInfoKey() { return QStringLiteral("terminal_shield"); }
|
|
//Keys used to store the color and the section (mm2) of the terminal
|
|
static QString colorInfoKey() { return QStringLiteral("terminal_color"); }
|
|
static QString sectionInfoKey() { return QStringLiteral("terminal_section"); }
|
|
//Key used to store the width (mm) of the terminal, drawn in the terminal strip
|
|
static QString widthInfoKey() { return QStringLiteral("terminal_width"); }
|
|
//Key used to store the terminal chosen in the catalog (TerminalCatalog::WidthEntry::label)
|
|
static QString catalogEntryInfoKey() { return QStringLiteral("terminal_catalog_entry"); }
|
|
//Key used to store if a separator plate is mounted after the terminal
|
|
static QString separatorInfoKey() { return QStringLiteral("terminal_separator"); }
|
|
|
|
static void applyCatalogEntry(DiagramContext &informations, const QString &entry_label);
|
|
|
|
QString conductor() const;
|
|
|
|
ElementData::TerminalType type() const;
|
|
ElementData::TerminalFunction function() const;
|
|
|
|
bool isLed() const;
|
|
bool isElement() const;
|
|
bool isBridged() const;
|
|
|
|
QSharedPointer<TerminalStripBridge> bridge() const;
|
|
|
|
Element* element() const;
|
|
QUuid elementUuid() const;
|
|
|
|
static QString xmlTagName();
|
|
|
|
private :
|
|
bool hasData() const;
|
|
|
|
QPointer<Element> m_element;
|
|
//A spare terminal has no element : it is on no folio, its data are its own
|
|
bool m_spare = false;
|
|
QUuid m_spare_uuid;
|
|
ElementData m_spare_data;
|
|
QWeakPointer<RealTerminal> m_this_weak;
|
|
QSharedPointer<PhysicalTerminal> m_physical_terminal;
|
|
};
|
|
|
|
#endif // REALTERMINAL_H
|