From f15bac92efd0a08eb048e8d683c03409c9a033d4 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Fri, 13 Apr 2012 19:25:18 +0200 Subject: [PATCH] Fix transition track lost, first steps for drag & drop in empty effect stack zone --- src/effectstack/collapsibleeffect.cpp | 5 +++ src/effectstack/collapsibleeffect.h | 1 + src/effectstack/effectstackview2.cpp | 53 +++++++++++++++++++++++++++ src/effectstack/effectstackview2.h | 2 + src/effectstackedit.cpp | 15 +------- src/effectstackedit.h | 4 -- 6 files changed, 62 insertions(+), 18 deletions(-) diff --git a/src/effectstack/collapsibleeffect.cpp b/src/effectstack/collapsibleeffect.cpp index 0bf2bb2e..e8d1d827 100644 --- a/src/effectstack/collapsibleeffect.cpp +++ b/src/effectstack/collapsibleeffect.cpp @@ -1334,6 +1334,11 @@ QString ParameterContainer::getWipeString(wipeInfo info) return QString(start + ";-1=" + end); } +void ParameterContainer::updateParameter(const QString &key, const QString &value) +{ + m_effect.setAttribute(key, value); +} + void ParameterContainer::slotStartFilterJobAction() { QDomNodeList namenode = m_effect.elementsByTagName("parameter"); diff --git a/src/effectstack/collapsibleeffect.h b/src/effectstack/collapsibleeffect.h index 07132f1a..35bafcc5 100644 --- a/src/effectstack/collapsibleeffect.h +++ b/src/effectstack/collapsibleeffect.h @@ -73,6 +73,7 @@ public: ~ParameterContainer(); void updateTimecodeFormat(); void updateProjectFormat(MltVideoProfile profile, Timecode t); + void updateParameter(const QString &key, const QString &value); private slots: void slotCollectAllParameters(); diff --git a/src/effectstack/effectstackview2.cpp b/src/effectstack/effectstackview2.cpp index 27f77f42..22b9f91c 100644 --- a/src/effectstack/effectstackview2.cpp +++ b/src/effectstack/effectstackview2.cpp @@ -54,6 +54,7 @@ EffectStackView2::EffectStackView2(Monitor *monitor, QWidget *parent) : m_effectMetaInfo.trackMode = false; m_effectMetaInfo.monitor = monitor; m_effects = QList (); + setAcceptDrops(true); m_ui.setupUi(this); setFont(KGlobalSettings::smallestReadableFont()); @@ -788,4 +789,56 @@ void EffectStackView2::slotRenameGroup(CollapsibleGroup *group) } } +void EffectStackView2::dragEnterEvent(QDragEnterEvent *event) +{ + if (event->mimeData()->hasFormat("kdenlive/effectslist")) { + event->acceptProposedAction(); + } +} + +void EffectStackView2::dropEvent(QDropEvent *event) +{ + const QString effects = QString::fromUtf8(event->mimeData()->data("kdenlive/effectslist")); + //event->acceptProposedAction(); + QDomDocument doc; + doc.setContent(effects, true); + QDomElement e = doc.documentElement(); + int ix = e.attribute("kdenlive_ix").toInt(); + if (e.tagName() == "effectgroup") { + // We are dropping a group, all effects in group should be moved + QDomNodeList effects = e.elementsByTagName("effect"); + if (effects.count() == 0) { + event->ignore(); + return; + } + EffectInfo info; + info.fromString(effects.at(0).toElement().attribute("kdenlive_info")); + if (info.groupIndex < 0) { + // Adding a new group effect to the stack + event->setDropAction(Qt::CopyAction); + event->accept(); + slotAddEffect(e); + return; + } + for (int i = 0; i < effects.count(); i++) { + //TODO: not working because wee need to move all effects in one go + slotMoveEffect(effects.at(i).toElement().attribute("kdenlive_ix").toInt(), m_currentEffectList.count() + 1 + i, info.groupIndex, info.groupName); + } + } + else if (ix == 0) { + // effect dropped from effects list, add it + e.setAttribute("kdenlive_ix", m_currentEffectList.count() + 1); + event->setDropAction(Qt::CopyAction); + event->accept(); + slotAddEffect(e); + return; + } + else { + // User is moving an effect + slotMoveEffect(ix, m_currentEffectList.count() + 1, -1); + } + event->setDropAction(Qt::MoveAction); + event->accept(); +} + #include "effectstackview2.moc" diff --git a/src/effectstack/effectstackview2.h b/src/effectstack/effectstackview2.h index 2a1da032..25177727 100644 --- a/src/effectstack/effectstackview2.h +++ b/src/effectstack/effectstackview2.h @@ -74,6 +74,8 @@ protected: virtual void mouseMoveEvent(QMouseEvent * event); virtual void mouseReleaseEvent(QMouseEvent * event); virtual void resizeEvent ( QResizeEvent * event ); + virtual void dragEnterEvent(QDragEnterEvent *event); + virtual void dropEvent(QDropEvent *event); private: Ui::EffectStack2_UI m_ui; diff --git a/src/effectstackedit.cpp b/src/effectstackedit.cpp index 8ec639f4..85a526f1 100644 --- a/src/effectstackedit.cpp +++ b/src/effectstackedit.cpp @@ -174,7 +174,7 @@ void EffectStackEdit::meetDependency(const QString& name, QString type, QString void EffectStackEdit::updateParameter(const QString &name, const QString &value) { - m_params.setAttribute(name, value); + m_paramWidget->updateParameter(name, value); if (name == "disable") { // if effect is disabled, disable parameters widget @@ -855,18 +855,5 @@ void EffectStackEdit::slotSyncEffectsPos(int pos) emit syncEffectsPos(pos); } -void EffectStackEdit::slotStartFilterJobAction() -{ - QDomNodeList namenode = m_params.elementsByTagName("parameter"); - for (int i = 0; i < namenode.count() ; i++) { - QDomElement pa = namenode.item(i).toElement(); - QString type = pa.attribute("type"); - if (type == "filterjob") { - emit startFilterJob(pa.attribute("filtertag"), pa.attribute("filterparams"), pa.attribute("finalfilter"), pa.attribute("consumer"), pa.attribute("consumerparams"), pa.attribute("wantedproperties")); - kDebug()<<" - - -PROPS:\n"< m_uiItems; - QDomElement m_params; QMap m_valueItems; int m_in; int m_out; @@ -88,9 +87,6 @@ public slots: /** @brief Pass position changes of the timeline cursor to the effects to keep their local timelines in sync. */ void slotSyncEffectsPos(int pos); - -private slots: - void slotStartFilterJobAction(); signals: void parameterChanged(const QDomElement, const QDomElement, int); -- 2.39.5