Fix various selection regressions

parent bcd22090
Pipeline #4242 passed with stage
in 14 minutes and 27 seconds
......@@ -86,9 +86,6 @@ template <typename Service> void MoveableItem<Service>::setCurrentTrackId(int ti
Q_UNUSED(finalMove);
QWriteLocker locker(&m_lock);
m_currentTrackId = tid;
if (tid == -1) {
selected = false;
}
}
template <typename Service> void MoveableItem<Service>::setInOut(int in, int out)
......
......@@ -569,7 +569,7 @@ bool TimelineFunctions::changeClipState(const std::shared_ptr<TimelineItemModel>
// For the state change to work, we need to unplant/replant the clip
bool result = true;
if (track > -1) {
result = timeline->getTrackById(track)->requestClipDeletion(clipId, true, invalidate, local_undo, local_redo);
result = timeline->getTrackById(track)->requestClipDeletion(clipId, true, invalidate, local_undo, local_redo, false, false);
}
result = timeline->m_allClips[clipId]->setClipState(status, local_undo, local_redo);
if (result && track > -1) {
......
......@@ -558,7 +558,7 @@ bool TimelineModel::requestClipMove(int clipId, int trackId, int position, bool
if (notifyViewOnly) {
PUSH_LAMBDA(update_model, local_undo);
}
ok = getTrackById(old_trackId)->requestClipDeletion(clipId, updateView, finalMove, local_undo, local_redo, groupMove);
ok = getTrackById(old_trackId)->requestClipDeletion(clipId, updateView, finalMove, local_undo, local_redo, groupMove, false);
if (!ok) {
bool undone = local_undo();
Q_ASSERT(undone);
......@@ -1123,7 +1123,7 @@ bool TimelineModel::requestClipDeletion(int clipId, Fun &undo, Fun &redo)
{
int trackId = getClipTrackId(clipId);
if (trackId != -1) {
bool res = getTrackById(trackId)->requestClipDeletion(clipId, true, true, undo, redo);
bool res = getTrackById(trackId)->requestClipDeletion(clipId, true, true, undo, redo, false, true);
if (!res) {
undo();
return false;
......@@ -1149,7 +1149,7 @@ bool TimelineModel::requestCompositionDeletion(int compositionId, Fun &undo, Fun
{
int trackId = getCompositionTrackId(compositionId);
if (trackId != -1) {
bool res = getTrackById(trackId)->requestCompositionDeletion(compositionId, true, true, undo, redo);
bool res = getTrackById(trackId)->requestCompositionDeletion(compositionId, true, true, undo, redo, true);
if (!res) {
undo();
return false;
......@@ -1406,7 +1406,6 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
std::unordered_map<int, int> old_track_ids, old_position, old_forced_track;
// First, remove clips
if (delta_track != 0) {
// We delete our clips only if changing track
for (int item : sorted_clips) {
......@@ -1415,7 +1414,7 @@ bool TimelineModel::requestGroupMove(int itemId, int groupId, int delta_track, i
if (old_trackId != -1) {
bool updateThisView = allowViewRefresh;
if (isClip(item)) {
ok = ok && getTrackById(old_trackId)->requestClipDeletion(item, updateThisView, finalMove, local_undo, local_redo, true);
ok = ok && getTrackById(old_trackId)->requestClipDeletion(item, updateThisView, finalMove, local_undo, local_redo, true, false);
old_position[item] = m_allClips[item]->getPosition();
} else {
// ok = ok && getTrackById(old_trackId)->requestCompositionDeletion(item, updateThisView, finalMove, local_undo, local_redo);
......@@ -2556,7 +2555,7 @@ bool TimelineModel::requestCompositionMove(int compoId, int trackId, int composi
PUSH_LAMBDA(update_model, local_undo);
}
UPDATE_UNDO_REDO(delete_operation, delete_reverse, local_undo, local_redo);
ok = getTrackById(old_trackId)->requestCompositionDeletion(compoId, updateView, finalMove, local_undo, local_redo);
ok = getTrackById(old_trackId)->requestCompositionDeletion(compoId, updateView, finalMove, local_undo, local_redo, false);
}
if (!ok) {
qDebug() << "Move failed because of first deletion request";
......@@ -2975,7 +2974,7 @@ void TimelineModel::requestClipReload(int clipId)
std::shared_ptr<ProjectClip> binClip = pCore->projectItemModel()->getClipByBinID(getClipBinId(clipId));
bool refreshView = oldOut > (int)binClip->frameDuration();
if (old_trackId != -1) {
getTrackById(old_trackId)->requestClipDeletion(clipId, refreshView, true, local_undo, local_redo);
getTrackById(old_trackId)->requestClipDeletion(clipId, refreshView, true, local_undo, local_redo, false, false);
}
if (old_trackId != -1) {
m_allClips[clipId]->refreshProducerFromBin();
......@@ -3013,7 +3012,7 @@ bool TimelineModel::requestClipTimeWarp(int clipId, double speed, Fun &undo, Fun
bool success = true;
int trackId = getClipTrackId(clipId);
if (trackId != -1) {
success = success && getTrackById(trackId)->requestClipDeletion(clipId, true, true, local_undo, local_redo);
success = success && getTrackById(trackId)->requestClipDeletion(clipId, true, true, local_undo, local_redo, false, false);
}
if (success) {
success = m_allClips[clipId]->useTimewarpProducer(speed, local_undo, local_redo);
......@@ -3147,7 +3146,7 @@ bool TimelineModel::requestClearSelection(bool onDeletion)
}
if (isGroup(m_currentSelection)) {
// Reset offset display on clips
std::unordered_set<int> items = getCurrentSelection();
std::unordered_set<int> items = m_groups->getLeaves(m_currentSelection);
for (auto &id : items) {
if (isGroup(id)) {
std::unordered_set<int> children = m_groups->getLeaves(id);
......@@ -3206,6 +3205,7 @@ std::unordered_set<int> TimelineModel::getCurrentSelection() const
return {m_currentSelection};
}
}
void TimelineModel::requestAddToSelection(int itemId, bool clear)
{
QWriteLocker locker(&m_lock);
......
......@@ -333,7 +333,7 @@ Fun TrackModel::requestClipDeletion_lambda(int clipId, bool updateView, bool fin
};
}
bool TrackModel::requestClipDeletion(int clipId, bool updateView, bool finalMove, Fun &undo, Fun &redo, bool groupMove)
bool TrackModel::requestClipDeletion(int clipId, bool updateView, bool finalMove, Fun &undo, Fun &redo, bool groupMove, bool finalDeletion)
{
QWriteLocker locker(&m_lock);
Q_ASSERT(m_allClips.count(clipId) > 0);
......@@ -343,6 +343,9 @@ bool TrackModel::requestClipDeletion(int clipId, bool updateView, bool finalMove
auto old_clip = m_allClips[clipId];
int old_position = old_clip->getPosition();
// qDebug() << "/// REQUESTOING CLIP DELETION_: " << updateView;
if (finalDeletion) {
m_allClips[clipId]->selected = false;
}
auto operation = requestClipDeletion_lambda(clipId, updateView, finalMove, groupMove);
if (operation()) {
auto reverse = requestClipInsertion_lambda(clipId, old_position, updateView, finalMove, groupMove);
......@@ -1038,7 +1041,7 @@ bool TrackModel::requestCompositionInsertion(int compoId, int position, bool upd
return false;
}
bool TrackModel::requestCompositionDeletion(int compoId, bool updateView, bool finalMove, Fun &undo, Fun &redo)
bool TrackModel::requestCompositionDeletion(int compoId, bool updateView, bool finalMove, Fun &undo, Fun &redo, bool finalDeletion)
{
QWriteLocker locker(&m_lock);
if (isLocked()) {
......@@ -1049,6 +1052,9 @@ bool TrackModel::requestCompositionDeletion(int compoId, bool updateView, bool f
int old_position = old_composition->getPosition();
Q_ASSERT(m_compoPos.count(old_position) > 0);
Q_ASSERT(m_compoPos[old_position] == compoId);
if (finalDeletion) {
m_allCompositions[compoId]->selected = false;
}
auto operation = requestCompositionDeletion_lambda(compoId, updateView, finalMove);
if (operation()) {
auto reverse = requestCompositionInsertion_lambda(compoId, old_position, updateView, finalMove);
......
......@@ -149,10 +149,12 @@ protected:
@param finalMove if the move is finished (not while dragging), so we invalidate timeline preview / check project duration
@param undo Lambda function containing the current undo stack. Will be updated with current operation
@param redo Lambda function containing the current redo queue. Will be updated with current operation
@param groupMove If true, this is part of a larger operation and some operations like checking track duration will not be performed and have to be performed separately
@param finalDeletion If true, the clip will be deselected (should be false if this is a clip move doing delte/insert)
*/
bool requestClipDeletion(int clipId, bool updateView, bool finalMove, Fun &undo, Fun &redo, bool groupMove = false);
bool requestClipDeletion(int clipId, bool updateView, bool finalMove, Fun &undo, Fun &redo, bool groupMove, bool finalDeletion);
/* @brief This function returns a lambda that performs the requested operation */
Fun requestClipDeletion_lambda(int clipId, bool updateView, bool finalMove, bool groupMove = false);
Fun requestClipDeletion_lambda(int clipId, bool updateView, bool finalMove, bool groupMove);
/* @brief Performs an insertion of the given composition.
Returns true if the operation succeeded, and otherwise, the track is not modified.
......@@ -168,7 +170,7 @@ protected:
/* @brief This function returns a lambda that performs the requested operation */
Fun requestCompositionInsertion_lambda(int compoId, int position, bool updateView, bool finalMove = false);
bool requestCompositionDeletion(int compoId, bool updateView, bool finalMove, Fun &undo, Fun &redo);
bool requestCompositionDeletion(int compoId, bool updateView, bool finalMove, Fun &undo, Fun &redo, bool finalDeletion);
Fun requestCompositionDeletion_lambda(int compoId, bool updateView, bool finalMove = false);
Fun requestCompositionResize_lambda(int compoId, int in, int out = -1, bool logUndo = false);
......
......@@ -191,7 +191,7 @@ Item {
anchors.topMargin: displayHeight * 1.2
height: displayHeight * 1.3
color: selected ? 'mediumpurple' : Qt.darker('mediumpurple')
border.color: selected ? activePalette.highlight : grouped ? root.groupColor : borderColor
border.color: selected ? root.selectionColor : grouped ? root.groupColor : borderColor
border.width: isGrabbed ? 8 : 1.5
opacity: dragProxyArea.drag.active && dragProxy.draggedItem == clipId ? 0.5 : 1.0
Item {
......
......@@ -2189,7 +2189,7 @@ bool TimelineController::endFakeMove(int clipId, int position, bool updateView,
int currentTrack = m_model->m_allClips[clipId]->getCurrentTrackId();
bool res = true;
if (currentTrack > -1) {
res = res && m_model->getTrackById(currentTrack)->requestClipDeletion(clipId, updateView, invalidateTimeline, undo, redo);
res = res && m_model->getTrackById(currentTrack)->requestClipDeletion(clipId, updateView, invalidateTimeline, undo, redo, false, false);
}
if (m_model->m_editMode == TimelineMode::OverwriteEdit) {
res = res && TimelineFunctions::liftZone(m_model, trackId, QPoint(position, position + duration), undo, redo);
......@@ -2274,7 +2274,7 @@ bool TimelineController::endFakeGroupMove(int clipId, int groupId, int delta_tra
int duration = m_model->m_allClips[item]->getPlaytime();
min = min < 0 ? old_position[item] + delta_pos : qMin(min, old_position[item] + delta_pos);
max = max < 0 ? old_position[item] + delta_pos + duration : qMax(max, old_position[item] + delta_pos + duration);
ok = ok && m_model->getTrackById(old_trackId)->requestClipDeletion(item, updateThisView, finalMove, undo, redo);
ok = ok && m_model->getTrackById(old_trackId)->requestClipDeletion(item, updateThisView, finalMove, undo, redo, false, false);
} else {
// ok = ok && getTrackById(old_trackId)->requestCompositionDeletion(item, updateThisView, local_undo, local_redo);
old_position[item] = m_model->m_allCompositions[item]->getPosition();
......
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