Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 1510447c authored by Nicolas Carion's avatar Nicolas Carion

[Timeline2][Model] Forbid grouping of uninserted clips

parent e95a2d4a
......@@ -425,8 +425,17 @@ bool TimelineModel::requestClipTrim(int cid, int delta, bool right, bool ripple,
bool TimelineModel::requestClipsGroup(const std::unordered_set<int>& ids)
{
std::function<bool (void)> undo = [](){return true;};
std::function<bool (void)> redo = [](){return true;};
for (int id : ids) {
if (isClip(id)) {
if (getClipTrackId(id) == -1) {
return false;
}
} else if (!isGroup(id)) {
return false;
}
}
Fun undo = [](){return true;};
Fun redo = [](){return true;};
int gid = m_groups->groupItems(ids, undo, redo);
if (gid != -1) {
PUSH_UNDO(undo, redo, i18n("Group clips"));
......
......@@ -193,6 +193,7 @@ public:
bool requestClipTrim(int cid, int delta, bool right, bool ripple = false, bool test_only = false);
/* @brief Group together a set of ids
The ids are either a group ids or clip ids. The involved clip must already be inserted in a track
This action is undoable
Returns true on success. If it fails, nothing is modified.
Typically, ids would be ids of clips, but for convenience, some of them can be ids of groups as well.
......
......@@ -387,6 +387,7 @@ TEST_CASE("Undo/redo", "[GroupsModel]")
for (int i = 0; i < 4; i++) {
clips.push_back(ClipModel::construct(timeline, producer));
}
int tid1 = TrackModel::construct(timeline);
int init_index = undoStack->index();
SECTION("Basic Creation") {
......@@ -398,6 +399,13 @@ TEST_CASE("Undo/redo", "[GroupsModel]")
};
auto g1 = std::unordered_set<int>({clips[0],clips[1]});
int gid1, gid2, gid3;
//this fails because clips are not inserted
REQUIRE_FALSE(timeline->requestClipsGroup(g1));
for (int i = 0; i < 4; i++) {
REQUIRE(timeline->requestClipMove(clips[i], tid1, i*length));
}
init_index = undoStack->index();
REQUIRE(timeline->requestClipsGroup(g1));
auto state1 = [&](){
gid1 = timeline->m_groups->getRootId(clips[0]);
......
......@@ -531,7 +531,8 @@ TEST_CASE("Clip manipulation", "[ClipModel]")
state();
//grouping
REQUIRE(timeline->requestClipsGroup({cid1, cid3, cid4}));
REQUIRE(timeline->requestClipsGroup({cid1, cid3}));
REQUIRE(timeline->requestClipsGroup({cid1, cid4}));
//move left is now forbidden, because clip1 is at position 0
REQUIRE_FALSE(timeline->requestClipMove(cid3, tid1, 2*length + 3));
......
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