mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-23 23:44:13 +02:00
Add a Show name box to the selection properties of a terminal
The box hides the name of the terminal on the sheet only: the element keeps all of its data, and with the labelling split the terminal keeps its number, drawn once - in its own field when the symbol has one, alone in the label field when it has not. Only a terminal may have its name undrawn: the box is shown for the element type Terminal alone, and Element::labelShown() obeys the stored information for a terminal only. The choice is stored as the element information "label_shown" = "false" and only that, so files of every element which still draws its name stay exactly as they are. Multi-selection: the flag appears for terminals only and counts an absent information as "shown", so a mixed selection shows the box ticked only when every terminal has it ticked. Includes four test cases: hidden name keeps the stored data, keeps the number without a number field, leaves the number to its own field, and a non-terminal draws its name whatever the file says.
This commit is contained in:
@@ -262,6 +262,9 @@ void ElementInfoWidget::enableLiveEdit()
|
||||
if (m_freeze_cb) {
|
||||
connect(m_freeze_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply);
|
||||
}
|
||||
if (m_label_shown_cb) {
|
||||
connect(m_label_shown_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply);
|
||||
}
|
||||
if (m_number_cb) {
|
||||
connect(m_number_cb, QOverload<int>::of(&QComboBox::activated), this, &ElementInfoWidget::apply);
|
||||
}
|
||||
@@ -283,6 +286,9 @@ void ElementInfoWidget::disableLiveEdit()
|
||||
if (m_freeze_cb) {
|
||||
disconnect(m_freeze_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply);
|
||||
}
|
||||
if (m_label_shown_cb) {
|
||||
disconnect(m_label_shown_cb, &QCheckBox::clicked, this, &ElementInfoWidget::apply);
|
||||
}
|
||||
if (m_number_cb) {
|
||||
disconnect(m_number_cb, QOverload<int>::of(&QComboBox::activated), this, &ElementInfoWidget::apply);
|
||||
}
|
||||
@@ -318,6 +324,7 @@ void ElementInfoWidget::buildInterface()
|
||||
setupSchemeRow();
|
||||
setupNumberRow();
|
||||
setupFreezeRow();
|
||||
setupLabelShownRow();
|
||||
|
||||
m_add_custom_property_btn = new QPushButton(tr("Add a custom property"), this);
|
||||
connect(m_add_custom_property_btn, &QPushButton::clicked, this, [this]() { addCustomProperty(); });
|
||||
@@ -367,7 +374,8 @@ QStringList ElementInfoWidget::predefinedKeys() const
|
||||
keys << QETInformation::ELMT_FORMULA_ID
|
||||
<< QStringLiteral("auto_num_locked")
|
||||
<< QStringLiteral("potential_isolating")
|
||||
<< QStringLiteral("exclude_from_bom");
|
||||
<< QStringLiteral("exclude_from_bom")
|
||||
<< QStringLiteral("label_shown");
|
||||
|
||||
return keys;
|
||||
}
|
||||
@@ -672,6 +680,9 @@ void ElementInfoWidget::updateUi()
|
||||
m_freeze_cb->setChecked(m_element->isFreezeLabel());
|
||||
updateFreezeRow();
|
||||
}
|
||||
if (m_label_shown_cb) {
|
||||
m_label_shown_cb->setChecked(m_element->labelShown());
|
||||
}
|
||||
refreshNumberRow();
|
||||
updateSuggestions();
|
||||
|
||||
@@ -759,6 +770,13 @@ DiagramContext ElementInfoWidget::currentInfo() const
|
||||
info_.addValue(QStringLiteral("exclude_from_bom"), m_exclude_from_bom_cb->isChecked() ? QStringLiteral("true") : QStringLiteral("false"));
|
||||
}
|
||||
|
||||
// The name is drawn unless the element says otherwise: only a name
|
||||
// which is not drawn needs an information, so that elements which
|
||||
// draw it keep their files exactly as they are.
|
||||
if (m_label_shown_cb && !m_label_shown_cb->isChecked()) {
|
||||
info_.addValue(QStringLiteral("label_shown"), QStringLiteral("false"));
|
||||
}
|
||||
|
||||
//The element keeps following its numbering scheme as long as its
|
||||
//formula is left as it is; a formula edited by hand is its own.
|
||||
const DiagramContext &elmt_info = m_element->elementInformations();
|
||||
@@ -846,6 +864,38 @@ void ElementInfoWidget::updateFreezeRow()
|
||||
updateNumberRow();
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ElementInfoWidget::setupLabelShownRow
|
||||
Add under the freeze box a check box which decides whether the name
|
||||
of this element is drawn on the sheet: the choice belongs to the
|
||||
placed element, not to the symbol, so everyone can decide for
|
||||
himself.
|
||||
*/
|
||||
void ElementInfoWidget::setupLabelShownRow()
|
||||
{
|
||||
//The box means something for a terminal only, so it is drawn
|
||||
//for a terminal only - the same rule as the function separation
|
||||
//box just below it.
|
||||
if (!m_element || m_element->elementData().m_type != ElementData::Terminal) {
|
||||
return;
|
||||
}
|
||||
m_label_shown_cb = new QCheckBox(tr("Show name"), this);
|
||||
m_label_shown_cb->setObjectName(QStringLiteral("m_label_shown_cb"));
|
||||
m_label_shown_cb->setToolTip(tr("Untick to not draw the name of this element on the sheet: "
|
||||
"its data is kept, and a terminal keeps its number."));
|
||||
|
||||
int row = ui->scroll_vlayout->indexOf(m_freeze_cb);
|
||||
if (row < 0) {
|
||||
ElementInfoPartWidget *label = infoPartWidgetForKey(QETInformation::ELMT_LABEL);
|
||||
row = label ? ui->scroll_vlayout->indexOf(label) : -1;
|
||||
}
|
||||
if (row >= 0) {
|
||||
ui->scroll_vlayout->insertWidget(row + 1, m_label_shown_cb);
|
||||
} else {
|
||||
ui->scroll_vlayout->addWidget(m_label_shown_cb);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ElementInfoWidget::setupNumberRow
|
||||
Add under the numbering a list of the numbers the element may be given
|
||||
|
||||
Reference in New Issue
Block a user