|
From: Tapio V. <aa...@us...> - 2011-01-17 09:19:19
|
Module: editor
Branch: master
Commit: 838324eb5e2a041d6030b498cd67e36cad21aa81
Author: Tapio Vierros <tap...@gm...>
Date: Mon Jan 17 10:50:02 2011 +0200
Opening a file can be undone in one step.
Doesn't bring back the old notes though.
---
editorapp.cc | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/editorapp.cc b/editorapp.cc
index e541701..03591a7 100644
--- a/editorapp.cc
+++ b/editorapp.cc
@@ -174,7 +174,10 @@ void EditorApp::on_actionOpen_triggered()
song.reset(new Song(QString(finfo.path()+"/").toStdString(), finfo.fileName().toStdString()));
noteGraph->setLyrics(song->getVocalTrack());
updateSongMeta(true);
- noteGraph->doOperation(Operation("BLOCK")); // Lock the undo stack
+ // Combine the import into one undo action
+ Operation combiner("COMBINER"); combiner << opStack.size();
+ operationDone(combiner);
+ //noteGraph->doOperation(Operation("BLOCK")); // Lock the undo stack
}
} catch (const std::exception& e) {
QMessageBox::critical(this, tr("Error loading file!"), e.what());
@@ -273,6 +276,8 @@ void EditorApp::on_actionExit_triggered()
void EditorApp::on_actionUndo_triggered()
{
+ if (opStack.isEmpty())
+ return;
if (opStack.top().op() == "BLOCK")
return;
else if (opStack.top().op() == "COMBINER") {
@@ -280,7 +285,6 @@ void EditorApp::on_actionUndo_triggered()
for (int i = 0; i < count; ++i) opStack.pop();
// TODO: Redo handling
}
-
// TODO: Move popped to redo stack
opStack.pop();
doOpStack();
|