separation of ui from backend in project

This commit is contained in:
itsmattkc
2019-03-30 13:26:00 +11:00
parent 114606c28e
commit 5ddf2726dd
32 changed files with 1046 additions and 810 deletions
+53
View File
@@ -29,6 +29,7 @@ namespace OCIO = OCIO_NAMESPACE::v1;
#include "project/previewgenerator.h"
#include "timeline/clip.h"
#include "global/config.h"
#include "global/global.h"
Footage::Footage() :
ready(false),
@@ -48,6 +49,58 @@ Footage::~Footage() {
reset();
}
void Footage::Save(QXmlStreamWriter &stream)
{
QDir proj_dir = QFileInfo(olive::ActiveProjectFilename).absoluteDir();
stream.writeStartElement("footage");
stream.writeAttribute("id", QString::number(media_id));
stream.writeAttribute("name", name);
stream.writeAttribute("url", proj_dir.relativeFilePath(url));
stream.writeAttribute("duration", QString::number(length));
stream.writeAttribute("using_inout", QString::number(using_inout));
stream.writeAttribute("in", QString::number(in));
stream.writeAttribute("out", QString::number(out));
stream.writeAttribute("speed", QString::number(speed));
stream.writeAttribute("alphapremul", QString::number(alpha_is_associated));
stream.writeAttribute("startnumber", QString::number(start_number));
stream.writeAttribute("colorspace", Colorspace());
stream.writeAttribute("proxy", QString::number(proxy));
stream.writeAttribute("proxypath", proxy_path);
// save video stream metadata
for (int j=0;j<f->video_tracks.size();j++) {
const FootageStream& ms = f->video_tracks.at(j);
stream.writeStartElement("video");
stream.writeAttribute("id", QString::number(ms.file_index));
stream.writeAttribute("width", QString::number(ms.video_width));
stream.writeAttribute("height", QString::number(ms.video_height));
stream.writeAttribute("framerate", QString::number(ms.video_frame_rate, 'f', 10));
stream.writeAttribute("infinite", QString::number(ms.infinite_length));
stream.writeEndElement(); // video
}
// save audio stream metadata
for (int j=0;j<f->audio_tracks.size();j++) {
const FootageStream& ms = f->audio_tracks.at(j);
stream.writeStartElement("audio");
stream.writeAttribute("id", QString::number(ms.file_index));
stream.writeAttribute("channels", QString::number(ms.audio_channels));
stream.writeAttribute("layout", QString::number(ms.audio_layout));
stream.writeAttribute("frequency", QString::number(ms.audio_frequency));
stream.writeEndElement(); // audio
}
// save footage markers
for (int j=0;j<f->markers.size();j++) {
f->markers.at(j).Save(stream);
}
stream.writeEndElement(); // footage
media_id++;
}
QString Footage::Colorspace()
{
if (!colorspace_.isEmpty()) {
+5
View File
@@ -70,6 +70,8 @@ public:
Footage();
~Footage();
void Save(QXmlStreamWriter& stream);
// footage metadata
QString url;
QString name;
@@ -107,6 +109,9 @@ public:
long get_length_in_frames(double frame_rate);
FootageStream *get_stream_from_file_index(bool video, int index);
void reset();
static QString get_channel_layout_name(int channels, uint64_t layout);
static QString get_interlacing_name(int interlacing);
private:
QString colorspace_;
};
+17
View File
@@ -68,6 +68,23 @@ Media::Media() :
{
}
void Media::Save(QXmlStreamWriter &stream)
{
switch (type) {
case MEDIA_TYPE_FOLDER:
stream.writeStartElement("folder");
stream.writeAttribute("name", get_name());
stream.writeEndElement();
break;
case MEDIA_TYPE_FOOTAGE:
to_footage()->Save(stream);
break;
case MEDIA_TYPE_SEQUENCE:
to_sequence()->Save(stream);
break;
}
}
Footage* Media::to_footage() {
return static_cast<Footage*>(object.get());
}
+2
View File
@@ -47,6 +47,8 @@ class Media
public:
Media();
void Save(QXmlStreamWriter& stream);
Footage *to_footage();
SequencePtr to_sequence();
void set_icon(const QString& str);
+83
View File
@@ -0,0 +1,83 @@
#include "projectfunctions.h"
#include "projectmodel.h"
#include "global/config.h"
MediaPtr olive::project::CreateFolder(QString name) {
MediaPtr item = std::make_shared<Media>();
item->set_folder();
item->set_name(name);
return item;
}
SequencePtr olive::project::CreateSequenceFromMedia(QVector<olive::timeline::MediaImportData> &media_list)
{
SequencePtr s = std::make_shared<Sequence>();
s->name = olive::project_model.GetNextSequenceName();
// Retrieve default Sequence settings from Config
s->width = olive::CurrentConfig.default_sequence_width;
s->height = olive::CurrentConfig.default_sequence_height;
s->frame_rate = olive::CurrentConfig.default_sequence_framerate;
s->audio_frequency = olive::CurrentConfig.default_sequence_audio_frequency;
s->audio_layout = olive::CurrentConfig.default_sequence_audio_channel_layout;
bool got_video_values = false;
bool got_audio_values = false;
for (int i=0;i<media_list.size();i++) {
Media* media = media_list.at(i).media();
switch (media->get_type()) {
case MEDIA_TYPE_FOOTAGE:
{
Footage* m = media->to_footage();
if (m->ready) {
if (!got_video_values) {
for (int j=0;j<m->video_tracks.size();j++) {
const FootageStream& ms = m->video_tracks.at(j);
s->width = ms.video_width;
s->height = ms.video_height;
if (!qFuzzyCompare(ms.video_frame_rate, 0.0)) {
s->frame_rate = ms.video_frame_rate * m->speed;
if (ms.video_interlacing != VIDEO_PROGRESSIVE) s->frame_rate *= 2;
// only break with a decent frame rate, otherwise there may be a better candidate
got_video_values = true;
break;
}
}
}
if (!got_audio_values && m->audio_tracks.size() > 0) {
const FootageStream& ms = m->audio_tracks.at(0);
s->audio_frequency = ms.audio_frequency;
got_audio_values = true;
}
}
}
break;
case MEDIA_TYPE_SEQUENCE:
{
// Clone all attributes of the original sequence (seq) into the new one (s)
Sequence* seq = media->to_sequence().get();
s->width = seq->width;
s->height = seq->height;
s->frame_rate = seq->frame_rate;
s->audio_frequency = seq->audio_frequency;
s->audio_layout = seq->audio_layout;
got_video_values = true;
got_audio_values = true;
}
break;
}
if (got_video_values && got_audio_values) break;
}
return s;
}
+18
View File
@@ -0,0 +1,18 @@
#ifndef PROJECTFUNCTIONS_H
#define PROJECTFUNCTIONS_H
#include "project/media.h"
#include "timeline/sequence.h"
#include "timeline/mediaimportdata.h"
namespace olive {
namespace project {
MediaPtr CreateFolder(QString name);
SequencePtr CreateSequenceFromMedia(QVector<olive::timeline::MediaImportData> &media_list);
}
}
#endif // PROJECTFUNCTIONS_H
+355
View File
@@ -36,6 +36,57 @@ ProjectModel::~ProjectModel() {
destroy_root();
}
int ProjectModel::PrepareToSave()
{
int element_count = 0;
PrepareToSaveInternal(element_count, get_root());
return element_count;
}
void ProjectModel::PrepareToSaveInternal(int& element_count, Media *root)
{
for (int i=0;i<root->childCount();i++) {
Media* child = root->child(i);
switch (child->get_type()) {
case MEDIA_TYPE_FOLDER:
child->temp_id = element_count;
break;
case MEDIA_TYPE_FOOTAGE:
child->to_footage()->save_id = element_count;
break;
case MEDIA_TYPE_SEQUENCE:
child->to_sequence()->save_id = element_count;
break;
}
element_count++;
if (child->childCount() > 0) {
PrepareToSaveInternal(element_count, child);
}
}
}
void ProjectModel::Save(QXmlStreamWriter &stream, Media* root)
{
if (root == nullptr) {
root = get_root();
}
for (int i=0;i<root->childCount();i++) {
Media* child = root->child(i);
child->Save(stream);
if (child->childCount() > 0) {
Save(stream, child);
}
}
}
void ProjectModel::make_root() {
root_item_ = std::make_shared<Media>();
root_item_->temp_id = 0;
@@ -211,6 +262,58 @@ QVector<Media *> ProjectModel::GetAllFolders()
return GetAllMediaOfType(MEDIA_TYPE_FOLDER);
}
QString ProjectModel::GetNextSequenceName(QString prepend)
{
if (prepend.isEmpty()) {
prepend = tr("Sequence %1");
}
int sequence_number = 1;
QString test;
QVector<Media*> all_sequences = GetAllSequences();
bool found;
do {
found = false;
test = prepend.arg(sequence_number);
for (int i=0;i<all_sequences.size();i++) {
if (all_sequences.at(i)->get_name() == test) {
found = true;
sequence_number++;
break;
}
}
} while (found);
return test;
}
MediaPtr ProjectModel::CreateSequence(ComboAction *ca, SequencePtr s, bool open, Media *parent)
{
MediaPtr item = std::make_shared<Media>();
item->set_sequence(s);
if (ca != nullptr) {
ca->append(new AddMediaCommand(item, parent));
if (open) {
ca->append(new ChangeSequenceAction(s));
}
} else {
appendChild(parent, item);
if (open) {
olive::Global->set_sequence(s);
}
}
return item;
}
QVector<Media *> ProjectModel::GetAllMediaOfType(int search_type)
{
QVector<Media*> media_list;
@@ -296,3 +399,255 @@ int ProjectModel::childCount(Media *parent) {
}
return parent->childCount();
}
void ProjectModel::process_file_list(QStringList& files, bool recursive, MediaPtr replace, Media* parent) {
bool imported = false;
// retrieve the array of image formats from the user's configuration
QStringList image_sequence_formats = olive::CurrentConfig.img_seq_formats.split("|");
// a cache of image sequence formatted URLS to assist the user in importing image sequences
QVector<QString> image_sequence_urls;
QVector<bool> image_sequence_importassequence;
if (!recursive) last_imported_media.clear();
bool create_undo_action = (!recursive && replace == nullptr);
ComboAction* ca = nullptr;
if (create_undo_action) ca = new ComboAction();
// Loop through received files
for (int i=0;i<files.size();i++) {
// If this file is a directory, we'll recursively call this function again to process the directory's contents
if (QFileInfo(files.at(i)).isDir()) {
QString folder_name = get_file_name_from_path(files.at(i));
MediaPtr folder = CreateFolder(folder_name);
QDir directory(files.at(i));
directory.setFilter(QDir::NoDotAndDotDot | QDir::AllEntries);
QFileInfoList subdir_files = directory.entryInfoList();
QStringList subdir_filenames;
for (int j=0;j<subdir_files.size();j++) {
subdir_filenames.append(subdir_files.at(j).filePath());
}
if (create_undo_action) {
ca->append(new AddMediaCommand(folder, parent));
} else {
appendChild(parent, folder);
}
process_file_list(subdir_filenames, true, nullptr, folder.get());
imported = true;
} else if (!files.at(i).isEmpty()) {
QString file = files.at(i);
// Check if the user is importing an Olive project file
if (file.endsWith(".ove", Qt::CaseInsensitive)) {
// This file is an Olive project file. Ask the user if they really want to import it.
if (QMessageBox::question(this,
tr("Import a Project"),
tr("\"%1\" is an Olive project file. It will merge with this project. "
"Do you wish to continue?").arg(file),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
// load the project without clearing the current one
olive::Global->ImportProject(file);
}
} else {
// This file is NOT an Olive project file
// Used later if this file is part of an already processed image sequence
bool skip = false;
/* Heuristic to determine whether file is part of an image sequence */
// Firstly, we run a heuristic on whether this file is an image by checking its file extension
bool file_is_an_image = false;
// Get the string position of the extension in the filename
int lastcharindex = file.lastIndexOf(".");
if (lastcharindex != -1 && lastcharindex > file.lastIndexOf('/')) {
QString ext = file.mid(lastcharindex+1);
// If the file extension is part of a predetermined list (from Config::img_seq_formats), we'll treat it
// as an image
if (image_sequence_formats.contains(ext, Qt::CaseInsensitive)) {
file_is_an_image = true;
}
} else {
// If we're here, the file has no extension, but we'll still check if its an image sequence just in case
lastcharindex = file.length();
file_is_an_image = true;
}
// Some image sequence's don't start at "0", if it is indeed an image sequence, we'll use this variable
// later to determine where it does start
int start_number = 0;
// Check if we passed the earlier heuristic to check whether this is a file, and whether the last number in
// the filename (before the extension) is a number
if (file_is_an_image && file[lastcharindex-1].isDigit()) {
// Check how many digits are at the end of this filename
int digit_count = 0;
int digit_test = lastcharindex-1;
while (file[digit_test].isDigit()) {
digit_count++;
digit_test--;
}
// Retrieve the integer represented at the end of this filename
digit_test++;
int file_number = file.mid(digit_test, digit_count).toInt();
// Check whether a file exists with the same format but one number higher or one number lower
if (QFileInfo::exists(QString(file.left(digit_test) + QString("%1").arg(file_number-1, digit_count, 10, QChar('0')) + file.mid(lastcharindex)))
|| QFileInfo::exists(QString(file.left(digit_test) + QString("%1").arg(file_number+1, digit_count, 10, QChar('0')) + file.mid(lastcharindex)))) {
//
// If so, it certainly looks like it *could* be an image sequence, but we'll ask the user just in case
//
// Firstly we should check if this file is part of a sequence the user has already confirmed as either a
// sequence or not a sequence (e.g. if the user happened to select a bunch of images that happen to increase
// consecutively). We format the filename with FFmpeg's '%Nd' (N = digits) formatting for reading image
// sequences
QString new_filename = file.left(digit_test) + "%" + QString::number(digit_count) + "d" + file.mid(lastcharindex);
int does_url_cache_already_contain_this = image_sequence_urls.indexOf(new_filename);
if (does_url_cache_already_contain_this > -1) {
// We've already processed an image with the same formatting
// Check if the last time we saw this formatting, the user chose to import as a sequence
if (image_sequence_importassequence.at(does_url_cache_already_contain_this)) {
// If so, no need to import this file too, so we signal to the rest of the function to skip this file
skip = true;
}
// If not, we can fall-through to the next step which is importing normally
} else {
// If we're here, we've never seen a file with this formatting before, so we'll ask whether to import
// as a sequence or not
// Add this file formatting file to the URL cache
image_sequence_urls.append(new_filename);
// This does look like an image sequence, let's ask the user if it'll indeed be an image sequence
if (QMessageBox::question(this,
tr("Image sequence detected"),
tr("The file '%1' appears to be part of an image sequence. "
"Would you like to import it as such?").arg(file),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::Yes) == QMessageBox::Yes) {
// Proceed to the next step of this with the formatted filename
file = new_filename;
// Cache the user's answer alongside the image_sequence_urls value - in this case, YES, this will be an
// image sequence
image_sequence_importassequence.append(true);
// FFmpeg needs to know what file number to start at in the sequence. In case the image sequence doesn't
// start at a zero, we'll loop decreasing the number until it doesn't exist anymore
QString test_filename_format = QString("%1%2%3").arg(file.left(digit_test), "%1", file.mid(lastcharindex));
int test_file_number = file_number;
do {
test_file_number--;
} while (QFileInfo::exists(test_filename_format.arg(QString("%1").arg(test_file_number, digit_count, 10, QChar('0')))));
// set the image sequence's start number to the last that existed
start_number = test_file_number + 1;
} else {
// Cache the user's response to the image sequence question - i.e. none of the files imported with this
// formatting should be imported as an image sequence
image_sequence_importassequence.append(false);
}
}
}
}
// If we're not skipping this file, let's import it
if (!skip) {
MediaPtr item;
FootagePtr m;
if (replace != nullptr) {
item = replace;
} else {
item = std::make_shared<Media>();
}
m = std::make_shared<Footage>();
// Edge case for PNGs that standardized unassociated alpha
if (file.endsWith("png", Qt::CaseInsensitive)) {
m->alpha_is_associated = false;
}
m->using_inout = false;
m->url = file;
m->name = QFileInfo(files.at(i)).fileName();
m->start_number = start_number;
item->set_footage(m);
last_imported_media.append(item.get());
if (replace == nullptr) {
if (create_undo_action) {
ca->append(new AddMediaCommand(item, parent));
} else {
appendChild(parent, item);
}
}
imported = true;
}
}
}
}
if (create_undo_action) {
if (imported) {
olive::UndoStack.push(ca);
for (int i=0;i<last_imported_media.size();i++) {
// generate waveform/thumbnail in another thread
PreviewGenerator::AnalyzeMedia(last_imported_media.at(i));
}
} else {
delete ca;
}
}
}
+56
View File
@@ -24,6 +24,7 @@
#include <QAbstractItemModel>
#include "project/media.h"
#include "undo/comboaction.h"
class ProjectModel : public QAbstractItemModel
{
@@ -32,6 +33,42 @@ public:
ProjectModel(QObject* parent = nullptr);
~ProjectModel() override;
/**
* @brief Makes preparations for saving the project file.
*
* Some items require IDs to link between them (e.g. the Footage or Nested Sequences used by Clips, linked clips,
* etc). This function sets up those IDs before saving.
*
* NOTE: This function should **always** be called before Save().
*
* @return
*
* A count of the elements in the project to save into the project file. The loading system can later use this value
* to determine the load progress.
*/
int PrepareToSave();
/**
* @brief Initiate a save of all the project data
*
* Recursively goes through the entire project tree saving everything to a specified QXmlStreamWriter object.
*
* It's not recommended to use this function directly as it expects an existing QXmlStreamWriter and doesn't write a
* header and footer for the resulting XML document. Instead use olive::Save().
*
* NOTE: **Always** call PrepareToSave() just before calling this function to set up valid IDs for saving.
*
* @param stream
*
* A QXmlStreamWriter object.
*
* @param root
*
* Used for recursion, set to any child and called again whenever a child is found with children. If this is nullptr,
* this function will loop over the root item.
*/
void Save(QXmlStreamWriter& stream, Media *root = nullptr);
void make_root();
void destroy_root();
void clear();
@@ -58,15 +95,34 @@ public:
int childCount(Media* parent = nullptr);
void set_icon(Media* m, const QIcon &ico);
void process_file_list(QStringList& files, bool recursive = false, MediaPtr replace = nullptr, Media *parent = nullptr);
/**
* @brief Get a list of the last imported media
*
* @return
*
* Returns a list of all the Media processed by the last call to process_file_list().
*/
QVector<Media*> GetLastImportedMedia();
QVector<Media*> GetAllSequences();
QVector<Media*> GetAllFootage();
QVector<Media*> GetAllFolders();
QString GetNextSequenceName(QString prepend = QString());
MediaPtr CreateSequence(ComboAction *ca, SequencePtr s, bool open, Media* parent);
private:
MediaPtr root_item_;
QVector<Media*> last_imported_media;
QVector<Media*> GetAllMediaOfType(int search_type);
void RecurseTree(Media* parent, QVector<Media *> &list, int search_type);
void PrepareToSaveInternal(int& element_count, Media* root);
};
namespace olive {
+97
View File
@@ -0,0 +1,97 @@
#include "savethread.h"
#include <QXmlStreamWriter>
#include <QFile>
#include <QDir>
#include <QDebug>
#include "global/global.h"
#include "global/config.h"
#include "projectmodel.h"
void RecursiveSave() {
}
void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only, const QModelIndex& parent) {
for (int i=0;i<olive::project_model.rowCount(parent);i++) {
const QModelIndex& item = olive::project_model.index(i, 0, parent);
Media* m = olive::project_model.getItem(item);
if (type == m->get_type()) {
if (m->get_type() == MEDIA_TYPE_FOLDER) {
if (set_ids_only) {
m->temp_id = folder_id; // saves a temporary ID for matching in the project file
folder_id++;
} else {
// if we're saving folders, save the folder
stream.writeStartElement("folder");
stream.writeAttribute("name", m->get_name());
stream.writeAttribute("id", QString::number(m->temp_id));
if (!item.parent().isValid()) {
stream.writeAttribute("parent", "0");
} else {
stream.writeAttribute("parent", QString::number(olive::project_model.getItem(item.parent())->temp_id));
}
stream.writeEndElement();
}
// save_folder(stream, item, type, set_ids_only);
} else {
int folder = m->parentItem()->temp_id;
if (type == MEDIA_TYPE_FOOTAGE) {
} else if (type == MEDIA_TYPE_SEQUENCE) {
Sequence* s = m->to_sequence().get();
if (set_ids_only) {
s->save_id = sequence_id;
sequence_id++;
} else {
s->Save(stream);
}
}
}
}
if (m->get_type() == MEDIA_TYPE_FOLDER) {
save_folder(stream, type, set_ids_only, item);
}
}
}
void olive::Save(bool autorecovery)
{
QFile file(autorecovery ? olive::Global->get_autorecovery_filename() : olive::ActiveProjectFilename);
if (!file.open(QIODevice::WriteOnly)) {
qCritical() << "Could not open file";
return;
}
QXmlStreamWriter stream(&file);
stream.setAutoFormatting(true);
stream.writeStartDocument(); // doc
stream.writeStartElement("project"); // project
stream.writeTextElement("version", QString::number(olive::kSaveVersion));
stream.writeTextElement("url", olive::ActiveProjectFilename);
// Prepare project for saving and retrieve element count
int element_count = olive::project_model.PrepareToSave();
// Write element count to file - used by the loading thread to determine its loading progress
stream.writeTextElement("elements", QString::number(element_count));
olive::project_model.Save(stream);
stream.writeEndElement(); // project
stream.writeEndDocument(); // doc
file.close();
if (!autorecovery) {
add_recent_project(olive::ActiveProjectFilename);
olive::Global->set_modified(false);
}
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef SAVETHREAD_H
#define SAVETHREAD_H
namespace olive {
void Save(bool autorecovery);
}
#endif // SAVETHREAD_H
+22 -5
View File
@@ -25,6 +25,7 @@
#include <QMimeData>
#include <QMessageBox>
#include <QDesktopServices>
#include <QFileDialog>
#include <QDebug>
#include "ui/menuhelper.h"
@@ -43,6 +44,7 @@
#include "dialogs/proxydialog.h"
#include "ui/viewerwidget.h"
#include "project/proxygenerator.h"
#include "project/projectfunctions.h"
#include "ui/mainwindow.h"
#include "ui/menu.h"
#include "undo/undostack.h"
@@ -64,13 +66,13 @@ void SourcesCommon::create_seq_from_selected() {
}
ComboAction* ca = new ComboAction();
SequencePtr s = create_sequence_from_media(media_list);
SequencePtr s = olive::project::CreateSequenceFromMedia(media_list);
// add clips to it
panel_timeline->create_ghosts_from_media(s.get(), 0, media_list);
panel_timeline->add_clips_from_ghosts(ca, s.get());
project_parent->create_sequence_internal(ca, s, true, nullptr);
olive::project_model.CreateSequence(ca, s, true, nullptr);
olive::UndoStack.push(ca);
}
}
@@ -239,6 +241,21 @@ void SourcesCommon::show_context_menu(QWidget* parent, const QModelIndexList& it
menu.exec(QCursor::pos());
}
void SourcesCommon::replace_media(MediaPtr item, QString filename)
{
if (filename.isEmpty()) {
filename = QFileDialog::getOpenFileName(
this,
tr("Replace '%1'").arg(item->get_name()),
"",
tr("All Files") + " (*)");
}
if (!filename.isEmpty()) {
ReplaceMediaCommand* rmc = new ReplaceMediaCommand(item, filename);
olive::UndoStack.push(rmc);
}
}
void SourcesCommon::mousePressEvent(QMouseEvent *) {
stop_rename_timer();
}
@@ -255,7 +272,7 @@ void SourcesCommon::item_click(Media *m, const QModelIndex& index) {
void SourcesCommon::mouseDoubleClickEvent(const QModelIndexList& selected_items) {
stop_rename_timer();
if (selected_items.size() == 0) {
project_parent->import_dialog();
olive::Global->open_import_dialog();
} else if (selected_items.size() == 1) {
Media* media = project_parent->item_to_media(selected_items.at(0));
if (media->get_type() == MEDIA_TYPE_SEQUENCE) {
@@ -292,7 +309,7 @@ void SourcesCommon::dropEvent(QWidget* parent,
tr("You dropped a file onto '%1'. Would you like to replace it with the dropped file?").arg(m->get_name()),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) {
replace = true;
project_parent->replace_media(m, paths.at(0));
replace_media(m, paths.at(0));
}
if (!replace) {
QModelIndex parent;
@@ -303,7 +320,7 @@ void SourcesCommon::dropEvent(QWidget* parent,
parent = drop_item.parent();
}
}
project_parent->process_file_list(paths, false, nullptr, panel_project->item_to_media(parent));
olive::project_model.process_file_list(paths, false, nullptr, panel_project->item_to_media(parent));
}
}
event->acceptProposedAction();
+3 -1
View File
@@ -27,10 +27,10 @@
#include "project/footage.h"
#include "project/projectfilter.h"
#include "media.h"
class Project;
class QMouseEvent;
class Media;
class QAbstractItemView;
class QDropEvent;
@@ -41,6 +41,8 @@ public:
QAbstractItemView* view;
void show_context_menu(QWidget* parent, const QModelIndexList &items);
void replace_media(MediaPtr item, QString filename);
void mousePressEvent(QMouseEvent* e);
void mouseDoubleClickEvent(const QModelIndexList& selected_items);
void dropEvent(QWidget *parent, QDropEvent* e, const QModelIndex& drop_item, const QModelIndexList &items);