]> git.sesse.net Git - nageru/commitdiff
Make duplicated rows show up after the old ones, and also give them new IDs.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 28 Dec 2018 19:22:24 +0000 (20:22 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Fri, 28 Dec 2018 19:22:24 +0000 (20:22 +0100)
futatabi/clip_list.cpp

index 7e554b08536d0d03820d7cfb05ba7bb20552542d..f76906f2a2b4f539a02506f2a01324e6c17b8836 100644 (file)
@@ -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<ClipWithID> 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();
 }