AutoNum: a lot of changes

Schemas now get saved with a UUID and do not have to be looked up according to the form. They can be renamed and it gets reflected in existing elements. The GUI for
editing them is now much easier, e.g. forms can be reshuffled. A formula can be applied. Many options now also for conductors and sheets.
This commit is contained in:
Andre Rummler
2026-10-03 17:53:27 +02:00
parent 389fd454da
commit d76f3528ae
52 changed files with 6040 additions and 382 deletions
+21
View File
@@ -16,6 +16,7 @@
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
*/
#include "elementspanelwidget.h"
#include "autoNum/elementautonumschemecommand.h"
#include "diagram.h"
#include "qetgraphicsitem/conductor.h"
#include "editor/ui/qetelementeditor.h"
@@ -699,6 +700,14 @@ void ElementsPanelWidget::duplicateDiagram()
elmt->initLink(new_elements);
}
// The numberings the copies follow, known before the label
// erasing below empties their formula
const bool autonumber = QSettings().value(
"diagramcommands/autonumber-pasted-elements", true).toBool();
const QMap<QString, QVector<Element *>> copy_schemes = autonumber
? ElementAutoNumSchemeCommand::pastedSchemes(project, new_elements)
: QMap<QString, QVector<Element *>>();
for (QGraphicsItem *item : new_diagram->items()) {
if (Element *elmt = dynamic_cast<Element *>(item)) {
// The XML round-trip kept the source elements' uuids. Give the
@@ -835,6 +844,18 @@ void ElementsPanelWidget::duplicateDiagram()
}
}
// The copies follow the numberings of the project: they get the
// next numbers, as pasted elements do. This duplication is not
// undoable, so neither is the numbering: it is done at once.
ElementAutoNumSchemeCommand::linkPasted(project, new_elements);
if (!copy_schemes.isEmpty())
{
QUndoCommand numbering;
if (ElementAutoNumSchemeCommand::numberPasted(project, copy_schemes, &numbering)) {
numbering.redo();
}
}
// Groups too: a group of the copy is its own, so selecting it
// is the same on both folios but the database tells them apart.
QHash<QUuid, QUuid> renewed_groups;