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

Fix bug in timeline clip insertion

parent 16be2415
......@@ -3682,7 +3682,7 @@ void MainWindow::slotInsertZoneToTimeline()
{
QPoint info = m_clipMonitor->getZoneInfo();
QString clipData = QString("%1#%2#%3").arg(m_clipMonitor->activeClipId()).arg(info.x()).arg(info.y());
int cid = getMainTimeline()->controller()->insertClip(-1, -1, clipData, true);
int cid = getMainTimeline()->controller()->insertClip(-1, -1, clipData, true, true);
if (cid == -1) {
pCore->displayMessage(i18n("Cannot insert clip at requested position"), InformationMessage);
} else {
......
......@@ -436,7 +436,7 @@ int TimelineModel::suggestCompositionMove(int compoId, int trackId, int position
return position;
}
bool TimelineModel::requestClipInsertion(const QString &binClipId, int trackId, int position, int &id, bool logUndo)
bool TimelineModel::requestClipInsertion(const QString &binClipId, int trackId, int position, int &id, bool logUndo, bool refreshView)
{
#ifdef LOGGING
m_logFile << "timeline->requestClipInsertion(" << binClipId.toStdString() << "," << trackId << " ," << position << ", dummy_id );" << std::endl;
......@@ -444,7 +444,7 @@ bool TimelineModel::requestClipInsertion(const QString &binClipId, int trackId,
QWriteLocker locker(&m_lock);
Fun undo = []() { return true; };
Fun redo = []() { return true; };
bool result = requestClipInsertion(binClipId, trackId, position, id, logUndo, undo, redo);
bool result = requestClipInsertion(binClipId, trackId, position, id, logUndo, refreshView, undo, redo);
if (result && logUndo) {
PUSH_UNDO(undo, redo, i18n("Insert Clip"));
}
......@@ -486,12 +486,12 @@ bool TimelineModel::requestClipCreation(const QString &binClipId, int &id, Fun &
return true;
}
bool TimelineModel::requestClipInsertion(const QString &binClipId, int trackId, int position, int &id, bool logUndo, Fun &undo, Fun &redo)
bool TimelineModel::requestClipInsertion(const QString &binClipId, int trackId, int position, int &id, bool logUndo, bool refreshView, Fun &undo, Fun &redo)
{
std::function<bool(void)> local_undo = []() { return true; };
std::function<bool(void)> local_redo = []() { return true; };
bool res = requestClipCreation(binClipId, id, local_undo, local_redo);
res = res && requestClipMove(id, trackId, position, logUndo, logUndo, local_undo, local_redo);
res = res && requestClipMove(id, trackId, position, refreshView, logUndo, local_undo, local_redo);
if (!res) {
bool undone = local_undo();
Q_ASSERT(undone);
......
......@@ -294,9 +294,9 @@ public:
insert @param Requested position @param ID return parameter of the id of
the inserted clip @param logUndo if set to false, no undo object is
stored */
bool requestClipInsertion(const QString &binClipId, int trackId, int position, int &id, bool logUndo = true);
bool requestClipInsertion(const QString &binClipId, int trackId, int position, int &id, bool logUndo = true, bool refreshView = false);
/* Same function, but accumulates undo and redo*/
bool requestClipInsertion(const QString &binClipId, int trackId, int position, int &id, bool logUndo, Fun &undo, Fun &redo);
bool requestClipInsertion(const QString &binClipId, int trackId, int position, int &id, bool logUndo, bool refreshView, Fun &undo, Fun &redo);
/* @brief Creates a new clip instance without inserting it.
This action is undoable, returns true on success
......
......@@ -197,12 +197,12 @@ Rectangle {
onEntered: {
if (clipBeingMovedId == -1) {
var track = Logic.getTrackIdFromPos(drag.y)
var frame = Math.round((drag.x + scrollView.flickableItem.contentX) / timeline.scaleFactor)
droppedPosition = frame
if (track >= 0) {
var frame = Math.round((drag.x + scrollView.flickableItem.contentX) / timeline.scaleFactor)
droppedPosition = frame
//drag.acceptProposedAction()
clipBeingDroppedData = drag.getDataAsString('kdenlive/producerslist')
clipBeingDroppedId = timeline.insertClip(track, frame, clipBeingDroppedData, false)
clipBeingDroppedId = timeline.insertClip(track, frame, clipBeingDroppedData, false, true)
continuousScrolling(drag.x + scrollView.flickableItem.contentX)
} else {
drag.accepted = false
......@@ -227,7 +227,7 @@ Rectangle {
controller.requestClipMove(clipBeingDroppedId, track, frame, true, false, false)
continuousScrolling(drag.x + scrollView.flickableItem.contentX)
} else {
clipBeingDroppedId = timeline.insertClip(track, frame, drag.getDataAsString('kdenlive/producerslist'), false)
clipBeingDroppedId = timeline.insertClip(track, frame, drag.getDataAsString('kdenlive/producerslist'), false, true)
continuousScrolling(drag.x + scrollView.flickableItem.contentX)
}
}
......@@ -238,7 +238,7 @@ Rectangle {
var track = controller.getClipTrackId(clipBeingDroppedId)
// we simulate insertion at the final position so that stored undo has correct value
controller.requestItemDeletion(clipBeingDroppedId, false)
timeline.insertClip(track, frame, clipBeingDroppedData, true)
timeline.insertClip(track, frame, clipBeingDroppedData, true, true)
}
clipBeingDroppedId = -1
droppedPosition = -1
......
......@@ -263,7 +263,7 @@ bool TimelineController::scrub()
return false;
}
int TimelineController::insertClip(int tid, int position, const QString &data_str, bool logUndo)
int TimelineController::insertClip(int tid, int position, const QString &data_str, bool logUndo, bool refreshView)
{
int id;
if (tid == -1) {
......@@ -274,7 +274,7 @@ int TimelineController::insertClip(int tid, int position, const QString &data_st
if (position == -1) {
position = m_position;
}
if (!m_model->requestClipInsertion(data_str, tid, position, id, logUndo)) {
if (!m_model->requestClipInsertion(data_str, tid, position, id, logUndo, refreshView)) {
id = -1;
}
return id;
......
......@@ -108,7 +108,7 @@ public:
@param logUndo if set to false, no undo object is stored
@return the id of the inserted clip
*/
Q_INVOKABLE int insertClip(int tid, int position, const QString &xml, bool logUndo);
Q_INVOKABLE int insertClip(int tid, int position, const QString &xml, bool logUndo, bool refreshView);
/* @brief Request inserting a new composition in timeline (dragged from compositions list)
@param tid is the destination 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