Commit b2c4af4c authored by Nicolas Carion's avatar Nicolas Carion

Fix moving keyframes + tests

parent 8db25d94
......@@ -101,7 +101,6 @@ template <typename AssetType> void AbstractAssetsRepository<AssetType>::init()
template <typename AssetType> void AbstractAssetsRepository<AssetType>::parseBlackList(const QString &path)
{
qDebug() << "BLACKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK"<<path;
QFile blacklist_file(path);
if (blacklist_file.open(QIODevice::ReadOnly)) {
QTextStream stream(&blacklist_file);
......
......@@ -143,6 +143,7 @@ bool KeyframeModel::moveKeyframe(GenTime oldPos, GenTime pos, Fun &undo, Fun &re
KeyframeType oldType = m_keyframeList[oldPos].first;
double oldValue = m_keyframeList[oldPos].second;
if (oldPos == pos ) return true;
if ( hasKeyframe(pos) ) return false;
Fun local_undo = []() { return true; };
Fun local_redo = []() { return true; };
qDebug() << getAnimProperty();
......
......@@ -53,7 +53,6 @@ AssetParameterModel::AssetParameterModel(Mlt::Properties *asset, const QDomEleme
}
qDebug() << "XML parsing of " << assetId << ". found : " << nodeList.count();
qDebug() << assetXml.text();
for (int i = 0; i < nodeList.count(); ++i) {
QDomElement currentParameter = nodeList.item(i).toElement();
......
......@@ -515,6 +515,7 @@ std::shared_ptr<ProjectItemModel> Core::projectItemModel()
void Core::invalidateItem(ObjectId itemId)
{
if (!m_mainWindow) return;
switch (itemId.first) {
case ObjectType::TimelineClip:
m_mainWindow->getCurrentTimeline()->controller()->invalidateClip(itemId.second);
......
......@@ -161,4 +161,58 @@ TEST_CASE("Keyframe model", "[KeyframeModel]")
undoStack->undo(); state3();
undoStack->redo(); state0();
}
SECTION("Move keyframes + undo")
{
auto state0 = [&]() {
REQUIRE(model->rowCount() == 1);
REQUIRE(check_anim_identity(model));
};
state0();
REQUIRE(model->addKeyframe(GenTime(1.1), KeyframeType::Linear, 42));
auto state1 = [&](double pos) {
REQUIRE(model->rowCount() == 2);
REQUIRE(check_anim_identity(model));
REQUIRE(model->hasKeyframe(GenTime(pos)));
bool ok;
auto k = model->getKeyframe(GenTime(pos), &ok);
REQUIRE(ok);
auto k0 = model->getKeyframe(GenTime(0), &ok);
REQUIRE(ok);
auto k1 = model->getClosestKeyframe(GenTime(pos + 10), &ok);
REQUIRE(ok);
REQUIRE(k == k1);
auto k2 = model->getNextKeyframe(GenTime(pos - 0.3), &ok);
REQUIRE(ok);
REQUIRE(k == k2);
auto k3 = model->getPrevKeyframe(GenTime(pos - 0.3), &ok);
REQUIRE(ok);
REQUIRE(k3 == k0);
auto k4 = model->getPrevKeyframe(GenTime(pos + 0.3), &ok);
REQUIRE(ok);
REQUIRE(k == k4);
model->getNextKeyframe(GenTime(pos + 0.3), &ok);
REQUIRE_FALSE(ok);
};
state1(1.1);
REQUIRE(model->moveKeyframe(GenTime(1.1), GenTime(2.6), true));
state1(2.6);
undoStack->undo(); state1(1.1);
undoStack->redo(); state1(2.6);
REQUIRE(model->moveKeyframe(GenTime(2.6), GenTime(6.1), true));
state1(6.1);
undoStack->undo(); state1(2.6);
undoStack->undo(); state1(1.1);
undoStack->redo(); state1(2.6);
undoStack->redo(); state1(6.1);
REQUIRE(model->addKeyframe(GenTime(12.6), KeyframeType::Discrete, 33));
REQUIRE_FALSE(model->moveKeyframe(GenTime(6.1), GenTime(12.6), true));
undoStack->undo(); state1(6.1);
}
}
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