diff --git a/app/core.cpp b/app/core.cpp index 944699b19..deb7b0dcb 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -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"); +} diff --git a/app/core.h b/app/core.h index 362717078..9b1f77626 100644 --- a/app/core.h +++ b/app/core.h @@ -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 { diff --git a/app/decoder/ffmpeg/ffmpegdecoder.cpp b/app/decoder/ffmpeg/ffmpegdecoder.cpp index 046e61ade..2af558164 100644 --- a/app/decoder/ffmpeg/ffmpegdecoder.cpp +++ b/app/decoder/ffmpeg/ffmpegdecoder.cpp @@ -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) diff --git a/app/decoder/probeserver.cpp b/app/decoder/probeserver.cpp index fb4a42ba6..66d73dd04 100644 --- a/app/decoder/probeserver.cpp +++ b/app/decoder/probeserver.cpp @@ -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; } diff --git a/app/project/item/folder/folder.cpp b/app/project/item/folder/folder.cpp index 1e187af2f..37f85bafb 100644 --- a/app/project/item/folder/folder.cpp +++ b/app/project/item/folder/folder.cpp @@ -20,9 +20,11 @@ #include "folder.h" +#include "ui/icons/icons.h" + Folder::Folder() { - + set_icon(olive::icon::Folder); } Item::Type Folder::type() const diff --git a/app/project/item/footage/footage.cpp b/app/project/item/footage/footage.cpp index 04cc8ca89..656fbd3ac 100644 --- a/app/project/item/footage/footage.cpp +++ b/app/project/item/footage/footage.cpp @@ -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() diff --git a/app/project/item/footage/footage.h b/app/project/item/footage/footage.h index 3b537a307..7ad641e3d 100644 --- a/app/project/item/footage/footage.h +++ b/app/project/item/footage/footage.h @@ -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 diff --git a/app/project/item/item.cpp b/app/project/item/item.cpp index 1cf500531..b841a3163 100644 --- a/app/project/item/item.cpp +++ b/app/project/item/item.cpp @@ -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_; diff --git a/app/project/item/item.h b/app/project/item/item.h index 96500dce1..94645085f 100644 --- a/app/project/item/item.h +++ b/app/project/item/item.h @@ -21,8 +21,9 @@ #ifndef ITEM_H #define ITEM_H -#include +#include #include +#include 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 diff --git a/app/project/projectviewmodel.cpp b/app/project/projectviewmodel.cpp index f54016e90..861a316bd 100644 --- a/app/project/projectviewmodel.cpp +++ b/app/project/projectviewmodel.cpp @@ -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(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(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(); } diff --git a/app/task/task.h b/app/task/task.h index 43093504d..d26e3637f 100644 --- a/app/task/task.h +++ b/app/task/task.h @@ -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_; diff --git a/app/task/taskmanager.cpp b/app/task/taskmanager.cpp index 1414d84b4..896bf3027 100644 --- a/app/task/taskmanager.cpp +++ b/app/task/taskmanager.cpp @@ -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 diff --git a/app/ui/icons/icons.cpp b/app/ui/icons/icons.cpp index 530a30b41..8ae54caa9 100644 --- a/app/ui/icons/icons.cpp +++ b/app/ui/icons/icons.cpp @@ -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) diff --git a/app/ui/icons/icons.h b/app/ui/icons/icons.h index 2d0be7a42..53b4a84ac 100644 --- a/app/ui/icons/icons.h +++ b/app/ui/icons/icons.h @@ -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