QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
terminalstrip.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef TERMINALSTRIP_H
19#define TERMINALSTRIP_H
20
21#include <QObject>
22#include <QPointer>
23#include <QColor>
24
25#include "terminalstripdata.h"
26#include "../properties/elementdata.h"
27
28class Element;
29class RealTerminal;
30class QETProject;
32class TerminalStripIndex;
33class TerminalElement;
34class TerminalStrip;
36
44class TerminalStrip : public QObject
45{
46 friend class TerminalStripModel;
47 friend class RealTerminalData;
48
49 Q_OBJECT
50
51 public:
52 signals:
53 void orderChanged(); //Emitted when the order of the physical terminal is changed
55 void bridgeColorChanged(QSharedPointer<TerminalStripBridge> bridge);
56 public:
57
59
60 TerminalStrip(const QString &installation,
61 const QString &location,
62 const QString &name,
64
65 void setInstallation(const QString &installation);
66 QString installation() const {return m_data.m_installation;}
67 void setLocation(const QString &location);
68 QString location() const {return m_data.m_location;}
69 void setName(const QString &name);
70 QString name() const {return m_data.m_name;}
71 void setComment(const QString &comment);
72 QString comment() const {return m_data.m_comment;}
73 void setDescription(const QString &description);
74 QString description() const {return m_data.m_description;}
75 QUuid uuid() const {return m_data.m_uuid;}
76 QETProject *project() const;
77
78 TerminalStripData data() const;
79 void setData(const TerminalStripData &data);
80
81 bool addTerminal (QSharedPointer<RealTerminal> real_t);
82 void addTerminals (QVector<QSharedPointer<RealTerminal>> real_t_vector);
83 void addAndGroupTerminals (const QVector<QVector<QSharedPointer<RealTerminal>>> &real_t_vector);
84 bool removeTerminal (QSharedPointer<RealTerminal> real_t);
85 void removeTerminals (QVector<QSharedPointer<RealTerminal>> real_t_vector);
86 bool addTerminal (Element *terminal);
87 bool removeTerminal (Element *terminal);
88 bool addTerminal (QSharedPointer<PhysicalTerminal> phy_t);
89 void addTerminals (QVector<QSharedPointer<PhysicalTerminal>> phy_t_vector);
90 bool removeTerminal (QSharedPointer<PhysicalTerminal> phy_t);
91 void removeTerminals (QVector<QSharedPointer<PhysicalTerminal>> phy_t_vector);
92
93 int pos(const QSharedPointer<PhysicalTerminal> &terminal) const;
94 int physicalTerminalCount() const;
95 QSharedPointer<PhysicalTerminal> physicalTerminal(int index) const;
96 QSharedPointer<PhysicalTerminal> physicalTerminal(const QUuid &uuid) const;
97 QVector<QSharedPointer<PhysicalTerminal>> physicalTerminal() const;
98 QSharedPointer<RealTerminal> realTerminalForUuid(const QUuid &uuid) const;
99 QVector<QSharedPointer<RealTerminal>> realTerminals() const;
100
101 bool setOrderTo(const QVector<QSharedPointer<PhysicalTerminal>> &sorted_vector);
102 bool groupTerminals(const QSharedPointer<PhysicalTerminal> &receiver_terminal, const QVector<QSharedPointer<RealTerminal>> &added_terminals);
103 void unGroupTerminals(const QVector<QSharedPointer<RealTerminal>> &terminals_to_ungroup);
104 bool setLevel(const QSharedPointer<RealTerminal> &real_terminal, int level);
105
106 bool isBridgeable(const QVector<QSharedPointer<RealTerminal>> &real_terminals) const;
107 bool isBridgeable(QSharedPointer<TerminalStripBridge> bridge, const QVector<QSharedPointer<RealTerminal>> &real_terminals) const;
108 bool setBridge(const QVector<QSharedPointer<RealTerminal>> &real_terminals);
109 bool setBridge(const QSharedPointer<TerminalStripBridge> &bridge, const QVector<QSharedPointer<RealTerminal>> &real_terminals);
110 void unBridge(const QVector<QSharedPointer<RealTerminal>> &real_terminals);
111 bool canUnBridge(const QVector <QSharedPointer<RealTerminal>> &real_terminals) const;
112 QSharedPointer<TerminalStripBridge> isBridged(const QSharedPointer<RealTerminal> real_terminal) const;
113 QSharedPointer<TerminalStripBridge> bridgeFor (const QVector<QSharedPointer<RealTerminal>> &terminal_vector) const;
114
115 QSharedPointer<RealTerminal> previousTerminalInLevel(const QSharedPointer<RealTerminal> &real_terminal) const;
116 QSharedPointer<RealTerminal> nextTerminalInLevel(const QSharedPointer<RealTerminal> &real_terminal) const;
117 QSharedPointer<RealTerminal> previousRealTerminal(const QSharedPointer<RealTerminal> &real_terminal) const;
118 QSharedPointer<RealTerminal> nextRealTerminal(const QSharedPointer<RealTerminal> &real_terminal) const;
119
120 static QString xmlTagName() {return QStringLiteral("terminal_strip");}
121 QDomElement toXml(QDomDocument &parent_document);
122 bool fromXml(QDomElement &xml_element);
123
124 private:
126 QPointer<QETProject> m_project;
127 QVector<QSharedPointer<PhysicalTerminal>> m_physical_terminals;
128 QVector<QSharedPointer<TerminalStripBridge>> m_bridge;
129};
130
131#endif // TERMINALSTRIP_H
Definition element.h:43
The PhysicalTerminal class Represent a physical terminal. A physical terminal is composed a least by ...
Definition physicalterminal.h:62
Definition qetproject.h:62
The RealTerminal class Represent a real terminal. A real terminal can be a drawn terminal in a folio ...
Definition realterminal.h:43
The TerminalElement class.
Definition terminalelement.h:31
Definition terminalstripbridge.h:32
Definition terminalstripdata.h:26
QString m_comment
Definition terminalstripdata.h:50
QString m_description
Definition terminalstripdata.h:51
QString m_name
Definition terminalstripdata.h:49
QString m_location
Definition terminalstripdata.h:48
QString m_installation
Definition terminalstripdata.h:47
QUuid m_uuid
Definition terminalstripdata.h:52
The TerminalStrip class This class hold all the datas and configurations of a terminal strip (but the...
Definition terminalstrip.h:45
bool addTerminal(QSharedPointer< RealTerminal > real_t)
Definition terminalstrip.cpp:105
QString name() const
Definition terminalstrip.h:70
void bridgeChanged()
void removeTerminals(QVector< QSharedPointer< RealTerminal > > real_t_vector)
TerminalStrip::removeTerminals Remove terminals in real_t_vector from this terminal strip.
Definition terminalstrip.cpp:209
QString description() const
Definition terminalstrip.h:74
QSharedPointer< TerminalStripBridge > isBridged(const QSharedPointer< RealTerminal > real_terminal) const
TerminalStrip::isBridged Check if real_terminal is bridged.
Definition terminalstrip.cpp:855
QSharedPointer< RealTerminal > realTerminalForUuid(const QUuid &uuid) const
TerminalStrip::realTerminalForUuid.
Definition terminalstrip.cpp:451
void addTerminals(QVector< QSharedPointer< RealTerminal > > real_t_vector)
TerminalStrip::addTerminals Add terminal in real_t_vector to this terminal.
Definition terminalstrip.cpp:129
QString location() const
Definition terminalstrip.h:68
TerminalStripData data() const
TerminalStrip::data.
Definition terminalstrip.cpp:89
bool isBridgeable(const QVector< QSharedPointer< RealTerminal > > &real_terminals) const
TerminalStrip::isBridgeable Check if all realTerminal in real_terminals are bridgeable together....
Definition terminalstrip.cpp:624
int physicalTerminalCount() const
TerminalStrip::physicalTerminalCount.
Definition terminalstrip.cpp:400
void bridgeColorChanged(QSharedPointer< TerminalStripBridge > bridge)
friend class RealTerminalData
Definition terminalstrip.h:47
void orderChanged()
QVector< QSharedPointer< RealTerminal > > realTerminals() const
TerminalStrip::realTerminals.
Definition terminalstrip.cpp:466
void setLocation(const QString &location)
Definition terminalstrip.cpp:61
QSharedPointer< RealTerminal > nextTerminalInLevel(const QSharedPointer< RealTerminal > &real_terminal) const
TerminalStrip::nextTerminalInLevel.
Definition terminalstrip.cpp:928
QSharedPointer< RealTerminal > previousRealTerminal(const QSharedPointer< RealTerminal > &real_terminal) const
Definition terminalstrip.cpp:947
void setName(const QString &name)
Definition terminalstrip.cpp:65
QString installation() const
Definition terminalstrip.h:66
QVector< QSharedPointer< TerminalStripBridge > > m_bridge
Definition terminalstrip.h:128
QSharedPointer< RealTerminal > previousTerminalInLevel(const QSharedPointer< RealTerminal > &real_terminal) const
TerminalStrip::previousTerminalInLevel.
Definition terminalstrip.cpp:903
QVector< QSharedPointer< PhysicalTerminal > > m_physical_terminals
Definition terminalstrip.h:127
bool setLevel(const QSharedPointer< RealTerminal > &real_terminal, int level)
TerminalStrip::setLevel.
Definition terminalstrip.cpp:597
QETProject * project() const
TerminalStrip::project.
Definition terminalstrip.cpp:81
QVector< QSharedPointer< PhysicalTerminal > > physicalTerminal() const
TerminalStrip::physicalTerminal.
Definition terminalstrip.cpp:442
QUuid uuid() const
Definition terminalstrip.h:75
void addAndGroupTerminals(const QVector< QVector< QSharedPointer< RealTerminal > > > &real_t_vector)
TerminalStrip::addAndGroupTerminals For each real terminals of second vector, add it to terminal stri...
Definition terminalstrip.cpp:154
int pos(const QSharedPointer< PhysicalTerminal > &terminal) const
TerminalStrip::pos.
Definition terminalstrip.cpp:390
void setInstallation(const QString &installation)
Definition terminalstrip.cpp:57
void setDescription(const QString &description)
Definition terminalstrip.cpp:73
QDomElement toXml(QDomDocument &parent_document)
TerminalStrip::toXml.
Definition terminalstrip.cpp:972
bool setBridge(const QVector< QSharedPointer< RealTerminal > > &real_terminals)
TerminalStrip::setBridge Set a bridge between all real terminal of real_terminals.
Definition terminalstrip.cpp:722
bool removeTerminal(QSharedPointer< RealTerminal > real_t)
Definition terminalstrip.cpp:180
bool fromXml(QDomElement &xml_element)
TerminalStrip::fromXml.
Definition terminalstrip.cpp:998
QSharedPointer< RealTerminal > nextRealTerminal(const QSharedPointer< RealTerminal > &real_terminal) const
Definition terminalstrip.cpp:957
void unGroupTerminals(const QVector< QSharedPointer< RealTerminal > > &terminals_to_ungroup)
TerminalStrip::unGroupTerminals Ungroup all real terminals of terminals_to_ungroup.
Definition terminalstrip.cpp:566
static QString xmlTagName()
Definition terminalstrip.h:120
void unBridge(const QVector< QSharedPointer< RealTerminal > > &real_terminals)
TerminalStrip::unBridge Unbridge all real terminals of real_terminals.
Definition terminalstrip.cpp:775
TerminalStripData m_data
Definition terminalstrip.h:125
void setData(const TerminalStripData &data)
TerminalStrip::setData Set the internal data of this strip to data. the uuid of the new data is set t...
Definition terminalstrip.cpp:101
void setComment(const QString &comment)
Definition terminalstrip.cpp:69
bool setOrderTo(const QVector< QSharedPointer< PhysicalTerminal > > &sorted_vector)
TerminalStrip::setSortedTo Sort the physical terminal owned by this strip in the same order as sorted...
Definition terminalstrip.cpp:490
bool canUnBridge(const QVector< QSharedPointer< RealTerminal > > &real_terminals) const
TerminalStrip::canUnBridge.
Definition terminalstrip.cpp:792
QSharedPointer< TerminalStripBridge > bridgeFor(const QVector< QSharedPointer< RealTerminal > > &terminal_vector) const
TerminalStrip::bridgeFor Return the bridge where at least one terminal of terminal_vector belong....
Definition terminalstrip.cpp:876
QPointer< QETProject > m_project
Definition terminalstrip.h:126
bool groupTerminals(const QSharedPointer< PhysicalTerminal > &receiver_terminal, const QVector< QSharedPointer< RealTerminal > > &added_terminals)
TerminalStrip::groupTerminal Add added_terminal to receiver_terminal. At the end of this method,...
Definition terminalstrip.cpp:526
QString comment() const
Definition terminalstrip.h:72
Definition terminalstripmodel.h:47