Revert "Add cable management: drawing, cores, numbering, cross-references and cable list"

This commit is contained in:
Laurent Trinques
2026-10-10 16:49:39 +02:00
committed by GitHub
parent 738ffbfc36
commit 2bb3343d2d
113 changed files with 209 additions and 18793 deletions
+2 -108
View File
@@ -17,16 +17,12 @@
*/
#include <utility>
#include <QFontDialog>
#include <QHash>
#include <QMetaEnum>
#include <QPushButton>
#include "xrefpropertieswidget.h"
#include "ui_xrefpropertieswidget.h"
#include "qdebug.h"
#include "../qetapp.h"
#include "../utils/qetutils.h"
/**
@brief XRefPropertiesWidget::XRefPropertiesWidget
@@ -41,12 +37,10 @@ XRefPropertiesWidget::XRefPropertiesWidget(QHash <QString, XRefProperties> prope
{
ui->setupUi(this);
buildUi();
fillMissingTypes();
connect(ui->m_display_has_cross_rb, &QRadioButton::toggled, ui->m_cross_properties_gb, &QWidget::setEnabled);
connect(ui->m_display_has_contacts_rb, &QRadioButton::toggled, ui->m_show_all_slaves_cb, &QWidget::setEnabled);
connect(ui->m_type_cb, qOverload<int>(&QComboBox::currentIndexChanged), this, &XRefPropertiesWidget::typeChanged);
connect(ui->m_snap_to_cb, qOverload<int>(&QComboBox::currentIndexChanged), this, &XRefPropertiesWidget::enableOffsetSB);
connect(ui->m_font_pb, &QPushButton::clicked, this, &XRefPropertiesWidget::chooseXRefFont);
updateDisplay();
}
@@ -60,7 +54,6 @@ XRefPropertiesWidget::~XRefPropertiesWidget()
disconnect(ui->m_display_has_contacts_rb, &QRadioButton::toggled, ui->m_show_all_slaves_cb, &QWidget::setEnabled);
disconnect(ui->m_type_cb, qOverload<int>(&QComboBox::currentIndexChanged), this, &XRefPropertiesWidget::typeChanged);
disconnect(ui->m_snap_to_cb, qOverload<int>(&QComboBox::currentIndexChanged), this, &XRefPropertiesWidget::enableOffsetSB);
disconnect(ui->m_font_pb, &QPushButton::clicked, this, &XRefPropertiesWidget::chooseXRefFont);
delete ui;
}
@@ -72,33 +65,10 @@ XRefPropertiesWidget::~XRefPropertiesWidget()
void XRefPropertiesWidget::setProperties(const QHash <QString,
XRefProperties> &properties) {
m_properties = properties;
fillMissingTypes();
updateDisplay();
m_previous_type_index = ui->m_type_cb->currentIndex();
}
/**
@brief XRefPropertiesWidget::fillMissingTypes
Make sure every type the combo box offers has properties of its own.
A project built before a type existed does not hold that type, and
neither does a settings file written before it. Without an entry the
form would make one up out of thin air, and for a cable that would be
the very default of the coil ("%f-%l%c"), which reads as a stray dash
behind the folio number and two empty numbers after it.
*/
void XRefPropertiesWidget::fillMissingTypes()
{
const QHash<QString, XRefProperties> defaults = XRefProperties::defaultProperties();
for (int i = 0; i < ui->m_type_cb->count(); ++i)
{
const QString type = ui->m_type_cb->itemData(i).toString();
if (!m_properties.contains(type)) {
m_properties.insert(type, defaults.value(type));
}
}
}
/**
@brief XRefPropertiesWidget::properties
@return the properties edited by this widget
@@ -118,9 +88,6 @@ void XRefPropertiesWidget::setReadOnly(bool ro) {
ui->m_type_cb->setDisabled(ro);
ui->m_display_gb->setDisabled(ro);
ui->m_cross_properties_gb->setDisabled(ro);
//The texts stand on their own since they are needed for a cable
//too, and they are as much a setting as the rest.
ui->m_labels_gb->setDisabled(ro);
if (!ro && ui->m_display_has_contacts_rb->isChecked()) {
ui->m_cross_properties_gb->setDisabled(true);
@@ -133,16 +100,10 @@ void XRefPropertiesWidget::setReadOnly(bool ro) {
*/
void XRefPropertiesWidget::buildUi()
{
//Wording of the master label as the .ui wrote it, kept to put it
//back for every type which does not rename it.
m_master_label_text = ui->label_6->text();
ui -> m_type_cb -> addItem(tr("Coil"), "coil");
ui -> m_type_cb -> addItem(tr("Organ of protection"), "protection");
ui -> m_type_cb -> addItem(tr("Switch / button"), "commutator");
ui -> m_type_cb -> addItem(tr("Programmable Logic Controller (PLC)"), "plc");
//Not an element: the type of the cross references a cable writes
//in its own label when it runs on several folios.
ui -> m_type_cb -> addItem(tr("Cable"), "cable");
ui -> m_snap_to_cb -> addItem(tr("Footer"), "bottom");
ui -> m_snap_to_cb -> addItem(tr("Under the label of the element"), "label");
@@ -191,7 +152,6 @@ void XRefPropertiesWidget::saveProperties(int index) {
xrp.setPrefix("switch", ui->m_switch_prefix_le->text());
xrp.setMasterLabel(ui->m_master_le->text());
xrp.setSlaveLabel(ui->m_slave_le->text());
xrp.setFont(m_current_font);
//The boxes cannot show a value below their minimum (the offset's
//minimum is its "Default" entry, standing for the stored 0): keep
//the stored value unless the box shows something else.
@@ -225,10 +185,6 @@ void XRefPropertiesWidget::updateDisplay()
QString master = xrp.masterLabel();
ui->m_master_le->setText(master);
//Which font that type's reference is written with: the button
//offers it for a cable alone, but every type carries its own.
m_current_font = xrp.font();
QString slave = xrp.slaveLabel();
ui->m_slave_le->setText(slave);
@@ -280,42 +236,8 @@ void XRefPropertiesWidget::updateDisplay()
ui->m_display_has_cross_rb->setVisible(!is_plc);
ui->m_show_terminal_name_cb->setVisible(!is_plc);
ui->m_show_all_slaves_cb->setVisible(!is_plc);
//A cable is not an element: it draws no cross of its own and stands
//at no place of the sheet to be pointed at. Its reference is a line
//of the label of the cable itself, written once per other folio the
//cable runs on, so the whole presentation (where a cross is put, how
//it is drawn) and the text of the slave have no meaning for it: what
//is left is the one text which is written into that line.
const bool is_cable = type == QLatin1String("cable");
ui->m_display_gb->setVisible(!is_cable);
ui->label_7->setVisible(!is_cable);
ui->m_slave_le->setVisible(!is_cable);
//The wording of every type which is not a cable comes back from
//the .ui, so the label cannot drift away from the designer one.
ui->label_6->setText(is_cable ? tr("Text:") : m_master_label_text);
//Only a cable writes its reference into its own label, so only a
//cable has a text whose font to choose here: the cross references
//of the elements keep the font they have always been drawn with.
ui->m_font_pb->setVisible(is_cable);
if (m_current_font.isEmpty())
{
ui->m_font_pb->setToolTip(tr("Font and size: those of the cable texts"));
}
else
{
QFont font;
if (QETUtils::fontFromString(font, m_current_font)) {
ui->m_font_pb->setToolTip(tr("Font and size: %1, %2 pt")
.arg(font.family()).arg(font.pointSizeF()));
}
}
//A cable stacks the lines of its references by itself, so the
//option is only worth showing for the elements.
ui->m_stack_overlapping_cb->setVisible(!is_plc && !is_cable);
ui->m_cross_properties_gb->setVisible(!is_plc && !is_cable);
ui->m_stack_overlapping_cb->setVisible(!is_plc);
ui->m_cross_properties_gb->setVisible(!is_plc);
}
/**
@@ -345,31 +267,3 @@ void XRefPropertiesWidget::enableOffsetSB(int i){
ui->m_offset_sb->setEnabled(true);
ui->m_stack_overlapping_cb->setEnabled(ui->m_offset_sb->isEnabled());
}
/**
@brief XRefPropertiesWidget::chooseXRefFont
Let him pick the font -- family, size and style, all three at once --
the reference of a cable is written with.
The font is only kept when he presses OK: cancelling the dialog
leaves the previous one standing. What he picked is written into the
properties by saveProperties(), the way every other field of this
form is, so leaving the type or pressing OK in the settings window
is what really stores it.
*/
void XRefPropertiesWidget::chooseXRefFont()
{
QFont initial;
if (m_current_font.isEmpty() || !QETUtils::fontFromString(initial, m_current_font)) {
initial = QETApp::cableTextsFont();
}
bool ok = false;
const QFont font = QFontDialog::getFont(&ok, initial, this,
tr("Font of the cross-reference text"));
if (!ok) return;
m_current_font = QETUtils::fontToString(font);
ui->m_font_pb->setToolTip(tr("Font and size: %1, %2 pt")
.arg(font.family()).arg(font.pointSizeF()));
}