From 031710b5fca25b305da4a66faf78e4df5fb1ad23 Mon Sep 17 00:00:00 2001 From: ispyisail Date: Sun, 2 Aug 2026 08:24:01 +1200 Subject: [PATCH] Add quick reset buttons to the auto-numbering dock Resetting an active numbering counter back to a starting value, or marking it as needing manual numbering, currently requires the full round trip through the project properties dialog: open it from the dock's Configure button, locate the right numbering context, select the specific part row, clear and retype the value, confirm. Add two small buttons next to each of the three combo boxes (Conductor/Element/Folio) on AutoNumberingDockWidget itself: - Reset to start: calls NumerotationContext::replaceValue() on every part that represents a progressing counter, using a sensible per-type value -- the part's own stored initialvalue for folio-anchored types (unitfolio/tenfolio/hundredfolio), "1" for plain numeric types and wrap, "a" for alpha. Non-incrementing types (string, plant, locmach, idfolio, folio, elementline, elementcolumn, elementprefix) are left untouched, since there's no meaningful "start" distinct from whatever the user configured for a fixed/contextual value. - Reset to "?": sets every part's value to the literal placeholder "?" unconditionally, for marking a context as needing manual numbering. Both write the updated context back via the same addConductorAutoNum/addElementAutoNum/addFolioAutoNum calls the project properties dialog itself already uses, so the dock's existing refresh signals fire exactly as they do today. Verified with a full build (Qt6) after the change -- clean compile and link, including the .ui-generated Ui class correctly picking up the six new button object names. Wasn't able to get a reliable live GUI run in this environment to click-test the buttons themselves (ran into unrelated session/display instability before any interaction with the new buttons occurred), so this is verified by code review and successful build rather than a runtime screenshot. Implements https://github.com/qelectrotech/qelectrotech-source-mirror/discussions/597 --- .../autoNum/ui/autonumberingdockwidget.cpp | 94 +++++++++++++++ sources/autoNum/ui/autonumberingdockwidget.h | 23 +++- sources/autoNum/ui/autonumberingdockwidget.ui | 108 ++++++++++++++++++ 3 files changed, 224 insertions(+), 1 deletion(-) diff --git a/sources/autoNum/ui/autonumberingdockwidget.cpp b/sources/autoNum/ui/autonumberingdockwidget.cpp index 97f2d2f1b..397995590 100644 --- a/sources/autoNum/ui/autonumberingdockwidget.cpp +++ b/sources/autoNum/ui/autonumberingdockwidget.cpp @@ -26,6 +26,8 @@ #include "../numerotationcontext.h" #include "ui_autonumberingdockwidget.h" +#include + /** @brief AutoNumberingDockWidget::AutoNumberingDockWidget Constructor @@ -339,3 +341,95 @@ void AutoNumberingDockWidget::on_m_configure_pb_clicked() ppd.exec(); } } + +void AutoNumberingDockWidget::on_m_conductor_reset_start_pb_clicked() +{ + resetAutoNum(ui->m_conductor_cb, AutoNumCategory::Conductor, false); +} + +void AutoNumberingDockWidget::on_m_conductor_reset_placeholder_pb_clicked() +{ + resetAutoNum(ui->m_conductor_cb, AutoNumCategory::Conductor, true); +} + +void AutoNumberingDockWidget::on_m_element_reset_start_pb_clicked() +{ + resetAutoNum(ui->m_element_cb, AutoNumCategory::Element, false); +} + +void AutoNumberingDockWidget::on_m_element_reset_placeholder_pb_clicked() +{ + resetAutoNum(ui->m_element_cb, AutoNumCategory::Element, true); +} + +void AutoNumberingDockWidget::on_m_folio_reset_start_pb_clicked() +{ + resetAutoNum(ui->m_folio_cb, AutoNumCategory::Folio, false); +} + +void AutoNumberingDockWidget::on_m_folio_reset_placeholder_pb_clicked() +{ + resetAutoNum(ui->m_folio_cb, AutoNumCategory::Folio, true); +} + +/** + @brief AutoNumberingDockWidget::resetAutoNum + Reset the numerotation context currently selected in combo_box (for + category) either to a per-type starting value (to_placeholder = false) + or to the literal placeholder "?" on every part (to_placeholder = + true), then write it back so the existing refresh signals fire as + normal. Does nothing if no context is selected. + + "Reset to start" only touches parts that actually represent a + progressing counter (numeric types, wrap, alpha): folio-anchored + numeric types go back to their own stored initialvalue, plain numeric + types and wrap go back to "1", alpha goes back to "a". Non-incrementing + types (string, plant, locmach, idfolio, folio, elementline, + elementcolumn, elementprefix) are left untouched -- there's no + meaningful "start" distinct from whatever the user configured for a + fixed/contextual value. "Reset to ?" applies to every part + unconditionally, since its purpose is marking the whole context as + needing manual attention. +*/ +void AutoNumberingDockWidget::resetAutoNum(QComboBox *combo_box, AutoNumCategory category, bool to_placeholder) +{ + if (!m_project || combo_box->currentText().isEmpty()) + return; + + const QString key = combo_box->currentText(); + NumerotationContext context; + switch (category) { + case AutoNumCategory::Conductor: context = m_project->conductorAutoNum(key); break; + case AutoNumCategory::Element: context = m_project->elementAutoNum(key); break; + case AutoNumCategory::Folio: context = m_project->folioAutoNum(key); break; + } + + for (int i = 0; i < context.size(); ++i) + { + if (to_placeholder) + { + context.replaceValue(i, QStringLiteral("?")); + continue; + } + + const QStringList item = context.itemAt(i); + const QString &type = item.at(0); + if (type == QLatin1String("unitfolio") + || type == QLatin1String("tenfolio") + || type == QLatin1String("hundredfolio")) + context.replaceValue(i, item.size() > 3 ? item.at(3) : QStringLiteral("1")); + else if (type == QLatin1String("unit") + || type == QLatin1String("ten") + || type == QLatin1String("hundred") + || type == QLatin1String("wrap")) + context.replaceValue(i, QStringLiteral("1")); + else if (type == QLatin1String("alpha")) + context.replaceValue(i, QStringLiteral("a")); + } + + switch (category) { + case AutoNumCategory::Conductor: m_project->addConductorAutoNum(key, context); break; + case AutoNumCategory::Element: m_project->addElementAutoNum(key, context); break; + case AutoNumCategory::Folio: m_project->addFolioAutoNum(key, context); break; + } +} diff --git a/sources/autoNum/ui/autonumberingdockwidget.h b/sources/autoNum/ui/autonumberingdockwidget.h index 9232b908b..6b994f6bc 100644 --- a/sources/autoNum/ui/autonumberingdockwidget.h +++ b/sources/autoNum/ui/autonumberingdockwidget.h @@ -23,6 +23,8 @@ #include +class QComboBox; + namespace Ui { class AutoNumberingDockWidget; } @@ -53,11 +55,30 @@ class AutoNumberingDockWidget : public QDockWidget void projectClosed(); void on_m_configure_pb_clicked(); - + + void on_m_conductor_reset_start_pb_clicked(); + void on_m_conductor_reset_placeholder_pb_clicked(); + void on_m_element_reset_start_pb_clicked(); + void on_m_element_reset_placeholder_pb_clicked(); + void on_m_folio_reset_start_pb_clicked(); + void on_m_folio_reset_placeholder_pb_clicked(); + signals: void folioAutoNumChanged(QString); private: + enum class AutoNumCategory { Conductor, Element, Folio }; + + /** + @brief resetAutoNum + Reset the numerotation context currently selected in combo_box + (for the given category) either to a per-type starting value + (to_placeholder = false) or to the literal placeholder "?" on + every part (to_placeholder = true). Does nothing if no context + is selected. + */ + void resetAutoNum(QComboBox *combo_box, AutoNumCategory category, bool to_placeholder); + Ui::AutoNumberingDockWidget *ui; QETProject* m_project = nullptr; ProjectView* m_project_view = nullptr; diff --git a/sources/autoNum/ui/autonumberingdockwidget.ui b/sources/autoNum/ui/autonumberingdockwidget.ui index a1d9082aa..846609274 100644 --- a/sources/autoNum/ui/autonumberingdockwidget.ui +++ b/sources/autoNum/ui/autonumberingdockwidget.ui @@ -28,6 +28,42 @@ + + + + + 24 + 16777215 + + + + Réinitialiser à la valeur de départ + + + + + + + :/ico/16x16/view-refresh.png:/ico/16x16/view-refresh.png + + + + + + + + 24 + 16777215 + + + + Réinitialiser à « ? » (à numéroter manuellement) + + + ? + + + @@ -42,9 +78,81 @@ + + + + + 24 + 16777215 + + + + Réinitialiser à la valeur de départ + + + + + + + :/ico/16x16/view-refresh.png:/ico/16x16/view-refresh.png + + + + + + + + 24 + 16777215 + + + + Réinitialiser à « ? » (à numéroter manuellement) + + + ? + + + + + + + + 24 + 16777215 + + + + Réinitialiser à la valeur de départ + + + + + + + :/ico/16x16/view-refresh.png:/ico/16x16/view-refresh.png + + + + + + + + 24 + 16777215 + + + + Réinitialiser à « ? » (à numéroter manuellement) + + + ? + + +