src/mainwindow.cpp

changeset 983
05ba93066194
parent 981
5d5d84ab2c48
child 984
a7b6f987d269
--- a/src/mainwindow.cpp	Sun Sep 06 01:52:37 2015 +0300
+++ b/src/mainwindow.cpp	Sun Sep 06 03:00:28 2015 +0300
@@ -1033,10 +1033,10 @@
 {
 	if (m_currentDocument != null and m_currentDocument->history() != null)
 	{
-		History* his = m_currentDocument->history();
+		EditHistory* his = m_currentDocument->history();
 		int pos = his->position();
 		ui.actionUndo->setEnabled (pos != -1);
-		ui.actionRedo->setEnabled (pos < (long) his->getSize() - 1);
+		ui.actionRedo->setEnabled (pos < (long) his->size() - 1);
 	}
 
 	ui.actionWireframe->setChecked (m_configOptions.drawWireframe());
@@ -1085,6 +1085,14 @@
 
 // ---------------------------------------------------------------------------------------------------------------------
 //
+void MainWindow::historyTraversed()
+{
+	updateActions();
+	refresh();
+}
+
+// ---------------------------------------------------------------------------------------------------------------------
+//
 void MainWindow::loadShortcuts()
 {
 	for (QAction* act : findChildren<QAction*>())
@@ -1216,12 +1224,17 @@
 //
 LDDocument* MainWindow::newDocument (bool cache)
 {
-	m_documents.append (new LDDocument (this));
+	LDDocument* document = new LDDocument (this);
+	m_documents.append (document);
+
+	connect (document->history(), SIGNAL (undone()), this, SLOT (historyTraversed()));
+	connect (document->history(), SIGNAL (redone()), this, SLOT (historyTraversed()));
+	connect (document->history(), SIGNAL (stepAdded()), this, SLOT (updateActions()));
 
 	if (not cache)
-		m_documents.last()->openForEditing();
+		document->openForEditing();
 
-	return m_documents.last();
+	return document;
 }
 
 // ---------------------------------------------------------------------------------------------------------------------

mercurial