Several fixes for subclips (names, zone in monitor, sorting, thumbs)

parent 07851dd6
......@@ -136,6 +136,9 @@ QVariant AbstractProjectItem::getData(DataType type) const
case DataDuration:
data = QVariant(m_duration);
break;
case DataInPoint:
data = QVariant(m_inPoint);
break;
case DataDate:
data = QVariant(m_date);
break;
......
......@@ -121,6 +121,8 @@ public:
ItemTypeRole,
// Duration of the clip
DataDuration,
// Inpoint of the subclip (0 for clips)
DataInPoint,
// If there is a running job, which type
JobType,
// Current progress of the job
......@@ -194,6 +196,7 @@ protected:
QString m_description;
QIcon m_thumbnail;
QString m_duration;
int m_inPoint;
QDateTime m_date;
QString m_binId;
uint m_usage;
......
......@@ -1099,7 +1099,7 @@ void Bin::setMonitor(Monitor *monitor)
m_monitor = monitor;
connect(m_monitor, &Monitor::addClipToProject, this, &Bin::slotAddClipToProject);
connect(m_monitor, &Monitor::refreshCurrentClip, this, &Bin::slotOpenCurrent);
connect(this, &Bin::openClip, [&](std::shared_ptr<ProjectClip> clip) { m_monitor->slotOpenClip(clip); });
connect(this, &Bin::openClip, [&](std::shared_ptr<ProjectClip> clip, int in, int out) { m_monitor->slotOpenClip(clip, in, out); });
}
void Bin::setDocument(KdenliveDoc *project)
......
......@@ -71,6 +71,7 @@ ProjectClip::ProjectClip(const QString &id, const QIcon &thumb, std::shared_ptr<
m_clipStatus = StatusReady;
m_name = clipName();
m_duration = getStringDuration();
m_inPoint = 0;
m_date = date;
m_description = ClipController::description();
if (m_clipType == ClipType::Audio) {
......
......@@ -182,7 +182,7 @@ bool ProjectItemModel::dropMimeData(const QMimeData *data, Qt::DropAction action
QStringList clipData = ids.constFirst().split(QLatin1Char('/'));
if (clipData.length() >= 3) {
QString id;
return requestAddBinSubClip(id, clipData.at(1).toInt(), clipData.at(2).toInt(), clipData.at(0));
return requestAddBinSubClip(id, clipData.at(1).toInt(), clipData.at(2).toInt(), QString(), clipData.at(0));
} else {
// error, malformed clip zone, abort
return false;
......@@ -206,7 +206,7 @@ bool ProjectItemModel::dropMimeData(const QMimeData *data, Qt::DropAction action
if (data->hasFormat(QStringLiteral("kdenlive/clip"))) {
const QStringList list = QString(data->data(QStringLiteral("kdenlive/clip"))).split(QLatin1Char(';'));
QString id;
return requestAddBinSubClip(id, list.at(1).toInt(), list.at(2).toInt(), list.at(0));
return requestAddBinSubClip(id, list.at(1).toInt(), list.at(2).toInt(), QString(), list.at(0));
}
return false;
......@@ -427,7 +427,7 @@ void ProjectItemModel::loadSubClips(const QString &id, const QMap<QString, QStri
}
QString subId;
requestAddBinSubClip(subId, in, out, id, undo, redo);
requestAddBinSubClip(subId, in, out, i.key(), id, undo, redo);
}
}
......@@ -588,7 +588,7 @@ bool ProjectItemModel::requestAddBinClip(QString &id, std::shared_ptr<Mlt::Produ
return res;
}
bool ProjectItemModel::requestAddBinSubClip(QString &id, int in, int out, const QString &parentId, Fun &undo, Fun &redo)
bool ProjectItemModel::requestAddBinSubClip(QString &id, int in, int out, const QString &zoneName, const QString &parentId, Fun &undo, Fun &redo)
{
QWriteLocker locker(&m_lock);
if (id.isEmpty()) {
......@@ -598,7 +598,7 @@ bool ProjectItemModel::requestAddBinSubClip(QString &id, int in, int out, const
auto clip = getClipByBinID(parentId);
Q_ASSERT(clip->itemType() == AbstractProjectItem::ClipItem);
auto tc = pCore->currentDoc()->timecode().getDisplayTimecodeFromFrames(in, KdenliveSettings::frametimecode());
std::shared_ptr<ProjectSubClip> new_clip = ProjectSubClip::construct(id, clip, std::static_pointer_cast<ProjectItemModel>(shared_from_this()), in, out, tc);
std::shared_ptr<ProjectSubClip> new_clip = ProjectSubClip::construct(id, clip, std::static_pointer_cast<ProjectItemModel>(shared_from_this()), in, out, tc, zoneName);
bool res = addItem(new_clip, parentId, undo, redo);
if (res) {
int parentJob = pCore->jobManager()->getBlockingJobId(parentId, AbstractClipJob::LOADJOB);
......@@ -606,11 +606,11 @@ bool ProjectItemModel::requestAddBinSubClip(QString &id, int in, int out, const
}
return res;
}
bool ProjectItemModel::requestAddBinSubClip(QString &id, int in, int out, const QString &parentId)
bool ProjectItemModel::requestAddBinSubClip(QString &id, int in, int out, const QString &zoneName, const QString &parentId)
{
Fun undo = []() { return true; };
Fun redo = []() { return true; };
bool res = requestAddBinSubClip(id, in, out, parentId, undo, redo);
bool res = requestAddBinSubClip(id, in, out, zoneName, parentId, undo, redo);
if (res) {
pCore->pushUndo(undo, redo, i18n("Add a sub clip"));
}
......
......@@ -163,8 +163,8 @@ public:
@param in,out : zone that corresponds to the subclip
@param undo,redo: lambdas that are updated to accumulate operation.
*/
bool requestAddBinSubClip(QString &id, int in, int out, const QString &parentId, Fun &undo, Fun &redo);
bool requestAddBinSubClip(QString &id, int in, int out, const QString &parentId);
bool requestAddBinSubClip(QString &id, int in, int out, const QString &zoneName, const QString &parentId, Fun &undo, Fun &redo);
bool requestAddBinSubClip(QString &id, int in, int out, const QString &zoneName, const QString &parentId);
/* @brief Request that a folder's name is changed
@param clip : pointer to the folder to rename
......
......@@ -97,8 +97,8 @@ bool ProjectSortProxyModel::lessThan(const QModelIndex &left, const QModelIndex
QVariant rightData;
if (leftType == AbstractProjectItem::SubClipItem) {
// Subclips, sort by start position
leftData = sourceModel()->data(left, AbstractProjectItem::DataDuration);
rightData = sourceModel()->data(right, AbstractProjectItem::DataDuration);
leftData = sourceModel()->data(left, AbstractProjectItem::DataInPoint);
rightData = sourceModel()->data(right, AbstractProjectItem::DataInPoint);
} else {
leftData = sourceModel()->data(left, Qt::DisplayRole);
rightData = sourceModel()->data(right, Qt::DisplayRole);
......
......@@ -33,9 +33,9 @@ ProjectSubClip::ProjectSubClip(const QString &id, const std::shared_ptr<ProjectC
const QString &timecode, const QString &name)
: AbstractProjectItem(AbstractProjectItem::SubClipItem, id, model)
, m_masterClip(parent)
, m_in(in)
, m_out(out)
{
m_inPoint = in;
m_duration = timecode;
QPixmap pix(64, 36);
pix.fill(Qt::lightGray);
......@@ -66,7 +66,7 @@ ProjectSubClip::~ProjectSubClip()
void ProjectSubClip::gotThumb(int pos, const QImage &img)
{
if (pos == m_in) {
if (pos == m_inPoint) {
setThumbnail(img);
disconnect(m_masterClip.get(), &ProjectClip::thumbReady, this, &ProjectSubClip::gotThumb);
}
......@@ -106,7 +106,7 @@ GenTime ProjectSubClip::duration() const
QPoint ProjectSubClip::zone() const
{
return QPoint(m_in, m_out);
return QPoint(m_inPoint, m_out);
}
std::shared_ptr<ProjectClip> ProjectSubClip::clipAt(int ix)
......@@ -119,14 +119,14 @@ QDomElement ProjectSubClip::toXml(QDomDocument &document, bool)
{
QDomElement sub = document.createElement(QStringLiteral("subclip"));
sub.setAttribute(QStringLiteral("id"), m_masterClip->AbstractProjectItem::clipId());
sub.setAttribute(QStringLiteral("in"), m_in);
sub.setAttribute(QStringLiteral("in"), m_inPoint);
sub.setAttribute(QStringLiteral("out"), m_out);
return sub;
}
std::shared_ptr<ProjectSubClip> ProjectSubClip::subClip(int in, int out)
{
if (m_in == in && m_out == out) {
if (m_inPoint == in && m_out == out) {
return std::static_pointer_cast<ProjectSubClip>(shared_from_this());
}
return std::shared_ptr<ProjectSubClip>();
......
......@@ -84,7 +84,6 @@ public:
private:
std::shared_ptr<ProjectClip> m_masterClip;
int m_in;
int m_out;
private slots:
......
......@@ -155,7 +155,7 @@ bool SceneSplitJob::commitResult(Fun &undo, Fun &redo)
QMap <QString, QString> zoneData;
for (const QString marker : markerData) {
int pos = marker.section(QLatin1Char('='), 0, 0).toInt();
if (pos == lastCut || pos - lastCut < m_minInterval) {
if (pos <= lastCut + 1 || pos - lastCut < m_minInterval) {
continue;
}
zoneData.insert(i18n("Scene %1", ix), QString("%1;%2").arg(lastCut).arg(pos - 1));
......
......@@ -66,8 +66,12 @@ bool ThumbJob::startJob()
if (m_subClip) {
auto item = pCore->projectItemModel()->getItemByBinId(m_clipId);
m_binClip = std::static_pointer_cast<ProjectClip>(item->parent());
m_frameNumber = item->zone().x();
} else {
m_binClip = pCore->projectItemModel()->getClipByBinID(m_clipId);
if (m_frameNumber < 0) {
m_frameNumber = qMax(0, m_binClip->getProducerIntProperty(QStringLiteral("kdenlive:thumbnailFrame")));
}
}
if (m_binClip->clipType() == ClipType::Audio) {
// Don't create thumbnail for audio clips
......@@ -75,9 +79,6 @@ bool ThumbJob::startJob()
return true;
}
m_inCache = false;
if (m_frameNumber < 0) {
m_frameNumber = qMax(0, m_binClip->getProducerIntProperty(QStringLiteral("kdenlive:thumbnailFrame")));
}
if (ThumbnailCache::get()->hasThumbnail(m_binClip->clipId(), m_frameNumber, !m_persistent)) {
m_done = true;
m_result = ThumbnailCache::get()->getThumbnail(m_binClip->clipId(), m_frameNumber);
......
......@@ -3640,7 +3640,7 @@ void MainWindow::slotInsertZoneToTree()
}
QPoint info = m_clipMonitor->getZoneInfo();
QString id;
pCore->projectItemModel()->requestAddBinSubClip(id, info.x(), info.y(), m_clipMonitor->activeClipId());
pCore->projectItemModel()->requestAddBinSubClip(id, info.x(), info.y(), QString(), m_clipMonitor->activeClipId());
}
void MainWindow::slotInsertZoneToTimeline()
......
......@@ -1338,7 +1338,6 @@ void Monitor::updateClipProducer(const QString &playlist)
void Monitor::slotOpenClip(std::shared_ptr<ProjectClip> controller, int in, int out)
{
Q_UNUSED(out)
if (m_controller) {
disconnect(m_controller->getMarkerModel().get(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &, const QVector<int> &)), this,
SLOT(checkOverlay()));
......@@ -1364,7 +1363,11 @@ void Monitor::slotOpenClip(std::shared_ptr<ProjectClip> controller, int in, int
updateMarkers();
connect(m_glMonitor->getControllerProxy(), &MonitorProxy::addSnap, this, &Monitor::addSnapPoint, Qt::DirectConnection);
connect(m_glMonitor->getControllerProxy(), &MonitorProxy::removeSnap, this, &Monitor::removeSnapPoint, Qt::DirectConnection);
m_glMonitor->getControllerProxy()->setZone(m_controller->zone());
if (out == -1) {
m_glMonitor->getControllerProxy()->setZone(m_controller->zone());
} else {
m_glMonitor->getControllerProxy()->setZone(in, out);
}
m_snaps->addPoint(m_controller->frameDuration());
// Loading new clip / zone, stop if playing
if (m_playAction->isActive()) {
......
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