4 #include "mainindexes.h"
6 #include "mainsession.h"
9 #include "mwindowgui.h"
12 MainUndo::MainUndo(MWindow *mwindow)
14 this->mwindow = mwindow;
15 undo_before_updated = 0;
22 void MainUndo::update_undo_before(char *description, uint32_t load_flags)
24 if(!undo_before_updated)
27 mwindow->session->changes_made = 1;
28 mwindow->edl->save_xml(mwindow->plugindb,
33 file.terminate_string();
35 current_entry = undo_stack.push();
36 current_entry->load_flags = load_flags;
37 current_entry->set_data_before(file.string);
38 current_entry->set_description(description);
40 // the after update is always without a description
41 mwindow->gui->lock_window();
42 mwindow->gui->mainmenu->undo->update_caption(description);
43 mwindow->gui->mainmenu->redo->update_caption("");
44 mwindow->gui->unlock_window();
46 undo_before_updated = 1;
50 void MainUndo::update_undo_after()
52 if(undo_before_updated)
55 mwindow->edl->save_xml(mwindow->plugindb,
60 file.terminate_string();
61 current_entry->set_data_after(file.string);
62 undo_before_updated = 0;
73 if(undo_stack.current)
75 current_entry = undo_stack.current;
76 if(current_entry->description && mwindow->gui)
77 mwindow->gui->mainmenu->redo->update_caption(current_entry->description);
81 file.read_from_string(current_entry->data_before);
82 load_from_undo(&file, current_entry->load_flags);
84 undo_stack.pull(); // move current back
87 current_entry = undo_stack.current;
89 mwindow->gui->mainmenu->undo->update_caption(current_entry->description);
91 mwindow->gui->mainmenu->undo->update_caption("");
99 current_entry = undo_stack.pull_next();
104 file.read_from_string(current_entry->data_after);
105 load_from_undo(&file, current_entry->load_flags);
109 mwindow->gui->mainmenu->undo->update_caption(current_entry->description);
111 if(current_entry->next)
112 mwindow->gui->mainmenu->redo->update_caption(current_entry->next->description);
114 mwindow->gui->mainmenu->redo->update_caption("");
121 // Here the master EDL loads
122 int MainUndo::load_from_undo(FileXML *file, uint32_t load_flags)
124 mwindow->edl->load_xml(mwindow->plugindb, file, load_flags);
125 for(Asset *asset = mwindow->edl->assets->first;
129 mwindow->mainindexes->add_next_asset(asset);
131 mwindow->mainindexes->start_build();