Move marker undo code to seperate file
This commit is contained in:
@@ -20,5 +20,7 @@ set(OLIVE_SOURCES
|
||||
widget/marker/marker.cpp
|
||||
widget/marker/markercopypaste.h
|
||||
widget/marker/markercopypaste.cpp
|
||||
widget/marker/markerundo.h
|
||||
widget/marker/markerundo.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "markercopypaste.h"
|
||||
|
||||
#include "core.h"
|
||||
#include "markerundo.h"
|
||||
#include "widget/timebased/timebasedwidget.h"
|
||||
|
||||
namespace olive {
|
||||
@@ -108,7 +109,7 @@ void MarkerCopyPasteService::PasteMarkersFromClipboard(TimelineMarkerList* list,
|
||||
}
|
||||
}
|
||||
|
||||
command->add_child(new TimeBasedWidget::MarkerAddCommand(Core::instance()->GetActiveProject(),
|
||||
command->add_child(new MarkerAddCommand(Core::instance()->GetActiveProject(),
|
||||
list,
|
||||
TimeRange(in + offset, out + offset),
|
||||
name,
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/***
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2021 Olive Team
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#include "markerundo.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
MarkerAddCommand::MarkerAddCommand(Project *project, TimelineMarkerList *marker_list, const TimeRange &range, const QString &name, int color) :
|
||||
project_(project),
|
||||
marker_list_(marker_list),
|
||||
range_(range),
|
||||
name_(name),
|
||||
color_(color)
|
||||
{
|
||||
}
|
||||
|
||||
Project* MarkerAddCommand::GetRelevantProject() const
|
||||
{
|
||||
return project_;
|
||||
}
|
||||
|
||||
void MarkerAddCommand::redo()
|
||||
{
|
||||
added_marker_ = marker_list_->AddMarker(range_, name_, color_);
|
||||
}
|
||||
|
||||
void MarkerAddCommand::undo()
|
||||
{
|
||||
marker_list_->RemoveMarker(added_marker_);
|
||||
}
|
||||
|
||||
MarkerRemoveCommand::MarkerRemoveCommand(Project *project, TimelineMarker *marker, TimelineMarkerList *marker_list) :
|
||||
project_(project),
|
||||
marker_(marker),
|
||||
marker_list_(marker_list),
|
||||
range_(marker->time()),
|
||||
name_(marker->name()),
|
||||
color_(marker->color())
|
||||
{
|
||||
}
|
||||
|
||||
Project* MarkerRemoveCommand::GetRelevantProject() const
|
||||
{
|
||||
return project_;
|
||||
}
|
||||
|
||||
void MarkerRemoveCommand::redo()
|
||||
{
|
||||
marker_list_->RemoveMarker(marker_);
|
||||
}
|
||||
|
||||
void MarkerRemoveCommand::undo()
|
||||
{
|
||||
marker_list_->AddMarker(range_, name_, color_);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/***
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2021 Olive Team
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
***/
|
||||
|
||||
#ifndef MARKERUNDO_H
|
||||
#define MARKERUNDO_H
|
||||
|
||||
#include "undo/undocommand.h"
|
||||
#include "timeline/timelinemarker.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class MarkerAddCommand : public UndoCommand {
|
||||
public:
|
||||
MarkerAddCommand(Project* project, TimelineMarkerList* marker_list, const TimeRange& range, const QString& name,
|
||||
int color = -1);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
|
||||
private:
|
||||
Project* project_;
|
||||
TimelineMarkerList* marker_list_;
|
||||
TimeRange range_;
|
||||
QString name_;
|
||||
int color_;
|
||||
|
||||
TimelineMarker* added_marker_;
|
||||
};
|
||||
|
||||
class MarkerRemoveCommand : public UndoCommand {
|
||||
public:
|
||||
MarkerRemoveCommand(Project* project, TimelineMarker* marker, TimelineMarkerList* marker_list);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
|
||||
private:
|
||||
Project* project_;
|
||||
TimelineMarker* marker_;
|
||||
TimelineMarkerList* marker_list_;
|
||||
TimeRange range_;
|
||||
QString name_;
|
||||
int color_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // TIMELINEUNDOTRACK_H
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "config/config.h"
|
||||
#include "core.h"
|
||||
#include "node/project/sequence/sequence.h"
|
||||
#include "widget/marker/markerundo.h"
|
||||
#include "widget/timelinewidget/undo/timelineundoworkarea.h"
|
||||
|
||||
namespace olive {
|
||||
@@ -665,55 +666,6 @@ void TimeBasedWidget::DeleteSelected()
|
||||
}
|
||||
}
|
||||
|
||||
TimeBasedWidget::MarkerAddCommand::MarkerAddCommand(Project *project, TimelineMarkerList *marker_list, const TimeRange &range, const QString &name, int color) :
|
||||
project_(project),
|
||||
marker_list_(marker_list),
|
||||
range_(range),
|
||||
name_(name),
|
||||
color_(color)
|
||||
{
|
||||
}
|
||||
|
||||
Project *TimeBasedWidget::MarkerAddCommand::GetRelevantProject() const
|
||||
{
|
||||
return project_;
|
||||
}
|
||||
|
||||
void TimeBasedWidget::MarkerAddCommand::redo()
|
||||
{
|
||||
added_marker_ = marker_list_->AddMarker(range_, name_, color_);
|
||||
}
|
||||
|
||||
void TimeBasedWidget::MarkerAddCommand::undo()
|
||||
{
|
||||
marker_list_->RemoveMarker(added_marker_);
|
||||
}
|
||||
|
||||
TimeBasedWidget::MarkerRemoveCommand::MarkerRemoveCommand(Project* project, TimelineMarker* marker, TimelineMarkerList* marker_list) :
|
||||
project_(project),
|
||||
marker_(marker),
|
||||
marker_list_(marker_list),
|
||||
range_(marker->time()),
|
||||
name_(marker->name()),
|
||||
color_(marker->color())
|
||||
{
|
||||
}
|
||||
|
||||
Project *TimeBasedWidget::MarkerRemoveCommand::GetRelevantProject() const
|
||||
{
|
||||
return project_;
|
||||
}
|
||||
|
||||
void TimeBasedWidget::MarkerRemoveCommand::redo()
|
||||
{
|
||||
marker_list_->RemoveMarker(marker_);
|
||||
}
|
||||
|
||||
void TimeBasedWidget::MarkerRemoveCommand::undo()
|
||||
{
|
||||
marker_list_->AddMarker(range_, name_, color_);
|
||||
}
|
||||
|
||||
bool TimeBasedWidget::eventFilter(QObject *object, QEvent *event)
|
||||
{
|
||||
if (wheel_passthrough_objects_.contains(object) && event->type() == QEvent::Wheel) {
|
||||
|
||||
@@ -54,47 +54,6 @@ public:
|
||||
|
||||
virtual bool eventFilter(QObject* object, QEvent* event) override;
|
||||
|
||||
// Temp file location
|
||||
|
||||
class MarkerAddCommand : public UndoCommand {
|
||||
public:
|
||||
MarkerAddCommand(Project* project, TimelineMarkerList* marker_list, const TimeRange& range, const QString& name, int color = -1);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
|
||||
private:
|
||||
Project* project_;
|
||||
TimelineMarkerList* marker_list_;
|
||||
TimeRange range_;
|
||||
QString name_;
|
||||
int color_;
|
||||
|
||||
TimelineMarker* added_marker_;
|
||||
};
|
||||
|
||||
class MarkerRemoveCommand : public UndoCommand {
|
||||
public:
|
||||
MarkerRemoveCommand(Project* project, TimelineMarker* marker, TimelineMarkerList* marker_list);
|
||||
|
||||
virtual Project* GetRelevantProject() const override;
|
||||
|
||||
protected:
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
|
||||
private:
|
||||
Project* project_;
|
||||
TimelineMarker* marker_;
|
||||
TimelineMarkerList* marker_list_;
|
||||
TimeRange range_;
|
||||
QString name_;
|
||||
int color_;
|
||||
};
|
||||
|
||||
public slots:
|
||||
void SetTime(const rational &time);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "common/qtutils.h"
|
||||
#include "core.h"
|
||||
#include "widget/timebased/timebasedwidget.h"
|
||||
#include "widget/marker/markerundo.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
@@ -95,7 +96,7 @@ void SeekableWidget::DeleteSelected() {
|
||||
MultiUndoCommand* command = new MultiUndoCommand();
|
||||
|
||||
foreach (TimelineMarker *marker, GetActiveTimelineMarkers()) {
|
||||
command->add_child(new TimeBasedWidget::MarkerRemoveCommand(Core::instance()->GetActiveProject(), marker, timeline_points_->markers()));
|
||||
command->add_child(new MarkerRemoveCommand(Core::instance()->GetActiveProject(), marker, timeline_points_->markers()));
|
||||
}
|
||||
|
||||
Core::instance()->undo_stack()->pushIfHasChildren(command);
|
||||
|
||||
Reference in New Issue
Block a user