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:
Kellermorph
2026-10-09 20:22:45 +02:00
parent 955dfb3a73
commit d55a3c7881
7 changed files with 92 additions and 25 deletions
+18 -7
View File
@@ -2331,11 +2331,20 @@ void QETDiagramEditor::selectGroupTriggered(QAction *action)
bool QETDiagramEditor::cableNumberingGate(Diagram *diagram)
{
if (!diagram || !diagram->project()) return true;
if (diagram->project()->hasCableAutoNum()) return true;
QETProject *project = diagram->project();
if (project->hasCableAutoNum()) return true;
QSettings settings;
const QString ask_key = QStringLiteral("cable-management/ask_numbering_rule");
if (!settings.value(ask_key, true).toBool()) {
//A read-only project is left alone without a question: there is
//nowhere to define a rule in it, so asking whether he wants to
//would be a way to nowhere. Its cables are drawn called W, the
//same as any project without a rule.
if (project->isReadOnly()) return true;
//Whether he has once answered no in THIS project. The answer is
//kept with the project rather than in the program settings, so
//one project being answered with no does not stop every other
//project from being asked.
if (!project->cableAskNumbering()) {
return true;
}
@@ -2358,9 +2367,11 @@ bool QETDiagramEditor::cableNumberingGate(Diagram *diagram)
box.exec();
if (box.clickedButton() == later_button) {
//For good, in the program settings: he has answered this
//once and should not be asked again at every start.
settings.setValue(ask_key, false);
//With this project only: he has answered once here and
//should not be asked again every time he picks the tool
//up in this project -- another project is free to ask.
project->setCableAskNumbering(false);
project->setModified(true);
return true;
}
if (box.clickedButton() != define_button) {