Merge branch 'master' of https://github.com/olive-editor/olive into proxies
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include <QMutex>
|
||||
#include <QVector>
|
||||
|
||||
#include "marker.h"
|
||||
|
||||
#define SKIP_TYPE_DISCARD 0
|
||||
#define SKIP_TYPE_SEEK 1
|
||||
|
||||
@@ -73,6 +75,9 @@ struct Clip
|
||||
bool maintain_audio_pitch;
|
||||
bool autoscale;
|
||||
|
||||
// markers
|
||||
QVector<Marker> markers;
|
||||
|
||||
// other variables (should be deep copied/duplicated in copy())
|
||||
QList<Effect*> effects;
|
||||
QVector<int> linked;
|
||||
|
||||
@@ -1 +1,18 @@
|
||||
#include "marker.h"
|
||||
|
||||
void draw_marker(QPainter &p, int x, int y, int bottom, bool selected, bool flipped) {
|
||||
const QPoint points[5] = {
|
||||
QPoint(x, bottom),
|
||||
QPoint(x + MARKER_SIZE, bottom - MARKER_SIZE),
|
||||
QPoint(x + MARKER_SIZE, y),
|
||||
QPoint(x - MARKER_SIZE, y),
|
||||
QPoint(x - MARKER_SIZE, bottom - MARKER_SIZE)
|
||||
};
|
||||
p.setPen(Qt::black);
|
||||
if (selected) {
|
||||
p.setBrush(QColor(208, 255, 208));
|
||||
} else {
|
||||
p.setBrush(QColor(128, 224, 128));
|
||||
}
|
||||
p.drawPolygon(points, 5);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
#ifndef MARKER_H
|
||||
#define MARKER_H
|
||||
|
||||
#define MARKER_SIZE 4
|
||||
|
||||
#include <QString>
|
||||
#include <QPainter>
|
||||
|
||||
struct Marker {
|
||||
long frame;
|
||||
QString name;
|
||||
};
|
||||
|
||||
void draw_marker(QPainter& p, int x, int y, int bottom, bool selected, bool flipped);
|
||||
|
||||
#endif // MARKER_H
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "projectfilter.h"
|
||||
|
||||
#include "project/media.h"
|
||||
#include "project/sequence.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
@@ -15,17 +16,48 @@ bool ProjectFilter::get_show_sequences() {
|
||||
|
||||
void ProjectFilter::set_show_sequences(bool b) {
|
||||
show_sequences = b;
|
||||
invalidateFilter();
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
void ProjectFilter::update_search_filter(const QString &s) {
|
||||
search_filter = s;
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
bool ProjectFilter::filterAcceptsRow(int source_row, const QModelIndex &source_parent) const {
|
||||
// retrieve media object from index
|
||||
QModelIndex index = sourceModel()->index(source_row, 0, source_parent);
|
||||
Media* media = static_cast<Media*>(index.internalPointer());
|
||||
|
||||
// hide sequences if show_sequences is false
|
||||
if (!show_sequences) {
|
||||
// hide sequences if show_sequences is false
|
||||
QModelIndex index = sourceModel()->index(source_row, 0, source_parent);
|
||||
Media* media = static_cast<Media*>(index.internalPointer());
|
||||
if (media != nullptr && media->get_type() == MEDIA_TYPE_SEQUENCE) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// filter by search filter string
|
||||
if (!search_filter.isEmpty()) {
|
||||
// search markers if media is a sequene
|
||||
bool marker_contains_search = false;
|
||||
|
||||
if (media->get_type() == MEDIA_TYPE_SEQUENCE) {
|
||||
Sequence* s = media->to_sequence();
|
||||
for (int i=0;i<s->markers.size();i++) {
|
||||
if (s->markers.at(i).name.contains(search_filter, Qt::CaseInsensitive)) {
|
||||
marker_contains_search = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// hide any rows that don't contain the search string (unless it's a folder)
|
||||
if (!marker_contains_search
|
||||
&& media->get_type() != MEDIA_TYPE_FOLDER
|
||||
&& !media->get_name().contains(search_filter, Qt::CaseInsensitive)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return QSortFilterProxyModel::filterAcceptsRow(source_row, source_parent);
|
||||
}
|
||||
|
||||
+19
-1
@@ -7,13 +7,31 @@ class ProjectFilter : public QSortFilterProxyModel {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ProjectFilter(QObject *parent = nullptr);
|
||||
|
||||
// are sequences visible
|
||||
bool get_show_sequences();
|
||||
|
||||
public slots:
|
||||
|
||||
// set whether sequences are visible
|
||||
void set_show_sequences(bool b);
|
||||
|
||||
// update search filter
|
||||
void update_search_filter(const QString& s);
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
|
||||
|
||||
// function that filters whether rows are displayed or not
|
||||
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
|
||||
|
||||
private:
|
||||
|
||||
// internal variable for whether to show sequences
|
||||
bool show_sequences;
|
||||
|
||||
// search filter variable
|
||||
QString search_filter;
|
||||
|
||||
};
|
||||
|
||||
#endif // PROJECTFILTER_H
|
||||
|
||||
+20
-9
@@ -803,18 +803,23 @@ void SetAutoscaleAction::redo() {
|
||||
mainWindow->setWindowModified(true);
|
||||
}
|
||||
|
||||
AddMarkerAction::AddMarkerAction(Sequence* s, long t, QString n) :
|
||||
seq(s),
|
||||
AddMarkerAction::AddMarkerAction(bool is_sequence, void* s, long t, QString n) :
|
||||
is_sequence_internal(is_sequence),
|
||||
target(s),
|
||||
time(t),
|
||||
name(n),
|
||||
old_project_changed(mainWindow->isWindowModified())
|
||||
{}
|
||||
|
||||
void AddMarkerAction::undo() {
|
||||
QVector<Marker>& markers = is_sequence_internal ?
|
||||
static_cast<Sequence*>(target)->markers :
|
||||
static_cast<Clip*>(target)->markers;
|
||||
|
||||
if (index == -1) {
|
||||
seq->markers.removeLast();
|
||||
markers.removeLast();
|
||||
} else {
|
||||
seq->markers[index].name = old_name;
|
||||
markers[index].name = old_name;
|
||||
}
|
||||
|
||||
mainWindow->setWindowModified(old_project_changed);
|
||||
@@ -822,8 +827,13 @@ void AddMarkerAction::undo() {
|
||||
|
||||
void AddMarkerAction::redo() {
|
||||
index = -1;
|
||||
for (int i=0;i<seq->markers.size();i++) {
|
||||
if (seq->markers.at(i).frame == time) {
|
||||
|
||||
QVector<Marker>& markers = is_sequence_internal ?
|
||||
static_cast<Sequence*>(target)->markers :
|
||||
static_cast<Clip*>(target)->markers;
|
||||
|
||||
for (int i=0;i<markers.size();i++) {
|
||||
if (markers.at(i).frame == time) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
@@ -832,10 +842,11 @@ void AddMarkerAction::redo() {
|
||||
if (index == -1) {
|
||||
Marker m;
|
||||
m.frame = time;
|
||||
seq->markers.append(m);
|
||||
m.name = name;
|
||||
markers.append(m);
|
||||
} else {
|
||||
old_name = seq->markers.at(index).name;
|
||||
seq->markers[index].name = name;
|
||||
old_name = markers.at(index).name;
|
||||
markers[index].name = name;
|
||||
}
|
||||
|
||||
mainWindow->setWindowModified(true);
|
||||
|
||||
+3
-2
@@ -384,11 +384,12 @@ private:
|
||||
|
||||
class AddMarkerAction : public QUndoCommand {
|
||||
public:
|
||||
AddMarkerAction(Sequence* s, long t, QString n);
|
||||
AddMarkerAction(bool is_sequence, void* s, long t, QString n);
|
||||
void undo();
|
||||
void redo();
|
||||
private:
|
||||
Sequence* seq;
|
||||
bool is_sequence_internal;
|
||||
void* target;
|
||||
long time;
|
||||
QString name;
|
||||
QString old_name;
|
||||
|
||||
Reference in New Issue
Block a user