new undo system
Also enables undoing when working with node input arrays
This commit is contained in:
@@ -571,7 +571,7 @@ void ProjectExplorer::DeleteSelected()
|
||||
return;
|
||||
}
|
||||
|
||||
QUndoCommand* command = new QUndoCommand();
|
||||
MultiUndoCommand* command = new MultiUndoCommand();
|
||||
|
||||
foreach (Item* item, selected) {
|
||||
// Verify whether this item is in use anywhere
|
||||
@@ -629,7 +629,7 @@ void ProjectExplorer::DeleteSelected()
|
||||
if (msgbox.clickedButton() == offline_btn || msgbox.clickedButton() == delete_clip_btn) {
|
||||
|
||||
// For safety, even if we're deleting clips, we'll offline the footage nodes too
|
||||
new OfflineFootageCommand(footage_nodes, command);
|
||||
command->add_child(new OfflineFootageCommand(footage_nodes));
|
||||
|
||||
}
|
||||
|
||||
@@ -676,7 +676,7 @@ void ProjectExplorer::DeleteSelected()
|
||||
break;
|
||||
}
|
||||
|
||||
new ProjectViewModel::RemoveItemCommand(&model_, item, command);
|
||||
command->add_child(new ProjectViewModel::RemoveItemCommand(&model_, item));
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->pushIfHasChildren(command);
|
||||
|
||||
@@ -31,8 +31,7 @@ namespace olive {
|
||||
*/
|
||||
class OfflineFootageCommand : public UndoCommand {
|
||||
public:
|
||||
OfflineFootageCommand(const QVector<MediaInput*>& media, QUndoCommand* parent = nullptr) :
|
||||
UndoCommand(parent)
|
||||
OfflineFootageCommand(const QVector<MediaInput*>& media)
|
||||
{
|
||||
foreach (MediaInput* i, media) {
|
||||
stream_data_.insert(i, i->stream());
|
||||
@@ -46,15 +45,14 @@ public:
|
||||
return project_;
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override
|
||||
virtual void redo() override
|
||||
{
|
||||
for (auto it=stream_data_.cbegin(); it!=stream_data_.cend(); it++) {
|
||||
it.key()->SetStream(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void undo_internal() override
|
||||
virtual void undo() override
|
||||
{
|
||||
for (auto it=stream_data_.cbegin(); it!=stream_data_.cend(); it++) {
|
||||
it.key()->SetStream(it.value());
|
||||
|
||||
Reference in New Issue
Block a user