Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit c30f8b77 authored by Nicolas Carion's avatar Nicolas Carion

Timeline model is not built by widget

parent 424d4052
......@@ -18,6 +18,7 @@ the Free Software Foundation, either version 3 of the License, or
#include "mltcontroller/bincontroller.h"
#include "mltcontroller/producerqueue.h"
#include "monitor/monitormanager.h"
#include "profiles/profilemodel.hpp"
#include "project/dialogs/archivewidget.h"
#include "project/dialogs/backupwidget.h"
#include "project/dialogs/projectsettings.h"
......@@ -879,7 +880,8 @@ void ProjectManager::updateTimeline(Mlt::Tractor tractor)
if (!m_timelineWidgetLoaded) {
m_timelineWidgetLoaded = true;
qDebug() << "CONSTRUCTING TIMELINEWIDGET";
m_timelineWidget = new TimelineWidget(pCore->window()->actionCollection(), pCore->binController(), m_project->commandStack(), pCore->window());
m_timelineWidget = new TimelineWidget(pCore->window()->actionCollection(), pCore->binController(), pCore->window());
m_timelineWidget->setModel(TimelineItemModel::construct(&pCore->getCurrentProfile()->profile(), m_project->commandStack()));
pCore->addTimeline(m_timelineWidget, m_project->url().fileName());
connect(pCore->monitorManager()->projectMonitor(), &Monitor::seekTimeline, m_timelineWidget, &TimelineWidget::seek, Qt::DirectConnection);
connect(m_timelineWidget, &TimelineWidget::seeked, pCore->monitorManager()->projectMonitor(), &Monitor::requestSeek, Qt::DirectConnection);
......
......@@ -44,10 +44,8 @@ const int TimelineWidget::comboScale[] = {1, 2, 5, 10, 25, 50, 125, 250, 500, 75
int TimelineWidget::m_duration = 0;
TimelineWidget::TimelineWidget(KActionCollection *actionCollection, std::shared_ptr<BinController> binController, std::weak_ptr<DocUndoStack> undoStack,
QWidget *parent)
TimelineWidget::TimelineWidget(KActionCollection *actionCollection, std::shared_ptr<BinController> binController, QWidget *parent)
: QQuickWidget(parent)
, m_model(TimelineItemModel::construct(&pCore->getCurrentProfile()->profile(), undoStack))
, m_actionCollection(actionCollection)
, m_binController(binController)
, m_position(0)
......@@ -55,10 +53,6 @@ TimelineWidget::TimelineWidget(KActionCollection *actionCollection, std::shared_
, m_scale(3.0)
{
registerTimelineItems();
auto *proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel(m_model.get());
proxyModel->setSortRole(TimelineItemModel::ItemIdRole);
proxyModel->sort(0, Qt::DescendingOrder);
m_transitionModel.reset(new TransitionTreeModel(true, this));
......@@ -72,16 +66,29 @@ TimelineWidget::TimelineWidget(KActionCollection *actionCollection, std::shared_
kdeclarative.initialize();
kdeclarative.setupBindings();
setResizeMode(QQuickWidget::SizeRootObjectToView);
m_thumbnailer = new ThumbnailProvider;
engine()->addImageProvider(QStringLiteral("thumbnail"), m_thumbnailer);
setFocusPolicy(Qt::StrongFocus);
setVisible(false);
// connect(&*m_model, SIGNAL(seeked(int)), this, SLOT(onSeeked(int)));
}
void TimelineWidget::setModel(std::shared_ptr<TimelineItemModel> model)
{
m_model = model;
auto *proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel(m_model.get());
proxyModel->setSortRole(TimelineItemModel::ItemIdRole);
proxyModel->sort(0, Qt::DescendingOrder);
rootContext()->setContextProperty("multitrack", proxyModel);
rootContext()->setContextProperty("controller", m_model.get());
rootContext()->setContextProperty("timeline", this);
rootContext()->setContextProperty("transitionModel", m_transitionProxyModel.get());
setSource(QUrl(QStringLiteral("qrc:/qml/timeline.qml")));
setVisible(true);
m_thumbnailer = new ThumbnailProvider;
engine()->addImageProvider(QStringLiteral("thumbnail"), m_thumbnailer);
setFocusPolicy(Qt::StrongFocus);
// connect(&*m_model, SIGNAL(seeked(int)), this, SLOT(onSeeked(int)));
}
void TimelineWidget::setSelection(const QList<int> &newSelection, int trackIndex, bool isMultitrack)
......
......@@ -55,8 +55,12 @@ class TimelineWidget : public QQuickWidget
Q_PROPERTY(bool showAudioThumbnails READ showAudioThumbnails NOTIFY showAudioThumbnailsChanged)
public:
TimelineWidget(KActionCollection *actionCollection, std::shared_ptr<BinController> binController, std::weak_ptr<DocUndoStack> undoStack,
QWidget *parent = Q_NULLPTR);
TimelineWidget(KActionCollection *actionCollection, std::shared_ptr<BinController> binController, QWidget *parent = Q_NULLPTR);
/* @brief Sets the model shown by this widget */
void setModel(std::shared_ptr<TimelineItemModel> model);
/* @brief Sets the list of currently selected clips
@param selection is the list of id's
@param trackIndex is current clip's track
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment