mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-12 07:04:12 +02:00
Fix cable numbering rule questions: per project, and a first rule counts
Two defects found while re-testing the cable management after the upstream merge, plus one change of intent for the numbering question. The question "define a cable numbering rule now?" kept its answer in the program settings, so saying no once silenced every project of the program -- the exact opposite of what it should do. The answer now travels with the project itself, stored on the <cable_autonums> element as ask_numbering_rule="false"; a file which does not hold the answer asks again, and taking the rule away in the project properties or in the numbering window brings the question back for that project alone. Read-only projects are no longer asked at all, since there is nowhere in them to define a rule. The numbering window could not hand out the first rule of a project: it drew the rule, worked the numbers out with it, and only wrote the rule into the project together with those numbers -- while the planning refused to run on a project which had no rule saved yet. The counters of a cable rule are kept under its fixed name anyway, so planning now falls back to that name when the project holds no rule yet: a rule which is being drawn in the window counts from the moment it is complete, and the first renumbering of a project works.
This commit is contained in:
@@ -967,6 +967,32 @@ void QETProject::setCableXAxisFirst(bool x_axis_first)
|
||||
m_cable_axis_x_first = x_axis_first;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::cableAskNumbering
|
||||
@return true when the cable tool may still ask this project whether
|
||||
a numbering rule should be defined. The answer to that question is
|
||||
kept with the project rather than in the program settings, so that
|
||||
one project being answered with no does not stop every other
|
||||
project from asking.
|
||||
*/
|
||||
bool QETProject::cableAskNumbering() const
|
||||
{
|
||||
return m_cable_ask_numbering;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::setCableAskNumbering
|
||||
Take the answer he gave to the numbering question down with the
|
||||
project. False means he has said no once here and is not to be
|
||||
asked again in this project; taking the rule away puts it back to
|
||||
true so the question comes again.
|
||||
@param ask
|
||||
*/
|
||||
void QETProject::setCableAskNumbering(bool ask)
|
||||
{
|
||||
m_cable_ask_numbering = ask;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief QETProject::renumberElementsBySchemeTitle
|
||||
Renumber existing elements by element autonumbering scheme title.
|
||||
@@ -2597,6 +2623,13 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
|
||||
m_cable_axis_x_first = cable_autonums.attribute(
|
||||
QStringLiteral("axis_priority"), QStringLiteral("x"))
|
||||
!= QLatin1String("y");
|
||||
//Whether the numbering question was already answered with
|
||||
//no in this project. A file which does not hold the answer
|
||||
//yet asks again rather than staying silent: it is his own
|
||||
//answer per project which is kept, not a default saying no.
|
||||
m_cable_ask_numbering = cable_autonums.attribute(
|
||||
QStringLiteral("ask_numbering_rule"), QStringLiteral("true"))
|
||||
!= QLatin1String("false");
|
||||
for (auto elmt : QET::findInDomElement(cable_autonums, QStringLiteral("cable_autonum")))
|
||||
{
|
||||
NumerotationContext nc;
|
||||
@@ -2865,6 +2898,12 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element)
|
||||
cable_autonums.setAttribute("current_autonum", m_current_cable_autonum);
|
||||
cable_autonums.setAttribute("axis_priority",
|
||||
m_cable_axis_x_first ? "x" : "y");
|
||||
//Only the no is written down: a project which has not answered
|
||||
//the numbering question yet asks again, so silence in the file
|
||||
//means asking rather than holding back.
|
||||
if (!m_cable_ask_numbering) {
|
||||
cable_autonums.setAttribute("ask_numbering_rule", "false");
|
||||
}
|
||||
QStringList cable_autonum_keys = cableAutoNum().keys();
|
||||
cable_autonum_keys.sort();
|
||||
for (const QString &key : std::as_const(cable_autonum_keys)) {
|
||||
|
||||
Reference in New Issue
Block a user