fixed indentations of the remaining *.cpp/*.h files

This commit is contained in:
plc-user 2024-05-02 08:39:27 +02:00
parent e9448be986
commit b3ac3c82af
41 changed files with 1007 additions and 1007 deletions

View File

@ -83,8 +83,8 @@ class TerminalStripLayoutPattern
int m_bridge_point_d{5}; int m_bridge_point_d{5};
QVector<int> m_bridge_point_y_offset{50,70,90,110}; QVector<int> m_bridge_point_y_offset{50,70,90,110};
QUuid m_uuid{QUuid::createUuid()}; QUuid m_uuid{QUuid::createUuid()};
QString m_name; QString m_name;
private: private:
void updateHeaderTextOption(); void updateHeaderTextOption();

View File

@ -26,9 +26,9 @@ namespace TerminalStripDrawer {
* @param pattern * @param pattern
*/ */
TerminalStripDrawer::TerminalStripDrawer(QSharedPointer<AbstractTerminalStripInterface> strip, TerminalStripDrawer::TerminalStripDrawer(QSharedPointer<AbstractTerminalStripInterface> strip,
QSharedPointer<TerminalStripLayoutPattern> layout) : QSharedPointer<TerminalStripLayoutPattern> layout) :
m_strip { strip }, m_strip { strip },
m_pattern { layout } m_pattern { layout }
{} {}
void TerminalStripDrawer::setStrip(QSharedPointer<AbstractTerminalStripInterface> strip) void TerminalStripDrawer::setStrip(QSharedPointer<AbstractTerminalStripInterface> strip)
@ -42,248 +42,248 @@ void TerminalStripDrawer::setStrip(QSharedPointer<AbstractTerminalStripInterface
*/ */
void TerminalStripDrawer::paint(QPainter *painter) void TerminalStripDrawer::paint(QPainter *painter)
{ {
if (m_strip && m_pattern) if (m_strip && m_pattern)
{ {
//To draw text, QPainter need a Qrect. Instead of create an instance //To draw text, QPainter need a Qrect. Instead of create an instance
//for each text, we re-use the same instance of QRect. //for each text, we re-use the same instance of QRect.
QRect text_rect; QRect text_rect;
painter->save(); painter->save();
auto pen_{painter->pen()}; auto pen_{painter->pen()};
pen_.setColor(Qt::black); pen_.setColor(Qt::black);
pen_.setWidth(1); pen_.setWidth(1);
auto brush_ = painter->brush(); auto brush_ = painter->brush();
brush_.setColor(Qt::white); brush_.setColor(Qt::white);
painter->setPen(pen_); painter->setPen(pen_);
painter->setBrush(brush_); painter->setBrush(brush_);
if (m_preview_draw) if (m_preview_draw)
{ {
painter->save(); painter->save();
painter->setPen(Qt::blue); painter->setPen(Qt::blue);
painter->drawRect(boundingRect()); painter->drawRect(boundingRect());
painter->restore(); painter->restore();
} }
//Draw header //Draw header
painter->drawRect(m_pattern->m_header_rect); painter->drawRect(m_pattern->m_header_rect);
//Draw the header text //Draw the header text
painter->save(); painter->save();
if (m_pattern->m_header_text_orientation == Qt::Horizontal) if (m_pattern->m_header_text_orientation == Qt::Horizontal)
{ {
text_rect.setRect(0,m_pattern->m_header_rect.y(),m_pattern->m_header_rect.width(),m_pattern->m_header_rect.height()); text_rect.setRect(0,m_pattern->m_header_rect.y(),m_pattern->m_header_rect.width(),m_pattern->m_header_rect.height());
} }
else else
{ {
painter->translate(m_pattern->m_header_rect.bottomLeft()); painter->translate(m_pattern->m_header_rect.bottomLeft());
painter->rotate(270); painter->rotate(270);
text_rect.setRect(0,0,m_pattern->m_header_rect.height(),m_pattern->m_header_rect.width()); text_rect.setRect(0,0,m_pattern->m_header_rect.height(),m_pattern->m_header_rect.width());
} }
const auto text_{m_strip->installation() + " " + m_strip->location() + " " + m_strip->name()}; const auto text_{m_strip->installation() + " " + m_strip->location() + " " + m_strip->name()};
painter->drawText(text_rect, text_, m_pattern->headerTextOption()); painter->drawText(text_rect, text_, m_pattern->headerTextOption());
painter->restore(); painter->restore();
//Move painter pos to next drawing //Move painter pos to next drawing
painter->translate(m_pattern->m_header_rect.width(),0); painter->translate(m_pattern->m_header_rect.width(),0);
int x_offset{m_pattern->m_header_rect.width()}; int x_offset{m_pattern->m_header_rect.width()};
//Draw spacer //Draw spacer
painter->drawRect(m_pattern->m_spacer_rect); painter->drawRect(m_pattern->m_spacer_rect);
//Move painter pos to next drawing //Move painter pos to next drawing
painter->translate(m_pattern->m_spacer_rect.width(),0); painter->translate(m_pattern->m_spacer_rect.width(),0);
x_offset += m_pattern->m_spacer_rect.width(); x_offset += m_pattern->m_spacer_rect.width();
//Draw terminals //Draw terminals
const auto terminals_text_rect{m_pattern->m_terminals_text_rect}; const auto terminals_text_rect{m_pattern->m_terminals_text_rect};
const auto terminals_text_orientation{m_pattern->m_terminals_text_orientation}; const auto terminals_text_orientation{m_pattern->m_terminals_text_orientation};
const auto terminals_text_option{m_pattern->terminalsTextOption()}; const auto terminals_text_option{m_pattern->terminalsTextOption()};
QRect terminal_rect; QRect terminal_rect;
QHash<QUuid, QVector<QPointF>> bridges_anchor_points; QHash<QUuid, QVector<QPointF>> bridges_anchor_points;
//Loop over physical terminals //Loop over physical terminals
for (const auto &physical_t : m_strip->physicalTerminal()) for (const auto &physical_t : m_strip->physicalTerminal())
{ {
//Get the good offset according to how many level have the current physical terminal //Get the good offset according to how many level have the current physical terminal
const QVector<QSharedPointer<AbstractRealTerminalInterface>> real_terminal_vector{physical_t->realTerminals()}; const QVector<QSharedPointer<AbstractRealTerminalInterface>> real_terminal_vector{physical_t->realTerminals()};
const auto real_t_count{real_terminal_vector.size()}; const auto real_t_count{real_terminal_vector.size()};
const auto offset_{4 - real_t_count}; const auto offset_{4 - real_t_count};
//Loop over real terminals //Loop over real terminals
for (auto i=0 ; i<real_t_count ; ++i) for (auto i=0 ; i<real_t_count ; ++i)
{ {
const auto index_ = offset_ + i; const auto index_ = offset_ + i;
if (index_ >= 4) { if (index_ >= 4) {
break; break;
} }
terminal_rect = m_pattern->m_terminal_rect[index_]; terminal_rect = m_pattern->m_terminal_rect[index_];
//Draw terminal rect //Draw terminal rect
painter->drawRect(terminal_rect); painter->drawRect(terminal_rect);
//Draw a stronger line if the current terminal have level //Draw a stronger line if the current terminal have level
//and the current level is the first //and the current level is the first
if (real_t_count > 1 && i == 0) if (real_t_count > 1 && i == 0)
{ {
painter->save(); painter->save();
pen_ = painter->pen(); pen_ = painter->pen();
pen_.setWidth(4); pen_.setWidth(4);
pen_.setCapStyle(Qt::FlatCap); pen_.setCapStyle(Qt::FlatCap);
painter->setPen(pen_); painter->setPen(pen_);
const auto p1 { terminal_rect.topLeft() }; const auto p1 { terminal_rect.topLeft() };
//We can't use terminal_rect.bottomLeft for p2 because //We can't use terminal_rect.bottomLeft for p2 because
//the returned value deviate from the true value //the returned value deviate from the true value
//(see Qt documentation about QRect) //(see Qt documentation about QRect)
const QPoint p2 { p1.x(), p1.y() + terminal_rect.height() }; const QPoint p2 { p1.x(), p1.y() + terminal_rect.height() };
painter->drawLine(p1, p2); painter->drawLine(p1, p2);
painter->restore(); painter->restore();
} }
//Draw text //Draw text
painter->save(); painter->save();
if (terminals_text_orientation[index_] == Qt::Horizontal) if (terminals_text_orientation[index_] == Qt::Horizontal)
{ {
text_rect = terminals_text_rect[index_]; text_rect = terminals_text_rect[index_];
} }
else else
{ {
const auto rect_{terminals_text_rect[index_]}; const auto rect_{terminals_text_rect[index_]};
painter->translate(rect_.bottomLeft()); painter->translate(rect_.bottomLeft());
painter->rotate(270); painter->rotate(270);
text_rect.setRect(0, 0, rect_.height(), terminal_rect.width()); text_rect.setRect(0, 0, rect_.height(), terminal_rect.width());
} }
const auto shared_real_terminal{real_terminal_vector[i]}; const auto shared_real_terminal{real_terminal_vector[i]};
painter->drawText(text_rect, painter->drawText(text_rect,
shared_real_terminal ? shared_real_terminal->label() : QLatin1String(), shared_real_terminal ? shared_real_terminal->label() : QLatin1String(),
terminals_text_option[index_]); terminals_text_option[index_]);
if (m_preview_draw) if (m_preview_draw)
{ {
painter->setPen(Qt::blue); painter->setPen(Qt::blue);
painter->drawRect(text_rect); painter->drawRect(text_rect);
} }
painter->restore(); painter->restore();
//Add bridge anchor //Add bridge anchor
if (shared_real_terminal->isBridged()) if (shared_real_terminal->isBridged())
{ {
painter->save(); painter->save();
if (QScopedPointer<AbstractBridgeInterface> bridge_ { if (QScopedPointer<AbstractBridgeInterface> bridge_ {
shared_real_terminal->bridge() }) shared_real_terminal->bridge() })
{ {
const auto x_anchor{terminal_rect.width()/2}; const auto x_anchor{terminal_rect.width()/2};
const auto y_anchor {m_pattern->m_bridge_point_y_offset[index_]}; const auto y_anchor {m_pattern->m_bridge_point_y_offset[index_]};
const auto radius_anchor{m_pattern->m_bridge_point_d/2}; const auto radius_anchor{m_pattern->m_bridge_point_d/2};
painter->setBrush(Qt::SolidPattern); painter->setBrush(Qt::SolidPattern);
painter->drawEllipse(QPointF(x_anchor, y_anchor), painter->drawEllipse(QPointF(x_anchor, y_anchor),
radius_anchor, radius_anchor); radius_anchor, radius_anchor);
auto anchor_points{bridges_anchor_points.value(bridge_->uuid())}; auto anchor_points{bridges_anchor_points.value(bridge_->uuid())};
anchor_points.append(QPointF(x_offset + x_anchor, y_anchor)); anchor_points.append(QPointF(x_offset + x_anchor, y_anchor));
bridges_anchor_points.insert(bridge_->uuid(), anchor_points); bridges_anchor_points.insert(bridge_->uuid(), anchor_points);
} }
painter->restore(); painter->restore();
} }
//Move painter pos to next drawing //Move painter pos to next drawing
painter->translate(terminal_rect.width(),0); painter->translate(terminal_rect.width(),0);
x_offset += terminal_rect.width(); x_offset += terminal_rect.width();
} }
} }
painter->restore(); painter->restore();
//Draw the bridges //Draw the bridges
for (const auto &points_ : qAsConst(bridges_anchor_points)) for (const auto &points_ : qAsConst(bridges_anchor_points))
{ {
painter->save(); painter->save();
auto pen_{painter->pen()}; auto pen_{painter->pen()};
pen_.setWidth(2); pen_.setWidth(2);
painter->setPen(pen_); painter->setPen(pen_);
painter->drawPolyline(QPolygonF{points_}); painter->drawPolyline(QPolygonF{points_});
painter->restore(); painter->restore();
} }
} }
} }
QRectF TerminalStripDrawer::boundingRect() const QRectF TerminalStripDrawer::boundingRect() const
{ {
return QRect{0, 0, width(), height()};; return QRect{0, 0, width(), height()};;
} }
void TerminalStripDrawer::setLayout(QSharedPointer<TerminalStripLayoutPattern> layout) void TerminalStripDrawer::setLayout(QSharedPointer<TerminalStripLayoutPattern> layout)
{ {
m_pattern = layout; m_pattern = layout;
} }
bool TerminalStripDrawer::haveLayout() const bool TerminalStripDrawer::haveLayout() const
{ {
return !m_pattern.isNull(); return !m_pattern.isNull();
} }
void TerminalStripDrawer::setPreviewDraw(bool draw) { void TerminalStripDrawer::setPreviewDraw(bool draw) {
m_preview_draw = draw; m_preview_draw = draw;
} }
int TerminalStripDrawer::height() const int TerminalStripDrawer::height() const
{ {
if (m_pattern) if (m_pattern)
{ {
auto height_{m_pattern->m_header_rect.y() + m_pattern->m_header_rect.height()}; auto height_{m_pattern->m_header_rect.y() + m_pattern->m_header_rect.height()};
height_ = std::max(height_, m_pattern->m_spacer_rect.y() + m_pattern->m_spacer_rect.height()); height_ = std::max(height_, m_pattern->m_spacer_rect.y() + m_pattern->m_spacer_rect.height());
for (const auto &rect : m_pattern->m_terminal_rect) { for (const auto &rect : m_pattern->m_terminal_rect) {
height_ = std::max(height_, rect.y() + rect.height()); height_ = std::max(height_, rect.y() + rect.height());
} }
return height_; return height_;
} }
return 0; return 0;
} }
int TerminalStripDrawer::width() const int TerminalStripDrawer::width() const
{ {
if (m_pattern) if (m_pattern)
{ {
int width_{m_pattern->m_header_rect.width() + m_pattern->m_spacer_rect.width()}; int width_{m_pattern->m_header_rect.width() + m_pattern->m_spacer_rect.width()};
if (m_strip) if (m_strip)
{ {
//Loop over physical terminals //Loop over physical terminals
for (const auto &physical_t : m_strip->physicalTerminal()) for (const auto &physical_t : m_strip->physicalTerminal())
{ {
//Get the good offset according to how many level have the current physical terminal //Get the good offset according to how many level have the current physical terminal
const QVector<QSharedPointer<AbstractRealTerminalInterface>> real_terminal_vector{physical_t->realTerminals()}; const QVector<QSharedPointer<AbstractRealTerminalInterface>> real_terminal_vector{physical_t->realTerminals()};
const auto real_t_count{real_terminal_vector.size()}; const auto real_t_count{real_terminal_vector.size()};
const auto offset_{4 - real_t_count}; const auto offset_{4 - real_t_count};
//Loop over real terminals //Loop over real terminals
for (auto i=0 ; i<real_t_count ; ++i) for (auto i=0 ; i<real_t_count ; ++i)
{ {
const auto index_ = offset_ + i; const auto index_ = offset_ + i;
if (index_ >= 4) { if (index_ >= 4) {
break; break;
} }
width_ += m_pattern->m_terminal_rect[index_].width(); width_ += m_pattern->m_terminal_rect[index_].width();
} }
} }
} }
return width_; return width_;
} }
return 0; return 0;
} }
} //End namespace TerminalStripDrawer } //End namespace TerminalStripDrawer

View File

@ -26,35 +26,35 @@
#include "trueterminalstrip.h" #include "trueterminalstrip.h"
TerminalStripItem::TerminalStripItem(QPointer<TerminalStrip> strip, TerminalStripItem::TerminalStripItem(QPointer<TerminalStrip> strip,
QGraphicsItem *parent) : QGraphicsItem *parent) :
QetGraphicsItem { parent }, QetGraphicsItem { parent },
m_strip { strip }, m_strip { strip },
m_drawer { QSharedPointer<TerminalStripDrawer::TrueTerminalStrip> { m_drawer { QSharedPointer<TerminalStripDrawer::TrueTerminalStrip> {
new TerminalStripDrawer::TrueTerminalStrip { strip }} new TerminalStripDrawer::TrueTerminalStrip { strip }}
} }
{ {
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
setAcceptHoverEvents(true); setAcceptHoverEvents(true);
setDefaultLayout(); setDefaultLayout();
} }
TerminalStripItem::TerminalStripItem(QGraphicsItem *parent) : TerminalStripItem::TerminalStripItem(QGraphicsItem *parent) :
QetGraphicsItem { parent } QetGraphicsItem { parent }
{ {
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable); setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
setAcceptHoverEvents(true); setAcceptHoverEvents(true);
} }
void TerminalStripItem::setTerminalStrip(TerminalStrip *strip) void TerminalStripItem::setTerminalStrip(TerminalStrip *strip)
{ {
m_strip = strip; m_strip = strip;
m_drawer.setStrip(QSharedPointer<TerminalStripDrawer::TrueTerminalStrip> { m_drawer.setStrip(QSharedPointer<TerminalStripDrawer::TrueTerminalStrip> {
new TerminalStripDrawer::TrueTerminalStrip { strip }}); new TerminalStripDrawer::TrueTerminalStrip { strip }});
m_pending_strip_uuid = QUuid(); m_pending_strip_uuid = QUuid();
if (!m_drawer.haveLayout()) { if (!m_drawer.haveLayout()) {
setDefaultLayout(); setDefaultLayout();
} }
} }
/** /**
@ -62,7 +62,7 @@ void TerminalStripItem::setTerminalStrip(TerminalStrip *strip)
* @return The strip drawed by this item * @return The strip drawed by this item
*/ */
QPointer<TerminalStrip> TerminalStripItem::terminalStrip() const { QPointer<TerminalStrip> TerminalStripItem::terminalStrip() const {
return m_strip; return m_strip;
} }
void TerminalStripItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) void TerminalStripItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
@ -91,42 +91,42 @@ QRectF TerminalStripItem::boundingRect() const
* @return usual name of this item * @return usual name of this item
*/ */
QString TerminalStripItem::name() const { QString TerminalStripItem::name() const {
return tr("plan de bornes"); return tr("plan de bornes");
} }
void TerminalStripItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) void TerminalStripItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{ {
Q_UNUSED (event); Q_UNUSED (event);
if (m_strip) { if (m_strip) {
TerminalStripEditorWindow::edit(m_strip); TerminalStripEditorWindow::edit(m_strip);
} }
} }
void TerminalStripItem::refreshPending() void TerminalStripItem::refreshPending()
{ {
if (!m_pending_strip_uuid.isNull() if (!m_pending_strip_uuid.isNull()
&& diagram() && diagram()
&& diagram()->project()) && diagram()->project())
{ {
for (const auto &strip_ : diagram()->project()->terminalStrip()) { for (const auto &strip_ : diagram()->project()->terminalStrip()) {
if (strip_->uuid() == m_pending_strip_uuid) { if (strip_->uuid() == m_pending_strip_uuid) {
setTerminalStrip(strip_); setTerminalStrip(strip_);
m_pending_strip_uuid = QUuid(); m_pending_strip_uuid = QUuid();
break; break;
} }
} }
} }
} }
void TerminalStripItem::setLayout(QSharedPointer<TerminalStripLayoutPattern> layout) void TerminalStripItem::setLayout(QSharedPointer<TerminalStripLayoutPattern> layout)
{ {
m_drawer.setLayout(layout); m_drawer.setLayout(layout);
} }
void TerminalStripItem::setDefaultLayout() void TerminalStripItem::setDefaultLayout()
{ {
if (m_strip && m_strip->project()) { if (m_strip && m_strip->project()) {
m_drawer.setLayout(m_strip->project()->projectPropertiesHandler().terminalStripLayoutHandler().defaultLayout()); m_drawer.setLayout(m_strip->project()->projectPropertiesHandler().terminalStripLayoutHandler().defaultLayout());
} }
} }

View File

@ -28,16 +28,16 @@ class TerminalStrip;
class TerminalStripItem : public QetGraphicsItem class TerminalStripItem : public QetGraphicsItem
{ {
friend class TerminalStripItemXml; friend class TerminalStripItemXml;
Q_OBJECT Q_OBJECT
public: public:
TerminalStripItem(QPointer<TerminalStrip> strip, QGraphicsItem *parent = nullptr); TerminalStripItem(QPointer<TerminalStrip> strip, QGraphicsItem *parent = nullptr);
TerminalStripItem(QGraphicsItem *parent = nullptr); TerminalStripItem(QGraphicsItem *parent = nullptr);
void setTerminalStrip(TerminalStrip *strip); void setTerminalStrip(TerminalStrip *strip);
QPointer<TerminalStrip> terminalStrip() const; QPointer<TerminalStrip> terminalStrip() const;
enum {Type = UserType + 1011}; enum {Type = UserType + 1011};
int type() const override {return Type;} int type() const override {return Type;}
@ -46,17 +46,17 @@ class TerminalStripItem : public QetGraphicsItem
QRectF boundingRect() const override; QRectF boundingRect() const override;
QString name() const override; QString name() const override;
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
void refreshPending(); void refreshPending();
void setLayout(QSharedPointer<TerminalStripLayoutPattern> layout); void setLayout(QSharedPointer<TerminalStripLayoutPattern> layout);
private: private:
void setDefaultLayout(); void setDefaultLayout();
private: private:
QPointer<TerminalStrip> m_strip; QPointer<TerminalStrip> m_strip;
TerminalStripDrawer::TerminalStripDrawer m_drawer; TerminalStripDrawer::TerminalStripDrawer m_drawer;
QUuid m_pending_strip_uuid; QUuid m_pending_strip_uuid;
}; };

View File

@ -25,109 +25,109 @@
namespace TerminalStripDrawer namespace TerminalStripDrawer
{ {
/** /**
* @brief TrueTerminalStrip::TrueTerminalStrip * @brief TrueTerminalStrip::TrueTerminalStrip
* Constructor, this class don't take ownership of @a strip * Constructor, this class don't take ownership of @a strip
* @param strip * @param strip
*/ */
TrueTerminalStrip::TrueTerminalStrip(TerminalStrip *strip) : TrueTerminalStrip::TrueTerminalStrip(TerminalStrip *strip) :
m_strip { strip } m_strip { strip }
{} {}
QString TrueTerminalStrip::installation() const QString TrueTerminalStrip::installation() const
{ {
if (m_strip) { if (m_strip) {
return m_strip->installation(); return m_strip->installation();
} else { } else {
return QString(); return QString();
} }
} }
QString TrueTerminalStrip::location() const QString TrueTerminalStrip::location() const
{ {
if (m_strip) { if (m_strip) {
return m_strip->location(); return m_strip->location();
} else { } else {
return QString(); return QString();
} }
} }
QString TrueTerminalStrip::name() const QString TrueTerminalStrip::name() const
{ {
if (m_strip) { if (m_strip) {
return m_strip->name(); return m_strip->name();
} else { } else {
return QString(); return QString();
} }
} }
QVector<QSharedPointer<AbstractPhysicalTerminalInterface>> TrueTerminalStrip::physicalTerminal() const QVector<QSharedPointer<AbstractPhysicalTerminalInterface>> TrueTerminalStrip::physicalTerminal() const
{ {
QVector<QSharedPointer<AbstractPhysicalTerminalInterface>> vector_; QVector<QSharedPointer<AbstractPhysicalTerminalInterface>> vector_;
if (m_strip) { if (m_strip) {
for (const auto &phy : m_strip->physicalTerminal()) { for (const auto &phy : m_strip->physicalTerminal()) {
vector_.append(QSharedPointer<AbstractPhysicalTerminalInterface>{ new TruePhysicalTerminal(phy) }); vector_.append(QSharedPointer<AbstractPhysicalTerminalInterface>{ new TruePhysicalTerminal(phy) });
} }
} }
return vector_; return vector_;
} }
TruePhysicalTerminal::TruePhysicalTerminal(QSharedPointer<PhysicalTerminal> physical) : TruePhysicalTerminal::TruePhysicalTerminal(QSharedPointer<PhysicalTerminal> physical) :
m_physical { physical } m_physical { physical }
{} {}
QVector<QSharedPointer<AbstractRealTerminalInterface>> TruePhysicalTerminal::realTerminals() const QVector<QSharedPointer<AbstractRealTerminalInterface>> TruePhysicalTerminal::realTerminals() const
{ {
QVector<QSharedPointer<AbstractRealTerminalInterface>> vector_; QVector<QSharedPointer<AbstractRealTerminalInterface>> vector_;
if (m_physical) { if (m_physical) {
for (const auto &real_ : m_physical->realTerminals()) { for (const auto &real_ : m_physical->realTerminals()) {
vector_.append(QSharedPointer<AbstractRealTerminalInterface> { new TrueRealTerminal{ real_ }}); vector_.append(QSharedPointer<AbstractRealTerminalInterface> { new TrueRealTerminal{ real_ }});
} }
} }
return vector_; return vector_;
} }
TrueRealTerminal::TrueRealTerminal(QSharedPointer<RealTerminal> real) : TrueRealTerminal::TrueRealTerminal(QSharedPointer<RealTerminal> real) :
m_real { real } m_real { real }
{} {}
QString TrueRealTerminal::label() const QString TrueRealTerminal::label() const
{ {
if (m_real) { if (m_real) {
return m_real->label(); return m_real->label();
} else { } else {
return QString(); return QString();
} }
} }
bool TrueRealTerminal::isBridged() const bool TrueRealTerminal::isBridged() const
{ {
if (m_real) { if (m_real) {
return m_real->isBridged(); return m_real->isBridged();
} else { } else {
return false; return false;
} }
} }
//Return a raw pointer, the pointer is not managed by this class //Return a raw pointer, the pointer is not managed by this class
AbstractBridgeInterface* TrueRealTerminal::bridge() const AbstractBridgeInterface* TrueRealTerminal::bridge() const
{ {
return new TrueBridge(m_real->bridge()); return new TrueBridge(m_real->bridge());
} }
TrueBridge::TrueBridge(QSharedPointer<TerminalStripBridge> bridge) : TrueBridge::TrueBridge(QSharedPointer<TerminalStripBridge> bridge) :
m_bridge { bridge } m_bridge { bridge }
{} {}
QUuid TrueBridge::uuid() const QUuid TrueBridge::uuid() const
{ {
if (m_bridge) { if (m_bridge) {
return m_bridge->uuid(); return m_bridge->uuid();
} else { } else {
return QUuid(); return QUuid();
} }
} }
} }

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "addterminalstripcommand.h" #include "addterminalstripcommand.h"
#include "../../qetproject.h" #include "../../qetproject.h"
@ -35,22 +35,22 @@ AddTerminalStripCommand::AddTerminalStripCommand(TerminalStrip *strip,
m_strip(strip), m_strip(strip),
m_project(project) m_project(project)
{ {
setText(QObject::tr("Ajouter un groupe de bornes")); setText(QObject::tr("Ajouter un groupe de bornes"));
} }
AddTerminalStripCommand::~AddTerminalStripCommand() AddTerminalStripCommand::~AddTerminalStripCommand()
{} {}
void AddTerminalStripCommand::undo() { void AddTerminalStripCommand::undo() {
if (m_project && m_strip) { if (m_project && m_strip) {
m_project->removeTerminalStrip(m_strip); m_project->removeTerminalStrip(m_strip);
} }
} }
void AddTerminalStripCommand::redo() { void AddTerminalStripCommand::redo() {
if (m_project && m_strip) { if (m_project && m_strip) {
m_project->addTerminalStrip(m_strip); m_project->addTerminalStrip(m_strip);
} }
} }
RemoveTerminalStripCommand::RemoveTerminalStripCommand(TerminalStrip *strip, RemoveTerminalStripCommand::RemoveTerminalStripCommand(TerminalStrip *strip,

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef ADDTERMINALSTRIPCOMMAND_H #ifndef ADDTERMINALSTRIPCOMMAND_H
#define ADDTERMINALSTRIPCOMMAND_H #define ADDTERMINALSTRIPCOMMAND_H
@ -28,16 +28,16 @@ class Element;
class AddTerminalStripCommand : public QUndoCommand class AddTerminalStripCommand : public QUndoCommand
{ {
public: public:
AddTerminalStripCommand(TerminalStrip *strip, QETProject *project, QUndoCommand *parent = nullptr); AddTerminalStripCommand(TerminalStrip *strip, QETProject *project, QUndoCommand *parent = nullptr);
~AddTerminalStripCommand() override; ~AddTerminalStripCommand() override;
void undo() override; void undo() override;
void redo() override; void redo() override;
private: private:
QPointer<TerminalStrip> m_strip; QPointer<TerminalStrip> m_strip;
QPointer<QETProject> m_project; QPointer<QETProject> m_project;
}; };
class RemoveTerminalStripCommand : public QUndoCommand class RemoveTerminalStripCommand : public QUndoCommand

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "addterminaltostripcommand.h" #include "addterminaltostripcommand.h"
#include "../../qetgraphicsitem/terminalelement.h" #include "../../qetgraphicsitem/terminalelement.h"
@ -72,7 +72,7 @@ void AddTerminalToStripCommand::undo()
{ {
if (m_new_strip) { if (m_new_strip) {
m_new_strip->removeTerminals(m_terminal); m_new_strip->removeTerminals(m_terminal);
} }
} }
/** /**
@ -83,7 +83,7 @@ void AddTerminalToStripCommand::redo()
{ {
if (m_new_strip) { if (m_new_strip) {
m_new_strip->addTerminals(m_terminal); m_new_strip->addTerminals(m_terminal);
} }
} }
/** /**

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef ADDTERMINALTOSTRIPCOMMAND_H #ifndef ADDTERMINALTOSTRIPCOMMAND_H
#define ADDTERMINALTOSTRIPCOMMAND_H #define ADDTERMINALTOSTRIPCOMMAND_H
@ -36,17 +36,17 @@ class PhysicalTerminal;
*/ */
class AddTerminalToStripCommand : public QUndoCommand class AddTerminalToStripCommand : public QUndoCommand
{ {
public: public:
AddTerminalToStripCommand(QSharedPointer<RealTerminal> terminal, TerminalStrip *strip, QUndoCommand *parent = nullptr); AddTerminalToStripCommand(QSharedPointer<RealTerminal> terminal, TerminalStrip *strip, QUndoCommand *parent = nullptr);
AddTerminalToStripCommand(QVector<QSharedPointer<RealTerminal>> terminals, TerminalStrip *strip, QUndoCommand *parent = nullptr); AddTerminalToStripCommand(QVector<QSharedPointer<RealTerminal>> terminals, TerminalStrip *strip, QUndoCommand *parent = nullptr);
~AddTerminalToStripCommand() override; ~AddTerminalToStripCommand() override;
void undo() override; void undo() override;
void redo() override; void redo() override;
private: private:
QVector<QSharedPointer<RealTerminal>> m_terminal; QVector<QSharedPointer<RealTerminal>> m_terminal;
QPointer<TerminalStrip> m_new_strip; QPointer<TerminalStrip> m_new_strip;
}; };
/** /**

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "bridgeterminalscommand.h" #include "bridgeterminalscommand.h"
#include "../terminalstripbridge.h" #include "../terminalstripbridge.h"
@ -58,18 +58,18 @@ UnBridgeTerminalsCommand::UnBridgeTerminalsCommand(TerminalStrip *strip,
if (strip->canUnBridge(real_terminal)) if (strip->canUnBridge(real_terminal))
{ {
m_bridge = strip->isBridged(real_terminal.first()); m_bridge = strip->isBridged(real_terminal.first());
//If bridge have one more terminals than @real_terminal //If bridge have one more terminals than @real_terminal
//that mean every terminals of the bridge must be unbridged by this undo command, //that mean every terminals of the bridge must be unbridged by this undo command,
//else the single terminal who's not umbridged by this undo command //else the single terminal who's not umbridged by this undo command
//continue to have a bridge (to nothing) and this nowhere bridge is visible //continue to have a bridge (to nothing) and this nowhere bridge is visible
//in the terminal strip graphic item and terminal strip editor dialog. //in the terminal strip graphic item and terminal strip editor dialog.
if (m_bridge->realTerminals().size() == real_terminal.size() + 1) { if (m_bridge->realTerminals().size() == real_terminal.size() + 1) {
m_terminals = m_bridge->realTerminals(); m_terminals = m_bridge->realTerminals();
} else { } else {
m_terminals = real_terminal; m_terminals = real_terminal;
} }
} }
} }

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef BRIDGETERMINALSCOMMAND_H #ifndef BRIDGETERMINALSCOMMAND_H
#define BRIDGETERMINALSCOMMAND_H #define BRIDGETERMINALSCOMMAND_H

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "changeterminallevel.h" #include "changeterminallevel.h"
#include "../realterminal.h" #include "../realterminal.h"

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CHANGETERMINALLEVEL_H #ifndef CHANGETERMINALLEVEL_H
#define CHANGETERMINALLEVEL_H #define CHANGETERMINALLEVEL_H

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "changeterminalstripcolor.h" #include "changeterminalstripcolor.h"
#include "../terminalstripbridge.h" #include "../terminalstripbridge.h"

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CHANGETERMINALSTRIPCOLOR_H #ifndef CHANGETERMINALSTRIPCOLOR_H
#define CHANGETERMINALSTRIPCOLOR_H #define CHANGETERMINALSTRIPCOLOR_H

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "changeterminalstripdata.h" #include "changeterminalstripdata.h"

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef CHANGETERMINALSTRIPDATA_H #ifndef CHANGETERMINALSTRIPDATA_H
#define CHANGETERMINALSTRIPDATA_H #define CHANGETERMINALSTRIPDATA_H
@ -27,15 +27,15 @@
*/ */
class ChangeTerminalStripData : public QUndoCommand class ChangeTerminalStripData : public QUndoCommand
{ {
public: public:
ChangeTerminalStripData(TerminalStrip *strip, const TerminalStripData &data, QUndoCommand *parent = nullptr); ChangeTerminalStripData(TerminalStrip *strip, const TerminalStripData &data, QUndoCommand *parent = nullptr);
void undo() override; void undo() override;
void redo() override; void redo() override;
private: private:
QPointer<TerminalStrip> m_strip; QPointer<TerminalStrip> m_strip;
TerminalStripData m_old_data, m_new_data; TerminalStripData m_old_data, m_new_data;
}; };
#endif // CHANGETERMINALSTRIPDATA_H #endif // CHANGETERMINALSTRIPDATA_H

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "groupterminalscommand.h" #include "groupterminalscommand.h"
#include "../physicalterminal.h" #include "../physicalterminal.h"

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef GROUPTERMINALSCOMMAND_H #ifndef GROUPTERMINALSCOMMAND_H
#define GROUPTERMINALSCOMMAND_H #define GROUPTERMINALSCOMMAND_H

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "sortterminalstripcommand.h" #include "sortterminalstripcommand.h"
#include "../terminalstrip.h" #include "../terminalstrip.h"

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef SORTTERMINALSTRIPCOMMAND_H #ifndef SORTTERMINALSTRIPCOMMAND_H
#define SORTTERMINALSTRIPCOMMAND_H #define SORTTERMINALSTRIPCOMMAND_H

View File

@ -976,7 +976,7 @@ QDomElement TerminalStrip::toXml(QDomDocument &parent_document)
root_elmt.appendChild(m_data.toXml(parent_document)); root_elmt.appendChild(m_data.toXml(parent_document));
//Undrawed terminals //Undrawed terminals
auto xml_layout = parent_document.createElement(QStringLiteral("layout")); auto xml_layout = parent_document.createElement(QStringLiteral("layout"));
for (auto &phy_t : m_physical_terminals) { for (auto &phy_t : m_physical_terminals) {
xml_layout.appendChild(phy_t->toXml(parent_document)); xml_layout.appendChild(phy_t->toXml(parent_document));

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "terminalstripdata.h" #include "terminalstripdata.h"
#include "../qetxml.h" #include "../qetxml.h"
@ -34,7 +34,7 @@ QDomElement TerminalStripData::toXml(QDomDocument &xml_document) const
root_elmt.setAttribute(QStringLiteral("uuid"), m_uuid.toString()); root_elmt.setAttribute(QStringLiteral("uuid"), m_uuid.toString());
auto info_elmt = xml_document.createElement(QStringLiteral("informations")); auto info_elmt = xml_document.createElement(QStringLiteral("informations"));
root_elmt.appendChild(info_elmt); root_elmt.appendChild(info_elmt);
if (!m_installation.isEmpty()) { if (!m_installation.isEmpty()) {
@ -65,23 +65,23 @@ bool TerminalStripData::fromXml(const QDomElement &xml_element)
return false; return false;
} }
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
m_uuid = QUuid::fromString(xml_element.attribute(QStringLiteral("uuid"))); m_uuid = QUuid::fromString(xml_element.attribute(QStringLiteral("uuid")));
#else #else
m_uuid = QUuid(xml_element.attribute(QStringLiteral("uuid"))); m_uuid = QUuid(xml_element.attribute(QStringLiteral("uuid")));
#endif #endif
for (auto &xml_info : for (auto &xml_info :
QETXML::findInDomElement(xml_element.firstChildElement(QStringLiteral("informations")), QETXML::findInDomElement(xml_element.firstChildElement(QStringLiteral("informations")),
QStringLiteral("information"))) QStringLiteral("information")))
{ {
auto name = xml_info.attribute(QStringLiteral("name")); auto name = xml_info.attribute(QStringLiteral("name"));
auto value = xml_info.text(); auto value = xml_info.text();
if (name == QLatin1String("installation")) { m_installation = value;} if (name == QLatin1String("installation")) { m_installation = value;}
else if (name == QLatin1String("location")) {m_location = value;} else if (name == QLatin1String("location")) {m_location = value;}
else if (name == QLatin1String("name")) {m_name = value;} else if (name == QLatin1String("name")) {m_name = value;}
else if (name == QLatin1String("comment")) {m_comment = value;} else if (name == QLatin1String("comment")) {m_comment = value;}
else if (name == QLatin1String("description")) {m_description = value;} else if (name == QLatin1String("description")) {m_description = value;}
} }
return true; return true;
@ -101,7 +101,7 @@ TerminalStripData &TerminalStripData::operator=(const TerminalStripData &other)
QDomElement TerminalStripData::infoToXml(QDomDocument &xml_doc, const QString &name, const QString &value) QDomElement TerminalStripData::infoToXml(QDomDocument &xml_doc, const QString &name, const QString &value)
{ {
auto xml_elmt = xml_doc.createElement(QStringLiteral("information")); auto xml_elmt = xml_doc.createElement(QStringLiteral("information"));
xml_elmt.setAttribute(QStringLiteral("name"), name); xml_elmt.setAttribute(QStringLiteral("name"), name);
xml_elmt.appendChild(xml_doc.createTextNode(value)); xml_elmt.appendChild(xml_doc.createTextNode(value));

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TERMINALSTRIPDATA_H #ifndef TERMINALSTRIPDATA_H
#define TERMINALSTRIPDATA_H #define TERMINALSTRIPDATA_H

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "terminalstripprojectconfigpage.h" #include "terminalstripprojectconfigpage.h"
#include "../../../qeticons.h" #include "../../../qeticons.h"
@ -23,26 +23,26 @@
#include <QVBoxLayout> #include <QVBoxLayout>
TerminalStripProjectConfigPage::TerminalStripProjectConfigPage(QETProject *project, TerminalStripProjectConfigPage::TerminalStripProjectConfigPage(QETProject *project,
QWidget *parent) : QWidget *parent) :
ProjectConfigPage { project, parent } ProjectConfigPage { project, parent }
{ {
initWidgets(); initWidgets();
} }
QString TerminalStripProjectConfigPage::title() const { QString TerminalStripProjectConfigPage::title() const {
return tr("Plan de bornes"); return tr("Plan de bornes");
} }
QIcon TerminalStripProjectConfigPage::icon() const { QIcon TerminalStripProjectConfigPage::icon() const {
return QET::Icons::TerminalStrip; return QET::Icons::TerminalStrip;
} }
void TerminalStripProjectConfigPage::initWidgets() void TerminalStripProjectConfigPage::initWidgets()
{ {
m_layout_editor = new TerminalStripLayoutEditor{ project()->projectPropertiesHandler().terminalStripLayoutHandler().defaultLayout(), m_layout_editor = new TerminalStripLayoutEditor{ project()->projectPropertiesHandler().terminalStripLayoutHandler().defaultLayout(),
this }; this };
auto v_layout = new QVBoxLayout { this }; auto v_layout = new QVBoxLayout { this };
v_layout->addWidget(m_layout_editor); v_layout->addWidget(m_layout_editor);
setLayout(v_layout); setLayout(v_layout);
} }

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TERMINALSTRIPPROJECTCONFIGPAGE_H #ifndef TERMINALSTRIPPROJECTCONFIGPAGE_H
#define TERMINALSTRIPPROJECTCONFIGPAGE_H #define TERMINALSTRIPPROJECTCONFIGPAGE_H
@ -24,23 +24,23 @@ class TerminalStripLayoutEditor;
class TerminalStripProjectConfigPage : public ProjectConfigPage class TerminalStripProjectConfigPage : public ProjectConfigPage
{ {
Q_OBJECT Q_OBJECT
public: public:
TerminalStripProjectConfigPage(QETProject *project, QWidget *parent = nullptr); TerminalStripProjectConfigPage(QETProject *project, QWidget *parent = nullptr);
QString title() const override; QString title() const override;
QIcon icon() const override; QIcon icon() const override;
void applyProjectConf() override {} void applyProjectConf() override {}
protected: protected:
void initWidgets() override; void initWidgets() override;
void initLayout() override{} void initLayout() override{}
void readValuesFromProject() override {} void readValuesFromProject() override {}
void adjustReadOnly() override {} void adjustReadOnly() override {}
private: private:
TerminalStripLayoutEditor *m_layout_editor { nullptr }; TerminalStripLayoutEditor *m_layout_editor { nullptr };
}; };
#endif // TERMINALSTRIPPROJECTCONFIGPAGE_H #endif // TERMINALSTRIPPROJECTCONFIGPAGE_H

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "freeterminaleditor.h" #include "freeterminaleditor.h"
#include "ui_freeterminaleditor.h" #include "ui_freeterminaleditor.h"

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef FREETERMINALEDITOR_H #ifndef FREETERMINALEDITOR_H
#define FREETERMINALEDITOR_H #define FREETERMINALEDITOR_H

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <QComboBox> #include <QComboBox>
@ -333,7 +333,7 @@ QWidget *FreeTerminalModelDelegate::createEditor(QWidget *parent, const QStyleOp
{ {
if (index.column() == TYPE_CELL) { if (index.column() == TYPE_CELL) {
auto qcb = new QComboBox(parent); auto qcb = new QComboBox(parent);
qcb->setObjectName(QStringLiteral("terminal_type")); qcb->setObjectName(QStringLiteral("terminal_type"));
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTGeneric), ElementData::TTGeneric); qcb->addItem(ElementData::translatedTerminalType(ElementData::TTGeneric), ElementData::TTGeneric);
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTFuse), ElementData::TTFuse); qcb->addItem(ElementData::translatedTerminalType(ElementData::TTFuse), ElementData::TTFuse);
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTSectional), ElementData::TTSectional); qcb->addItem(ElementData::translatedTerminalType(ElementData::TTSectional), ElementData::TTSectional);
@ -344,7 +344,7 @@ QWidget *FreeTerminalModelDelegate::createEditor(QWidget *parent, const QStyleOp
} }
if (index.column() == FUNCTION_CELL) { if (index.column() == FUNCTION_CELL) {
auto qcb = new QComboBox(parent); auto qcb = new QComboBox(parent);
qcb->setObjectName(QStringLiteral("terminal_function")); qcb->setObjectName(QStringLiteral("terminal_function"));
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFGeneric), ElementData::TFGeneric); qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFGeneric), ElementData::TFGeneric);
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFPhase), ElementData::TFPhase); qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFPhase), ElementData::TFPhase);
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFNeutral), ElementData::TFNeutral); qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFNeutral), ElementData::TFNeutral);

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef FREETERMINALMODEL_H #ifndef FREETERMINALMODEL_H
#define FREETERMINALMODEL_H #define FREETERMINALMODEL_H

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef MODELTERMINALDATA_H #ifndef MODELTERMINALDATA_H
#define MODELTERMINALDATA_H #define MODELTERMINALDATA_H

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "terminalstripcreatordialog.h" #include "terminalstripcreatordialog.h"
#include "ui_terminalstripcreatordialog.h" #include "ui_terminalstripcreatordialog.h"

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TERMINALSTRIPCREATORDIALOG_H #ifndef TERMINALSTRIPCREATORDIALOG_H
#define TERMINALSTRIPCREATORDIALOG_H #define TERMINALSTRIPCREATORDIALOG_H
@ -33,9 +33,9 @@ namespace Ui {
*/ */
class TerminalStripCreatorDialog : public QDialog class TerminalStripCreatorDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit TerminalStripCreatorDialog(QETProject *project, QWidget *parent = nullptr); explicit TerminalStripCreatorDialog(QETProject *project, QWidget *parent = nullptr);
~TerminalStripCreatorDialog() override; ~TerminalStripCreatorDialog() override;
@ -46,8 +46,8 @@ class TerminalStripCreatorDialog : public QDialog
private: private:
void setCursorToEmptyLine(); void setCursorToEmptyLine();
private: private:
Ui::TerminalStripCreatorDialog *ui; Ui::TerminalStripCreatorDialog *ui;
QETProject *m_project = nullptr; QETProject *m_project = nullptr;
}; };

View File

@ -180,7 +180,7 @@ void TerminalStripEditor::reload()
if (m_model) if (m_model)
{ {
m_model->reload(); m_model->reload();
spanMultiLevelTerminals(); spanMultiLevelTerminals();
} }
} }

View File

@ -41,12 +41,12 @@ static const int TERMINAL_STRIP_PAGE = 2;
*/ */
void TerminalStripEditorWindow::edit(TerminalStrip *strip) void TerminalStripEditorWindow::edit(TerminalStrip *strip)
{ {
if (const auto project_ = strip->project()) if (const auto project_ = strip->project())
{ {
auto editor_ = TerminalStripEditorWindow::instance(project_, QETApp::diagramEditor(project_)); auto editor_ = TerminalStripEditorWindow::instance(project_, QETApp::diagramEditor(project_));
editor_->setCurrentStrip(strip); editor_->setCurrentStrip(strip);
editor_->show(); editor_->show();
} }
} }
TerminalStripEditorWindow::TerminalStripEditorWindow(QETProject *project, QWidget *parent) : TerminalStripEditorWindow::TerminalStripEditorWindow(QETProject *project, QWidget *parent) :
@ -73,11 +73,11 @@ TerminalStripEditorWindow::TerminalStripEditorWindow(QETProject *project, QWidge
*/ */
TerminalStripEditorWindow::~TerminalStripEditorWindow() TerminalStripEditorWindow::~TerminalStripEditorWindow()
{ {
delete ui; delete ui;
} }
void TerminalStripEditorWindow::setCurrentStrip(TerminalStrip *strip) { void TerminalStripEditorWindow::setCurrentStrip(TerminalStrip *strip) {
m_tree_dock->setSelectedStrip(strip); m_tree_dock->setSelectedStrip(strip);
} }
/** /**

View File

@ -37,41 +37,41 @@ class TerminalStripEditorWindow : public QMainWindow
{ {
Q_OBJECT Q_OBJECT
private: private:
//We need to use a QPointer instead of a raw pointer because when window_ //We need to use a QPointer instead of a raw pointer because when window_
//have got a parent widget, the parent widget can delete the window_ //have got a parent widget, the parent widget can delete the window_
//instance in her destrucor and then window_ become a dangling pointer. //instance in her destrucor and then window_ become a dangling pointer.
static QPointer<TerminalStripEditorWindow> window_; static QPointer<TerminalStripEditorWindow> window_;
public: public:
static TerminalStripEditorWindow* instance(QETProject *project, QWidget *parent = nullptr) { static TerminalStripEditorWindow* instance(QETProject *project, QWidget *parent = nullptr) {
static QMutex mutex_; static QMutex mutex_;
if (!window_) { if (!window_) {
mutex_.lock(); mutex_.lock();
if (!window_) if (!window_)
window_ = new TerminalStripEditorWindow{project, parent}; window_ = new TerminalStripEditorWindow{project, parent};
mutex_.unlock(); mutex_.unlock();
} }
return window_; return window_;
} }
static void dropInstance () { static void dropInstance () {
static QMutex mutex; static QMutex mutex;
if (window_) { if (window_) {
mutex.lock(); mutex.lock();
window_->deleteLater(); window_->deleteLater();
window_.clear(); window_.clear();
mutex.unlock(); mutex.unlock();
} }
} }
static void edit(TerminalStrip *strip); static void edit(TerminalStrip *strip);
public: public:
explicit TerminalStripEditorWindow(QETProject *project, QWidget *parent = nullptr); explicit TerminalStripEditorWindow(QETProject *project, QWidget *parent = nullptr);
~TerminalStripEditorWindow(); ~TerminalStripEditorWindow();
void setCurrentStrip(TerminalStrip *strip); void setCurrentStrip(TerminalStrip *strip);
private slots: private slots:
void on_m_add_terminal_strip_triggered(); void on_m_add_terminal_strip_triggered();

View File

@ -1,34 +1,34 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "terminalstriplayouteditor.h" #include "terminalstriplayouteditor.h"
#include "ui_terminalstriplayouteditor.h" #include "ui_terminalstriplayouteditor.h"
#include "../GraphicsItem/properties/terminalstriplayoutpattern.h" #include "../GraphicsItem/properties/terminalstriplayoutpattern.h"
TerminalStripLayoutEditor::TerminalStripLayoutEditor(QSharedPointer<TerminalStripLayoutPattern> layout, TerminalStripLayoutEditor::TerminalStripLayoutEditor(QSharedPointer<TerminalStripLayoutPattern> layout,
QWidget *parent) : QWidget *parent) :
QWidget{ parent }, QWidget{ parent },
ui{ new Ui::TerminalStripLayoutEditor }, ui{ new Ui::TerminalStripLayoutEditor },
m_layout{ layout } m_layout{ layout }
{ {
ui->setupUi(this); ui->setupUi(this);
ui->m_graphics_view->setScene(new QGraphicsScene{ this }); ui->m_graphics_view->setScene(new QGraphicsScene{ this });
ui->m_graphics_view->scene()->addItem(&m_preview_strip_item); ui->m_graphics_view->scene()->addItem(&m_preview_strip_item);
updateUi(); updateUi();
} }
TerminalStripLayoutEditor::~TerminalStripLayoutEditor() TerminalStripLayoutEditor::~TerminalStripLayoutEditor()
@ -50,87 +50,87 @@ void TerminalStripLayoutEditor::showEvent(QShowEvent *event)
void TerminalStripLayoutEditor::valueEdited() void TerminalStripLayoutEditor::valueEdited()
{ {
if (!m_layout || m_ui_updating) { if (!m_layout || m_ui_updating) {
return; return;
} }
//auto *data_ = m_layout.data(); //auto *data_ = m_layout.data();
m_layout.data()->m_header_rect.setRect(0, m_layout.data()->m_header_rect.setRect(0,
ui->m_y_header_sb->value(), ui->m_y_header_sb->value(),
ui->m_width_header_sb->value(), ui->m_width_header_sb->value(),
ui->m_height_header_sb->value()); ui->m_height_header_sb->value());
m_layout.data()->m_spacer_rect.setRect(0, m_layout.data()->m_spacer_rect.setRect(0,
ui->m_y_spacer_sb->value(), ui->m_y_spacer_sb->value(),
ui->m_width_spacer_sb->value(), ui->m_width_spacer_sb->value(),
ui->m_height_spacer_sb->value()); ui->m_height_spacer_sb->value());
m_layout.data()->m_terminal_rect[0].setRect(0, m_layout.data()->m_terminal_rect[0].setRect(0,
ui->m_y_terminal_0_sb->value(), ui->m_y_terminal_0_sb->value(),
ui->m_width_terminal_0_sb->value(), ui->m_width_terminal_0_sb->value(),
ui->m_height_terminal_0_sb->value()); ui->m_height_terminal_0_sb->value());
m_layout.data()->m_terminal_rect[1].setRect(0, m_layout.data()->m_terminal_rect[1].setRect(0,
ui->m_y_terminal_1_sb->value(), ui->m_y_terminal_1_sb->value(),
ui->m_width_terminal_1_sb->value(), ui->m_width_terminal_1_sb->value(),
ui->m_height_terminal_1_sb->value()); ui->m_height_terminal_1_sb->value());
m_layout.data()->m_terminal_rect[2].setRect(0, m_layout.data()->m_terminal_rect[2].setRect(0,
ui->m_y_terminal_2_sb->value(), ui->m_y_terminal_2_sb->value(),
ui->m_width_terminal_2_sb->value(), ui->m_width_terminal_2_sb->value(),
ui->m_height_terminal_2_sb->value()); ui->m_height_terminal_2_sb->value());
m_layout.data()->m_terminal_rect[3].setRect(0, m_layout.data()->m_terminal_rect[3].setRect(0,
ui->m_y_terminal_3_sb->value(), ui->m_y_terminal_3_sb->value(),
ui->m_width_terminal_3_sb->value(), ui->m_width_terminal_3_sb->value(),
ui->m_height_terminal_3_sb->value()); ui->m_height_terminal_3_sb->value());
m_layout.data()->m_bridge_point_y_offset[0] = ui->m_bridge_point_0_sb->value(); m_layout.data()->m_bridge_point_y_offset[0] = ui->m_bridge_point_0_sb->value();
m_layout.data()->m_bridge_point_y_offset[1] = ui->m_bridge_point_1_sb->value(); m_layout.data()->m_bridge_point_y_offset[1] = ui->m_bridge_point_1_sb->value();
m_layout.data()->m_bridge_point_y_offset[2] = ui->m_bridge_point_2_sb->value(); m_layout.data()->m_bridge_point_y_offset[2] = ui->m_bridge_point_2_sb->value();
m_layout.data()->m_bridge_point_y_offset[3] = ui->m_bridge_point_3_sb->value(); m_layout.data()->m_bridge_point_y_offset[3] = ui->m_bridge_point_3_sb->value();
m_layout.data()->m_header_text_orientation = ui->m_header_text_orientation_cb->currentIndex() == 0 ? m_layout.data()->m_header_text_orientation = ui->m_header_text_orientation_cb->currentIndex() == 0 ?
Qt::Horizontal : Qt::Horizontal :
Qt::Vertical; Qt::Vertical;
switch (ui->m_header_text_alignment_cb->currentIndex()) { switch (ui->m_header_text_alignment_cb->currentIndex()) {
case 0: case 0:
m_layout.data()->setHeaderTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); break; m_layout.data()->setHeaderTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); break;
case 1: case 1:
m_layout.data()->setHeaderTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); break; m_layout.data()->setHeaderTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter); break;
default: default:
m_layout.data()->setHeaderTextAlignment(Qt::AlignRight | Qt::AlignVCenter); break; m_layout.data()->setHeaderTextAlignment(Qt::AlignRight | Qt::AlignVCenter); break;
} }
m_layout.data()->m_terminals_text_orientation[0] = ui->m_terminal_text_orientation_cb->currentIndex() == 0 ? m_layout.data()->m_terminals_text_orientation[0] = ui->m_terminal_text_orientation_cb->currentIndex() == 0 ?
Qt::Horizontal : Qt::Horizontal :
Qt::Vertical; Qt::Vertical;
switch (ui->m_terminal_text_alignment_cb->currentIndex()) { switch (ui->m_terminal_text_alignment_cb->currentIndex()) {
case 0: case 0:
m_layout.data()->setTerminalsTextAlignment( m_layout.data()->setTerminalsTextAlignment(
QVector<Qt::Alignment> { Qt::AlignLeft | Qt::AlignVCenter, QVector<Qt::Alignment> { Qt::AlignLeft | Qt::AlignVCenter,
Qt::AlignLeft | Qt::AlignVCenter, Qt::AlignLeft | Qt::AlignVCenter,
Qt::AlignLeft | Qt::AlignVCenter, Qt::AlignLeft | Qt::AlignVCenter,
Qt::AlignLeft | Qt::AlignVCenter }); Qt::AlignLeft | Qt::AlignVCenter });
break; break;
case 1: case 1:
m_layout.data()->setTerminalsTextAlignment( m_layout.data()->setTerminalsTextAlignment(
QVector<Qt::Alignment> { Qt::AlignHCenter | Qt::AlignVCenter, QVector<Qt::Alignment> { Qt::AlignHCenter | Qt::AlignVCenter,
Qt::AlignHCenter | Qt::AlignVCenter, Qt::AlignHCenter | Qt::AlignVCenter,
Qt::AlignHCenter | Qt::AlignVCenter, Qt::AlignHCenter | Qt::AlignVCenter,
Qt::AlignHCenter | Qt::AlignVCenter }); Qt::AlignHCenter | Qt::AlignVCenter });
break; break;
default: default:
m_layout.data()->setTerminalsTextAlignment( m_layout.data()->setTerminalsTextAlignment(
QVector<Qt::Alignment> { Qt::AlignRight | Qt::AlignVCenter, QVector<Qt::Alignment> { Qt::AlignRight | Qt::AlignVCenter,
Qt::AlignRight | Qt::AlignVCenter, Qt::AlignRight | Qt::AlignVCenter,
Qt::AlignRight | Qt::AlignVCenter, Qt::AlignRight | Qt::AlignVCenter,
Qt::AlignRight | Qt::AlignVCenter }); Qt::AlignRight | Qt::AlignVCenter });
break; break;
} }
updateUi(); updateUi();
m_preview_strip_item.update(); m_preview_strip_item.update();
@ -138,76 +138,76 @@ void TerminalStripLayoutEditor::valueEdited()
void TerminalStripLayoutEditor::updateUi() void TerminalStripLayoutEditor::updateUi()
{ {
if (!m_layout) { if (!m_layout) {
return; return;
} }
const auto data = m_layout.data(); const auto data = m_layout.data();
m_ui_updating = true; m_ui_updating = true;
ui->m_y_header_sb->setValue(data->m_header_rect.y()); ui->m_y_header_sb->setValue(data->m_header_rect.y());
ui->m_width_header_sb->setValue(data->m_header_rect.width()); ui->m_width_header_sb->setValue(data->m_header_rect.width());
ui->m_height_header_sb->setValue(data->m_header_rect.height()); ui->m_height_header_sb->setValue(data->m_header_rect.height());
ui->m_y_spacer_sb->setValue(data->m_spacer_rect.y()); ui->m_y_spacer_sb->setValue(data->m_spacer_rect.y());
ui->m_width_spacer_sb->setValue(data->m_spacer_rect.width()); ui->m_width_spacer_sb->setValue(data->m_spacer_rect.width());
ui->m_height_spacer_sb->setValue(data->m_spacer_rect.height()); ui->m_height_spacer_sb->setValue(data->m_spacer_rect.height());
const auto terminal_0 = data->m_terminal_rect[0]; const auto terminal_0 = data->m_terminal_rect[0];
ui->m_y_terminal_0_sb->setValue(terminal_0.y()); ui->m_y_terminal_0_sb->setValue(terminal_0.y());
ui->m_height_terminal_0_sb->setValue(terminal_0.height()); ui->m_height_terminal_0_sb->setValue(terminal_0.height());
ui->m_width_terminal_0_sb->setValue(terminal_0.width()); ui->m_width_terminal_0_sb->setValue(terminal_0.width());
const auto terminal_1 = data->m_terminal_rect[1]; const auto terminal_1 = data->m_terminal_rect[1];
ui->m_y_terminal_1_sb->setValue(terminal_1.y()); ui->m_y_terminal_1_sb->setValue(terminal_1.y());
ui->m_height_terminal_1_sb->setValue(terminal_1.height()); ui->m_height_terminal_1_sb->setValue(terminal_1.height());
ui->m_width_terminal_1_sb->setValue(terminal_1.width()); ui->m_width_terminal_1_sb->setValue(terminal_1.width());
const auto terminal_2 = data->m_terminal_rect[2]; const auto terminal_2 = data->m_terminal_rect[2];
ui->m_y_terminal_2_sb->setValue(terminal_2.y()); ui->m_y_terminal_2_sb->setValue(terminal_2.y());
ui->m_height_terminal_2_sb->setValue(terminal_2.height()); ui->m_height_terminal_2_sb->setValue(terminal_2.height());
ui->m_width_terminal_2_sb->setValue(terminal_2.width()); ui->m_width_terminal_2_sb->setValue(terminal_2.width());
const auto terminal_3 = data->m_terminal_rect[3]; const auto terminal_3 = data->m_terminal_rect[3];
ui->m_y_terminal_3_sb->setValue(terminal_3.y()); ui->m_y_terminal_3_sb->setValue(terminal_3.y());
ui->m_height_terminal_3_sb->setValue(terminal_3.height()); ui->m_height_terminal_3_sb->setValue(terminal_3.height());
ui->m_width_terminal_3_sb->setValue(terminal_3.width()); ui->m_width_terminal_3_sb->setValue(terminal_3.width());
const auto bridge_point = data->m_bridge_point_y_offset; const auto bridge_point = data->m_bridge_point_y_offset;
ui->m_bridge_point_0_sb->setValue(bridge_point[0]); ui->m_bridge_point_0_sb->setValue(bridge_point[0]);
ui->m_bridge_point_1_sb->setValue(bridge_point[1]); ui->m_bridge_point_1_sb->setValue(bridge_point[1]);
ui->m_bridge_point_2_sb->setValue(bridge_point[2]); ui->m_bridge_point_2_sb->setValue(bridge_point[2]);
ui->m_bridge_point_3_sb->setValue(bridge_point[3]); ui->m_bridge_point_3_sb->setValue(bridge_point[3]);
if (data->m_header_text_orientation == Qt::Horizontal) { if (data->m_header_text_orientation == Qt::Horizontal) {
ui->m_header_text_orientation_cb->setCurrentIndex(0); ui->m_header_text_orientation_cb->setCurrentIndex(0);
} else { } else {
ui->m_header_text_orientation_cb->setCurrentIndex(1); ui->m_header_text_orientation_cb->setCurrentIndex(1);
} }
if (data->m_terminals_text_orientation[0] == Qt::Horizontal) { if (data->m_terminals_text_orientation[0] == Qt::Horizontal) {
ui->m_terminal_text_orientation_cb->setCurrentIndex(0); ui->m_terminal_text_orientation_cb->setCurrentIndex(0);
} else { } else {
ui->m_terminal_text_orientation_cb->setCurrentIndex(1); ui->m_terminal_text_orientation_cb->setCurrentIndex(1);
} }
const auto header_alignment = data->headerTextAlignment(); const auto header_alignment = data->headerTextAlignment();
if (header_alignment &Qt::AlignLeft) { if (header_alignment &Qt::AlignLeft) {
ui->m_header_text_alignment_cb->setCurrentIndex(0); ui->m_header_text_alignment_cb->setCurrentIndex(0);
} else if (header_alignment &Qt::AlignHCenter) { } else if (header_alignment &Qt::AlignHCenter) {
ui->m_header_text_alignment_cb->setCurrentIndex(1); ui->m_header_text_alignment_cb->setCurrentIndex(1);
} else if (header_alignment &Qt::AlignRight) { } else if (header_alignment &Qt::AlignRight) {
ui->m_header_text_alignment_cb->setCurrentIndex(2); ui->m_header_text_alignment_cb->setCurrentIndex(2);
} }
const auto terminal_alignment = data->terminalsTextAlignment().at(0); const auto terminal_alignment = data->terminalsTextAlignment().at(0);
if (terminal_alignment &Qt::AlignLeft) { if (terminal_alignment &Qt::AlignLeft) {
ui->m_terminal_text_alignment_cb->setCurrentIndex(0); ui->m_terminal_text_alignment_cb->setCurrentIndex(0);
} else if (terminal_alignment &Qt::AlignHCenter) { } else if (terminal_alignment &Qt::AlignHCenter) {
ui->m_terminal_text_alignment_cb->setCurrentIndex(1); ui->m_terminal_text_alignment_cb->setCurrentIndex(1);
} else if (terminal_alignment &Qt::AlignRight) { } else if (terminal_alignment &Qt::AlignRight) {
ui->m_terminal_text_alignment_cb->setCurrentIndex(2); ui->m_terminal_text_alignment_cb->setCurrentIndex(2);
} }
m_ui_updating = false; m_ui_updating = false;
@ -222,7 +222,7 @@ void TerminalStripLayoutEditor::updatePreview()
void TerminalStripLayoutEditor::on_m_display_preview_help_clicked(bool checked) void TerminalStripLayoutEditor::on_m_display_preview_help_clicked(bool checked)
{ {
m_preview_strip_item.m_drawer.setPreviewDraw(checked); m_preview_strip_item.m_drawer.setPreviewDraw(checked);
m_preview_strip_item.update(); m_preview_strip_item.update();
} }

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TERMINALSTRIPLAYOUTEDITOR_H #ifndef TERMINALSTRIPLAYOUTEDITOR_H
#define TERMINALSTRIPLAYOUTEDITOR_H #define TERMINALSTRIPLAYOUTEDITOR_H
@ -27,35 +27,35 @@
class TerminalStripLayoutPattern; class TerminalStripLayoutPattern;
namespace Ui { namespace Ui {
class TerminalStripLayoutEditor; class TerminalStripLayoutEditor;
} }
class PreviewStripItem : public QGraphicsItem class PreviewStripItem : public QGraphicsItem
{ {
friend class TerminalStripLayoutEditor; friend class TerminalStripLayoutEditor;
public: public:
PreviewStripItem (QSharedPointer<TerminalStripLayoutPattern> layout) : PreviewStripItem (QSharedPointer<TerminalStripLayoutPattern> layout) :
m_drawer {QSharedPointer<TerminalStripDrawer::DemoTerminalStrip>{new TerminalStripDrawer::DemoTerminalStrip}, m_drawer {QSharedPointer<TerminalStripDrawer::DemoTerminalStrip>{new TerminalStripDrawer::DemoTerminalStrip},
layout} layout}
{} {}
QRectF boundingRect() const override { QRectF boundingRect() const override {
return m_drawer.boundingRect(); return m_drawer.boundingRect();
} }
protected: protected:
void paint(QPainter *painter, void paint(QPainter *painter,
const QStyleOptionGraphicsItem *option, const QStyleOptionGraphicsItem *option,
QWidget *widget = nullptr) override QWidget *widget = nullptr) override
{ {
Q_UNUSED (option); Q_UNUSED (widget); Q_UNUSED (option); Q_UNUSED (widget);
m_drawer.paint(painter); m_drawer.paint(painter);
} }
private: private:
TerminalStripDrawer::TerminalStripDrawer m_drawer; TerminalStripDrawer::TerminalStripDrawer m_drawer;
}; };
/** /**
* @brief The TerminalStripLayoutEditor class * @brief The TerminalStripLayoutEditor class
@ -63,30 +63,30 @@ class PreviewStripItem : public QGraphicsItem
*/ */
class TerminalStripLayoutEditor : public QWidget class TerminalStripLayoutEditor : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit TerminalStripLayoutEditor(QSharedPointer<TerminalStripLayoutPattern> layout, explicit TerminalStripLayoutEditor(QSharedPointer<TerminalStripLayoutPattern> layout,
QWidget *parent = nullptr); QWidget *parent = nullptr);
~TerminalStripLayoutEditor(); ~TerminalStripLayoutEditor();
protected: protected:
void resizeEvent(QResizeEvent *event) override; void resizeEvent(QResizeEvent *event) override;
void showEvent(QShowEvent *event) override; void showEvent(QShowEvent *event) override;
private slots: private slots:
void valueEdited(); void valueEdited();
void on_m_display_preview_help_clicked(bool checked); void on_m_display_preview_help_clicked(bool checked);
private: private:
void updateUi(); void updateUi();
void updatePreview(); void updatePreview();
private: private:
Ui::TerminalStripLayoutEditor *ui; Ui::TerminalStripLayoutEditor *ui;
QSharedPointer<TerminalStripLayoutPattern> m_layout; QSharedPointer<TerminalStripLayoutPattern> m_layout;
bool m_ui_updating { false } ; bool m_ui_updating { false } ;
PreviewStripItem m_preview_strip_item {m_layout}; PreviewStripItem m_preview_strip_item {m_layout};
}; };

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "terminalstripmodel.h" #include "terminalstripmodel.h"
#include "../terminalstrip.h" #include "../terminalstrip.h"
@ -105,8 +105,8 @@ TerminalStripModel::Column TerminalStripModel::columnTypeForIndex(const QModelIn
* @param parent * @param parent
*/ */
TerminalStripModel::TerminalStripModel(TerminalStrip *terminal_strip, QObject *parent) : TerminalStripModel::TerminalStripModel(TerminalStrip *terminal_strip, QObject *parent) :
QAbstractTableModel(parent), QAbstractTableModel(parent),
m_terminal_strip(terminal_strip) m_terminal_strip(terminal_strip)
{ {
fillPhysicalTerminalData(); fillPhysicalTerminalData();
@ -129,11 +129,11 @@ void TerminalStripModel::setTerminalStrip(TerminalStrip *terminal_strip)
int TerminalStripModel::rowCount(const QModelIndex &parent) const int TerminalStripModel::rowCount(const QModelIndex &parent) const
{ {
Q_UNUSED(parent) Q_UNUSED(parent)
if (!m_terminal_strip) { if (!m_terminal_strip) {
return 0; return 0;
} }
auto count = 0; auto count = 0;
for (const auto &mptd : m_physical_data) { for (const auto &mptd : m_physical_data) {
@ -145,7 +145,7 @@ int TerminalStripModel::rowCount(const QModelIndex &parent) const
int TerminalStripModel::columnCount(const QModelIndex &parent) const int TerminalStripModel::columnCount(const QModelIndex &parent) const
{ {
Q_UNUSED(parent) Q_UNUSED(parent)
return COLUMN_COUNT; return COLUMN_COUNT;
} }
@ -186,7 +186,7 @@ QVariant TerminalStripModel::data(const QModelIndex &index, int role) const
{ {
return mrtd.led_ ? Qt::Checked : Qt::Unchecked; return mrtd.led_ ? Qt::Checked : Qt::Unchecked;
} }
else if (role == Qt::BackgroundRole && index.column() < COLUMN_COUNT ) else if (role == Qt::BackgroundRole && index.column() < COLUMN_COUNT )
{ {
if (m_modified_cell.contains(mrtd.element_) && if (m_modified_cell.contains(mrtd.element_) &&
m_modified_cell.value(mrtd.element_).at(index.column())) m_modified_cell.value(mrtd.element_).at(index.column()))
@ -794,7 +794,7 @@ QWidget *TerminalStripModelDelegate::createEditor(QWidget *parent, const QStyleO
{ {
if (index.column() == TYPE_CELL) { if (index.column() == TYPE_CELL) {
auto qcb = new QComboBox(parent); auto qcb = new QComboBox(parent);
qcb->setObjectName(QStringLiteral("terminal_type")); qcb->setObjectName(QStringLiteral("terminal_type"));
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTGeneric), ElementData::TTGeneric); qcb->addItem(ElementData::translatedTerminalType(ElementData::TTGeneric), ElementData::TTGeneric);
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTFuse), ElementData::TTFuse); qcb->addItem(ElementData::translatedTerminalType(ElementData::TTFuse), ElementData::TTFuse);
qcb->addItem(ElementData::translatedTerminalType(ElementData::TTSectional), ElementData::TTSectional); qcb->addItem(ElementData::translatedTerminalType(ElementData::TTSectional), ElementData::TTSectional);
@ -805,7 +805,7 @@ QWidget *TerminalStripModelDelegate::createEditor(QWidget *parent, const QStyleO
} }
if (index.column() == FUNCTION_CELL) { if (index.column() == FUNCTION_CELL) {
auto qcb = new QComboBox(parent); auto qcb = new QComboBox(parent);
qcb->setObjectName(QStringLiteral("terminal_function")); qcb->setObjectName(QStringLiteral("terminal_function"));
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFGeneric), ElementData::TFGeneric); qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFGeneric), ElementData::TFGeneric);
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFPhase), ElementData::TFPhase); qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFPhase), ElementData::TFPhase);
qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFNeutral), ElementData::TFNeutral); qcb->addItem(ElementData::translatedTerminalFunction(ElementData::TFNeutral), ElementData::TFNeutral);

View File

@ -1,19 +1,19 @@
/* /*
Copyright 2006-2024 The QElectroTech Team Copyright 2006-2024 The QElectroTech Team
This file is part of QElectroTech. This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or the Free Software Foundation, either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
QElectroTech is distributed in the hope that it will be useful, QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>. along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef TERMINALSTRIPMODEL_H #ifndef TERMINALSTRIPMODEL_H
#define TERMINALSTRIPMODEL_H #define TERMINALSTRIPMODEL_H
@ -67,14 +67,14 @@ class TerminalStripModel : public QAbstractTableModel
static int levelForColumn(TerminalStripModel::Column column); static int levelForColumn(TerminalStripModel::Column column);
static TerminalStripModel::Column columnTypeForIndex(const QModelIndex &index); static TerminalStripModel::Column columnTypeForIndex(const QModelIndex &index);
Q_OBJECT Q_OBJECT
public: public:
TerminalStripModel(TerminalStrip *terminal_strip, QObject *parent = nullptr); TerminalStripModel(TerminalStrip *terminal_strip, QObject *parent = nullptr);
void setTerminalStrip(TerminalStrip *terminal_strip); void setTerminalStrip(TerminalStrip *terminal_strip);
virtual int rowCount (const QModelIndex &parent = QModelIndex()) const override; virtual int rowCount (const QModelIndex &parent = QModelIndex()) const override;
virtual int columnCount (const QModelIndex &parent = QModelIndex()) const override; virtual int columnCount (const QModelIndex &parent = QModelIndex()) const override;
virtual QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override; virtual QVariant data (const QModelIndex &index, int role = Qt::DisplayRole) const override;
virtual bool setData (const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override; virtual bool setData (const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override; virtual QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
virtual Qt::ItemFlags flags (const QModelIndex &index) const override; virtual Qt::ItemFlags flags (const QModelIndex &index) const override;
@ -96,8 +96,8 @@ class TerminalStripModel : public QAbstractTableModel
modelRealTerminalData realDataAtIndex(int index) const; modelRealTerminalData realDataAtIndex(int index) const;
QPixmap bridgePixmapFor(const QModelIndex &index) const; QPixmap bridgePixmapFor(const QModelIndex &index) const;
private: private:
QPointer<TerminalStrip> m_terminal_strip; QPointer<TerminalStrip> m_terminal_strip;
QHash<QPointer<Element>, QVector<bool>> m_modified_cell; QHash<QPointer<Element>, QVector<bool>> m_modified_cell;
QVector<modelPhysicalTerminalData> m_physical_data; QVector<modelPhysicalTerminalData> m_physical_data;
struct BridgePixmap struct BridgePixmap

View File

@ -5,16 +5,16 @@
class mytest : public QObject class mytest : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
mytest(); mytest();
~mytest(); ~mytest();
private slots: private slots:
void initTestCase(); void initTestCase();
void cleanupTestCase(); void cleanupTestCase();
void test_case1(); void test_case1();
}; };