From 35fa8cce99a5d224609bde5bef15d13367506804 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 28 Dec 2018 20:22:24 +0100 Subject: [PATCH] Make duplicated rows show up after the old ones, and also give them new IDs. --- futatabi/clip_list.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/futatabi/clip_list.cpp b/futatabi/clip_list.cpp index 7e554b0..f76906f 100644 --- a/futatabi/clip_list.cpp +++ b/futatabi/clip_list.cpp @@ -379,8 +379,13 @@ void PlayList::add_clip(const Clip &clip) void PlayList::duplicate_clips(size_t first, size_t last) { - beginInsertRows(QModelIndex(), first, last); - clips.insert(clips.begin() + first, clips.begin() + first, clips.begin() + last + 1); + beginInsertRows(QModelIndex(), last + 1, last + 1 + (last - first)); + + vector new_clips; + for (auto it = clips.begin() + first; it <= clips.begin() + last; ++it) { + new_clips.emplace_back(ClipWithID{ it->clip, clip_counter++ }); // Give them new IDs. + } + clips.insert(clips.begin() + last + 1, new_clips.begin(), new_clips.end()); // Note: The new elements are inserted after the old ones. endInsertRows(); emit any_content_changed(); } -- 2.39.2