support for adding markers #123
This commit is contained in:
@@ -1378,3 +1378,41 @@ void SetAutoscaleAction::redo() {
|
||||
}
|
||||
panel_viewer->viewer_widget->update();
|
||||
}
|
||||
|
||||
AddMarkerAction::AddMarkerAction(Sequence* s, long t, QString n) :
|
||||
seq(s),
|
||||
time(t),
|
||||
name(n),
|
||||
old_project_changed(project_changed)
|
||||
{}
|
||||
|
||||
void AddMarkerAction::undo() {
|
||||
if (index == -1) {
|
||||
sequence->markers.removeLast();
|
||||
} else {
|
||||
sequence->markers[index].name = old_name;
|
||||
}
|
||||
|
||||
project_changed = old_project_changed;
|
||||
}
|
||||
|
||||
void AddMarkerAction::redo() {
|
||||
index = -1;
|
||||
for (int i=0;i<sequence->markers.size();i++) {
|
||||
if (sequence->markers.at(i).frame == time) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index == -1) {
|
||||
Marker m;
|
||||
m.frame = time;
|
||||
sequence->markers.append(m);
|
||||
} else {
|
||||
old_name = sequence->markers.at(index).name;
|
||||
sequence->markers[index].name = name;
|
||||
}
|
||||
|
||||
project_changed = true;
|
||||
}
|
||||
|
||||
@@ -463,4 +463,18 @@ public:
|
||||
QVector<Clip*> clips;
|
||||
};
|
||||
|
||||
class AddMarkerAction : public QUndoCommand {
|
||||
public:
|
||||
AddMarkerAction(Sequence* s, long t, QString n);
|
||||
void undo();
|
||||
void redo();
|
||||
private:
|
||||
Sequence* seq;
|
||||
long time;
|
||||
QString name;
|
||||
QString old_name;
|
||||
bool old_project_changed;
|
||||
int index;
|
||||
};
|
||||
|
||||
#endif // UNDO_H
|
||||
|
||||
Reference in New Issue
Block a user