Commit cdc5d15f authored by Julius Künzel's avatar Julius Künzel
Browse files

Fix ripple of groups after commit c1b0f275

parent d38d6c6a
......@@ -315,7 +315,7 @@ bool TimelineFunctions::requestClipCutAll(std::shared_ptr<TimelineItemModel> tim
return count > 0;
}
int TimelineFunctions::requestSpacerStartOperation(const std::shared_ptr<TimelineItemModel> &timeline, int trackId, int position, bool ignoreMultiTrackGroups)
int TimelineFunctions::requestSpacerStartOperation(const std::shared_ptr<TimelineItemModel> &timeline, int trackId, int position, bool ignoreMultiTrackGroups, bool allowGroupBreaking)
{
std::unordered_set<int> clips = timeline->getItemsInRange(trackId, position, -1);
timeline->requestClearSelection();
......@@ -337,42 +337,46 @@ int TimelineFunctions::requestSpacerStartOperation(const std::shared_ptr<Timelin
std::unordered_set<int> leavesToKeep;
for (int l : leaves) {
int pos = timeline->getItemPosition(l);
//int checkedParent = timeline->m_groups->getDirectAncestor(l);
if (pos + timeline->getItemPlaytime(l) < position) {
/*if (checkedParent == r) {
leavesToRemove.insert(l);
} else {
int grandParent = timeline->m_groups->getDirectAncestor(checkedParent);
while (grandParent != r) {
checkedParent = grandParent;
grandParent = timeline->m_groups->getDirectAncestor(checkedParent);
if (allowGroupBreaking) {
int checkedParent = timeline->m_groups->getDirectAncestor(l);
if (pos + timeline->getItemPlaytime(l) < position) {
if (checkedParent == r) {
leavesToRemove.insert(l);
} else {
int grandParent = timeline->m_groups->getDirectAncestor(checkedParent);
while (grandParent != r) {
checkedParent = grandParent;
grandParent = timeline->m_groups->getDirectAncestor(checkedParent);
}
leavesToRemove.insert(checkedParent);
}
} else if (ignoreMultiTrackGroups && trackId > -1 && timeline->getItemTrackId(l) != trackId) {
if (checkedParent == r) {
leavesToRemove.insert(l);
} else {
int grandParent = timeline->m_groups->getDirectAncestor(checkedParent);
while (grandParent != r) {
checkedParent = grandParent;
grandParent = timeline->m_groups->getDirectAncestor(checkedParent);
}
leavesToRemove.insert(checkedParent);
}
leavesToRemove.insert(checkedParent);
}*/
} else if (ignoreMultiTrackGroups && trackId > -1 && timeline->getItemTrackId(l) != trackId) {
/*if (checkedParent == r) {
leavesToRemove.insert(l);
} else {
int grandParent = timeline->m_groups->getDirectAncestor(checkedParent);
while (grandParent != r) {
checkedParent = grandParent;
grandParent = timeline->m_groups->getDirectAncestor(checkedParent);
if (checkedParent == r) {
leavesToKeep.insert(l);
} else {
int grandParent = timeline->m_groups->getDirectAncestor(checkedParent);
while (grandParent != r) {
checkedParent = grandParent;
grandParent = timeline->m_groups->getDirectAncestor(checkedParent);
}
leavesToKeep.insert(checkedParent);
}
leavesToRemove.insert(checkedParent);
}
leavesToRemove.insert(l);
*/
} else {
/*if (checkedParent == r) {
leavesToKeep.insert(l);
} else {
int grandParent = timeline->m_groups->getDirectAncestor(checkedParent);
while (grandParent != r) {
checkedParent = grandParent;
grandParent = timeline->m_groups->getDirectAncestor(checkedParent);
}
leavesToKeep.insert(checkedParent);
}*/
}
if (!(pos + timeline->getItemPlaytime(l) < position || (ignoreMultiTrackGroups && trackId > -1 && timeline->getItemTrackId(l) != trackId))) {
int tid = timeline->getItemTrackId(l);
// Check space in all tracks
if (!firstPositions.contains(tid)) {
......@@ -389,7 +393,7 @@ int TimelineFunctions::requestSpacerStartOperation(const std::shared_ptr<Timelin
}
}
}
/*if (leavesToKeep.size() == 1) {
if (leavesToKeep.size() == 1) {
// Only 1 item left in group, group will be deleted
int master = *leavesToKeep.begin();
roots.insert(master);
......@@ -401,7 +405,7 @@ int TimelineFunctions::requestSpacerStartOperation(const std::shared_ptr<Timelin
for (int l : leavesToRemove) {
spacerUngroupedItems.insert(l, r);
}
}*/
}
} else {
int pos = timeline->getItemPosition(r);
int tid = timeline->getItemTrackId(r);
......@@ -419,7 +423,7 @@ int TimelineFunctions::requestSpacerStartOperation(const std::shared_ptr<Timelin
}
}
}
/*for (int r : groupsToRemove) {
for (int r : groupsToRemove) {
roots.erase(r);
}
......@@ -429,7 +433,7 @@ int TimelineFunctions::requestSpacerStartOperation(const std::shared_ptr<Timelin
while (i.hasNext()) {
i.next();
timeline->m_groups->ungroupItem(i.value(), undo, redo, false);
}*/
}
timeline->requestSetSelection(roots);
if (!firstPositions.isEmpty()) {
......
......@@ -71,7 +71,19 @@ struct TimelineFunctions
*/
static bool requestDeleteBlankAt(const std::shared_ptr<TimelineItemModel> &timeline, int trackId, int position, bool affectAllTracks);
static int requestSpacerStartOperation(const std::shared_ptr<TimelineItemModel> &timeline, int trackId, int position, bool ignoreMultiTrackGroups = false);
/** @brief Starts a spacer operation. Should be used together with requestSpacerEndOperation
@returns clipId of the position-wise first clip in the temporary group
@param timeline TimelineItemModel where the operation should be performed on
@param trackId
@param position
@param ignoreMultiTrackGroups
@param allowGroupBreaking Whether independant move of grouped items is allowed
@see requestSpacerEndOperation
*/
static int requestSpacerStartOperation(const std::shared_ptr<TimelineItemModel> &timeline, int trackId, int position, bool ignoreMultiTrackGroups = false, bool allowGroupBreaking = false);
/**
@see requestSpacerStartOperation
*/
static bool requestSpacerEndOperation(const std::shared_ptr<TimelineItemModel> &timeline, int itemId, int startPosition, int endPosition, int affectedTrack, bool moveGuides, Fun &undo, Fun &redo, bool pushUndo = true);
static bool extractZone(const std::shared_ptr<TimelineItemModel> &timeline, QVector<int> tracks, QPoint zone, bool liftOnly);
static bool liftZone(const std::shared_ptr<TimelineItemModel> &timeline, int trackId, QPoint zone, Fun &undo, Fun &redo);
......
......@@ -3691,7 +3691,7 @@ bool TimelineModel::requestItemRippleResize(const std::shared_ptr<TimelineItemMo
if (right && getTrackById_const(trackId)->isLastClip(getItemPosition(itemId))) {
return true;
}
int cid = TimelineFunctions::requestSpacerStartOperation(timeline, affectAllTracks ? -1 : trackId, position, true);
int cid = TimelineFunctions::requestSpacerStartOperation(timeline, affectAllTracks ? -1 : trackId, position, true, true);
if (cid == -1) {
return false;
}
......
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