various improvements to import process and project management
This commit is contained in:
@@ -74,6 +74,8 @@ void Core::Start()
|
||||
startup_project_ = args.first();
|
||||
}
|
||||
|
||||
// Declare custom types for Qt signal/slot syste
|
||||
DeclareTypesForQt();
|
||||
|
||||
|
||||
//
|
||||
@@ -174,3 +176,8 @@ void Core::AddOpenProject(ProjectPtr p)
|
||||
open_projects_.append(p);
|
||||
emit ProjectOpened(p.get());
|
||||
}
|
||||
|
||||
void Core::DeclareTypesForQt()
|
||||
{
|
||||
qRegisterMetaType<Task::Status>("Task::Status");
|
||||
}
|
||||
|
||||
@@ -132,6 +132,14 @@ private:
|
||||
* @brief Currently active tool
|
||||
*/
|
||||
olive::tool::Tool tool_;
|
||||
|
||||
/**
|
||||
* @brief Declare custom types/classes for Qt's signal/slot system
|
||||
*
|
||||
* Qt's signal/slot system requires types to be declared. In the interest of doing this only at startup, we contain
|
||||
* them all in a function here.
|
||||
*/
|
||||
void DeclareTypesForQt();
|
||||
};
|
||||
|
||||
namespace olive {
|
||||
|
||||
@@ -150,8 +150,12 @@ void FFmpegDecoder::Close()
|
||||
|
||||
bool FFmpegDecoder::Probe(Footage *f)
|
||||
{
|
||||
// Variable for receiving errors from FFmpeg
|
||||
int error_code;
|
||||
|
||||
// Result to return
|
||||
bool result = false;
|
||||
|
||||
// Convert QString to a C strng
|
||||
QByteArray ba = f->filename().toUtf8();
|
||||
const char* filename = ba.constData();
|
||||
@@ -229,12 +233,15 @@ bool FFmpegDecoder::Probe(Footage *f)
|
||||
|
||||
f->add_stream(str);
|
||||
}
|
||||
|
||||
// As long as we can open the container and retrieve information, this was a successful probe
|
||||
result = true;
|
||||
}
|
||||
|
||||
// Free all memory
|
||||
Close();
|
||||
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
|
||||
void FFmpegDecoder::FFmpegErr(int error_code)
|
||||
|
||||
@@ -57,10 +57,13 @@ bool olive::ProbeMedia(Footage *f)
|
||||
// TODO Some way of "attaching" the Footage to the Decoder without having to iterate through Decoders again at
|
||||
// render time?
|
||||
|
||||
f->set_ready(true);
|
||||
f->set_status(Footage::kReady);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// We aren't able to use this Footage
|
||||
f->set_status(Footage::kInvalid);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -20,9 +20,11 @@
|
||||
|
||||
#include "folder.h"
|
||||
|
||||
#include "ui/icons/icons.h"
|
||||
|
||||
Folder::Folder()
|
||||
{
|
||||
|
||||
set_icon(olive::icon::Folder);
|
||||
}
|
||||
|
||||
Item::Type Folder::type() const
|
||||
|
||||
@@ -20,9 +20,11 @@
|
||||
|
||||
#include "footage.h"
|
||||
|
||||
Footage::Footage()
|
||||
{
|
||||
#include "ui/icons/icons.h"
|
||||
|
||||
Footage::Footage() :
|
||||
status_(kUnprobed)
|
||||
{
|
||||
}
|
||||
|
||||
Footage::~Footage()
|
||||
@@ -30,14 +32,28 @@ Footage::~Footage()
|
||||
ClearStreams();
|
||||
}
|
||||
|
||||
bool Footage::ready()
|
||||
const Footage::Status& Footage::status()
|
||||
{
|
||||
return ready_;
|
||||
return status_;
|
||||
}
|
||||
|
||||
void Footage::set_ready(const bool &ready)
|
||||
void Footage::set_status(const Footage::Status &status)
|
||||
{
|
||||
ready_ = ready;
|
||||
status_ = status;
|
||||
|
||||
switch (status_) {
|
||||
case kUnprobed:
|
||||
// FIXME Set a waiting icon
|
||||
set_icon(QIcon());
|
||||
break;
|
||||
case kReady:
|
||||
// FIXME Set a ready icon
|
||||
set_icon(QIcon());
|
||||
break;
|
||||
case kInvalid:
|
||||
set_icon(olive::icon::Error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Footage::Clear()
|
||||
@@ -46,7 +62,7 @@ void Footage::Clear()
|
||||
ClearStreams();
|
||||
|
||||
// Reset ready state
|
||||
set_ready(false);
|
||||
set_status(kUnprobed);
|
||||
}
|
||||
|
||||
const QString &Footage::filename()
|
||||
|
||||
@@ -31,6 +31,12 @@
|
||||
class Footage : public Item
|
||||
{
|
||||
public:
|
||||
enum Status {
|
||||
kUnprobed,
|
||||
kReady,
|
||||
kInvalid
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Footage Constructor
|
||||
*/
|
||||
@@ -70,14 +76,14 @@ public:
|
||||
*
|
||||
* If the Footage has been successfully probed, this will return TRUE.
|
||||
*/
|
||||
bool ready();
|
||||
const Status& status();
|
||||
|
||||
/**
|
||||
* @brief Set ready state
|
||||
*
|
||||
* This should only be set by olive::ProbeMedia. Sets the ready state (see ready()).
|
||||
*/
|
||||
void set_ready(const bool& ready);
|
||||
void set_status(const Status& status);
|
||||
|
||||
/**
|
||||
* @brief Reset Footage state ready for running through Probe() again
|
||||
@@ -190,7 +196,7 @@ private:
|
||||
/**
|
||||
* @brief Internal ready setting
|
||||
*/
|
||||
bool ready_;
|
||||
Status status_;
|
||||
};
|
||||
|
||||
#endif // FOOTAGE_H
|
||||
|
||||
@@ -73,6 +73,16 @@ void Item::set_name(const QString &n)
|
||||
name_ = n;
|
||||
}
|
||||
|
||||
const QIcon &Item::icon()
|
||||
{
|
||||
return icon_;
|
||||
}
|
||||
|
||||
void Item::set_icon(const QIcon &icon)
|
||||
{
|
||||
icon_ = icon;
|
||||
}
|
||||
|
||||
Item *Item::parent() const
|
||||
{
|
||||
return parent_;
|
||||
|
||||
@@ -21,8 +21,9 @@
|
||||
#ifndef ITEM_H
|
||||
#define ITEM_H
|
||||
|
||||
#include <QString>
|
||||
#include <QIcon>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
|
||||
class Item
|
||||
{
|
||||
@@ -73,6 +74,9 @@ public:
|
||||
const QString& name() const;
|
||||
void set_name(const QString& n);
|
||||
|
||||
const QIcon& icon();
|
||||
void set_icon(const QIcon& icon);
|
||||
|
||||
Item *parent() const;
|
||||
void set_parent(Item *p);
|
||||
|
||||
@@ -82,6 +86,9 @@ private:
|
||||
Item* parent_;
|
||||
|
||||
QString name_;
|
||||
|
||||
QIcon icon_;
|
||||
|
||||
};
|
||||
|
||||
#endif // ITEM_H
|
||||
|
||||
@@ -122,21 +122,33 @@ int ProjectViewModel::columnCount(const QModelIndex &parent) const
|
||||
|
||||
QVariant ProjectViewModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole) {
|
||||
Item* internal_item = static_cast<Item*>(index.internalPointer());
|
||||
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
// Standard text role
|
||||
ColumnType column_type = columns_.at(index.column());
|
||||
|
||||
switch (column_type) {
|
||||
case kName:
|
||||
return static_cast<Item*>(index.internalPointer())->name();
|
||||
return internal_item->name();
|
||||
case kDuration:
|
||||
// FIXME Return actual information
|
||||
return "00:00:00;00";
|
||||
case kRate:
|
||||
// FIXME Return actual information
|
||||
return "29.97 FPS";
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Add DecorationRole to column 1 for icons
|
||||
break;
|
||||
case Qt::DecorationRole:
|
||||
// If this is the first column, return the Item's icon
|
||||
if (index.column() == 0) {
|
||||
return internal_item->icon();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
+1
-1
@@ -180,7 +180,7 @@ private:
|
||||
/**
|
||||
* @brief Set the status of this Task (also emits StatusChanged())
|
||||
*/
|
||||
void set_status(const Status& status);
|
||||
void set_status(const Task::Status& status);
|
||||
|
||||
Status status_;
|
||||
|
||||
|
||||
@@ -70,15 +70,18 @@ void TaskManager::StartNextWaiting()
|
||||
Task* t = tasks_.at(i);
|
||||
|
||||
if (t->status() == Task::kWorking) {
|
||||
|
||||
// Task is active, add it to the count
|
||||
working_count++;
|
||||
|
||||
} else if (t->status() == Task::kWaiting) {
|
||||
|
||||
// Task is waiting and we have available threads, try to start it
|
||||
if (t->Start()) {
|
||||
// If it started correctly, add it to the working count
|
||||
// If it started, add it to the working count
|
||||
working_count++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check if the count exceeds our maximum threads, if so stop here
|
||||
|
||||
@@ -58,6 +58,7 @@ QIcon olive::icon::ZoomOut;
|
||||
QIcon olive::icon::Record;
|
||||
QIcon olive::icon::Add;
|
||||
QIcon olive::icon::Error;
|
||||
QIcon olive::icon::Folder;
|
||||
|
||||
void olive::icon::LoadAll()
|
||||
{
|
||||
@@ -92,6 +93,7 @@ void olive::icon::LoadAll()
|
||||
Record = Create("record");
|
||||
Add = Create("add-button");
|
||||
Error = Create("error");
|
||||
Folder = Create("folder");
|
||||
}
|
||||
|
||||
QIcon olive::icon::Create(const QString &name)
|
||||
|
||||
@@ -61,6 +61,7 @@ extern QIcon ZoomOut;
|
||||
extern QIcon Record;
|
||||
extern QIcon Add;
|
||||
extern QIcon Error;
|
||||
extern QIcon Folder;
|
||||
|
||||
/**
|
||||
* @brief Create an icon object loaded from file
|
||||
|
||||
Reference in New Issue
Block a user