Files
qelectrotech-source-mirror/sources/qetinformation.h
T
Kellermorph dfec60a3a5 Draw a terminal's label and its number apart, when asked to
A terminal's label is written as it is read off the plan, "X1:1", and
the symbol draws it as one field. On a long strip that field is long
enough to reach into the next terminal, and a user who wants the number
next to the screw and the label out of the way has no way to say so.

Settings > General > Appearance now has a "Display of the terminal
labelling" group with two choices: the label and its terminal number in
one field, the way it has always been drawn, or the two split. The
first is what every drawing gets, so nothing moves until the user asks
for it, and choosing the other one redraws the drawings already open --
nothing needs to be closed and opened again.

A symbol made for the split carries a text field bound to the new
"Terminal number" information (in the element editor's list, next to
the label, and as the %{terminal_number} variable of a composite text):
the label field then shows "X1" and the number field "1", each placed
where the symbol wants it, and hideable when it must be. A symbol which
has no such field -- every symbol drawn until now -- gets the number on
its own line inside the label field, so switching the setting on can
never make a number vanish, and never needs a symbol to be touched
first. A field which becomes, or stops being, the number field tells
the label fields of its symbol to draw themselves again.

Only the drawing reacts. What the element stores, the numbering, the
sorting in the terminal strip editor, the automatic strip import and
every export keep the whole label: the split is read where the text is
drawn (Element::labelForDisplay() and friends), not where the label is
made.

The new test covers both choices, with and without the number field, a
label with no colon at all, and the way back to the whole label. The
full test suite passes (124/124).
2026-10-22 10:01:12 +02:00

196 lines
9.6 KiB
C++

/*
Copyright 2006-2026 The QElectroTech Team
This file is part of QElectroTech.
QElectroTech is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
QElectroTech is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef QETINFORMATION_H
#define QETINFORMATION_H
#include <QHash>
#include <QRegularExpression>
#include <QRegularExpressionValidator>
#include <QStringList>
/**
* Inside this namespace you will find all information used in QElectrotech for
* element, conductor and diagram.
* Each information have 3 values :
* #1 the info key = the key of an information as a QString used in the code
* (example : label)
* #2 the info key to variable = the key in form of a variable. This is used
* by the user to replace a variable by the string of this variable
* (example : %{label})
* #3 the info key translated to the current local (example label in dutch =
* Betriebsmittelkennzeichen)
*/
namespace QETInformation
{
/** Default information related to element **/
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)
static QString ELMT_TERMINAL_NUMBER = "terminal_number";
static QString ELMT_FORMULA = "formula";
/**
Uuid of the project's element numbering scheme the element's
formula follows. Internal: never shown, edited, exported or
printed as an information of its own; it only exists alongside a
non-empty ELMT_FORMULA (see Element::setElementInformations()).
*/
static QString ELMT_FORMULA_ID = "formula_id";
static QString ELMT_COMMENT = "comment";
static QString ELMT_FUNCTION = "function";
static QString ELMT_DESCRIPTION = "description";
static QString ELMT_DESIGNATION = "designation";
static QString ELMT_MANUFACTURER = "manufacturer";
static QString ELMT_MANUFACTURER_REF = "manufacturer_reference";
static QString ELMT_MACHINE_MANUFACTURER_REF = "machine_manufacturer_reference";
static QString ELMT_SUPPLIER = "supplier";
static QString ELMT_QUANTITY = "quantity";
static QString ELMT_MODEL = "model";
static QString ELMT_CATEGORY = "category";
static QString ELMT_VOLTAGE_RATING = "voltage_rating";
static QString ELMT_CURRENT_RATING = "current_rating";
static QString ELMT_NOTES = "notes";
static QString ELMT_UNITY = "unity";
static QString ELMT_WIDTH = "width";
static QString ELMT_HEIGHT = "height";
static QString ELMT_DEPTH = "depth";
static QString ELMT_PLANT = "plant";
static QString ELMT_LOCATION = "location";
static QString ELMT_AUX1 = "auxiliary1";
static QString ELMT_DESCRIPTION_AUX1 = "description_auxiliary1";
static QString ELMT_DESIGNATION_AUX1 = "designation_auxiliary1";
static QString ELMT_MANUFACTURER_AUX1 = "manufacturer_auxiliary1";
static QString ELMT_MANUFACTURER_REF_AUX1 = "manufacturer_reference_auxiliary1";
static QString ELMT_MACHINE_MANUFACTURER_REF_AUX1 = "machine_manufacturer_reference_auxiliary1";
static QString ELMT_SUPPLIER_AUX1 = "supplier_auxiliary1";
static QString ELMT_QUANTITY_AUX1 = "quantity_auxiliary1";
static QString ELMT_UNITY_AUX1 = "unity_auxiliary1";
static QString ELMT_AUX2 = "auxiliary2";
static QString ELMT_DESCRIPTION_AUX2 = "description_auxiliary2";
static QString ELMT_DESIGNATION_AUX2 = "designation_auxiliary2";
static QString ELMT_MANUFACTURER_AUX2 = "manufacturer_auxiliary2";
static QString ELMT_MANUFACTURER_REF_AUX2 = "manufacturer_reference_auxiliary2";
static QString ELMT_MACHINE_MANUFACTURER_REF_AUX2 = "machine_manufacturer_reference_auxiliary2";
static QString ELMT_SUPPLIER_AUX2 = "supplier_auxiliary2";
static QString ELMT_QUANTITY_AUX2 = "quantity_auxiliary2";
static QString ELMT_UNITY_AUX2 = "unity_auxiliary2";
static QString ELMT_AUX3 = "auxiliary3";
static QString ELMT_DESCRIPTION_AUX3 = "description_auxiliary3";
static QString ELMT_DESIGNATION_AUX3 = "designation_auxiliary3";
static QString ELMT_MANUFACTURER_AUX3 = "manufacturer_auxiliary3";
static QString ELMT_MANUFACTURER_REF_AUX3 = "manufacturer_reference_auxiliary3";
static QString ELMT_MACHINE_MANUFACTURER_REF_AUX3 = "machine_manufacturer_reference_auxiliary3";
static QString ELMT_SUPPLIER_AUX3 = "supplier_auxiliary3";
static QString ELMT_QUANTITY_AUX3 = "quantity_auxiliary3";
static QString ELMT_UNITY_AUX3 = "unity_auxiliary3";
static QString ELMT_AUX4 = "auxiliary4";
static QString ELMT_DESCRIPTION_AUX4 = "description_auxiliary4";
static QString ELMT_DESIGNATION_AUX4 = "designation_auxiliary4";
static QString ELMT_MANUFACTURER_AUX4 = "manufacturer_auxiliary4";
static QString ELMT_MANUFACTURER_REF_AUX4 = "manufacturer_reference_auxiliary4";
static QString ELMT_MACHINE_MANUFACTURER_REF_AUX4 = "machine_manufacturer_reference_auxiliary4";
static QString ELMT_SUPPLIER_AUX4 = "supplier_auxiliary4";
static QString ELMT_QUANTITY_AUX4 = "quantity_auxiliary4";
static QString ELMT_UNITY_AUX4 = "unity_auxiliary4";
static QString ELMT_XREF = "xref";
/** Default information related to conductor **/
static QString COND_FUNCTION = "function";
static QString COND_TENSION_PROTOCOL = "tension_protocol";
static QString COND_COLOR = "conductor_color";
static QString COND_SECTION = "conductor_section";
static QString COND_FORMULA = "formula";
static QString COND_TEXT = "text";
/** Default information related to diagram **/
static QString DIA_AUTHOR = "author";
static QString DIA_DATE = "date";
static QString DIA_DISPLAY_FOLIO = "display_folio";
static QString DIA_FILENAME = "filename";
static QString DIA_FOLIO = "folio";
static QString DIA_INDEX_REV = "indexrev";
static QString DIA_LOCMACH = "locmach";
static QString DIA_PLANT = "plant";
static QString DIA_POS = "pos";
static QString DIA_TITLE = "title";
static QString DIA_FOLIO_ID = "folio-id";
static QString DIA_PREVIOUS_FOLIO_NUM = "previous-folio-num";
static QString DIA_NEXT_FOLIO_NUM = "next-folio-num";
/** Default information related to project **/
static QString PROJECT_FOLIO_TOTAL = "folio-total";
static QString PROJECT_TITLE = "projecttitle";
static QString PROJECT_PATH = "projectpath";
static QString PROJECT_FILE_NAME = "projectfilename";
static QString PROJECT_SAVE_DATE = "saveddate";
static QString PROJECT_SAVE_DATE_EU = "saveddate-eu";
static QString PROJECT_SAVE_DATE_US = "saveddate-us";
static QString PROJECT_SAVE_TIME = "savedtime";
static QString PROJECT_SAVED_FILE_NAME = "savedfilename";
static QString PROJECT_SAVED_FILE_PATH = "savedfilepath";
/** Default information related to QElectroTech **/
static QString QET_VERSION = "version";
/** PLC-specific information for slave elements **/
static QString ELMT_PLC_TYPE = "plc_type";
static QString ELMT_PLC_ADDRESS = "plc_address";
static QString ELMT_PLC_FUNCTION = "plc_function";
static QString ELMT_PLC_COMMENT = "plc_comment";
static QString ELMT_PLC_CROSSREF = "plc_crossref";
static QString ELMT_PLC_TC = "plc_tc";
static QString ELMT_PLC_T1 = "plc_t1";
static QString ELMT_PLC_T2 = "plc_t2";
static QString ELMT_PLC_T3 = "plc_t3";
static QString ELMT_PLC_T4 = "plc_t4";
QStringList titleblockInfoKeys();
QString titleblockInfoKeysToVar(const QString &info);
QHash <QString, QString> titleblockTranslatedKeyHashVar();
QStringList folioReportInfoKeys();
QHash <QString, QString> folioReportInfoKeyToVar();
QString folioReportInfoToVar(const QString &info);
QStringList conductorInfoKeys();
QStringList diagramInfoKeys();
QStringList elementInfoKeys();
QStringList elementEditorElementInfoKeys();
QString elementInfoToVar(const QString &info);
QRegularExpression numericInfoPattern();
class NumericInfoValidator : public QRegularExpressionValidator
{
public:
explicit NumericInfoValidator(QObject *parent = nullptr);
State validate(QString &input, int &pos) const override;
};
QString infoToVar(const QString &info);
QString translatedInfoKey(const QString &info);
}
#endif // QETINFORMATION_H