diff main/MainWindow.cpp @ 597:110eecb5d9f6

Reset cyclical counters when document is replaced (#182)
author Chris Cannam
date Wed, 24 Jul 2013 12:02:01 +0100
parents e37154e52d89
children c0a20cd1a9ff
line wrap: on
line diff
--- a/main/MainWindow.cpp	Wed Jul 24 11:43:09 2013 +0100
+++ b/main/MainWindow.cpp	Wed Jul 24 12:02:01 2013 +0100
@@ -775,9 +775,15 @@
         }
     }
 
+    action = new QAction(tr("Reset Numbering Counters"), this);
+    action->setStatusTip(tr("Reset to 1 all the counters used for counter-based labelling"));
+    connect(action, SIGNAL(triggered()), this, SLOT(resetInstantsCounters()));
+    connect(this, SIGNAL(replacedDocument()), action, SLOT(trigger()));
+    menu->addAction(action);
+
     action = new QAction(tr("Set Numbering Counters..."), this);
     action->setStatusTip(tr("Set the counters used for counter-based labelling"));
-    connect(action, SIGNAL(triggered()), this, SLOT(resetInstantsCounters()));
+    connect(action, SIGNAL(triggered()), this, SLOT(setInstantsCounters()));
     menu->addAction(action);
             
     action = new QAction(tr("Renumber Selected Instants"), this);
@@ -4049,7 +4055,7 @@
 }
 
 void
-MainWindow::resetInstantsCounters()
+MainWindow::setInstantsCounters()
 {
     LabelCounterInputDialog dialog(m_labeller, this);
     dialog.setWindowTitle(tr("Reset Counters"));
@@ -4057,6 +4063,12 @@
 }
 
 void
+MainWindow::resetInstantsCounters()
+{
+    if (m_labeller) m_labeller->resetCounters();
+}
+
+void
 MainWindow::modelGenerationFailed(QString transformName, QString message)
 {
     emit hideSplash();