massive rewrite of project data system

This commit is contained in:
itsmattkc
2018-12-13 14:29:09 +11:00
parent 6c3197aac6
commit ac1cb9d14f
44 changed files with 2562 additions and 2158 deletions
+2
View File
@@ -3,6 +3,7 @@
#include "timeline.h"
#include "effectcontrols.h"
#include "viewer.h"
#include "project.h"
#include "project/sequence.h"
#include "project/clip.h"
#include "project/transition.h"
@@ -100,6 +101,7 @@ void update_ui(bool modified) {
if (modified) {
update_effect_controls();
}
project_model.update_data();
panel_effect_controls->update_keyframes();
panel_timeline->repaint_timeline();
panel_sequence_viewer->update_viewer();
+222 -961
View File
File diff suppressed because it is too large Load Diff
+37 -42
View File
@@ -6,13 +6,15 @@
#include <QTimer>
#include <QDir>
struct Media;
#include "project/projectmodel.h"
struct Footage;
struct Sequence;
struct Clip;
class Timeline;
class Viewer;
class SourceTable;
class QTreeWidgetItem;
class Media;
class QXmlStreamWriter;
class QXmlStreamReader;
class QFile;
@@ -30,18 +32,20 @@ extern QString project_url;
extern QStringList recent_projects;
extern QString recent_proj_file;
int get_type_from_tree(QTreeWidgetItem* item);
extern ProjectModel project_model;
/*int get_type_from_tree(Media *item);
void* get_media_from_tree(QTreeWidgetItem* item);
Media* get_footage_from_tree(QTreeWidgetItem* item);
void set_footage_of_tree(QTreeWidgetItem* item, Media* media);
Footage* get_footage_from_tree(QTreeWidgetItem* item);
void set_footage_of_tree(QTreeWidgetItem* item, Footage* media);
Sequence* get_sequence_from_tree(QTreeWidgetItem* item);
void set_sequence_of_tree(QTreeWidgetItem* item, Sequence* sequence);
void set_item_to_folder(QTreeWidgetItem* item);
void update_footage_tooltip(QTreeWidgetItem* item, Media* media, QString error = 0);
void set_item_to_folder(QTreeWidgetItem* item);*/
//void update_footage_tooltip(Media* item, Footage* media, QString error = 0);
Sequence* create_sequence_from_media(QVector<void*>& media_list, QVector<int>& type_list);
Sequence* create_sequence_from_media(QVector<Media *> &media_list);
QString get_channel_layout_name(int channels, int layout);
QString get_channel_layout_name(int channels, uint64_t layout);
QString get_interlacing_name(int interlacing);
class Project : public QDockWidget
@@ -53,27 +57,33 @@ public:
~Project();
bool is_focused();
void clear();
void new_sequence(ComboAction *ca, Sequence* s, bool open, QTreeWidgetItem* parent);
QString get_next_sequence_name(QString start = 0);
void delete_media(QTreeWidgetItem* item);
void process_file_list(bool recursive, QStringList& files, QTreeWidgetItem *parent, QTreeWidgetItem* replace);
void replace_media(QTreeWidgetItem* item, QString filename);
QTreeWidgetItem* get_selected_folder();
bool reveal_media(void* media, QTreeWidgetItem *parent = 0);
Media* new_sequence(ComboAction *ca, Sequence* s, bool open, Media* parent);
QString get_next_sequence_name(QString start = 0);
void process_file_list(bool recursive, QStringList& files, Media *parent, Media* replace);
void replace_media(Media* item, QString filename);
Media* get_selected_folder();
bool reveal_media(void* media, QModelIndex parent = QModelIndex());
void add_recent_project(QString url);
void new_project();
void load_project(bool autorecovery);
void save_project(bool autorecovery);
QTreeWidgetItem* new_folder(QString name);
Media* new_folder(QString name);
void save_recent_projects();
QVector<Sequence*> list_all_project_sequences();
QVector<Media*> list_all_project_sequences();
SourceTable* source_table;
QVector<Media*> last_imported_media;
QVector<Media*> last_imported_media;
//Media *new_item();
void start_preview_generator(Media* item, bool replacing);
Ui::Project *ui;
public slots:
void import_dialog();
void delete_selected_media();
@@ -83,48 +93,33 @@ public slots:
void replace_clip_media();
void open_properties();
private:
Ui::Project *ui;
QTreeWidgetItem* new_item();
bool load_worker(QFile& f, QXmlStreamReader& stream, int type);
void save_folder(QXmlStreamWriter& stream, QTreeWidgetItem* parent, int type, bool set_ids_only);
bool show_err;
QString error_str;
void save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only, const QModelIndex &parent = QModelIndex());
int folder_id;
int media_id;
int sequence_id;
Sequence* open_seq;
QVector<QTreeWidgetItem*> loaded_folders;
QVector<Media*> loaded_media;
QVector<QTreeWidgetItem*> loaded_media_items;
QVector<Clip*> loaded_clips;
QVector<Sequence*> loaded_sequences;
QTreeWidgetItem* find_loaded_folder_by_id(int id);
void add_recent_project(QString url);
void get_all_media_from_table(QList<QTreeWidgetItem*> items, QList<QTreeWidgetItem*>& list, int type);
void start_preview_generator(QTreeWidgetItem* item, Media* media, bool replacing);
void list_all_sequences_worker(QVector<Sequence*>* list, QTreeWidgetItem* parent);
void get_all_media_from_table(QList<Media *> items, QList<Media *> &list, int type);
void list_all_sequences_worker(QVector<Media *> *list, Media* parent);
QString get_file_name_from_path(const QString &path);
QDir proj_dir;
QDir internal_proj_dir;
QString internal_proj_url;
private slots:
void rename_media(QTreeWidgetItem* item, int column);
void rename_media(Media* item, int column);
void clear_recent_projects();
};
class MediaThrobber : public QObject {
Q_OBJECT
public:
MediaThrobber(QTreeWidgetItem*);
MediaThrobber(Media*);
public slots:
void start();
void stop(int, bool replace);
private slots:
void animation_update();
private:
QPixmap pixmap;
int animation;
QTreeWidgetItem* item;
QTimer animator;
Media* item;
QTimer* animator;
};
#endif // PROJECT_H
+2 -38
View File
@@ -34,55 +34,19 @@
<number>0</number>
</property>
<item>
<widget class="SourceTable" name="treeWidget">
<widget class="SourceTable" name="treeView">
<property name="acceptDrops">
<bool>true</bool>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="dragEnabled">
<bool>false</bool>
</property>
<property name="dragDropMode">
<enum>QAbstractItemView::DragDrop</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="rootIsDecorated">
<bool>true</bool>
</property>
<property name="itemsExpandable">
<bool>true</bool>
</property>
<property name="headerHidden">
<bool>false</bool>
</property>
<property name="expandsOnDoubleClick">
<bool>false</bool>
</property>
<attribute name="headerStretchLastSection">
<bool>true</bool>
</attribute>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Duration</string>
</property>
</column>
<column>
<property name="text">
<string>Rate</string>
</property>
</column>
</widget>
</item>
</layout>
@@ -91,7 +55,7 @@
<customwidgets>
<customwidget>
<class>SourceTable</class>
<extends>QTreeWidget</extends>
<extends>QTreeView</extends>
<header>ui/sourcetable.h</header>
</customwidget>
</customwidgets>
+18 -18
View File
@@ -14,10 +14,11 @@
#include "playback/playback.h"
#include "ui_viewer.h"
#include "project/undo.h"
#include "project/media.h"
#include "io/config.h"
#include "project/effect.h"
#include "project/transition.h"
#include "io/media.h"
#include "project/footage.h"
#include "io/clipboard.h"
#include "debug.h"
@@ -160,23 +161,24 @@ void Timeline::toggle_show_all() {
}
}
void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector<void*>& media_list, QVector<int>& type_list) {
void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector<Media*>& media_list) {
video_ghosts = false;
audio_ghosts = false;
for (int i=0;i<media_list.size();i++) {
bool can_import = true;
Media* m = NULL;
Sequence* s = NULL;
void* media = NULL;
Media* medium = media_list.at(i);
Footage* m = NULL;
Sequence* s = NULL;
void* media = NULL;
long sequence_length;
long default_clip_in = 0;
long default_clip_out = 0;
switch (type_list.at(i)) {
switch (medium->get_type()) {
case MEDIA_TYPE_FOOTAGE:
m = static_cast<Media*>(media_list.at(i));
m = medium->to_footage();
media = m;
can_import = m->ready;
if (m->using_inout) {
@@ -187,7 +189,7 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector
}
break;
case MEDIA_TYPE_SEQUENCE:
s = static_cast<Sequence*>(media_list.at(i));
s = medium->to_sequence();
sequence_length = s->getEndFrame();
if (seq != NULL) sequence_length = refactor_frame_number(sequence_length, s->frame_rate, seq->frame_rate);
media = s;
@@ -203,15 +205,14 @@ void Timeline::create_ghosts_from_media(Sequence* seq, long entry_point, QVector
if (can_import) {
Ghost g;
g.clip = -1;
g.media_type = type_list.at(i);
g.clip = -1;
g.trimming = false;
g.old_clip_in = g.clip_in = default_clip_in;
g.media = media;
g.media = medium;
g.in = entry_point;
g.transition = NULL;
switch (type_list.at(i)) {
switch (medium->get_type()) {
case MEDIA_TYPE_FOOTAGE:
// is video source a still image?
if (m->video_tracks.size() > 0 && m->video_tracks[0]->infinite_length && m->audio_tracks.size() == 0) {
@@ -274,15 +275,14 @@ void Timeline::add_clips_from_ghosts(ComboAction* ca, Sequence* s) {
earliest_point = qMin(earliest_point, g.in);
Clip* c = new Clip(s);
c->media = g.media;
c->media_type = g.media_type;
c->media = g.media;
c->media_stream = g.media_stream;
c->timeline_in = g.in;
c->timeline_out = g.out;
c->clip_in = g.clip_in;
c->track = g.track;
if (c->media_type == MEDIA_TYPE_FOOTAGE) {
Media* m = static_cast<Media*>(c->media);
if (c->media->get_type() == MEDIA_TYPE_FOOTAGE) {
Footage* m = c->media->to_footage();
if (m->video_tracks.size() == 0) {
// audio only (greenish)
c->color_r = 128;
@@ -300,13 +300,13 @@ void Timeline::add_clips_from_ghosts(ComboAction* ca, Sequence* s) {
c->color_b = 192;
}
c->name = m->name;
} else if (c->media_type == MEDIA_TYPE_SEQUENCE) {
} else if (c->media->get_type() == MEDIA_TYPE_SEQUENCE) {
// sequence (red?ish?)
c->color_r = 192;
c->color_g = 128;
c->color_b = 128;
Sequence* media = static_cast<Sequence*>(c->media);
Sequence* media = c->media->to_sequence();
c->name = media->name;
}
c->recalculateMaxLength();
+5 -5
View File
@@ -22,12 +22,13 @@ class SourceTable;
class ViewerWidget;
class ComboAction;
class Effect;
class Media;
class Transition;
struct EffectMeta;
struct Sequence;
struct Clip;
struct Media;
struct MediaStream;
struct Footage;
struct FootageStream;
long refactor_frame_number(long framenumber, double source_frame_rate, double target_frame_rate);
int getScreenPointFromFrame(double zoom, long frame);
@@ -49,8 +50,7 @@ struct Ghost {
long old_clip_in;
// importing variables
void* media;
int media_type;
Media* media;
int media_stream;
// other variables
@@ -102,7 +102,7 @@ public:
void next_cut();
void toggle_show_all();
void create_ghosts_from_media(Sequence *seq, long entry_point, QVector<void *> &media_list, QVector<int> &type_list);
void create_ghosts_from_media(Sequence *seq, long entry_point, QVector<Media *> &media_list);
void add_clips_from_ghosts(ComboAction *ca, Sequence *s);
int getTimelineScreenPointFromFrame(long frame);
+78 -76
View File
@@ -8,7 +8,8 @@
#include "project/clip.h"
#include "panels/panels.h"
#include "io/config.h"
#include "io/media.h"
#include "project/footage.h"
#include "project/media.h"
#include "project/undo.h"
#include "ui/audiomonitor.h"
#include "ui_timeline.h"
@@ -33,6 +34,7 @@ Viewer::Viewer(QWidget *parent) :
QDockWidget(parent),
playing(false),
just_played(false),
media(NULL),
seq(NULL),
ui(new Ui::Viewer),
created_sequence(false),
@@ -46,7 +48,7 @@ Viewer::Viewer(QWidget *parent) :
ui->glViewerPane->child = ui->openGLWidget;
ui->openGLWidget->viewer = this;
viewer_widget = ui->openGLWidget;
set_media(MEDIA_TYPE_SEQUENCE, NULL);
set_media(NULL);
ui->currentTimecode->setEnabled(false);
ui->currentTimecode->set_minimum_value(0);
@@ -344,23 +346,23 @@ void Viewer::pause() {
// add it to the sequence
Clip* c = new Clip(seq);
Media* m = panel_project->last_imported_media.at(0);
Media* m = panel_project->last_imported_media.at(0);
Footage* f = m->to_footage();
m->ready_lock.lock();
f->ready_lock.lock();
c->media = m; // latest media
c->media_type = MEDIA_TYPE_FOOTAGE;
c->media = m; // latest media
c->media_stream = 0;
c->timeline_in = recording_start;
c->timeline_out = m->get_length_in_frames(seq->frame_rate);
c->timeline_out = f->get_length_in_frames(seq->frame_rate);
c->clip_in = 0;
c->track = recording_track;
c->color_r = 128;
c->color_g = 192;
c->color_b = 128;
c->name = m->name;
c->name = m->get_name();
m->ready_lock.unlock();
f->ready_lock.unlock();
QVector<Clip*> add_clips;
add_clips.append(c);
@@ -414,83 +416,83 @@ void Viewer::set_out_point() {
ui->headers->set_out_point(seq->playhead);
}
void Viewer::set_media(int type, void* media) {
void Viewer::set_media(Media* m) {
main_sequence = false;
clean_created_seq();
switch (type) {
case MEDIA_TYPE_FOOTAGE:
{
Media* footage = static_cast<Media*>(media);
media = m;
clean_created_seq();
if (media != NULL) {
switch (media->get_type()) {
case MEDIA_TYPE_FOOTAGE:
{
Footage* footage = media->to_footage();
seq = new Sequence();
created_sequence = true;
seq->wrapper_sequence = true;
seq->name = footage->name;
seq = new Sequence();
created_sequence = true;
seq->wrapper_sequence = true;
seq->name = footage->name;
seq->using_workarea = footage->using_inout;
if (footage->using_inout) {
seq->workarea_in = footage->in;
seq->workarea_out = footage->out;
}
seq->using_workarea = footage->using_inout;
if (footage->using_inout) {
seq->workarea_in = footage->in;
seq->workarea_out = footage->out;
}
seq->frame_rate = 30;
seq->frame_rate = 30;
if (footage->video_tracks.size() > 0) {
MediaStream* video_stream = footage->video_tracks.at(0);
seq->width = video_stream->video_width;
seq->height = video_stream->video_height;
if (video_stream->video_frame_rate > 0 && !video_stream->infinite_length) seq->frame_rate = video_stream->video_frame_rate;
if (footage->video_tracks.size() > 0) {
FootageStream* video_stream = footage->video_tracks.at(0);
seq->width = video_stream->video_width;
seq->height = video_stream->video_height;
if (video_stream->video_frame_rate > 0 && !video_stream->infinite_length) seq->frame_rate = video_stream->video_frame_rate;
Clip* c = new Clip(seq);
c->media = footage;
c->media_type = type;
c->media_stream = video_stream->file_index;
c->timeline_in = 0;
c->timeline_out = footage->get_length_in_frames(seq->frame_rate);
if (c->timeline_out <= 0) c->timeline_out = 150;
c->track = -1;
c->clip_in = 0;
c->recalculateMaxLength();
seq->clips.append(c);
} else {
seq->width = 1920;
seq->height = 1080;
}
Clip* c = new Clip(seq);
c->media = media;
c->media_stream = video_stream->file_index;
c->timeline_in = 0;
c->timeline_out = footage->get_length_in_frames(seq->frame_rate);
if (c->timeline_out <= 0) c->timeline_out = 150;
c->track = -1;
c->clip_in = 0;
c->recalculateMaxLength();
seq->clips.append(c);
} else {
seq->width = 1920;
seq->height = 1080;
}
if (footage->audio_tracks.size() > 0) {
MediaStream* audio_stream = footage->audio_tracks.at(0);
seq->audio_frequency = audio_stream->audio_frequency;
if (footage->audio_tracks.size() > 0) {
FootageStream* audio_stream = footage->audio_tracks.at(0);
seq->audio_frequency = audio_stream->audio_frequency;
Clip* c = new Clip(seq);
c->media = footage;
c->media_type = type;
c->media_stream = audio_stream->file_index;
c->timeline_in = 0;
c->timeline_out = footage->get_length_in_frames(seq->frame_rate);
c->track = 0;
c->clip_in = 0;
c->recalculateMaxLength();
seq->clips.append(c);
Clip* c = new Clip(seq);
c->media = media;
c->media_stream = audio_stream->file_index;
c->timeline_in = 0;
c->timeline_out = footage->get_length_in_frames(seq->frame_rate);
c->track = 0;
c->clip_in = 0;
c->recalculateMaxLength();
seq->clips.append(c);
if (footage->video_tracks.size() == 0) {
viewer_widget->waveform = true;
viewer_widget->waveform_clip = c;
viewer_widget->waveform_ms = audio_stream;
viewer_widget->update();
}
} else {
seq->audio_frequency = 48000;
}
if (footage->video_tracks.size() == 0) {
viewer_widget->waveform = true;
viewer_widget->waveform_clip = c;
viewer_widget->waveform_ms = audio_stream;
viewer_widget->update();
}
} else {
seq->audio_frequency = 48000;
}
seq->audio_layout = AV_CH_LAYOUT_STEREO;
set_sequence(false, seq);
}
break;
case MEDIA_TYPE_SEQUENCE:
set_sequence(false, static_cast<Sequence*>(media));
break;
}
seq->audio_layout = AV_CH_LAYOUT_STEREO;
}
break;
case MEDIA_TYPE_SEQUENCE:
seq = media->to_sequence();
break;
}
}
set_sequence(false, seq);
}
void Viewer::on_pushButton_clicked() {
+3 -1
View File
@@ -6,6 +6,7 @@
class Timeline;
class ViewerWidget;
class Media;
struct Sequence;
namespace Ui {
@@ -26,7 +27,7 @@ public:
bool is_focused();
void set_main_sequence();
void set_media(int type, void* media);
void set_media(Media *m);
void compose();
void set_playpause_icon(bool play);
void update_playhead_timecode(long p);
@@ -65,6 +66,7 @@ public:
ViewerWidget* viewer_widget;
Media* media;
Sequence* seq;
Ui::Viewer *ui;