From 3d4f546dbcbb7f9bb99d398c87511bf053470039 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Fri, 2 Oct 2026 10:34:03 +1300 Subject: [PATCH] Keep both folio report arrows in the folio's context menu Fixes #1210. The "Renvoi de folio" submenu offered the common coming and going arrows only while the project had no folio report element yet. Placing one copies it into the embedded collection, so from then on the menu listed just that one and the other arrow could not be inserted until the project was closed without saving. The two common arrows are now always listed, after the project's own report elements, each name once. Checked in the GUI on a blank one-folio project: on master the submenu drops from two entries to one after a coming arrow is placed and the second pick places another coming arrow; with this change it keeps two entries and the second pick places a going arrow (both in the saved file). Co-Authored-By: Claude Opus 5.5 --- sources/diagramview.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sources/diagramview.cpp b/sources/diagramview.cpp index 0b63fd105..f0cd7ca5f 100644 --- a/sources/diagramview.cpp +++ b/sources/diagramview.cpp @@ -1950,8 +1950,8 @@ void DiagramView::contextMenuEvent(QContextMenuEvent *e) @brief DiagramView::updateFolioReportMenu Fill the "Renvoi de folio" submenu of the context menu with the folio report elements this project already uses -- the ones in its embedded - collection -- or, when it has none yet, the coming and going arrows of - the common collection. An entry places its element where the context + collection -- and the coming and going arrows of the common collection, + each name listed once. An entry places its element where the context menu was opened. Left empty, and so hidden, on a read-only diagram. */ void DiagramView::updateFolioReportMenu() @@ -1965,9 +1965,9 @@ void DiagramView::updateFolioReportMenu() QETProject *project = m_diagram->project(); XmlElementCollection *collection = project ? project->embeddedElementCollection() : nullptr; + QSet names; if (collection) { - QSet names; const QDomNodeList definitions = collection->root().elementsByTagName(QStringLiteral("definition")); for (int i = 0 ; i < definitions.count() ; ++i) @@ -1990,16 +1990,16 @@ void DiagramView::updateFolioReportMenu() } } - if (locations.isEmpty()) + //Always offer both standard arrows: placing one copies it into the + //embedded collection, and must not hide the other one. + for (const auto path : { + "common://10_electric/10_allpole/100_folio_referencing/01coming_arrow.elmt", + "common://10_electric/10_allpole/100_folio_referencing/02going_arrow.elmt"}) { - for (const auto path : { - "common://10_electric/10_allpole/100_folio_referencing/01coming_arrow.elmt", - "common://10_electric/10_allpole/100_folio_referencing/02going_arrow.elmt"}) - { - const ElementsLocation location(QString::fromLatin1(path)); - if (location.exist()) { - locations << location; - } + const ElementsLocation location(QString::fromLatin1(path)); + if (location.exist() && !names.contains(location.name())) { + names.insert(location.name()); + locations << location; } }