R8: finish app/ pure C ABI migration (P3-P9) and make OTIO required
- app/ no longer includes engine C++ headers nor holds engine C++ types: engine access goes through the oakengine C ABI plus C++ wrappers (oakutil/oaknode.h, oakutil/oakvideo.h) and app-local mirror types (tooltypes, trackreferencehandle, timelinecommonapp, keyframetypes, subtitleapp, serializedlayoutinfoapp, nodevaluehandle, sliderdisplaytypeapp) - engine: new C ABI functions for block/track/clip/transition navigation and predicates, links, caches, waveform/playback, disk folder, sequence_track_list, node_free, footage_is_valid, block_get_track, get_brush; loadotio/saveotio ported to the current engine API - OTIO is now a required dependency: CI and CD build it on every platform, FindOpenTimelineIO fixed for OTIO 0.16/0.19 (the old deps include requirement silently disabled OTIO everywhere), runtime libraries are bundled into packages and copied next to macOS binaries (oak_copy_otio_runtime) - fix ProjectViewModel drag&drop mime read/write size mismatch (segfault) - unify color label naming (k_olive -> "Oak") in the app-side mirror - docs: OTIO required, FFmpeg minimum corrected to 6.0 (en/zh) - gtest suite: 1925 passed, 0 failed
This commit is contained in:
@@ -21,19 +21,108 @@
|
||||
|
||||
#include "historywidget.h"
|
||||
|
||||
#include "core.h"
|
||||
#include "oakengine/events.h"
|
||||
#include "oakengine/undo.h"
|
||||
|
||||
namespace olive
|
||||
{
|
||||
|
||||
HistoryModel::HistoryModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
{
|
||||
sub_ = oakengine_event_subscribe(
|
||||
oakengine_undo_handle(), OAKENGINE_EVENT_UNDO_INDEX_CHANGED,
|
||||
[](const oakengine_event *event, void *userdata) {
|
||||
Q_UNUSED(event)
|
||||
auto *self = static_cast<HistoryModel *>(userdata);
|
||||
self->beginResetModel();
|
||||
self->endResetModel();
|
||||
},
|
||||
this);
|
||||
}
|
||||
|
||||
HistoryModel::~HistoryModel()
|
||||
{
|
||||
if (sub_ > 0) {
|
||||
oakengine_event_unsubscribe(sub_);
|
||||
}
|
||||
}
|
||||
|
||||
QModelIndex HistoryModel::index(int row, int column,
|
||||
const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent)
|
||||
return createIndex(row, column, nullptr);
|
||||
}
|
||||
|
||||
QModelIndex HistoryModel::parent(const QModelIndex &index) const
|
||||
{
|
||||
Q_UNUSED(index)
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
int HistoryModel::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid()) {
|
||||
return 0;
|
||||
}
|
||||
return static_cast<int>(oakengine_undo_count());
|
||||
}
|
||||
|
||||
int HistoryModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
if (parent.isValid()) {
|
||||
return 0;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
QVariant HistoryModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch (index.column()) {
|
||||
case 0:
|
||||
return index.row() + 1;
|
||||
case 1: {
|
||||
char buf[1024];
|
||||
buf[0] = '\0';
|
||||
oakengine_undo_command_text(index.row(), buf, sizeof(buf));
|
||||
const QString name = QString::fromUtf8(buf);
|
||||
return name.isEmpty() ? tr("Command") : name;
|
||||
}
|
||||
}
|
||||
} else if (role == Qt::ForegroundRole) {
|
||||
// Rows at/after the current stack index are undone commands
|
||||
if (index.row() >= oakengine_undo_index()) {
|
||||
return QVariant(QColor(Qt::gray));
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariant HistoryModel::headerData(int section, Qt::Orientation orientation,
|
||||
int role) const
|
||||
{
|
||||
Q_UNUSED(orientation)
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch (section) {
|
||||
case 0:
|
||||
return QStringLiteral("Number");
|
||||
case 1:
|
||||
return QStringLiteral("Action");
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
HistoryWidget::HistoryWidget(QWidget *parent)
|
||||
: QTreeView(parent)
|
||||
{
|
||||
stack_ = Core::instance()->undo_stack();
|
||||
model_ = new HistoryModel(this);
|
||||
|
||||
this->setModel(stack_);
|
||||
this->setModel(model_);
|
||||
this->setRootIsDecorated(false);
|
||||
undo_sub_ = oakengine_event_subscribe(
|
||||
oakengine_undo_handle(), OAKENGINE_EVENT_UNDO_INDEX_CHANGED,
|
||||
|
||||
Reference in New Issue
Block a user