Fix auto scene split job (create markers)

parent aaa325bf
......@@ -353,10 +353,18 @@ void MarkerListModel::registerSnapModel(std::weak_ptr<SnapModel> snapModel)
bool MarkerListModel::importFromJson(const QString &data, bool ignoreConflicts, bool pushUndo)
{
QWriteLocker locker(&m_lock);
Fun undo = []() { return true; };
Fun redo = []() { return true; };
bool result = importFromJson(data, ignoreConflicts, undo ,redo);
if (pushUndo) {
PUSH_UNDO(undo, redo, m_guide ? i18n("Import guides") : i18n("Import markers"));
}
return result;
}
bool MarkerListModel::importFromJson(const QString &data, bool ignoreConflicts, Fun &undo, Fun &redo)
{
QWriteLocker locker(&m_lock);
auto json = QJsonDocument::fromJson(data.toUtf8());
if (!json.isArray()) {
qDebug() << "Error : Json file should be an array";
......@@ -387,6 +395,7 @@ bool MarkerListModel::importFromJson(const QString &data, bool ignoreConflicts,
int oldType = m_markerList[GenTime(pos, pCore->getCurrentFps())].second;
res = (oldComment == comment) && (type == oldType);
}
qDebug()<<"// ADDING MARKER AT POS: "<<pos<<", FPS: "<<pCore->getCurrentFps();
res = res && addMarker(GenTime(pos, pCore->getCurrentFps()), comment, type, undo, redo);
if (!res) {
bool undone = undo();
......@@ -395,9 +404,6 @@ bool MarkerListModel::importFromJson(const QString &data, bool ignoreConflicts,
}
}
if (pushUndo) {
PUSH_UNDO(undo, redo, m_guide ? i18n("Import guides") : i18n("Import markers"));
}
return true;
}
......
......@@ -137,6 +137,7 @@ public slots:
@param pushUndo: if true, create an undo object
*/
bool importFromJson(const QString &data, bool ignoreConflicts, bool pushUndo = true);
bool importFromJson(const QString &data, bool ignoreConflicts, Fun &undo, Fun &redo);
protected:
/* @brief Adds a snap point at marker position in the registered snap models
......
......@@ -124,6 +124,22 @@ bool SceneSplitJob::commitResult(Fun &undo, Fun &redo)
}
auto binClip = pCore->projectItemModel()->getClipByBinID(m_clipId);
if (m_markersType >= 0) {
// Build json data for markers
QJsonArray list;
QStringList markerData = result.split(QLatin1Char(';'));
int ix = 1;
for (const QString marker : markerData) {
QJsonObject currentMarker;
currentMarker.insert(QLatin1String("pos"), QJsonValue(marker.section(QLatin1Char('='), 0, 0).toInt()));
currentMarker.insert(QLatin1String("comment"), QJsonValue(i18n("Scene %1", ix)));
currentMarker.insert(QLatin1String("type"), QJsonValue(m_markersType));
list.push_back(currentMarker);
ix++;
}
QJsonDocument json(list);
binClip->getMarkerModel()->importFromJson(QString(json.toJson()), true, undo, redo);
}
qDebug() << "RESULT of the SCENESPLIT filter:" << result;
// TODO refac: reimplement add markers and subclips
......
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