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
This commit is contained in:
ispyisail
2026-08-02 08:24:01 +12:00
parent c1694f2b4f
commit 031710b5fc
3 changed files with 224 additions and 1 deletions
@@ -26,6 +26,8 @@
#include "../numerotationcontext.h"
#include "ui_autonumberingdockwidget.h"
#include <QComboBox>
/**
@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;
}
}
+22 -1
View File
@@ -23,6 +23,8 @@
#include <QDockWidget>
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;
@@ -28,6 +28,42 @@
<item row="2" column="1">
<widget class="QComboBox" name="m_conductor_cb"/>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="m_conductor_reset_start_pb">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Réinitialiser à la valeur de départ</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/view-refresh.png</normaloff>:/ico/16x16/view-refresh.png</iconset>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QPushButton" name="m_conductor_reset_placeholder_pb">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Réinitialiser à « ? » (à numéroter manuellement)</string>
</property>
<property name="text">
<string>?</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
@@ -42,9 +78,81 @@
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="m_element_reset_start_pb">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Réinitialiser à la valeur de départ</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/view-refresh.png</normaloff>:/ico/16x16/view-refresh.png</iconset>
</property>
</widget>
</item>
<item row="3" column="3">
<widget class="QPushButton" name="m_element_reset_placeholder_pb">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Réinitialiser à « ? » (à numéroter manuellement)</string>
</property>
<property name="text">
<string>?</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="m_folio_cb"/>
</item>
<item row="4" column="2">
<widget class="QPushButton" name="m_folio_reset_start_pb">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Réinitialiser à la valeur de départ</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../../qelectrotech.qrc">
<normaloff>:/ico/16x16/view-refresh.png</normaloff>:/ico/16x16/view-refresh.png</iconset>
</property>
</widget>
</item>
<item row="4" column="3">
<widget class="QPushButton" name="m_folio_reset_placeholder_pb">
<property name="maximumSize">
<size>
<width>24</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Réinitialiser à « ? » (à numéroter manuellement)</string>
</property>
<property name="text">
<string>?</string>
</property>
</widget>
</item>
<item row="6" column="0">
<spacer name="verticalSpacer">
<property name="orientation">