mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-23 15:34:12 +02:00
Move the terminal labelling setting into the project
The review asked for it, and it is the right place: the same file must draw the same way on every machine which opens it, so how a terminal writes its label belongs to the project, not to the application's own settings. The choice lives with the other display options of the sheets, in the project properties (General page), and is saved in the project as <terminal_labelling split="true"/> -- written only when on, so a project with it off saves byte for byte as before. Reading it is a member of the project now: no QSettings built per text refresh any more, and switching it redraws the labels of the drawings already open. The application setting (QetSettings, the General configuration page) is gone with it, and the test reads the project's own value.
This commit is contained in:
@@ -1259,7 +1259,7 @@ void DynamicElementTextItem::elementInfoChanged()
|
||||
if(element) {
|
||||
dc = element->elementInformations();
|
||||
//The label and the terminal number are drawn the way the
|
||||
//settings say (@sa QetSettings::terminalLabelSplit): a
|
||||
//project says (@sa QETProject::terminalLabelSplit): a
|
||||
//composite text which uses them must see the same values the
|
||||
//fields bound to them show
|
||||
dc.addValue(QETInformation::ELMT_LABEL, element->labelForDisplay());
|
||||
|
||||
@@ -33,7 +33,6 @@
|
||||
#include "../properties/terminaldata.h"
|
||||
#include "../properties/xrefproperties.h"
|
||||
#include "../qetinformation.h"
|
||||
#include "../utils/qetsettings.h"
|
||||
#include "../qetgraphicsitem/conductor.h"
|
||||
#include "../qetgraphicsitem/terminal.h"
|
||||
#include "../ui/elementpropertieswidget.h"
|
||||
@@ -1765,7 +1764,8 @@ void Element::removeDynamicTextItem(DynamicElementTextItem *deti)
|
||||
The fields which draw the label draw it again: what they show of the
|
||||
label has changed under them (a field for the terminal number added
|
||||
or removed, @sa Element::hasTerminalNumberText), or the terminal
|
||||
labelling setting was switched (@sa QetSettings::terminalLabelSplit).
|
||||
labelling setting of the project was switched
|
||||
(@sa QETProject::terminalLabelSplit).
|
||||
Only the fields which draw a label are refreshed, every other field
|
||||
follows its own information.
|
||||
*/
|
||||
@@ -2762,21 +2762,22 @@ QString Element::actualLabel()
|
||||
|
||||
/**
|
||||
@brief Element::labelForDisplay
|
||||
@return the label as the drawing must show it, the settings of the
|
||||
moment being read (@sa QetSettings::terminalLabelSplit): the whole
|
||||
label ("X1:1") while the labelling is shown in one field; the label
|
||||
alone ("X1") when it is shown split and this symbol has a text field
|
||||
of its own for the terminal number; and the two one under the other
|
||||
when it is split without such a field -- so a symbol drawn before
|
||||
the setting existed still shows all of its label, only shorter.
|
||||
Only an element of the terminal type is ever drawn split: the colon
|
||||
in any other label is part of the label ("-K1:13").
|
||||
@return the label as the drawing must show it, the terminal labelling
|
||||
of the project being read (@sa QETProject::terminalLabelSplit): the
|
||||
whole label ("X1:1") while the labelling is shown in one field; the
|
||||
label alone ("X1") when it is shown split and this symbol has a text
|
||||
field of its own for the terminal number; and the two one under the
|
||||
other when it is split without such a field -- so a symbol drawn
|
||||
before the setting existed still shows all of its label, only
|
||||
shorter. Only an element of the terminal type is ever drawn split:
|
||||
the colon in any other label is part of the label ("-K1:13").
|
||||
*/
|
||||
QString Element::labelForDisplay()
|
||||
{
|
||||
const QString label = actualLabel();
|
||||
const Diagram *d = diagram();
|
||||
const bool split = m_data.m_type == ElementData::Terminal
|
||||
&& QetSettings::terminalLabelSplit();
|
||||
&& d && d->project() && d->project()->terminalLabelSplit();
|
||||
|
||||
//The "Show name" box of the selection properties hides the name
|
||||
//of this element on the sheet only: the element keeps all of its
|
||||
@@ -2823,8 +2824,9 @@ QString Element::labelForDisplay()
|
||||
*/
|
||||
QString Element::terminalNumberForDisplay()
|
||||
{
|
||||
const Diagram *d = diagram();
|
||||
if (m_data.m_type != ElementData::Terminal
|
||||
|| !QetSettings::terminalLabelSplit()) {
|
||||
|| !d || !d->project() || !d->project()->terminalLabelSplit()) {
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
@@ -167,8 +167,8 @@ class Element : public QetGraphicsItem
|
||||
QString actualLabel();
|
||||
/**
|
||||
What the drawing shows of the label and of the terminal
|
||||
number, the terminal labelling setting of the moment being
|
||||
read (@sa QetSettings::terminalLabelSplit). The label itself
|
||||
number, the terminal labelling of the project being
|
||||
read (@sa QETProject::terminalLabelSplit). The label itself
|
||||
is never changed by any of them.
|
||||
*/
|
||||
QString labelForDisplay();
|
||||
@@ -180,8 +180,8 @@ class Element : public QetGraphicsItem
|
||||
The fields which draw the label draw it again: called when
|
||||
what they show of the label has changed under them, a
|
||||
field for the terminal number added or removed, or the
|
||||
terminal labelling setting switched (@sa
|
||||
QetSettings::terminalLabelSplit).
|
||||
terminal labelling setting of the project switched (@sa
|
||||
QETProject::terminalLabelSplit).
|
||||
*/
|
||||
void refreshLabelFields();
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace QETInformation
|
||||
static QString ELMT_LABEL = "label";
|
||||
//The part of the label behind its last colon ("1" in "X1:1"),
|
||||
//shown in a text field of its own when the terminal labelling
|
||||
//is drawn split (@sa QetSettings::terminalLabelSplit)
|
||||
//is drawn split (@sa QETProject::terminalLabelSplit)
|
||||
static QString ELMT_TERMINAL_NUMBER = "terminal_number";
|
||||
static QString ELMT_FORMULA = "formula";
|
||||
/**
|
||||
|
||||
@@ -2331,6 +2331,39 @@ void QETProject::setUprightSymbolTexts(bool upright)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::terminalLabelSplit
|
||||
@return whether the terminals of this project draw their label split,
|
||||
the label ("X1") and the terminal number ("1") each in their own text
|
||||
field, instead of the whole label ("X1:1") in one field. Off unless
|
||||
the project says otherwise, so a project saved without it draws as it
|
||||
always did. This is a setting of the project, not of the application:
|
||||
the same file draws the same way on every machine which opens it.
|
||||
@sa setTerminalLabelSplit
|
||||
*/
|
||||
bool QETProject::terminalLabelSplit() const {
|
||||
return m_terminal_label_split;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::setTerminalLabelSplit
|
||||
Set whether the terminals of this project draw their label split, and
|
||||
tell the labels of the drawings already open to draw it again.
|
||||
@param split
|
||||
*/
|
||||
void QETProject::setTerminalLabelSplit(bool split)
|
||||
{
|
||||
if (split == m_terminal_label_split) {
|
||||
return;
|
||||
}
|
||||
m_terminal_label_split = split;
|
||||
for (Diagram *diagram : diagrams()) {
|
||||
for (Element *element : diagram->elements()) {
|
||||
element->refreshLabelFields();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::wiringRules
|
||||
@return how many wires a terminal of this project may take
|
||||
@@ -2569,6 +2602,7 @@ QDomDocument QETProject::toXml(QHash<int, QByteArray> *kept_folios, QStringList
|
||||
writeUsageXml(project_root);
|
||||
writeWireHopsXml(project_root);
|
||||
writeSymbolTextsXml(project_root);
|
||||
writeTerminalLabelSplitXml(project_root);
|
||||
writeWiringRulesXml(project_root);
|
||||
|
||||
// Properties for news diagrams
|
||||
@@ -3529,6 +3563,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
|
||||
readUsageXml(xml_project);
|
||||
readWireHopsXml(xml_project);
|
||||
readSymbolTextsXml(xml_project);
|
||||
readTerminalLabelSplitXml(xml_project);
|
||||
readWiringRulesXml(xml_project);
|
||||
|
||||
//Load the default properties for the new diagrams
|
||||
@@ -3893,6 +3928,21 @@ void QETProject::readSymbolTextsXml(QDomDocument &xml_project)
|
||||
&& texts.attribute(QStringLiteral("upright")) == QLatin1String("true");
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::readTerminalLabelSplitXml
|
||||
Read the <terminal_labelling> element of the project, if any. A
|
||||
project without it was saved before the setting existed, or with it
|
||||
off, and draws the whole label of each terminal in one field.
|
||||
@param xml_project : the xml description of the project
|
||||
*/
|
||||
void QETProject::readTerminalLabelSplitXml(QDomDocument &xml_project)
|
||||
{
|
||||
const QDomElement labelling = xml_project.documentElement()
|
||||
.firstChildElement(QStringLiteral("terminal_labelling"));
|
||||
m_terminal_label_split = !labelling.isNull()
|
||||
&& labelling.attribute(QStringLiteral("split")) == QLatin1String("true");
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::readWiringRulesXml
|
||||
Read the <wiring_rules> element of the project, if any.
|
||||
@@ -4217,6 +4267,23 @@ void QETProject::writeSymbolTextsXml(QDomElement &xml_element)
|
||||
xml_element.appendChild(texts);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::writeTerminalLabelSplitXml
|
||||
Export whether the terminals draw their label split, as a
|
||||
<terminal_labelling> child of \a xml_element. Written only when on,
|
||||
so a project with it off saves exactly as before.
|
||||
*/
|
||||
void QETProject::writeTerminalLabelSplitXml(QDomElement &xml_element)
|
||||
{
|
||||
if (!m_terminal_label_split) {
|
||||
return;
|
||||
}
|
||||
QDomElement labelling = xml_element.ownerDocument()
|
||||
.createElement(QStringLiteral("terminal_labelling"));
|
||||
labelling.setAttribute(QStringLiteral("split"), QStringLiteral("true"));
|
||||
xml_element.appendChild(labelling);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::writeWiringRulesXml
|
||||
Export the project's wiring rules as a <wiring_rules> child of
|
||||
|
||||
@@ -324,6 +324,8 @@ class QETProject : public QObject
|
||||
void setWireHops(WireHops::Mode mode);
|
||||
bool uprightSymbolTexts() const;
|
||||
void setUprightSymbolTexts(bool upright);
|
||||
bool terminalLabelSplit() const;
|
||||
void setTerminalLabelSplit(bool split);
|
||||
WiringRules::Settings wiringRules() const;
|
||||
WiringRules::Settings projectWiringRules() const;
|
||||
void setWiringRules(const WiringRules::Settings &rules);
|
||||
@@ -453,6 +455,7 @@ class QETProject : public QObject
|
||||
void readUsageXml(QDomDocument &xml_project);
|
||||
void readWireHopsXml(QDomDocument &xml_project);
|
||||
void readSymbolTextsXml(QDomDocument &xml_project);
|
||||
void readTerminalLabelSplitXml(QDomDocument &xml_project);
|
||||
void readWiringRulesXml(QDomDocument &xml_project);
|
||||
|
||||
void writeProjectPropertiesXml(QDomElement &);
|
||||
@@ -462,6 +465,7 @@ class QETProject : public QObject
|
||||
void writeUsageXml(QDomElement &);
|
||||
void writeWireHopsXml(QDomElement &);
|
||||
void writeSymbolTextsXml(QDomElement &);
|
||||
void writeTerminalLabelSplitXml(QDomElement &);
|
||||
void writeWiringRulesXml(QDomElement &);
|
||||
void addDiagram(Diagram *diagram, int pos = -1);
|
||||
void detachDiagram(Diagram *diagram);
|
||||
@@ -577,6 +581,10 @@ class QETProject : public QObject
|
||||
/// Texts drawn in a turned symbol stay horizontal (on for a new
|
||||
/// project, off for one saved without it), see uprightSymbolTexts()
|
||||
bool m_upright_symbol_texts = false;
|
||||
/// Terminals draw their label split: the label ("X1") and the
|
||||
/// terminal number ("1") each in their own text field (off for
|
||||
/// a project saved without it), see terminalLabelSplit()
|
||||
bool m_terminal_label_split = false;
|
||||
WiringRules::Settings m_wiring_rules;
|
||||
XmlElementCollection *m_elements_collection = nullptr;
|
||||
QTimer m_save_backup_timer,
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
#include <QSettings>
|
||||
|
||||
#include "../../diagram.h"
|
||||
#include "../../qetgraphicsitem/element.h"
|
||||
#include "../../qetproject.h"
|
||||
|
||||
namespace {
|
||||
@@ -162,11 +161,6 @@ GeneralConfigurationPage::GeneralConfigurationPage(QWidget *parent) :
|
||||
enable(ui->m_wiring_rules_cb->isChecked());
|
||||
connect(ui->m_wiring_rules_cb, &QCheckBox::toggled, this, enable);
|
||||
}
|
||||
if (QetSettings::terminalLabelSplit()) {
|
||||
ui->m_terminal_label_split_rb->setChecked(true);
|
||||
} else {
|
||||
ui->m_terminal_label_combined_rb->setChecked(true);
|
||||
}
|
||||
ui->m_use_gesture_trackpad->setChecked(settings.value("diagramview/gestures", false).toBool());
|
||||
ui->m_save_label_paste->setChecked(settings.value("diagramcommands/erase-label-on-copy", true).toBool());
|
||||
ui->m_autonumber_pasted->setChecked(settings.value("diagramcommands/autonumber-pasted-elements", true).toBool());
|
||||
@@ -421,19 +415,6 @@ void GeneralConfigurationPage::applyConf()
|
||||
if (WiringRules::masterEnabled() && WiringRules::turnsRuleOn(before, rules)) {
|
||||
WiringRulesWarning::show(this);
|
||||
}
|
||||
}
|
||||
//The labelling setting is read where the label is drawn, so the
|
||||
//drawings already open are told to draw it again when it changes
|
||||
const bool label_split = ui->m_terminal_label_split_rb->isChecked();
|
||||
if (QetSettings::terminalLabelSplit() != label_split) {
|
||||
QetSettings::setTerminalLabelSplit(label_split);
|
||||
for (QETProject *project : QETApp::registeredProjects()) {
|
||||
for (Diagram *diagram : project->diagrams()) {
|
||||
for (Element *element : diagram->elements()) {
|
||||
element->refreshLabelFields();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
settings.setValue("diagrameditor/autosave-interval", ui->m_autosave_sb->value());
|
||||
settings.setValue("projectlock/enabled", ui->m_project_lock->isChecked());
|
||||
|
||||
@@ -140,48 +140,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="m_terminal_label_group">
|
||||
<property name="title">
|
||||
<string>Display of the terminal labelling</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="m_terminal_label_layout">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_terminal_label_combined_rb">
|
||||
<property name="toolTip">
|
||||
<string>A terminal's label (X1:1) is drawn as a whole, the way it has always been.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show the label and the terminal number in one field</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_terminal_label_split_rb">
|
||||
<property name="toolTip">
|
||||
<string>The label (X1) is drawn in one field and the terminal number (1) in another, which a terminal symbol may place where it wants -- and hide when it must. A symbol without such a field shows the two, one under the other.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Split the label and the terminal number</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="m_terminal_label_help">
|
||||
<property name="text">
|
||||
<string>Only the drawing changes: what is written in the element, the numbering, the sorting and the exports keep the whole label.</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line_2">
|
||||
<property name="orientation">
|
||||
|
||||
@@ -191,6 +191,11 @@ void ProjectMainConfigPage::applyProjectConf()
|
||||
modified_project = true;
|
||||
}
|
||||
|
||||
if (m_project -> terminalLabelSplit() != terminal_label_split_rb_ -> isChecked()) {
|
||||
m_project -> setTerminalLabelSplit(terminal_label_split_rb_ -> isChecked());
|
||||
modified_project = true;
|
||||
}
|
||||
|
||||
//Following the application's rules stores nothing in the project
|
||||
WiringRules::Settings wiring_rules;
|
||||
if (!use_application_rules_cb_ -> isChecked()) {
|
||||
@@ -266,6 +271,27 @@ void ProjectMainConfigPage::initWidgets()
|
||||
"text. Uncheck to make them turn with the element, as before.",
|
||||
"tooltip"));
|
||||
|
||||
//How the terminals draw their label: a setting of this project,
|
||||
//so the same file draws the same way on every machine which
|
||||
//opens it, like every other choice of how the sheets are drawn
|
||||
terminal_label_gb_ = new QGroupBox(tr("Display of the terminal labelling", "group box title"));
|
||||
terminal_label_combined_rb_ = new QRadioButton(
|
||||
tr("Show the label and the terminal number in one field", "radio button label"));
|
||||
terminal_label_combined_rb_ -> setToolTip(tr(
|
||||
"A terminal's label (X1:1) is drawn as a whole, the way it has always been.",
|
||||
"tooltip"));
|
||||
terminal_label_split_rb_ = new QRadioButton(tr("Split the label and the terminal number",
|
||||
"radio button label"));
|
||||
terminal_label_split_rb_ -> setToolTip(tr(
|
||||
"The label (X1) is drawn in one field and the terminal number (1) in another, "
|
||||
"which a terminal symbol may place where it wants -- and hide when it must. "
|
||||
"A symbol without such a field shows the two, one under the other.",
|
||||
"tooltip"));
|
||||
terminal_label_help_ = new QLabel(tr("Only the drawing changes: what is written in the element, "
|
||||
"the numbering, the sorting and the exports keep the whole label.",
|
||||
"informative label"));
|
||||
terminal_label_help_ -> setWordWrap(true);
|
||||
|
||||
//How many wires a terminal may take (discussion #1158)
|
||||
wiring_rules_gb_ = new QGroupBox(tr("Conductors per terminal", "group box title"));
|
||||
use_application_rules_cb_ = new QCheckBox(tr("Use the application settings", "checkbox label"));
|
||||
@@ -335,6 +361,13 @@ void ProjectMainConfigPage::initLayout()
|
||||
main_layout0 -> addWidget(upright_symbol_texts_cb_);
|
||||
main_layout0 -> addSpacing(10);
|
||||
|
||||
QVBoxLayout *terminal_label_layout = new QVBoxLayout(terminal_label_gb_);
|
||||
terminal_label_layout -> addWidget(terminal_label_combined_rb_);
|
||||
terminal_label_layout -> addWidget(terminal_label_split_rb_);
|
||||
terminal_label_layout -> addWidget(terminal_label_help_);
|
||||
main_layout0 -> addWidget(terminal_label_gb_);
|
||||
main_layout0 -> addSpacing(10);
|
||||
|
||||
QVBoxLayout *wiring_rules_layout = new QVBoxLayout(wiring_rules_gb_);
|
||||
wiring_rules_layout -> addWidget(use_application_rules_cb_);
|
||||
QHBoxLayout *max_wires_layout = new QHBoxLayout();
|
||||
@@ -369,6 +402,11 @@ void ProjectMainConfigPage::readValuesFromProject()
|
||||
const int wire_hops_index = wire_hops_cb_ -> findData(WireHops::toString(m_project -> wireHops()));
|
||||
wire_hops_cb_ -> setCurrentIndex(qMax(0, wire_hops_index));
|
||||
upright_symbol_texts_cb_ -> setChecked(m_project -> uprightSymbolTexts());
|
||||
if (m_project -> terminalLabelSplit()) {
|
||||
terminal_label_split_rb_ -> setChecked(true);
|
||||
} else {
|
||||
terminal_label_combined_rb_ -> setChecked(true);
|
||||
}
|
||||
|
||||
//The rules that apply: the project's own or the application's
|
||||
const WiringRules::Settings wiring_rules = m_project -> wiringRules();
|
||||
@@ -425,6 +463,7 @@ void ProjectMainConfigPage::adjustReadOnly()
|
||||
usage_reset_pb_ -> setDisabled(is_read_only);
|
||||
wire_hops_cb_ -> setDisabled(is_read_only);
|
||||
upright_symbol_texts_cb_ -> setDisabled(is_read_only);
|
||||
terminal_label_gb_ -> setDisabled(is_read_only);
|
||||
wiring_rules_gb_ -> setDisabled(is_read_only);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ class QLabel;
|
||||
class QComboBox;
|
||||
class QLineEdit;
|
||||
class QCheckBox;
|
||||
class QRadioButton;
|
||||
class QPushButton;
|
||||
class QSpinBox;
|
||||
class QGroupBox;
|
||||
@@ -140,6 +141,10 @@ class ProjectMainConfigPage : public ProjectConfigPage {
|
||||
QLabel *wire_hops_label_;
|
||||
QComboBox *wire_hops_cb_;
|
||||
QCheckBox *upright_symbol_texts_cb_;
|
||||
QGroupBox *terminal_label_gb_;
|
||||
QRadioButton *terminal_label_combined_rb_;
|
||||
QRadioButton *terminal_label_split_rb_;
|
||||
QLabel *terminal_label_help_;
|
||||
QGroupBox *wiring_rules_gb_;
|
||||
QCheckBox *use_application_rules_cb_;
|
||||
QLabel *max_wires_label_;
|
||||
|
||||
@@ -290,28 +290,4 @@ namespace QetSettings
|
||||
QSettings settings;
|
||||
settings.setValue(QStringLiteral("diagrameditor/sheet_background_recent"), colors);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief terminalLabelSplit
|
||||
* @return whether a terminal's label is drawn split, the label and
|
||||
* the terminal number each in their own text field, instead of the
|
||||
* whole label ("X1:1") in one field. Off unless the user turned it
|
||||
* on, so an existing drawing keeps its look. @sa setTerminalLabelSplit
|
||||
*/
|
||||
bool terminalLabelSplit()
|
||||
{
|
||||
QSettings settings;
|
||||
return settings.value(QStringLiteral("element/terminal_label_split"), false).toBool();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief setTerminalLabelSplit
|
||||
* Store whether a terminal's label is drawn split. @sa terminalLabelSplit
|
||||
* @param split
|
||||
*/
|
||||
void setTerminalLabelSplit(bool split)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue(QStringLiteral("element/terminal_label_split"), split);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,20 +76,6 @@ namespace QetSettings
|
||||
|
||||
QStringList sheetBackgroundRecentColors();
|
||||
void setSheetBackgroundRecentColors(const QStringList &colors);
|
||||
|
||||
/**
|
||||
@brief How a terminal's own label is drawn.
|
||||
|
||||
The label is stored as it is written ("X1:1"). With the split on,
|
||||
the drawing shows the label ("X1") and the terminal number ("1")
|
||||
as two parts, so a terminal symbol can keep the number in its own
|
||||
text field and place it where it wants. Only the drawing reacts:
|
||||
what the element stores, the numbering, the sorting in the
|
||||
terminal strip editor and every export keep the whole label.
|
||||
Off by default, so a drawing keeps the look it was made with.
|
||||
*/
|
||||
bool terminalLabelSplit();
|
||||
void setTerminalLabelSplit(bool split);
|
||||
}
|
||||
|
||||
#endif // QETSETTINGS_H
|
||||
|
||||
@@ -26,11 +26,10 @@
|
||||
#include "qetgraphicsitem/terminal.h"
|
||||
#include "qetinformation.h"
|
||||
#include "qetproject.h"
|
||||
#include "utils/qetsettings.h"
|
||||
|
||||
/**
|
||||
How a terminal's own label is drawn, the setting of the moment being
|
||||
read (@sa QetSettings::terminalLabelSplit).
|
||||
How a terminal's own label is drawn, the terminal labelling of the
|
||||
project being read (@sa QETProject::terminalLabelSplit).
|
||||
|
||||
The label stays whole wherever it is used as data: what the element
|
||||
stores, the numbering, the sorting in the terminal strip editor and
|
||||
@@ -149,19 +148,10 @@ class tst_terminallabeldisplay : public QObject
|
||||
}
|
||||
|
||||
private slots:
|
||||
void cleanup()
|
||||
{
|
||||
//Whatever a test left behind, the next one (and the rest of
|
||||
//the suite) starts from the shipped default
|
||||
QetSettings::setTerminalLabelSplit(false);
|
||||
}
|
||||
|
||||
//The shipped default: one field with the whole label, the way it has
|
||||
//always been drawn
|
||||
void oneFieldKeepsTheWholeLabel()
|
||||
{
|
||||
QetSettings::setTerminalLabelSplit(false);
|
||||
|
||||
const QString fixture = QFINDTESTDATA("fixtures/every_feature.qet");
|
||||
QETProject project(fixture);
|
||||
QCOMPARE(project.state(), QETProject::Ok);
|
||||
@@ -186,11 +176,10 @@ private slots:
|
||||
//can never make a number vanish
|
||||
void splitWithoutNumberFieldShowsTwoLines()
|
||||
{
|
||||
QetSettings::setTerminalLabelSplit(true);
|
||||
|
||||
const QString fixture = QFINDTESTDATA("fixtures/every_feature.qet");
|
||||
QETProject project(fixture);
|
||||
QCOMPARE(project.state(), QETProject::Ok);
|
||||
project.setTerminalLabelSplit(true);
|
||||
|
||||
Element *element = terminalWithLabel(project, QStringLiteral("X1:1"));
|
||||
QVERIFY(element);
|
||||
@@ -216,11 +205,10 @@ private slots:
|
||||
//part in its field, the label no longer carrying the number
|
||||
void splitWithNumberFieldShowsEachInItsOwnField()
|
||||
{
|
||||
QetSettings::setTerminalLabelSplit(true);
|
||||
|
||||
const QString fixture = QFINDTESTDATA("fixtures/every_feature.qet");
|
||||
QETProject project(fixture);
|
||||
QCOMPARE(project.state(), QETProject::Ok);
|
||||
project.setTerminalLabelSplit(true);
|
||||
|
||||
Element *element = terminalWithLabel(project, QStringLiteral("X1:1"));
|
||||
QVERIFY(element);
|
||||
@@ -240,11 +228,10 @@ private slots:
|
||||
//setting says
|
||||
void splitLeavesLabelsWithoutColonAlone()
|
||||
{
|
||||
QetSettings::setTerminalLabelSplit(true);
|
||||
|
||||
const QString fixture = QFINDTESTDATA("fixtures/every_feature.qet");
|
||||
QETProject project(fixture);
|
||||
QCOMPARE(project.state(), QETProject::Ok);
|
||||
project.setTerminalLabelSplit(true);
|
||||
|
||||
Element *element = terminalWithLabel(project, QStringLiteral("S7"));
|
||||
QVERIFY(element);
|
||||
@@ -266,15 +253,16 @@ private slots:
|
||||
QETProject project(fixture);
|
||||
QCOMPARE(project.state(), QETProject::Ok);
|
||||
|
||||
QetSettings::setTerminalLabelSplit(true);
|
||||
project.setTerminalLabelSplit(true);
|
||||
Element *element = terminalWithLabel(project, QStringLiteral("X1:1"));
|
||||
QVERIFY(element);
|
||||
DynamicElementTextItem *label = fieldBoundTo(element, QETInformation::ELMT_LABEL);
|
||||
QVERIFY(label);
|
||||
QCOMPARE(label->toPlainText(), QStringLiteral("X1\n1"));
|
||||
|
||||
QetSettings::setTerminalLabelSplit(false);
|
||||
element->refreshLabelFields();
|
||||
//The setter itself tells the labels of the drawings already
|
||||
//open to draw again: nothing else to ask for
|
||||
project.setTerminalLabelSplit(false);
|
||||
QCOMPARE(label->toPlainText(), QStringLiteral("X1:1"));
|
||||
QCOMPARE(element->actualLabel(), QStringLiteral("X1:1"));
|
||||
}
|
||||
@@ -284,8 +272,6 @@ private slots:
|
||||
//use of it as data -- only the drawing changes
|
||||
void hiddenNameKeepsEverythingStored()
|
||||
{
|
||||
QetSettings::setTerminalLabelSplit(false);
|
||||
|
||||
const QString fixture = QFINDTESTDATA("fixtures/every_feature.qet");
|
||||
QETProject project(fixture);
|
||||
QCOMPARE(project.state(), QETProject::Ok);
|
||||
@@ -308,11 +294,10 @@ private slots:
|
||||
//hiding the name can never hide the number
|
||||
void hiddenNameKeepsTheNumberWithSplit()
|
||||
{
|
||||
QetSettings::setTerminalLabelSplit(true);
|
||||
|
||||
const QString fixture = QFINDTESTDATA("fixtures/every_feature.qet");
|
||||
QETProject project(fixture);
|
||||
QCOMPARE(project.state(), QETProject::Ok);
|
||||
project.setTerminalLabelSplit(true);
|
||||
|
||||
Element *element = terminalWithLabel(project, QStringLiteral("X1:1"));
|
||||
QVERIFY(element);
|
||||
@@ -332,11 +317,10 @@ private slots:
|
||||
//draws nothing -- the number is never drawn twice
|
||||
void hiddenNameLeavesTheNumberToItsOwnField()
|
||||
{
|
||||
QetSettings::setTerminalLabelSplit(true);
|
||||
|
||||
const QString fixture = QFINDTESTDATA("fixtures/every_feature.qet");
|
||||
QETProject project(fixture);
|
||||
QCOMPARE(project.state(), QETProject::Ok);
|
||||
project.setTerminalLabelSplit(true);
|
||||
|
||||
Element *element = terminalWithLabel(project, QStringLiteral("X1:1"));
|
||||
QVERIFY(element);
|
||||
@@ -355,8 +339,6 @@ private slots:
|
||||
//file says
|
||||
void nonTerminalAlwaysDrawsItsName()
|
||||
{
|
||||
QetSettings::setTerminalLabelSplit(false);
|
||||
|
||||
const QString fixture = QFINDTESTDATA("fixtures/every_feature.qet");
|
||||
QETProject project(fixture);
|
||||
QCOMPARE(project.state(), QETProject::Ok);
|
||||
@@ -380,11 +362,10 @@ private slots:
|
||||
//part of the label, not a split waiting to happen
|
||||
void splitLeavesNonTerminalsWithColonAlone()
|
||||
{
|
||||
QetSettings::setTerminalLabelSplit(true);
|
||||
|
||||
const QString fixture = QFINDTESTDATA("fixtures/every_feature.qet");
|
||||
QETProject project(fixture);
|
||||
QCOMPARE(project.state(), QETProject::Ok);
|
||||
project.setTerminalLabelSplit(true);
|
||||
|
||||
Element *element = nonTerminalWithLabel(project, QStringLiteral("-K1:13"));
|
||||
QVERIFY2(element,
|
||||
@@ -404,8 +385,6 @@ private slots:
|
||||
//with it, both ways through the same signal
|
||||
void hiddenNameHidesTheLabelField()
|
||||
{
|
||||
QetSettings::setTerminalLabelSplit(false);
|
||||
|
||||
const QString fixture = QFINDTESTDATA("fixtures/every_feature.qet");
|
||||
QETProject project(fixture);
|
||||
QCOMPARE(project.state(), QETProject::Ok);
|
||||
|
||||
Reference in New Issue
Block a user