mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-05-27 00:49:58 +02:00
xref: add option to hide terminal names in cross-references
Add a new boolean property 'showTerminalName' (default: true) to XRefProperties, with full persistence in XML and QSettings. A new checkbox "Afficher les numéros de bornes dans les Xrefs" is added to the XRefPropertiesWidget in the main display group (not in the cross-only group), so it is active in both Cross and Contacts modes. When unchecked, terminal names are hidden in all three rendering paths: - drawContact() (Contacts mode: NO/NC/SW symbols) - fillCrossRef() (Cross mode: NO and NC columns) - setUpCrossBoundingRect() (Cross mode: bounding rect sizing) Backward compatible: existing project files without the attribute default to showTerminalName=true (no visual change). Files changed: sources/properties/xrefproperties.h sources/properties/xrefproperties.cpp sources/ui/xrefpropertieswidget.ui sources/ui/xrefpropertieswidget.cpp sources/qetgraphicsitem/crossrefitem.cpp
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
XRefProperties::XRefProperties()
|
||||
{
|
||||
m_show_power_ctc = true;
|
||||
m_show_terminal_name = true;
|
||||
m_display = Cross;
|
||||
m_snap_to = Bottom;
|
||||
m_prefix_keys << "power" << "delay" << "switch";
|
||||
@@ -48,6 +49,7 @@ void XRefProperties::toSettings(QSettings &settings,
|
||||
const QString prefix) const
|
||||
{
|
||||
settings.setValue(prefix % "showpowerctc", m_show_power_ctc);
|
||||
settings.setValue(prefix % "showterminalname", m_show_terminal_name);
|
||||
QString display = m_display == Cross? "cross" : "contacts";
|
||||
settings.setValue(prefix % "displayhas", display);
|
||||
QString snap = m_snap_to == Bottom? "bottom" : "label";
|
||||
@@ -78,6 +80,7 @@ void XRefProperties::fromSettings(const QSettings &settings,
|
||||
const QString prefix)
|
||||
{
|
||||
m_show_power_ctc = settings.value(prefix % "showpowerctc", true).toBool();
|
||||
m_show_terminal_name = settings.value(prefix % "showterminalname", true).toBool();
|
||||
QString display = settings.value(prefix % "displayhas", "cross").toString();
|
||||
display == "cross"? m_display = Cross : m_display = Contacts;
|
||||
QString snap = settings.value(prefix % "snapto", "label").toString();
|
||||
@@ -107,6 +110,7 @@ QDomElement XRefProperties::toXml(QDomDocument &xml_document) const
|
||||
xml_element.setAttribute("type", m_key);
|
||||
|
||||
xml_element.setAttribute("showpowerctc", m_show_power_ctc? "true" : "false");
|
||||
xml_element.setAttribute("showterminalname", m_show_terminal_name? "true" : "false");
|
||||
QString display = m_display == Cross? "cross" : "contacts";
|
||||
xml_element.setAttribute("displayhas", display);
|
||||
QString snap = m_snap_to == Bottom? "bottom" : "label";
|
||||
@@ -137,6 +141,7 @@ QDomElement XRefProperties::toXml(QDomDocument &xml_document) const
|
||||
*/
|
||||
bool XRefProperties::fromXml(const QDomElement &xml_element) {
|
||||
m_show_power_ctc = xml_element.attribute("showpowerctc") == "true";
|
||||
m_show_terminal_name = xml_element.attribute("showterminalname", "true") == "true";
|
||||
QString display = xml_element.attribute("displayhas", "cross");
|
||||
display == "cross"? m_display = Cross : m_display = Contacts;
|
||||
QString snap = xml_element.attribute("snapto", "label");
|
||||
@@ -188,6 +193,7 @@ QHash<QString, XRefProperties> XRefProperties::defaultProperties()
|
||||
|
||||
bool XRefProperties::operator ==(const XRefProperties &xrp) const{
|
||||
return (m_show_power_ctc == xrp.m_show_power_ctc
|
||||
&& m_show_terminal_name == xrp.m_show_terminal_name
|
||||
&& m_display == xrp.m_display
|
||||
&& m_snap_to == xrp.m_snap_to
|
||||
&& m_prefix == xrp.m_prefix
|
||||
|
||||
@@ -57,6 +57,9 @@ class XRefProperties : public PropertiesInterface
|
||||
void setShowPowerContac (const bool a) {m_show_power_ctc = a;}
|
||||
bool showPowerContact () const {return m_show_power_ctc;}
|
||||
|
||||
void setShowTerminalName (const bool a) {m_show_terminal_name = a;}
|
||||
bool showTerminalName () const {return m_show_terminal_name;}
|
||||
|
||||
void setDisplayHas (const DisplayHas dh) {m_display = dh;}
|
||||
DisplayHas displayHas () const {return m_display;}
|
||||
|
||||
@@ -81,6 +84,7 @@ class XRefProperties : public PropertiesInterface
|
||||
|
||||
private:
|
||||
bool m_show_power_ctc;
|
||||
bool m_show_terminal_name;
|
||||
DisplayHas m_display;
|
||||
SnapTo m_snap_to;
|
||||
Qt::AlignmentFlag m_xref_pos;
|
||||
|
||||
@@ -575,7 +575,7 @@ void CrossRefItem::setUpCrossBoundingRect(QPainter &painter)
|
||||
}
|
||||
|
||||
QString pos = elementPositionText(elmt, true);
|
||||
if (!tnames.isEmpty())
|
||||
if (!tnames.isEmpty() && m_properties.showTerminalName())
|
||||
return QStringLiteral("[") + tnames.join("-") + QStringLiteral("] ") + pos;
|
||||
return pos;
|
||||
};
|
||||
@@ -808,7 +808,7 @@ QRectF CrossRefItem::drawContact(QPainter &painter, int flags, Element *elmt, in
|
||||
|
||||
// Draw terminal names on each side of the contact symbol
|
||||
// terminal_names[0] on the left, terminal_names[1] on the right
|
||||
if (!terminal_names.isEmpty()) {
|
||||
if (!terminal_names.isEmpty() && m_properties.showTerminalName()) {
|
||||
QFont font = QETApp::diagramTextsFont(4);
|
||||
font.setBold(true);
|
||||
painter.setFont(font);
|
||||
@@ -939,7 +939,7 @@ QRectF CrossRefItem::drawContact(QPainter &painter, int flags, Element *elmt, in
|
||||
// terminal_names[0] = NO side (top left)
|
||||
// terminal_names[1] = NC side (bottom left)
|
||||
// terminal_names[2] = common side (right)
|
||||
if (!terminal_names.isEmpty()) {
|
||||
if (!terminal_names.isEmpty() && m_properties.showTerminalName()) {
|
||||
QFont font = QETApp::diagramTextsFont(4);
|
||||
font.setBold(true);
|
||||
painter.setFont(font);
|
||||
@@ -1102,7 +1102,7 @@ void CrossRefItem::fillCrossRef(QPainter &painter)
|
||||
}
|
||||
}
|
||||
QString terminal_label;
|
||||
if (!tnames.isEmpty())
|
||||
if (!tnames.isEmpty() && m_properties.showTerminalName())
|
||||
terminal_label = QStringLiteral("[") + tnames.join("-") + QStringLiteral("]");
|
||||
|
||||
QString str = elementPositionText(elmt, true);
|
||||
@@ -1184,7 +1184,7 @@ void CrossRefItem::fillCrossRef(QPainter &painter)
|
||||
}
|
||||
}
|
||||
QString terminal_label;
|
||||
if (!tnames_nc.isEmpty())
|
||||
if (!tnames_nc.isEmpty() && m_properties.showTerminalName())
|
||||
terminal_label = QStringLiteral("[") + tnames_nc.join("-") + QStringLiteral("]");
|
||||
|
||||
QString str = elementPositionText(elmt, true);
|
||||
|
||||
@@ -139,6 +139,7 @@ void XRefPropertiesWidget::saveProperties(int index) {
|
||||
else if(ui->m_xrefpos_cb->itemData(ui->m_xrefpos_cb->currentIndex()).toString() == "right") xrp.setXrefPos(Qt::AlignRight);
|
||||
else if(ui->m_xrefpos_cb->itemData(ui->m_xrefpos_cb->currentIndex()).toString() == "alignment") xrp.setXrefPos(Qt::AlignBaseline);
|
||||
xrp.setShowPowerContac(ui->m_show_power_cb->isChecked());
|
||||
xrp.setShowTerminalName(ui->m_show_terminal_name_cb->isChecked());
|
||||
xrp.setPrefix("power", ui->m_power_prefix_le->text());
|
||||
xrp.setPrefix("delay", ui->m_delay_prefix_le->text());
|
||||
xrp.setPrefix("switch", ui->m_switch_prefix_le->text());
|
||||
@@ -190,6 +191,7 @@ void XRefPropertiesWidget::updateDisplay()
|
||||
else if(xrp.getXrefPos() == Qt::AlignBaseline) ui->m_xrefpos_cb->setCurrentIndex(ui->m_xrefpos_cb->findData("alignment"));
|
||||
else if(xrp.getXrefPos() == Qt::AlignBottom) ui->m_xrefpos_cb->setCurrentIndex(ui->m_xrefpos_cb->findData("bottom"));
|
||||
ui->m_show_power_cb->setChecked(xrp.showPowerContact());
|
||||
ui->m_show_terminal_name_cb->setChecked(xrp.showTerminalName());
|
||||
ui->m_power_prefix_le-> setText(xrp.prefix("power"));
|
||||
ui->m_delay_prefix_le-> setText(xrp.prefix("delay"));
|
||||
ui->m_switch_prefix_le->setText(xrp.prefix("switch"));
|
||||
|
||||
@@ -108,6 +108,13 @@
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="m_show_terminal_name_cb">
|
||||
<property name="text">
|
||||
<string>Afficher les numéros de bornes dans les Xrefs</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_display_has_contacts_rb">
|
||||
<property name="text">
|
||||
@@ -283,6 +290,7 @@
|
||||
<tabstop>m_master_le</tabstop>
|
||||
<tabstop>m_slave_le</tabstop>
|
||||
<tabstop>m_show_power_cb</tabstop>
|
||||
<tabstop>m_show_terminal_name_cb</tabstop>
|
||||
<tabstop>m_power_prefix_le</tabstop>
|
||||
<tabstop>m_delay_prefix_le</tabstop>
|
||||
<tabstop>m_switch_prefix_le</tabstop>
|
||||
|
||||
Reference in New Issue
Block a user