Add editing the information of several elements at once (#1439)

Selecting several elements left the Selection properties panel blank and
Edit (Ctrl+E) disabled, so giving many elements the same supplier or
manufacturer meant editing them one by one.

The panel now shows the Information fields for two or more elements, or
for elements selected with other items (left unchanged, and counted in
the panel's header). Ctrl+E opens the same editor as a dialog when only
elements are selected.

- A field shows the value every element shares, or "Multiple values".
  Left alone, each element keeps its own value; typed text goes to every
  element; the erase box clears the field on every element.
- A restore button per field, and Reset, bring back the values the
  elements had.
- One apply is one undo step. The keystrokes typed in the panel merge
  into one step but never into an earlier change of the same elements
  (a paste of element information, another edit).
- Numbering scheme, label freezing and the number picker are left out:
  they are about one element. Custom properties are kept as they are.

Also:
- An element's own texts, selected with it by Select all, count as part
  of the element, not as other items.
- ElementInfoWidget::reset(): Reset in the element dialog now brings back
  the Information tab's values; it did nothing.
- The panel opens an element's editor on the tab picked last, instead of
  the first tab, after the selection went to something else and back.

Test: tst_multielementinfo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-10-18 21:44:00 +13:00
parent e46bb97c5b
commit ce0798bb18
12 changed files with 1506 additions and 48 deletions
+28 -2
View File
@@ -39,7 +39,9 @@
#include "qeticons.h"
#include "qetpalette.h"
#include "titleblock/integrationmovetemplateshandler.h"
#include "PropertiesEditor/propertieseditordialog.h"
#include "ui/diagrampropertiesdialog.h"
#include "ui/multielementinfowidget.h"
#include "ui/multipastedialog.h"
#include "undocommand/changetitleblockcommand.h"
#include "utils/conductorcreator.h"
@@ -2080,9 +2082,33 @@ bool DiagramView::selectedItemHasFocus()
*/
void DiagramView::editSelection()
{
if (m_diagram -> isReadOnly() || m_diagram -> selectedItems().size() != 1 ) return;
if (m_diagram -> isReadOnly()) return;
QGraphicsItem *item = m_diagram->selectedItems().first();
//Several elements and nothing else: edit their information together (#1439)
const QList<QGraphicsItem *> selection =
MultiElementInfoWidget::withoutOwnTexts(m_diagram -> selectedItems());
if (selection.size() > 1)
{
bool only_elements = true;
for (QGraphicsItem *qgi : selection) {
if (qgi->type() != Element::Type) {
only_elements = false;
break;
}
}
const QList<Element *> elements = MultiElementInfoWidget::informationElements(selection);
if (only_elements && elements.size() > 1)
{
PropertiesEditorDialog dialog(
new MultiElementInfoWidget(elements, selection.size() - elements.size()),
this);
dialog.exec();
}
return;
}
if (selection.size() != 1) return;
QGraphicsItem *item = selection.first();
//We use dynamic_cast instead of qgraphicsitem_cast for QetGraphicsItem
//because they haven't got their own type().