Start fixing tests

parent 48667806
......@@ -33,6 +33,7 @@ CompositionModel::CompositionModel(std::weak_ptr<TimelineModel> parent, Mlt::Tra
: MoveableItem<Mlt::Transition>(std::move(parent), id)
, AssetParameterModel(transition, transitionXml, transitionId, {ObjectType::TimelineComposition, m_id})
, a_track(-1)
, m_duration(0)
{
m_compositionName = TransitionsRepository::get()->getName(transitionId);
}
......@@ -74,9 +75,9 @@ bool CompositionModel::requestResize(int size, bool right, Fun &undo, Fun &redo,
return false;
}
int delta = getPlaytime() - size;
qDebug() << "compo request resize " << size << right << delta;
qDebug() << "compo request resize to " << size <<", ACTUAL SZ: "<<getPlaytime()<<", "<< right << delta;
int in = getIn();
int out = getOut();
int out = in + getPlaytime() - 1;
int oldDuration = out - in;
int old_in = in, old_out = out;
if (right) {
......@@ -99,6 +100,9 @@ bool CompositionModel::requestResize(int size, bool right, Fun &undo, Fun &redo,
qDebug() << "Error : Moving composition failed because parent timeline is not available anymore";
Q_ASSERT(false);
}
} else {
// Perform resize only
setInOut(in, out);
}
Fun operation = [in, out, track_operation, this]() {
if (track_operation()) {
......@@ -114,10 +118,10 @@ bool CompositionModel::requestResize(int size, bool right, Fun &undo, Fun &redo,
if (!right) {
roles.push_back(TimelineModel::StartRole);
}
QModelIndex ix = ptr->makeCompositionIndexFromID(m_id);
//TODO: integrate in undo
ptr->dataChanged(ix, ix, roles);
if (m_currentTrackId != -1 && ptr) {
QModelIndex ix = ptr->makeCompositionIndexFromID(m_id);
//TODO: integrate in undo
ptr->dataChanged(ix, ix, roles);
track_reverse = ptr->getTrackById(m_currentTrackId)->requestCompositionResize_lambda(m_id, old_in, old_out);
}
Fun reverse = [old_in, old_out, track_reverse, this]() {
......@@ -165,7 +169,7 @@ Mlt::Properties *CompositionModel::properties()
int CompositionModel::getPlaytime() const
{
READ_LOCK();
return getOut() - getIn() + 1;
return m_duration + 1;
}
int CompositionModel::getATrack() const
......@@ -226,6 +230,22 @@ const QString &CompositionModel::displayName() const
void CompositionModel::setInOut(int in, int out)
{
m_position = in;
MoveableItem::setInOut(in, out);
m_duration = out - in;
setPosition(in);
}
void CompositionModel::setCurrentTrackId(int tid)
{
MoveableItem::setCurrentTrackId(tid);
}
int CompositionModel::getOut() const
{
return getPosition() + m_duration;
}
int CompositionModel::getIn() const
{
return getPosition();
}
......@@ -94,6 +94,9 @@ public:
protected:
Mlt::Transition *service() const override;
void setInOut(int in, int out) override;
void setCurrentTrackId(int tid) override;
virtual int getOut() const override;
virtual int getIn() const override;
/* @brief Performs a resize of the given composition.
Returns true if the operation succeeded, and otherwise nothing is modified
......@@ -109,6 +112,7 @@ protected:
private:
int a_track;
QString m_compositionName;
int m_duration;
};
#endif
......@@ -60,8 +60,8 @@ public:
/* @brief returns the in and out times of the item
*/
std::pair<int, int> getInOut() const;
int getIn() const;
int getOut() const;
virtual int getIn() const;
virtual int getOut() const;
friend class TrackModel;
friend class TimelineModel;
......@@ -106,7 +106,7 @@ protected:
If you whish to actually change the track the item, use the slot in the timeline
slot.
*/
void setCurrentTrackId(int tid);
virtual void setCurrentTrackId(int tid);
/* Set in and out of service */
virtual void setInOut(int in, int out);
......
......@@ -1176,7 +1176,6 @@ int TimelineModel::requestItemResize(int itemId, int size, bool right, bool logU
// only test move if proposed_size is valid
bool success = false;
if (isClip(itemId)) {
qDebug() << "+++MODEL REQUEST RESIZE (LOGUNDO) " << logUndo << ", SIZE: " << proposed_size;
success = m_allClips[itemId]->requestResize(proposed_size, right, temp_undo, temp_redo, false);
} else {
success = m_allCompositions[itemId]->requestResize(proposed_size, right, temp_undo, temp_redo, false);
......@@ -2121,10 +2120,27 @@ bool TimelineModel::checkConsistency()
snaps[clip->getPosition() + clip->getPlaytime()] += 1;
}
}
for (const auto &cp : m_allCompositions) {
auto clip = (cp.second);
// Check parent/children link for tracks
if (auto ptr = clip->m_parent.lock()) {
if (ptr.get() != this) {
qDebug() << "Wrong parent for compo" << cp.first;
return false;
}
} else {
qDebug() << "NULL parent for compo" << cp.first;
return false;
}
if (getCompositionTrackId(cp.first) != -1) {
snaps[clip->getPosition()] += 1;
snaps[clip->getPosition() + clip->getPlaytime()] += 1;
}
}
// Check snaps
auto stored_snaps = m_snaps->_snaps();
if (snaps.size() != stored_snaps.size()) {
qDebug() << "Wrong number of snaps";
qDebug() << "Wrong number of snaps: "<<snaps.size()<<" == "<<stored_snaps.size();
return false;
}
for (auto i = snaps.begin(), j = stored_snaps.begin(); i != snaps.end(); ++i, ++j) {
......@@ -2196,7 +2212,7 @@ bool TimelineModel::checkConsistency()
// we iterate to try to find a matching compo
for (int compoId : remaining_compo) {
if (getTrackMltIndex(getCompositionTrackId(compoId)) == currentTrack &&
getTrackMltIndex(m_allCompositions[compoId]->getATrack()) == currentATrack && m_allCompositions[compoId]->getIn() == currentIn &&
m_allCompositions[compoId]->getATrack() == currentATrack && m_allCompositions[compoId]->getIn() == currentIn &&
m_allCompositions[compoId]->getOut() == currentOut) {
foundId = compoId;
break;
......@@ -2230,6 +2246,7 @@ bool TimelineModel::checkConsistency()
// We check consistency of groups
if (!m_groups->checkConsistency(true, true)) {
qDebug()<<"== ERROR IN GROUP CONSISTENCY";
return false;
}
return true;
......
......@@ -850,7 +850,7 @@ Fun TrackModel::requestCompositionResize_lambda(int compoId, int in, int out)
Q_ASSERT(m_compoPos.count(compo_position) > 0);
Q_ASSERT(m_compoPos[compo_position] == compoId);
int old_in = compo_position;
int old_out = old_in + m_allCompositions[compoId]->getPlaytime();
int old_out = old_in + m_allCompositions[compoId]->getPlaytime() - 1;
qDebug() << "compo resize " << compoId << in << "-" << out << " / " << old_in << "-" << old_out;
if (out == -1) {
out = in + old_out - old_in;
......@@ -859,7 +859,7 @@ Fun TrackModel::requestCompositionResize_lambda(int compoId, int in, int out)
auto update_snaps = [compoId, old_in, old_out, this](int new_in, int new_out) {
if (auto ptr = m_parent.lock()) {
ptr->m_snaps->removePoint(old_in);
ptr->m_snaps->removePoint(old_out);
ptr->m_snaps->removePoint(old_out + 1);
ptr->m_snaps->addPoint(new_in);
ptr->m_snaps->addPoint(new_out);
ptr->checkRefresh(old_in, old_out);
......@@ -872,17 +872,22 @@ Fun TrackModel::requestCompositionResize_lambda(int compoId, int in, int out)
};
if (in == compo_position && (out == -1 || out == old_out)) {
return []() { return true; };
return []() {
qDebug()<<"//// NO MOVE PERFORMES\n!!!!!!!!!!!!!!!!!!!!!!!!!!";
return true; };
}
// temporary remove of current compo to check collisions
qDebug()<<"// CURRENT COMPOSITIONS ----\n"<<m_compoPos<<"\n--------------";
m_compoPos.erase(compo_position);
bool intersecting = hasIntersectingComposition(in, out);
// put it back
m_compoPos[compo_position] = compoId;
if (intersecting) {
return []() { return false; };
return []() {
qDebug()<<"//// FALSE MOVE PERFORMES\n!!!!!!!!!!!!!!!!!!!!!!!!!!";
return false; };
}
return [in, out, compoId, update_snaps, this]() {
......
This diff is collapsed.
......@@ -32,7 +32,8 @@ TEST_CASE("Effects stack", "[Effects]")
QVector<QPair<QString, QString>> effects = EffectsRepository::get()->getNames();
REQUIRE(!effects.isEmpty());
anEffect = effects.first().first;
anEffect = "qtblend";//effects.first().first;
//qDebug()<<"// APPENDING EFFECT: "<<anEffect;
REQUIRE(!anEffect.isEmpty());
......
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