mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Add 'Other' option for slave device contact type
This option alows for displaying XRef without contact drawing. This is useful for spliting one physical part into multiple logical elements when the slave element is not a switch.
This commit is contained in:
committed by
Laurent Trinques
parent
f603b229db
commit
1a2fea84ff
@@ -128,6 +128,7 @@ void ElementPropertiesEditorWidget::setUpInterface()
|
||||
ui->m_state_cb->addItem(tr("Normalement ouvert"), ElementData::NO);
|
||||
ui->m_state_cb->addItem(tr("Normalement fermé"), ElementData::NC);
|
||||
ui->m_state_cb->addItem(tr("Inverseur"), ElementData::SW);
|
||||
ui->m_state_cb->addItem(tr("Other"), ElementData::Other);
|
||||
ui->m_type_cb->addItem(tr("Simple"), ElementData::SSimple);
|
||||
ui->m_type_cb->addItem(tr("Puissance"), ElementData::Power);
|
||||
ui->m_type_cb->addItem(tr("Temporisé travail"), ElementData::DelayOn);
|
||||
|
||||
@@ -425,6 +425,8 @@ QString ElementData::slaveStateToString(ElementData::SlaveState type)
|
||||
return QStringLiteral("NC");
|
||||
case SW:
|
||||
return QStringLiteral("SW");
|
||||
case Other:
|
||||
return QStringLiteral("Other");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -436,6 +438,8 @@ ElementData::SlaveState ElementData::slaveStateFromString(const QString &string)
|
||||
return ElementData::NC;
|
||||
} else if (string == QLatin1String("SW")) {
|
||||
return ElementData::SW;
|
||||
} else if (string == QLatin1String("Other")){
|
||||
return ElementData::Other;
|
||||
}
|
||||
|
||||
qDebug() << "ElementData::slaveStateFromString : string : "
|
||||
|
||||
@@ -64,7 +64,8 @@ class ElementData : public PropertiesInterface
|
||||
enum SlaveState {
|
||||
NO,
|
||||
NC,
|
||||
SW
|
||||
SW,
|
||||
Other
|
||||
};
|
||||
Q_ENUM(SlaveState)
|
||||
|
||||
|
||||
@@ -614,6 +614,7 @@ void CrossRefItem::drawAsContacts(QPainter &painter)
|
||||
if (state == "NO") option = NO;
|
||||
else if (state == "NC") option = NC;
|
||||
else if (state == "SW") option = SW;
|
||||
else if (state == "Other") option = Other;
|
||||
|
||||
QString type = info["type"].toString();
|
||||
if (type == "power") option += Power;
|
||||
@@ -644,7 +645,7 @@ QRectF CrossRefItem::drawContact(QPainter &painter, int flags, Element *elmt)
|
||||
{
|
||||
QString str = elementPositionText(elmt);
|
||||
int offset = m_drawed_contacts*10;
|
||||
QRectF bounding_rect;
|
||||
QRectF bounding_rect = QRectF(0, offset, 24, 10);
|
||||
|
||||
QPen pen = painter.pen();
|
||||
m_hovered_contact == elmt ? pen.setColor(Qt::blue) :pen.setColor(Qt::black);
|
||||
@@ -819,6 +820,23 @@ QRectF CrossRefItem::drawContact(QPainter &painter, int flags, Element *elmt)
|
||||
|
||||
//a switch contact take place of two normal contact
|
||||
m_drawed_contacts += 2;
|
||||
}else if(flags &Other){
|
||||
//Draw position text
|
||||
QRectF text_rect = painter.boundingRect(
|
||||
QRectF(30, offset+5, 5, 10),
|
||||
Qt::AlignLeft | Qt::AlignVCenter,
|
||||
str);
|
||||
painter.drawText(text_rect,
|
||||
Qt::AlignLeft | Qt::AlignVCenter,
|
||||
str);
|
||||
bounding_rect = bounding_rect.united(text_rect);
|
||||
|
||||
if (m_hovered_contacts_map.contains(elmt)) {
|
||||
m_hovered_contacts_map.insert(elmt, bounding_rect);
|
||||
}
|
||||
else {
|
||||
m_hovered_contacts_map.insert(elmt, bounding_rect);
|
||||
}
|
||||
}
|
||||
|
||||
return bounding_rect;
|
||||
|
||||
@@ -75,7 +75,8 @@ class CrossRefItem : public QGraphicsObject
|
||||
DelayOn = 16,
|
||||
DelayOff = 32,
|
||||
DelayOnOff = 64,
|
||||
Delay = 112
|
||||
Delay = 112,
|
||||
Other = 128
|
||||
};
|
||||
|
||||
QRectF boundingRect() const override;
|
||||
|
||||
Reference in New Issue
Block a user