mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-01-08 06:42:34 +01:00
fixed indentations of the remaining *.cpp/*.h files
This commit is contained in:
@@ -83,8 +83,8 @@ class TerminalStripLayoutPattern
|
||||
int m_bridge_point_d{5};
|
||||
QVector<int> m_bridge_point_y_offset{50,70,90,110};
|
||||
|
||||
QUuid m_uuid{QUuid::createUuid()};
|
||||
QString m_name;
|
||||
QUuid m_uuid{QUuid::createUuid()};
|
||||
QString m_name;
|
||||
|
||||
private:
|
||||
void updateHeaderTextOption();
|
||||
|
||||
@@ -26,9 +26,9 @@ namespace TerminalStripDrawer {
|
||||
* @param pattern
|
||||
*/
|
||||
TerminalStripDrawer::TerminalStripDrawer(QSharedPointer<AbstractTerminalStripInterface> strip,
|
||||
QSharedPointer<TerminalStripLayoutPattern> layout) :
|
||||
m_strip { strip },
|
||||
m_pattern { layout }
|
||||
QSharedPointer<TerminalStripLayoutPattern> layout) :
|
||||
m_strip { strip },
|
||||
m_pattern { layout }
|
||||
{}
|
||||
|
||||
void TerminalStripDrawer::setStrip(QSharedPointer<AbstractTerminalStripInterface> strip)
|
||||
@@ -42,248 +42,248 @@ void TerminalStripDrawer::setStrip(QSharedPointer<AbstractTerminalStripInterface
|
||||
*/
|
||||
void TerminalStripDrawer::paint(QPainter *painter)
|
||||
{
|
||||
if (m_strip && m_pattern)
|
||||
{
|
||||
//To draw text, QPainter need a Qrect. Instead of create an instance
|
||||
//for each text, we re-use the same instance of QRect.
|
||||
QRect text_rect;
|
||||
painter->save();
|
||||
if (m_strip && m_pattern)
|
||||
{
|
||||
//To draw text, QPainter need a Qrect. Instead of create an instance
|
||||
//for each text, we re-use the same instance of QRect.
|
||||
QRect text_rect;
|
||||
painter->save();
|
||||
|
||||
auto pen_{painter->pen()};
|
||||
pen_.setColor(Qt::black);
|
||||
pen_.setWidth(1);
|
||||
auto pen_{painter->pen()};
|
||||
pen_.setColor(Qt::black);
|
||||
pen_.setWidth(1);
|
||||
|
||||
auto brush_ = painter->brush();
|
||||
brush_.setColor(Qt::white);
|
||||
auto brush_ = painter->brush();
|
||||
brush_.setColor(Qt::white);
|
||||
|
||||
painter->setPen(pen_);
|
||||
painter->setBrush(brush_);
|
||||
painter->setPen(pen_);
|
||||
painter->setBrush(brush_);
|
||||
|
||||
if (m_preview_draw)
|
||||
{
|
||||
painter->save();
|
||||
painter->setPen(Qt::blue);
|
||||
painter->drawRect(boundingRect());
|
||||
painter->restore();
|
||||
}
|
||||
if (m_preview_draw)
|
||||
{
|
||||
painter->save();
|
||||
painter->setPen(Qt::blue);
|
||||
painter->drawRect(boundingRect());
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
//Draw header
|
||||
painter->drawRect(m_pattern->m_header_rect);
|
||||
//Draw header
|
||||
painter->drawRect(m_pattern->m_header_rect);
|
||||
|
||||
//Draw the header text
|
||||
painter->save();
|
||||
//Draw the header text
|
||||
painter->save();
|
||||
|
||||
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());
|
||||
}
|
||||
else
|
||||
{
|
||||
painter->translate(m_pattern->m_header_rect.bottomLeft());
|
||||
painter->rotate(270);
|
||||
text_rect.setRect(0,0,m_pattern->m_header_rect.height(),m_pattern->m_header_rect.width());
|
||||
}
|
||||
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());
|
||||
}
|
||||
else
|
||||
{
|
||||
painter->translate(m_pattern->m_header_rect.bottomLeft());
|
||||
painter->rotate(270);
|
||||
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()};
|
||||
painter->drawText(text_rect, text_, m_pattern->headerTextOption());
|
||||
painter->restore();
|
||||
const auto text_{m_strip->installation() + " " + m_strip->location() + " " + m_strip->name()};
|
||||
painter->drawText(text_rect, text_, m_pattern->headerTextOption());
|
||||
painter->restore();
|
||||
|
||||
//Move painter pos to next drawing
|
||||
painter->translate(m_pattern->m_header_rect.width(),0);
|
||||
//Move painter pos to next drawing
|
||||
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
|
||||
painter->drawRect(m_pattern->m_spacer_rect);
|
||||
//Move painter pos to next drawing
|
||||
painter->translate(m_pattern->m_spacer_rect.width(),0);
|
||||
x_offset += m_pattern->m_spacer_rect.width();
|
||||
//Draw spacer
|
||||
painter->drawRect(m_pattern->m_spacer_rect);
|
||||
//Move painter pos to next drawing
|
||||
painter->translate(m_pattern->m_spacer_rect.width(),0);
|
||||
x_offset += m_pattern->m_spacer_rect.width();
|
||||
|
||||
|
||||
//Draw terminals
|
||||
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_option{m_pattern->terminalsTextOption()};
|
||||
QRect terminal_rect;
|
||||
//Draw terminals
|
||||
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_option{m_pattern->terminalsTextOption()};
|
||||
QRect terminal_rect;
|
||||
|
||||
QHash<QUuid, QVector<QPointF>> bridges_anchor_points;
|
||||
QHash<QUuid, QVector<QPointF>> bridges_anchor_points;
|
||||
|
||||
//Loop over physical terminals
|
||||
for (const auto &physical_t : m_strip->physicalTerminal())
|
||||
{
|
||||
//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 auto real_t_count{real_terminal_vector.size()};
|
||||
const auto offset_{4 - real_t_count};
|
||||
//Loop over physical terminals
|
||||
for (const auto &physical_t : m_strip->physicalTerminal())
|
||||
{
|
||||
//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 auto real_t_count{real_terminal_vector.size()};
|
||||
const auto offset_{4 - real_t_count};
|
||||
|
||||
//Loop over real terminals
|
||||
for (auto i=0 ; i<real_t_count ; ++i)
|
||||
{
|
||||
const auto index_ = offset_ + i;
|
||||
if (index_ >= 4) {
|
||||
break;
|
||||
}
|
||||
//Loop over real terminals
|
||||
for (auto i=0 ; i<real_t_count ; ++i)
|
||||
{
|
||||
const auto index_ = offset_ + i;
|
||||
if (index_ >= 4) {
|
||||
break;
|
||||
}
|
||||
|
||||
terminal_rect = m_pattern->m_terminal_rect[index_];
|
||||
//Draw terminal rect
|
||||
painter->drawRect(terminal_rect);
|
||||
//Draw a stronger line if the current terminal have level
|
||||
//and the current level is the first
|
||||
if (real_t_count > 1 && i == 0)
|
||||
{
|
||||
painter->save();
|
||||
pen_ = painter->pen();
|
||||
pen_.setWidth(4);
|
||||
pen_.setCapStyle(Qt::FlatCap);
|
||||
painter->setPen(pen_);
|
||||
const auto p1 { terminal_rect.topLeft() };
|
||||
//We can't use terminal_rect.bottomLeft for p2 because
|
||||
//the returned value deviate from the true value
|
||||
//(see Qt documentation about QRect)
|
||||
const QPoint p2 { p1.x(), p1.y() + terminal_rect.height() };
|
||||
painter->drawLine(p1, p2);
|
||||
painter->restore();
|
||||
}
|
||||
terminal_rect = m_pattern->m_terminal_rect[index_];
|
||||
//Draw terminal rect
|
||||
painter->drawRect(terminal_rect);
|
||||
//Draw a stronger line if the current terminal have level
|
||||
//and the current level is the first
|
||||
if (real_t_count > 1 && i == 0)
|
||||
{
|
||||
painter->save();
|
||||
pen_ = painter->pen();
|
||||
pen_.setWidth(4);
|
||||
pen_.setCapStyle(Qt::FlatCap);
|
||||
painter->setPen(pen_);
|
||||
const auto p1 { terminal_rect.topLeft() };
|
||||
//We can't use terminal_rect.bottomLeft for p2 because
|
||||
//the returned value deviate from the true value
|
||||
//(see Qt documentation about QRect)
|
||||
const QPoint p2 { p1.x(), p1.y() + terminal_rect.height() };
|
||||
painter->drawLine(p1, p2);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
//Draw text
|
||||
painter->save();
|
||||
if (terminals_text_orientation[index_] == Qt::Horizontal)
|
||||
{
|
||||
text_rect = terminals_text_rect[index_];
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto rect_{terminals_text_rect[index_]};
|
||||
painter->translate(rect_.bottomLeft());
|
||||
painter->rotate(270);
|
||||
text_rect.setRect(0, 0, rect_.height(), terminal_rect.width());
|
||||
}
|
||||
//Draw text
|
||||
painter->save();
|
||||
if (terminals_text_orientation[index_] == Qt::Horizontal)
|
||||
{
|
||||
text_rect = terminals_text_rect[index_];
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto rect_{terminals_text_rect[index_]};
|
||||
painter->translate(rect_.bottomLeft());
|
||||
painter->rotate(270);
|
||||
text_rect.setRect(0, 0, rect_.height(), terminal_rect.width());
|
||||
}
|
||||
|
||||
const auto shared_real_terminal{real_terminal_vector[i]};
|
||||
painter->drawText(text_rect,
|
||||
shared_real_terminal ? shared_real_terminal->label() : QLatin1String(),
|
||||
terminals_text_option[index_]);
|
||||
const auto shared_real_terminal{real_terminal_vector[i]};
|
||||
painter->drawText(text_rect,
|
||||
shared_real_terminal ? shared_real_terminal->label() : QLatin1String(),
|
||||
terminals_text_option[index_]);
|
||||
|
||||
if (m_preview_draw)
|
||||
{
|
||||
painter->setPen(Qt::blue);
|
||||
painter->drawRect(text_rect);
|
||||
}
|
||||
if (m_preview_draw)
|
||||
{
|
||||
painter->setPen(Qt::blue);
|
||||
painter->drawRect(text_rect);
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
painter->restore();
|
||||
|
||||
//Add bridge anchor
|
||||
if (shared_real_terminal->isBridged())
|
||||
{
|
||||
painter->save();
|
||||
if (QScopedPointer<AbstractBridgeInterface> bridge_ {
|
||||
shared_real_terminal->bridge() })
|
||||
{
|
||||
const auto x_anchor{terminal_rect.width()/2};
|
||||
const auto y_anchor {m_pattern->m_bridge_point_y_offset[index_]};
|
||||
const auto radius_anchor{m_pattern->m_bridge_point_d/2};
|
||||
//Add bridge anchor
|
||||
if (shared_real_terminal->isBridged())
|
||||
{
|
||||
painter->save();
|
||||
if (QScopedPointer<AbstractBridgeInterface> bridge_ {
|
||||
shared_real_terminal->bridge() })
|
||||
{
|
||||
const auto x_anchor{terminal_rect.width()/2};
|
||||
const auto y_anchor {m_pattern->m_bridge_point_y_offset[index_]};
|
||||
const auto radius_anchor{m_pattern->m_bridge_point_d/2};
|
||||
|
||||
painter->setBrush(Qt::SolidPattern);
|
||||
painter->drawEllipse(QPointF(x_anchor, y_anchor),
|
||||
radius_anchor, radius_anchor);
|
||||
painter->setBrush(Qt::SolidPattern);
|
||||
painter->drawEllipse(QPointF(x_anchor, y_anchor),
|
||||
radius_anchor, radius_anchor);
|
||||
|
||||
auto anchor_points{bridges_anchor_points.value(bridge_->uuid())};
|
||||
anchor_points.append(QPointF(x_offset + x_anchor, y_anchor));
|
||||
bridges_anchor_points.insert(bridge_->uuid(), anchor_points);
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
auto anchor_points{bridges_anchor_points.value(bridge_->uuid())};
|
||||
anchor_points.append(QPointF(x_offset + x_anchor, y_anchor));
|
||||
bridges_anchor_points.insert(bridge_->uuid(), anchor_points);
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
//Move painter pos to next drawing
|
||||
painter->translate(terminal_rect.width(),0);
|
||||
x_offset += terminal_rect.width();
|
||||
}
|
||||
}
|
||||
painter->restore();
|
||||
//Move painter pos to next drawing
|
||||
painter->translate(terminal_rect.width(),0);
|
||||
x_offset += terminal_rect.width();
|
||||
}
|
||||
}
|
||||
painter->restore();
|
||||
|
||||
//Draw the bridges
|
||||
for (const auto &points_ : qAsConst(bridges_anchor_points))
|
||||
{
|
||||
painter->save();
|
||||
auto pen_{painter->pen()};
|
||||
pen_.setWidth(2);
|
||||
painter->setPen(pen_);
|
||||
painter->drawPolyline(QPolygonF{points_});
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
//Draw the bridges
|
||||
for (const auto &points_ : qAsConst(bridges_anchor_points))
|
||||
{
|
||||
painter->save();
|
||||
auto pen_{painter->pen()};
|
||||
pen_.setWidth(2);
|
||||
painter->setPen(pen_);
|
||||
painter->drawPolyline(QPolygonF{points_});
|
||||
painter->restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QRectF TerminalStripDrawer::boundingRect() const
|
||||
{
|
||||
return QRect{0, 0, width(), height()};;
|
||||
return QRect{0, 0, width(), height()};;
|
||||
}
|
||||
|
||||
void TerminalStripDrawer::setLayout(QSharedPointer<TerminalStripLayoutPattern> layout)
|
||||
{
|
||||
m_pattern = layout;
|
||||
m_pattern = layout;
|
||||
}
|
||||
|
||||
bool TerminalStripDrawer::haveLayout() const
|
||||
{
|
||||
return !m_pattern.isNull();
|
||||
return !m_pattern.isNull();
|
||||
}
|
||||
|
||||
void TerminalStripDrawer::setPreviewDraw(bool draw) {
|
||||
m_preview_draw = draw;
|
||||
m_preview_draw = draw;
|
||||
}
|
||||
|
||||
int TerminalStripDrawer::height() const
|
||||
{
|
||||
if (m_pattern)
|
||||
{
|
||||
auto height_{m_pattern->m_header_rect.y() + m_pattern->m_header_rect.height()};
|
||||
if (m_pattern)
|
||||
{
|
||||
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) {
|
||||
height_ = std::max(height_, rect.y() + rect.height());
|
||||
}
|
||||
for (const auto &rect : m_pattern->m_terminal_rect) {
|
||||
height_ = std::max(height_, rect.y() + rect.height());
|
||||
}
|
||||
|
||||
return height_;
|
||||
}
|
||||
return height_;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int TerminalStripDrawer::width() const
|
||||
{
|
||||
if (m_pattern)
|
||||
{
|
||||
int width_{m_pattern->m_header_rect.width() + m_pattern->m_spacer_rect.width()};
|
||||
if (m_pattern)
|
||||
{
|
||||
int width_{m_pattern->m_header_rect.width() + m_pattern->m_spacer_rect.width()};
|
||||
|
||||
if (m_strip)
|
||||
{
|
||||
//Loop over physical terminals
|
||||
for (const auto &physical_t : m_strip->physicalTerminal())
|
||||
{
|
||||
//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 auto real_t_count{real_terminal_vector.size()};
|
||||
const auto offset_{4 - real_t_count};
|
||||
if (m_strip)
|
||||
{
|
||||
//Loop over physical terminals
|
||||
for (const auto &physical_t : m_strip->physicalTerminal())
|
||||
{
|
||||
//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 auto real_t_count{real_terminal_vector.size()};
|
||||
const auto offset_{4 - real_t_count};
|
||||
|
||||
//Loop over real terminals
|
||||
for (auto i=0 ; i<real_t_count ; ++i)
|
||||
{
|
||||
const auto index_ = offset_ + i;
|
||||
if (index_ >= 4) {
|
||||
break;
|
||||
}
|
||||
//Loop over real terminals
|
||||
for (auto i=0 ; i<real_t_count ; ++i)
|
||||
{
|
||||
const auto index_ = offset_ + i;
|
||||
if (index_ >= 4) {
|
||||
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
|
||||
|
||||
@@ -26,35 +26,35 @@
|
||||
#include "trueterminalstrip.h"
|
||||
|
||||
TerminalStripItem::TerminalStripItem(QPointer<TerminalStrip> strip,
|
||||
QGraphicsItem *parent) :
|
||||
QetGraphicsItem { parent },
|
||||
m_strip { strip },
|
||||
m_drawer { QSharedPointer<TerminalStripDrawer::TrueTerminalStrip> {
|
||||
QGraphicsItem *parent) :
|
||||
QetGraphicsItem { parent },
|
||||
m_strip { strip },
|
||||
m_drawer { QSharedPointer<TerminalStripDrawer::TrueTerminalStrip> {
|
||||
new TerminalStripDrawer::TrueTerminalStrip { strip }}
|
||||
}
|
||||
{
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
setAcceptHoverEvents(true);
|
||||
setDefaultLayout();
|
||||
setAcceptHoverEvents(true);
|
||||
setDefaultLayout();
|
||||
}
|
||||
|
||||
TerminalStripItem::TerminalStripItem(QGraphicsItem *parent) :
|
||||
QetGraphicsItem { parent }
|
||||
QetGraphicsItem { parent }
|
||||
{
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
setAcceptHoverEvents(true);
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
|
||||
void TerminalStripItem::setTerminalStrip(TerminalStrip *strip)
|
||||
{
|
||||
m_strip = strip;
|
||||
m_drawer.setStrip(QSharedPointer<TerminalStripDrawer::TrueTerminalStrip> {
|
||||
new TerminalStripDrawer::TrueTerminalStrip { strip }});
|
||||
m_pending_strip_uuid = QUuid();
|
||||
m_strip = strip;
|
||||
m_drawer.setStrip(QSharedPointer<TerminalStripDrawer::TrueTerminalStrip> {
|
||||
new TerminalStripDrawer::TrueTerminalStrip { strip }});
|
||||
m_pending_strip_uuid = QUuid();
|
||||
|
||||
if (!m_drawer.haveLayout()) {
|
||||
setDefaultLayout();
|
||||
}
|
||||
if (!m_drawer.haveLayout()) {
|
||||
setDefaultLayout();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +62,7 @@ void TerminalStripItem::setTerminalStrip(TerminalStrip *strip)
|
||||
* @return The strip drawed by this item
|
||||
*/
|
||||
QPointer<TerminalStrip> TerminalStripItem::terminalStrip() const {
|
||||
return m_strip;
|
||||
return m_strip;
|
||||
}
|
||||
|
||||
void TerminalStripItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
@@ -91,42 +91,42 @@ QRectF TerminalStripItem::boundingRect() const
|
||||
* @return usual name of this item
|
||||
*/
|
||||
QString TerminalStripItem::name() const {
|
||||
return tr("plan de bornes");
|
||||
return tr("plan de bornes");
|
||||
}
|
||||
|
||||
void TerminalStripItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
Q_UNUSED (event);
|
||||
Q_UNUSED (event);
|
||||
|
||||
if (m_strip) {
|
||||
TerminalStripEditorWindow::edit(m_strip);
|
||||
}
|
||||
if (m_strip) {
|
||||
TerminalStripEditorWindow::edit(m_strip);
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalStripItem::refreshPending()
|
||||
{
|
||||
if (!m_pending_strip_uuid.isNull()
|
||||
&& diagram()
|
||||
&& diagram()->project())
|
||||
{
|
||||
for (const auto &strip_ : diagram()->project()->terminalStrip()) {
|
||||
if (strip_->uuid() == m_pending_strip_uuid) {
|
||||
setTerminalStrip(strip_);
|
||||
m_pending_strip_uuid = QUuid();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!m_pending_strip_uuid.isNull()
|
||||
&& diagram()
|
||||
&& diagram()->project())
|
||||
{
|
||||
for (const auto &strip_ : diagram()->project()->terminalStrip()) {
|
||||
if (strip_->uuid() == m_pending_strip_uuid) {
|
||||
setTerminalStrip(strip_);
|
||||
m_pending_strip_uuid = QUuid();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TerminalStripItem::setLayout(QSharedPointer<TerminalStripLayoutPattern> layout)
|
||||
{
|
||||
m_drawer.setLayout(layout);
|
||||
m_drawer.setLayout(layout);
|
||||
}
|
||||
|
||||
void TerminalStripItem::setDefaultLayout()
|
||||
{
|
||||
if (m_strip && m_strip->project()) {
|
||||
m_drawer.setLayout(m_strip->project()->projectPropertiesHandler().terminalStripLayoutHandler().defaultLayout());
|
||||
}
|
||||
if (m_strip && m_strip->project()) {
|
||||
m_drawer.setLayout(m_strip->project()->projectPropertiesHandler().terminalStripLayoutHandler().defaultLayout());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,16 +28,16 @@ class TerminalStrip;
|
||||
|
||||
class TerminalStripItem : public QetGraphicsItem
|
||||
{
|
||||
friend class TerminalStripItemXml;
|
||||
friend class TerminalStripItemXml;
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TerminalStripItem(QPointer<TerminalStrip> strip, QGraphicsItem *parent = nullptr);
|
||||
TerminalStripItem(QGraphicsItem *parent = nullptr);
|
||||
TerminalStripItem(QGraphicsItem *parent = nullptr);
|
||||
|
||||
void setTerminalStrip(TerminalStrip *strip);
|
||||
QPointer<TerminalStrip> terminalStrip() const;
|
||||
void setTerminalStrip(TerminalStrip *strip);
|
||||
QPointer<TerminalStrip> terminalStrip() const;
|
||||
|
||||
enum {Type = UserType + 1011};
|
||||
int type() const override {return Type;}
|
||||
@@ -46,17 +46,17 @@ class TerminalStripItem : public QetGraphicsItem
|
||||
QRectF boundingRect() const override;
|
||||
QString name() const override;
|
||||
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void refreshPending();
|
||||
void setLayout(QSharedPointer<TerminalStripLayoutPattern> layout);
|
||||
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void refreshPending();
|
||||
void setLayout(QSharedPointer<TerminalStripLayoutPattern> layout);
|
||||
|
||||
private:
|
||||
void setDefaultLayout();
|
||||
private:
|
||||
void setDefaultLayout();
|
||||
|
||||
private:
|
||||
QPointer<TerminalStrip> m_strip;
|
||||
TerminalStripDrawer::TerminalStripDrawer m_drawer;
|
||||
QUuid m_pending_strip_uuid;
|
||||
TerminalStripDrawer::TerminalStripDrawer m_drawer;
|
||||
QUuid m_pending_strip_uuid;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -25,109 +25,109 @@
|
||||
|
||||
namespace TerminalStripDrawer
|
||||
{
|
||||
/**
|
||||
* @brief TrueTerminalStrip::TrueTerminalStrip
|
||||
* Constructor, this class don't take ownership of @a strip
|
||||
* @param strip
|
||||
*/
|
||||
TrueTerminalStrip::TrueTerminalStrip(TerminalStrip *strip) :
|
||||
m_strip { strip }
|
||||
{}
|
||||
/**
|
||||
* @brief TrueTerminalStrip::TrueTerminalStrip
|
||||
* Constructor, this class don't take ownership of @a strip
|
||||
* @param strip
|
||||
*/
|
||||
TrueTerminalStrip::TrueTerminalStrip(TerminalStrip *strip) :
|
||||
m_strip { strip }
|
||||
{}
|
||||
|
||||
|
||||
QString TrueTerminalStrip::installation() const
|
||||
{
|
||||
if (m_strip) {
|
||||
return m_strip->installation();
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
QString TrueTerminalStrip::installation() const
|
||||
{
|
||||
if (m_strip) {
|
||||
return m_strip->installation();
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString TrueTerminalStrip::location() const
|
||||
{
|
||||
if (m_strip) {
|
||||
return m_strip->location();
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
QString TrueTerminalStrip::location() const
|
||||
{
|
||||
if (m_strip) {
|
||||
return m_strip->location();
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QString TrueTerminalStrip::name() const
|
||||
{
|
||||
if (m_strip) {
|
||||
return m_strip->name();
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
QString TrueTerminalStrip::name() const
|
||||
{
|
||||
if (m_strip) {
|
||||
return m_strip->name();
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QVector<QSharedPointer<AbstractPhysicalTerminalInterface>> TrueTerminalStrip::physicalTerminal() const
|
||||
{
|
||||
QVector<QSharedPointer<AbstractPhysicalTerminalInterface>> vector_;
|
||||
if (m_strip) {
|
||||
for (const auto &phy : m_strip->physicalTerminal()) {
|
||||
vector_.append(QSharedPointer<AbstractPhysicalTerminalInterface>{ new TruePhysicalTerminal(phy) });
|
||||
}
|
||||
}
|
||||
QVector<QSharedPointer<AbstractPhysicalTerminalInterface>> TrueTerminalStrip::physicalTerminal() const
|
||||
{
|
||||
QVector<QSharedPointer<AbstractPhysicalTerminalInterface>> vector_;
|
||||
if (m_strip) {
|
||||
for (const auto &phy : m_strip->physicalTerminal()) {
|
||||
vector_.append(QSharedPointer<AbstractPhysicalTerminalInterface>{ new TruePhysicalTerminal(phy) });
|
||||
}
|
||||
}
|
||||
|
||||
return vector_;
|
||||
}
|
||||
return vector_;
|
||||
}
|
||||
|
||||
TruePhysicalTerminal::TruePhysicalTerminal(QSharedPointer<PhysicalTerminal> physical) :
|
||||
m_physical { physical }
|
||||
{}
|
||||
TruePhysicalTerminal::TruePhysicalTerminal(QSharedPointer<PhysicalTerminal> physical) :
|
||||
m_physical { physical }
|
||||
{}
|
||||
|
||||
QVector<QSharedPointer<AbstractRealTerminalInterface>> TruePhysicalTerminal::realTerminals() const
|
||||
{
|
||||
QVector<QSharedPointer<AbstractRealTerminalInterface>> vector_;
|
||||
if (m_physical) {
|
||||
for (const auto &real_ : m_physical->realTerminals()) {
|
||||
vector_.append(QSharedPointer<AbstractRealTerminalInterface> { new TrueRealTerminal{ real_ }});
|
||||
}
|
||||
}
|
||||
QVector<QSharedPointer<AbstractRealTerminalInterface>> TruePhysicalTerminal::realTerminals() const
|
||||
{
|
||||
QVector<QSharedPointer<AbstractRealTerminalInterface>> vector_;
|
||||
if (m_physical) {
|
||||
for (const auto &real_ : m_physical->realTerminals()) {
|
||||
vector_.append(QSharedPointer<AbstractRealTerminalInterface> { new TrueRealTerminal{ real_ }});
|
||||
}
|
||||
}
|
||||
|
||||
return vector_;
|
||||
}
|
||||
return vector_;
|
||||
}
|
||||
|
||||
TrueRealTerminal::TrueRealTerminal(QSharedPointer<RealTerminal> real) :
|
||||
m_real { real }
|
||||
{}
|
||||
TrueRealTerminal::TrueRealTerminal(QSharedPointer<RealTerminal> real) :
|
||||
m_real { real }
|
||||
{}
|
||||
|
||||
QString TrueRealTerminal::label() const
|
||||
{
|
||||
if (m_real) {
|
||||
return m_real->label();
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
QString TrueRealTerminal::label() const
|
||||
{
|
||||
if (m_real) {
|
||||
return m_real->label();
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
bool TrueRealTerminal::isBridged() const
|
||||
{
|
||||
if (m_real) {
|
||||
return m_real->isBridged();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool TrueRealTerminal::isBridged() const
|
||||
{
|
||||
if (m_real) {
|
||||
return m_real->isBridged();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Return a raw pointer, the pointer is not managed by this class
|
||||
AbstractBridgeInterface* TrueRealTerminal::bridge() const
|
||||
{
|
||||
return new TrueBridge(m_real->bridge());
|
||||
}
|
||||
//Return a raw pointer, the pointer is not managed by this class
|
||||
AbstractBridgeInterface* TrueRealTerminal::bridge() const
|
||||
{
|
||||
return new TrueBridge(m_real->bridge());
|
||||
}
|
||||
|
||||
TrueBridge::TrueBridge(QSharedPointer<TerminalStripBridge> bridge) :
|
||||
m_bridge { bridge }
|
||||
{}
|
||||
TrueBridge::TrueBridge(QSharedPointer<TerminalStripBridge> bridge) :
|
||||
m_bridge { bridge }
|
||||
{}
|
||||
|
||||
QUuid TrueBridge::uuid() const
|
||||
{
|
||||
if (m_bridge) {
|
||||
return m_bridge->uuid();
|
||||
} else {
|
||||
return QUuid();
|
||||
}
|
||||
}
|
||||
QUuid TrueBridge::uuid() const
|
||||
{
|
||||
if (m_bridge) {
|
||||
return m_bridge->uuid();
|
||||
} else {
|
||||
return QUuid();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user