Merge branch 'master' of https://github.com/olive-editor/olive
This commit is contained in:
@@ -215,6 +215,20 @@ void Block::LinkChangeEvent()
|
||||
}
|
||||
}
|
||||
|
||||
bool Block::HashPassthrough(const QString &input, const QString &output, QCryptographicHash &hash, const rational &time, const VideoParams &video_params) const
|
||||
{
|
||||
if (IsInputConnected(input)) {
|
||||
rational t = InputTimeAdjustment(input, -1, TimeRange(time, time)).in();
|
||||
|
||||
NodeOutput out = GetConnectedOutput(input);
|
||||
out.node()->Hash(out.output(), hash, t, video_params);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Block::set_length_internal(const rational &length)
|
||||
{
|
||||
SetStandardValue(kLengthInput, QVariant::fromValue(length));
|
||||
|
||||
@@ -179,6 +179,8 @@ protected:
|
||||
|
||||
virtual void LinkChangeEvent() override;
|
||||
|
||||
bool HashPassthrough(const QString &input, const QString& output, QCryptographicHash &hash, const rational &time, const VideoParams& video_params) const;
|
||||
|
||||
Block* previous_;
|
||||
Block* next_;
|
||||
|
||||
|
||||
@@ -117,14 +117,7 @@ void ClipBlock::Retranslate()
|
||||
|
||||
void ClipBlock::Hash(const QString &out, QCryptographicHash &hash, const rational &time, const VideoParams &video_params) const
|
||||
{
|
||||
Q_UNUSED(out)
|
||||
|
||||
if (IsInputConnected(kBufferIn)) {
|
||||
rational t = InputTimeAdjustment(kBufferIn, -1, TimeRange(time, time)).in();
|
||||
|
||||
NodeOutput output = GetConnectedOutput(kBufferIn);
|
||||
output.node()->Hash(output.output(), hash, t, video_params);
|
||||
}
|
||||
HashPassthrough(kBufferIn, out, hash, time, video_params);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -121,16 +121,18 @@ double TransitionBlock::GetInProgress(const double &time) const
|
||||
|
||||
void TransitionBlock::Hash(const QString &output, QCryptographicHash &hash, const rational &time, const VideoParams &video_params) const
|
||||
{
|
||||
Node::Hash(output, hash, time, video_params);
|
||||
if (HashPassthrough(kInBlockInput, output, hash, time, video_params) || HashPassthrough(kOutBlockInput, output, hash, time, video_params)) {
|
||||
HashAddNodeSignature(hash, output);
|
||||
|
||||
double time_dbl = time.toDouble();
|
||||
double all_prog = GetTotalProgress(time_dbl);
|
||||
double in_prog = GetInProgress(time_dbl);
|
||||
double out_prog = GetOutProgress(time_dbl);
|
||||
double time_dbl = time.toDouble();
|
||||
double all_prog = GetTotalProgress(time_dbl);
|
||||
double in_prog = GetInProgress(time_dbl);
|
||||
double out_prog = GetOutProgress(time_dbl);
|
||||
|
||||
hash.addData(reinterpret_cast<const char*>(&all_prog), sizeof(double));
|
||||
hash.addData(reinterpret_cast<const char*>(&in_prog), sizeof(double));
|
||||
hash.addData(reinterpret_cast<const char*>(&out_prog), sizeof(double));
|
||||
hash.addData(reinterpret_cast<const char*>(&all_prog), sizeof(all_prog));
|
||||
hash.addData(reinterpret_cast<const char*>(&in_prog), sizeof(in_prog));
|
||||
hash.addData(reinterpret_cast<const char*>(&out_prog), sizeof(out_prog));
|
||||
}
|
||||
}
|
||||
|
||||
double TransitionBlock::GetInternalTransitionTime(const double &time) const
|
||||
@@ -217,7 +219,7 @@ NodeValueTable TransitionBlock::Value(const QString &output, NodeValueDatabase &
|
||||
|
||||
void TransitionBlock::InvalidateCache(const TimeRange &range, const QString &from, int element, InvalidateCacheOptions options)
|
||||
{
|
||||
TimeRange r;
|
||||
TimeRange r = range;
|
||||
|
||||
if (from == kOutBlockInput || from == kInBlockInput) {
|
||||
Block *n = dynamic_cast<Block*>(GetConnectedNode(from));
|
||||
@@ -283,7 +285,7 @@ void TransitionBlock::InputDisconnectedEvent(const QString &input, int element,
|
||||
|
||||
if (input == kOutBlockInput) {
|
||||
if (connected_out_block_) {
|
||||
connected_out_block_->set_in_transition(nullptr);
|
||||
connected_out_block_->set_out_transition(nullptr);
|
||||
connected_out_block_ = nullptr;
|
||||
}
|
||||
} else if (input == kInBlockInput) {
|
||||
|
||||
@@ -335,7 +335,7 @@ void TransformDistortNode::Hash(const QString &output, QCryptographicHash &hash,
|
||||
|
||||
if (!matrix.isIdentity()) {
|
||||
// Add fingerprint
|
||||
hash.addData(id().toUtf8());
|
||||
HashAddNodeSignature(hash, output);
|
||||
hash.addData(reinterpret_cast<const char*>(&matrix), sizeof(matrix));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ void MergeNode::Hash(const QString &output, QCryptographicHash &hash, const rati
|
||||
|
||||
if (!passthrough_base && !passthrough_blend) {
|
||||
// This merge will actually do something so we add a fingerprint
|
||||
hash.addData(id().toUtf8());
|
||||
HashAddNodeSignature(hash, output);
|
||||
}
|
||||
|
||||
if (!passthrough_base) {
|
||||
|
||||
+7
-4
@@ -1241,6 +1241,12 @@ bool Node::AreLinked(Node *a, Node *b)
|
||||
return a->links_.contains(b);
|
||||
}
|
||||
|
||||
void Node::HashAddNodeSignature(QCryptographicHash &hash, const QString &output) const
|
||||
{
|
||||
hash.addData(id().toUtf8());
|
||||
hash.addData(output.toUtf8());
|
||||
}
|
||||
|
||||
void Node::InsertInput(const QString &id, NodeValue::Type type, const QVariant &default_value, Node::InputFlags flags, int index)
|
||||
{
|
||||
if (id.isEmpty()) {
|
||||
@@ -1434,11 +1440,8 @@ void Node::SetLabel(const QString &s)
|
||||
|
||||
void Node::Hash(const QString &output, QCryptographicHash &hash, const rational& time, const VideoParams &video_params) const
|
||||
{
|
||||
Q_UNUSED(output)
|
||||
|
||||
// Add this Node's ID and output being used
|
||||
hash.addData(id().toUtf8());
|
||||
hash.addData(output.toUtf8());
|
||||
HashAddNodeSignature(hash, output);
|
||||
|
||||
auto inputs = inputs_for_output(output);
|
||||
foreach (const QString& input, inputs) {
|
||||
|
||||
@@ -183,6 +183,9 @@ public:
|
||||
|
||||
virtual QString duration() const {return QString();}
|
||||
|
||||
virtual qint64 creation_time() const {return 0;}
|
||||
virtual qint64 mod_time() const {return 0;}
|
||||
|
||||
virtual QString rate() const {return QString();}
|
||||
|
||||
const QVector<QString>& inputs() const
|
||||
@@ -849,6 +852,8 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
void HashAddNodeSignature(QCryptographicHash &hash, const QString &output) const;
|
||||
|
||||
void InsertInput(const QString& id, NodeValue::Type type, const QVariant& default_value, InputFlags flags, int index);
|
||||
|
||||
void PrependInput(const QString& id, NodeValue::Type type, const QVariant& default_value, InputFlags flags = InputFlags(kInputFlagNormal))
|
||||
|
||||
@@ -62,22 +62,30 @@ public:
|
||||
|
||||
static rational TransformTimeForBlock(const Block* block, const rational& time)
|
||||
{
|
||||
if (time == RATIONAL_MAX || time == RATIONAL_MIN) {
|
||||
return time;
|
||||
}
|
||||
|
||||
return time - block->in();
|
||||
}
|
||||
|
||||
static TimeRange TransformRangeForBlock(const Block* block, const TimeRange& range)
|
||||
{
|
||||
return range - block->in();
|
||||
return TimeRange(TransformTimeForBlock(block, range.in()), TransformTimeForBlock(block, range.out()));
|
||||
}
|
||||
|
||||
static rational TransformTimeFromBlock(const Block* block, const rational& time)
|
||||
{
|
||||
if (time == RATIONAL_MAX || time == RATIONAL_MIN) {
|
||||
return time;
|
||||
}
|
||||
|
||||
return time + block->in();
|
||||
}
|
||||
|
||||
static TimeRange TransformRangeFromBlock(const Block* block, const TimeRange& range)
|
||||
{
|
||||
return range + block->in();
|
||||
return TimeRange(TransformTimeFromBlock(block, range.in()), TransformTimeFromBlock(block, range.out()));
|
||||
}
|
||||
|
||||
const double& GetTrackHeight() const;
|
||||
|
||||
@@ -104,10 +104,14 @@ public:
|
||||
|
||||
foreach (Node* node, item_children_) {
|
||||
T* cast_test = dynamic_cast<T*>(node);
|
||||
|
||||
if (cast_test) {
|
||||
list.append(cast_test);
|
||||
}
|
||||
|
||||
Folder *folder_test = dynamic_cast<Folder*>(node);
|
||||
if (folder_test) {
|
||||
list.append(folder_test->ListChildrenOfType<T>());
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "codec/decoder.h"
|
||||
#include "common/clamp.h"
|
||||
#include "common/filefunctions.h"
|
||||
#include "common/qtutils.h"
|
||||
#include "common/xmlutils.h"
|
||||
#include "config/config.h"
|
||||
#include "core.h"
|
||||
@@ -483,6 +484,28 @@ rational Footage::AdjustTimeByLoopMode(rational time, Footage::LoopMode loop_mod
|
||||
return time;
|
||||
}
|
||||
|
||||
qint64 Footage::creation_time() const
|
||||
{
|
||||
QFileInfo info(filename());
|
||||
|
||||
if (info.exists()) {
|
||||
return QtUtils::GetCreationDate(info).toSecsSinceEpoch();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
qint64 Footage::mod_time() const
|
||||
{
|
||||
QFileInfo info(filename());
|
||||
|
||||
if (info.exists()) {
|
||||
return info.lastModified().toSecsSinceEpoch();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Footage::UpdateTooltip()
|
||||
{
|
||||
if (valid_) {
|
||||
|
||||
@@ -193,6 +193,9 @@ public:
|
||||
|
||||
static rational AdjustTimeByLoopMode(rational time, LoopMode loop_mode, const rational& length, VideoParams::Type type, const rational &timebase);
|
||||
|
||||
virtual qint64 creation_time() const override;
|
||||
virtual qint64 mod_time() const override;
|
||||
|
||||
static const QString kFilenameInput;
|
||||
static const QString kLoopModeInput;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <QMimeData>
|
||||
#include <QUrl>
|
||||
|
||||
#include "common/qtutils.h"
|
||||
#include "core.h"
|
||||
#include "widget/nodeview/nodeviewundo.h"
|
||||
#include "widget/nodeparamview/nodeparamviewundo.h"
|
||||
@@ -34,10 +35,6 @@ ProjectViewModel::ProjectViewModel(QObject *parent) :
|
||||
QAbstractItemModel(parent),
|
||||
project_(nullptr)
|
||||
{
|
||||
// FIXME: make this configurable
|
||||
columns_.append(kName);
|
||||
columns_.append(kDuration);
|
||||
columns_.append(kRate);
|
||||
}
|
||||
|
||||
Project *ProjectViewModel::project() const
|
||||
@@ -124,17 +121,18 @@ int ProjectViewModel::columnCount(const QModelIndex &parent) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
return columns_.size();
|
||||
return kColumnCount;
|
||||
}
|
||||
|
||||
QVariant ProjectViewModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
Node* internal_item = GetItemObjectFromIndex(index);
|
||||
|
||||
ColumnType column_type = columns_.at(index.column());
|
||||
ColumnType column_type = static_cast<ColumnType>(index.column());
|
||||
|
||||
switch (role) {
|
||||
case Qt::DisplayRole:
|
||||
case kInnerTextRole:
|
||||
{
|
||||
// Standard text role
|
||||
|
||||
@@ -145,6 +143,30 @@ QVariant ProjectViewModel::data(const QModelIndex &index, int role) const
|
||||
return internal_item->duration();
|
||||
case kRate:
|
||||
return internal_item->rate();
|
||||
case kLastModified:
|
||||
case kCreatedTime:
|
||||
{
|
||||
qint64 using_time = (column_type == kLastModified) ? internal_item->mod_time() : internal_item->creation_time();
|
||||
|
||||
if (using_time == 0) {
|
||||
// 0 is the null value, return nothing
|
||||
break;
|
||||
}
|
||||
|
||||
QVariant ret;
|
||||
|
||||
if (role == kInnerTextRole) {
|
||||
// Use time value directly for correct sorting
|
||||
ret = using_time;
|
||||
} else {
|
||||
// Display role, format to a human readable string
|
||||
ret = QtUtils::GetFormattedDateTime(QDateTime::fromSecsSinceEpoch(using_time));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
case kColumnCount:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -166,7 +188,7 @@ QVariant ProjectViewModel::headerData(int section, Qt::Orientation orientation,
|
||||
// Check if we need text data (DisplayRole) and orientation is horizontal
|
||||
// FIXME I'm not 100% sure what happens if the orientation is vertical/if that check is necessary
|
||||
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
||||
ColumnType column_type = columns_.at(section);
|
||||
ColumnType column_type = static_cast<ColumnType>(section);
|
||||
|
||||
// Return the name based on the column's current type
|
||||
switch (column_type) {
|
||||
@@ -176,6 +198,12 @@ QVariant ProjectViewModel::headerData(int section, Qt::Orientation orientation,
|
||||
return tr("Duration");
|
||||
case kRate:
|
||||
return tr("Rate");
|
||||
case kLastModified:
|
||||
return tr("Modified");
|
||||
case kCreatedTime:
|
||||
return tr("Created");
|
||||
case kColumnCount:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +222,7 @@ bool ProjectViewModel::hasChildren(const QModelIndex &parent) const
|
||||
bool ProjectViewModel::setData(const QModelIndex &index, const QVariant &value, int role)
|
||||
{
|
||||
// The name is editable
|
||||
if (index.isValid() && columns_.at(index.column()) == kName && role == Qt::EditRole) {
|
||||
if (index.isValid() && index.column() == kName && role == Qt::EditRole) {
|
||||
Node* item = GetItemObjectFromIndex(index);
|
||||
|
||||
QString new_name = value.toString();
|
||||
@@ -233,7 +261,7 @@ Qt::ItemFlags ProjectViewModel::flags(const QModelIndex &index) const
|
||||
}
|
||||
|
||||
// If the column is the kName column, that means it's editable
|
||||
if (columns_.at(index.column()) == kName) {
|
||||
if (index.column() == kName) {
|
||||
f |= Qt::ItemIsEditable;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,9 +49,20 @@ public:
|
||||
kDuration,
|
||||
|
||||
/// Media rate (frame rate for video, sample rate for audio)
|
||||
kRate
|
||||
kRate,
|
||||
|
||||
/// Last modified time (for footage/files)
|
||||
kLastModified,
|
||||
|
||||
/// Creation time (for footage/files)
|
||||
kCreatedTime,
|
||||
|
||||
/// Count
|
||||
kColumnCount
|
||||
};
|
||||
|
||||
static const int kInnerTextRole = Qt::UserRole + 1;
|
||||
|
||||
/**
|
||||
* @brief ProjectViewModel Constructor
|
||||
*
|
||||
@@ -137,8 +148,6 @@ private:
|
||||
|
||||
Project* project_;
|
||||
|
||||
QVector<ColumnType> columns_;
|
||||
|
||||
private slots:
|
||||
void FolderBeginInsertItem(Node *n, int insert_index);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user