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:
@@ -75,6 +75,15 @@ quint64 s_last_session = 0;
|
||||
const QString EXCLUDE_FROM_BOM = QStringLiteral("exclude_from_bom");
|
||||
const QString AUTO_NUM_LOCKED = QStringLiteral("auto_num_locked");
|
||||
const QString POTENTIAL_ISOLATING = QStringLiteral("potential_isolating");
|
||||
//The name is drawn unless the element says otherwise (@sa
|
||||
//Element::labelShown): an element which never got the box unticked
|
||||
//has no information for it, and counts as "shown".
|
||||
const QString LABEL_SHOWN = QStringLiteral("label_shown");
|
||||
|
||||
bool flagDefaultIsOn(const QString &key)
|
||||
{
|
||||
return key == LABEL_SHOWN;
|
||||
}
|
||||
|
||||
QString flagText(bool on)
|
||||
{
|
||||
@@ -449,7 +458,8 @@ void MultiElementInfoWidget::buildInterface()
|
||||
const QList<QPair<QString, QString>> flags {
|
||||
{EXCLUDE_FROM_BOM, tr("Exclude from the bill of materials")},
|
||||
{POTENTIAL_ISOLATING, tr("Function separation")},
|
||||
{AUTO_NUM_LOCKED, tr("Exclude from automatic numbering")}
|
||||
{AUTO_NUM_LOCKED, tr("Exclude from automatic numbering")},
|
||||
{LABEL_SHOWN, tr("Show name")}
|
||||
};
|
||||
for (const auto &pair : flags)
|
||||
{
|
||||
@@ -588,12 +598,19 @@ void MultiElementInfoWidget::fillRows()
|
||||
|
||||
for (Flag *flag : std::as_const(m_flags))
|
||||
{
|
||||
//"Show name" means something for a terminal only, so it is
|
||||
//shown for terminals only - the same rule as the two flags
|
||||
//before it.
|
||||
flag->check->setVisible(flag->key == EXCLUDE_FROM_BOM || all_terminals);
|
||||
flag->restore->setVisible(flag->check->isVisible());
|
||||
|
||||
int on = 0;
|
||||
for (Element *element : list) {
|
||||
if (QET::infoFlagIsTrue(m_snapshot.value(element).value(flag->key).toString())) {
|
||||
const QVariant value = m_snapshot.value(element).value(flag->key);
|
||||
const bool is_on = value.isValid()
|
||||
? QET::infoFlagIsTrue(value.toString())
|
||||
: flagDefaultIsOn(flag->key);
|
||||
if (is_on) {
|
||||
++on;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user