From: Steinar H. Gunderson Date: Fri, 28 Dec 2018 19:22:24 +0000 (+0100) Subject: Make duplicated rows show up after the old ones, and also give them new IDs. X-Git-Tag: 1.8.1~11 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=35fa8cce99a5d224609bde5bef15d13367506804 Make duplicated rows show up after the old ones, and also give them new IDs. --- 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(); }