m_limitedKeyFrames(false)
{
setZValue(2);
+ m_effectList = EffectsList(true);
FRAME_SIZE = frame_width;
setRect(0, 0, (info.endPos - info.startPos).frames(fps) - 0.02, (double) itemHeight());
setPos(info.startPos.frames(fps), (double)(info.track * KdenliveSettings::trackheight()) + 1 + itemOffset());
m_effectNames = m_effectList.effectNames().join(" / ");
if (!m_effectList.isEmpty()) {
for (int i = 0; i < m_effectList.count(); i++) {
- QString effectId = m_effectList.item(i).attribute("id");
+ QDomElement effect = m_effectList.itemFromIndex(i + 1);
+ QString effectId = effect.attribute("id");
// check if it is a fade effect
- QDomNodeList params = m_effectList.item(i).elementsByTagName("parameter");
+ QDomNodeList params = effect.elementsByTagName("parameter");
int fade = 0;
for (int j = 0; j < params.count(); j++) {
QDomElement e = params.item(j).toElement();
QDomElement ClipItem::effectAt(int ix) const
{
- if (ix > m_effectList.count() - 1 || ix < 0 || m_effectList.at(ix).isNull()) return QDomElement();
- return m_effectList.at(ix).cloneNode().toElement();
+ if (ix > m_effectList.count() || ix <= 0) return QDomElement();
+ return m_effectList.itemFromIndex(ix).cloneNode().toElement();
}
QDomElement ClipItem::getEffectAt(int ix) const
{
- if (ix > m_effectList.count() - 1 || ix < 0 || m_effectList.at(ix).isNull()) return QDomElement();
- return m_effectList.at(ix);
+ if (ix > m_effectList.count() || ix < 0) return QDomElement();
+ return m_effectList.itemFromIndex(ix);
}
-bool ClipItem::setEffectAt(int ix, QDomElement effect)
+bool ClipItem::updateEffect(QDomElement effect)
+{
+ //kDebug() << "CHange EFFECT AT: " << ix << ", CURR: " << m_effectList.at(ix).attribute("tag") << ", NEW: " << effect.attribute("tag");
+ m_effectList.updateEffect(effect);
+ m_effectNames = m_effectList.effectNames().join(" / ");
+ QString id = effect.attribute("id");
+ if (id == "fadein" || id == "fadeout" || id == "fade_from_black" || id == "fade_to_black")
+ update();
+ else {
+ QRectF r = boundingRect();
+ r.setHeight(20);
+ update(r);
+ }
+ return true;
+}
+
+bool ClipItem::moveEffect(QDomElement effect, int ix)
{
if (ix < 0 || ix > (m_effectList.count() - 1) || effect.isNull()) {
kDebug() << "Invalid effect index: " << ix;
return false;
}
- //kDebug() << "CHange EFFECT AT: " << ix << ", CURR: " << m_effectList.at(ix).attribute("tag") << ", NEW: " << effect.attribute("tag");
- effect.setAttribute("kdenlive_ix", ix + 1);
- m_effectList.replace(ix, effect);
+ m_effectList.removeAt(effect.attribute("kdenlive_ix").toInt());
+ effect.setAttribute("kdenlive_ix", ix);
+ m_effectList.insert(effect);
m_effectNames = m_effectList.effectNames().join(" / ");
QString id = effect.attribute("id");
if (id == "fadein" || id == "fadeout" || id == "fade_from_black" || id == "fade_to_black")
} else ix = effect.attribute("kdenlive_ix").toInt();
if (!m_effectList.isEmpty() && ix <= m_effectList.count()) {
needRepaint = true;
- m_effectList.insert(ix - 1, effect);
- for (int i = ix; i < m_effectList.count(); i++) {
- int index = m_effectList.item(i).attribute("kdenlive_ix").toInt();
- if (index >= ix) m_effectList.item(i).setAttribute("kdenlive_ix", index + 1);
- }
+ m_effectList.insert(effect);
} else m_effectList.append(effect);
EffectsParameterList parameters;
parameters.addParam("tag", effect.attribute("tag"));
void ClipItem::deleteEffect(QString index)
{
bool needRepaint = false;
- QString ix;
-
- for (int i = 0; i < m_effectList.count(); ++i) {
- ix = m_effectList.at(i).attribute("kdenlive_ix");
- if (ix == index) {
- QString effectId = m_effectList.at(i).attribute("id");
- if ((effectId == "fadein" && hasEffect(QString(), "fade_from_black") == -1) ||
- (effectId == "fade_from_black" && hasEffect(QString(), "fadein") == -1)) {
- m_startFade = 0;
- needRepaint = true;
- } else if ((effectId == "fadeout" && hasEffect(QString(), "fade_to_black") == -1) ||
- (effectId == "fade_to_black" && hasEffect(QString(), "fadeout") == -1)) {
- m_endFade = 0;
- needRepaint = true;
- } else if (EffectsList::hasKeyFrames(m_effectList.at(i))) needRepaint = true;
- m_effectList.removeAt(i);
- i--;
- } else if (ix.toInt() > index.toInt()) {
- m_effectList.item(i).setAttribute("kdenlive_ix", ix.toInt() - 1);
- }
- }
+ int ix = index.toInt();
+
+ QDomElement effect = m_effectList.itemFromIndex(ix);
+ QString effectId = effect.attribute("id");
+ if ((effectId == "fadein" && hasEffect(QString(), "fade_from_black") == -1) ||
+ (effectId == "fade_from_black" && hasEffect(QString(), "fadein") == -1)) {
+ m_startFade = 0;
+ needRepaint = true;
+ } else if ((effectId == "fadeout" && hasEffect(QString(), "fade_to_black") == -1) ||
+ (effectId == "fade_to_black" && hasEffect(QString(), "fadeout") == -1)) {
+ m_endFade = 0;
+ needRepaint = true;
+ } else if (EffectsList::hasKeyFrames(effect)) needRepaint = true;
+ m_effectList.removeAt(ix);
m_effectNames = m_effectList.effectNames().join(" / ");
- if (m_effectList.isEmpty() || m_selectedEffect + 1 == index.toInt()) {
+ if (m_effectList.isEmpty() || m_selectedEffect + 1 == ix) {
// Current effect was removed
- if (index.toInt() > m_effectList.count() - 1) {
+ if (ix > m_effectList.count() - 1) {
setSelectedEffect(m_effectList.count() - 1);
- } else setSelectedEffect(index.toInt());
+ } else setSelectedEffect(ix);
}
if (needRepaint) update(boundingRect());
else {
/** @brief Replaces an effect.
* @param ix The effect's index in effectlist
* @param effect The new effect */
- bool setEffectAt(int ix, QDomElement effect);
+ bool updateEffect(QDomElement effect);
+ bool moveEffect(QDomElement effect, int ix);
void flashClip();
void addTransition(Transition*);
if (effect.attribute("id") == "freeze" && m_cursorPos > item->startPos().frames(m_document->fps()) && m_cursorPos < item->endPos().frames(m_document->fps())) {
item->initEffect(effect, m_cursorPos - item->startPos().frames(m_document->fps()));
} else {
+ kDebug()<<"PREIT 0: "<<effect.attribute("kdenlive_ix");
item->initEffect(effect);
}
new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), effect, true, effectCommand);
if (strobe == 0) strobe = 1;
doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), speed, clip->speed(), strobe, clip->baseClip()->getId());
}
- if (clip->setEffectAt(ix, effect)) {
+ if (clip->updateEffect(effect)) {
if (ix == clip->selectedEffectIndex()) {
clip->setSelectedEffect(ix);
if (!triggeredByUser)
bool success = true;
if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - clip->track(), clip->startPos(), effectParams)) success = false;
- if (success && clip->setEffectAt(ix, effect)) {
+ if (success && clip->updateEffect(effect)) {
if (ix == clip->selectedEffectIndex()) {
clip->setSelectedEffect(ix);
if (!triggeredByUser)
if (newPos > m_document->getTrackEffects(m_document->tracksCount() - track - 1).count()) {
newPos = m_document->getTrackEffects(m_document->tracksCount() - track - 1).count();
}
- QDomElement act = m_document->getTrackEffect(m_document->tracksCount() - track - 1, newPos - 1);
- QDomElement before = m_document->getTrackEffect(m_document->tracksCount() - track - 1, oldPos - 1);
+ QDomElement act = m_document->getTrackEffect(m_document->tracksCount() - track - 1, newPos);
+ QDomElement before = m_document->getTrackEffect(m_document->tracksCount() - track - 1, oldPos);
if (!act.isNull() && !before.isNull()) {
- m_document->setTrackEffect(m_document->tracksCount() - track - 1, oldPos - 1, act);
- m_document->setTrackEffect(m_document->tracksCount() - track - 1, newPos - 1, before);
+ m_document->setTrackEffect(m_document->tracksCount() - track - 1, oldPos, act);
+ m_document->setTrackEffect(m_document->tracksCount() - track - 1, newPos, before);
m_document->renderer()->mltMoveEffect(m_document->tracksCount() - track, pos, oldPos, newPos);
emit showTrackEffects(m_document->tracksCount() - track, m_document->trackInfoAt(m_document->tracksCount() - track - 1));
} else emit displayMessage(i18n("Cannot move effect"), ErrorMessage);
if (newPos > clip->effectsCount()) {
newPos = clip->effectsCount();
}
- if (clip && !clip->effectAt(newPos - 1).isNull() && !clip->effectAt(oldPos - 1).isNull()) {
- QDomElement act = clip->effectAt(newPos - 1);
- QDomElement before = clip->effectAt(oldPos - 1);
- clip->setEffectAt(oldPos - 1, act);
- clip->setEffectAt(newPos - 1, before);
+ if (clip && !clip->effectAt(newPos ).isNull() && !clip->effectAt(oldPos).isNull()) {
+ QDomElement act = clip->effectAt(newPos);
+ QDomElement before = clip->effectAt(oldPos);
+ clip->moveEffect(act, oldPos);
+ clip->moveEffect(before, newPos);
// special case: speed effect, which is a pseudo-effect, not appearing in MLT's effects
if (act.attribute("id") == "speed") {
m_document->renderer()->mltUpdateEffectPosition(track, pos, oldPos, newPos);
if (clip) command = new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), oldeffect, effect, ix, true);
else command = new EditEffectCommand(this, m_document->tracksCount() - track, GenTime(-1), oldeffect, effect, ix, true);
m_commandStack->push(command);
- kDebug()<<"// UPDATE EFFECT, "<<EffectsList::property(effect, "kdenlive_ix")<<" / "<<EffectsList::property(effect, "kdenlive_info");
}
void CustomTrackView::slotUpdateClipRegion(ClipItem *clip, int ix, QString region)
#include <KLocale>
-EffectsList::EffectsList()
+EffectsList::EffectsList(bool indexRequired) : m_useIndex(indexRequired)
{
m_baseElement = createElement("list");
appendChild(m_baseElement);
void EffectsList::append(QDomElement e)
{
- m_baseElement.appendChild(importNode(e, true));
+ if (!e.isNull()) {
+ m_baseElement.appendChild(importNode(e, true));
+ if (m_useIndex) updateIndexes(m_baseElement.childNodes());
+ }
}
int EffectsList::count() const
void EffectsList::removeAt(int ix)
{
QDomNodeList effects = m_baseElement.childNodes();
- if (ix < 0 || ix >= effects.count()) return;
- m_baseElement.removeChild(effects.at(ix));
+ if (ix <= 0 || ix > effects.count()) return;
+ m_baseElement.removeChild(effects.at(ix - 1));
+ if (m_useIndex) updateIndexes(effects);
}
-QDomElement EffectsList::item(int ix)
+QDomElement EffectsList::itemFromIndex(int ix) const
{
QDomNodeList effects = m_baseElement.childNodes();
- if (ix < 0 || ix >= effects.count()) return QDomElement();
- return effects.at(ix).toElement();
+ if (ix <= 0 || ix > effects.count()) return QDomElement();
+ return effects.at(ix - 1).toElement();
}
-void EffectsList::insert(int ix, QDomElement effect)
+void EffectsList::insert(QDomElement effect)
{
QDomNodeList effects = m_baseElement.childNodes();
- if (ix < 0) ix = 0;
- if (ix >= effects.count()) m_baseElement.appendChild(importNode(effect, true));
- else m_baseElement.insertBefore(importNode(effect, true), effects.at(ix));
+ int ix = effect.attribute("kdenlive_ix").toInt();
+ if (ix > effects.count()) m_baseElement.appendChild(importNode(effect, true));
+ else {
+ QDomElement listeffect = effects.at(ix - 1).toElement();
+ m_baseElement.insertBefore(importNode(effect, true), listeffect);
+ }
+ if (m_useIndex) updateIndexes(effects);
}
-void EffectsList::replace(int ix, QDomElement effect)
+void EffectsList::updateIndexes(QDomNodeList effects)
+{
+ for (int i = 0; i < effects.count(); i++) {
+ QDomElement listeffect = effects.at(i).toElement();
+ listeffect.setAttribute("kdenlive_ix", i + 1);
+ }
+}
+
+QDomElement EffectsList::effectFromIndex(QDomNodeList effects, int ix)
+{
+ if (ix <= 0 || ix > effects.count()) return QDomElement();
+ return effects.at(ix - 1).toElement();
+}
+
+void EffectsList::updateEffect(QDomElement effect)
{
QDomNodeList effects = m_baseElement.childNodes();
- if (ix < 0) ix = 0;
- if (ix < effects.count()) m_baseElement.removeChild(effects.at(ix));
- if (ix == effects.count()) m_baseElement.appendChild(importNode(effect, true));
- else m_baseElement.insertBefore(importNode(effect, true), effects.at(ix));
+ int ix = effect.attribute("kdenlive_ix").toInt();
+ QDomElement current = effectFromIndex(effects, ix);
+ if (!current.isNull()) {
+ m_baseElement.insertBefore(importNode(effect, true), current);
+ m_baseElement.removeChild(current);
+ }
+ else m_baseElement.appendChild(importNode(effect, true));
}
class EffectsList: public QDomDocument
{
public:
- EffectsList();
+ EffectsList(bool indexRequired = false);
~EffectsList();
/** @brief Returns the XML element of an effect.
int count() const;
const QDomElement at(int ix) const;
void removeAt(int ix);
- QDomElement item(int ix);
- void insert(int ix, QDomElement effect);
- void replace(int ix, QDomElement effect);
+ QDomElement itemFromIndex(int ix) const;
+ void insert(QDomElement effect);
+ void updateEffect(QDomElement effect);
static bool hasKeyFrames(QDomElement effect);
static bool hasSimpleKeyFrames(QDomElement effect);
static bool hasGeometryKeyFrames(QDomElement effect);
/** @brief Remove all 'meta.*' properties from a producer, used when replacing proxy producers in xml for rendering. */
static void removeMetaProperties(QDomElement producer);
void clearList();
+ /** @brief Get am effect with effect index equal to ix. */
+ QDomElement effectFromIndex(QDomNodeList effects, int ix);
+ /** @brief Update all effects indexes to make sure they are 1, 2, 3, ... */
+ void updateIndexes(QDomNodeList effects);
private:
QDomElement m_baseElement;
+ bool m_useIndex;
};
setAcceptDrops(true);
title->setText(i18n("Effect Group"));
title->setIcon(KIcon("folder"));
+ m_menu->addAction(KIcon("list-remove"), i18n("Ungroup"), this, SLOT(slotUnGroup()));
}
title->setMenu(m_menu);
void CollapsibleEffect::slotCreateGroup()
{
- emit createGroup(m_paramWidget->index());
+ emit createGroup(effectIndex());
+}
+
+void CollapsibleEffect::slotUnGroup()
+{
+ emit unGroup(this);
}
bool CollapsibleEffect::eventFilter( QObject * o, QEvent * e )
void CollapsibleEffect::slotDeleteEffect()
{
- if (!m_isGroup) emit deleteEffect(m_effect, m_paramWidget->index());
+ if (!m_isGroup) emit deleteEffect(m_effect);
}
void CollapsibleEffect::slotEffectUp()
{
- if (!m_isGroup) emit changeEffectPosition(m_paramWidget->index(), true);
+ if (!m_isGroup) emit changeEffectPosition(effectIndex(), true);
}
void CollapsibleEffect::slotEffectDown()
{
- if (!m_isGroup) emit changeEffectPosition(m_paramWidget->index(), false);
+ if (!m_isGroup) emit changeEffectPosition(effectIndex(), false);
}
void CollapsibleEffect::slotSaveEffect()
void CollapsibleEffect::slotResetEffect()
{
- emit resetEffect(m_paramWidget->index());
+ emit resetEffect(effectIndex());
}
void CollapsibleEffect::slotSwitch()
m_info.isCollapsed = true;
}
m_effect.setAttribute("kdenlive_info", m_info.toString());
+ emit parameterChanged(m_original_effect, m_effect, m_index);
+}
+
+void CollapsibleEffect::updateGroupIndex(int groupIndex)
+{
+ m_info.groupIndex = groupIndex;
+ m_effect.setAttribute("kdenlive_info", m_info.toString());
emit parameterChanged(m_original_effect, m_effect, m_index);
-
}
void CollapsibleEffect::setGroupIndex(int ix)
vbox->addWidget(effect);
}
+QString CollapsibleEffect::infoString() const
+{
+ return m_info.toString();
+}
+
+void CollapsibleEffect::removeGroup(int ix, QVBoxLayout *layout)
+{
+ QVBoxLayout *vbox = static_cast<QVBoxLayout *>(widgetFrame->layout());
+ if (vbox == NULL) return;
+
+ for (int j = vbox->count() - 1; j >= 0; j--) {
+ QLayoutItem *child = vbox->takeAt(j);
+ CollapsibleEffect *e = static_cast<CollapsibleEffect *>(child->widget());
+ layout->insertWidget(ix, e);
+ e->updateGroupIndex(-1);
+ delete child;
+ }
+}
+
int CollapsibleEffect::index() const
{
return m_index;
int groupIndex() const;
int effectIndex() const;
void setGroupIndex(int ix);
+ void removeGroup(int ix, QVBoxLayout *layout);
+ QString infoString() const;
public slots:
void slotSyncEffectsPos(int pos);
void slotSaveEffect();
void slotResetEffect();
void slotCreateGroup();
+ void slotUnGroup();
private:
ParameterContainer *m_paramWidget;
int m_index;
EffectInfo m_info;
+ void updateGroupIndex(int groupIndex);
+
protected:
virtual void mouseDoubleClickEvent ( QMouseEvent * event );
virtual void mousePressEvent ( QMouseEvent * event );
void parameterChanged(const QDomElement, const QDomElement, int);
void syncEffectsPos(int);
void effectStateChanged(bool, int ix = -1);
- void deleteEffect(const QDomElement, int);
+ void deleteEffect(const QDomElement);
void changeEffectPosition(int, bool);
void activateEffect(int);
void checkMonitorPosition(int);
/** @brief Ask for creation of a group. */
void createGroup(int ix);
void moveEffect(int ix, CollapsibleEffect *group, int lastEffectIndex);
+ void unGroup(CollapsibleEffect *);
};
QWidget *view = m_ui.container->takeWidget();
if (view) {
delete view;
- //view->deleteLater();
}
blockSignals(false);
view = new QWidget(m_ui.container);
group = new CollapsibleEffect(QDomElement(), QDomElement(), ItemInfo(), effectInfo.groupIndex, &m_effectMetaInfo, false, true, m_ui.container->widget());
if (!effectInfo.groupName.isEmpty()) group->title->setText(effectInfo.groupName);
connect(group, SIGNAL(moveEffect(int,CollapsibleEffect*,int)), this , SLOT(slotMoveEffectToGroup(int,CollapsibleEffect*,int)));
+ connect(group, SIGNAL(unGroup(CollapsibleEffect*)), this , SLOT(slotUnGroup(CollapsibleEffect*)));
vbox1->addWidget(group);
}
if (effectInfo.groupIndex >= m_groupIndex) m_groupIndex = effectInfo.groupIndex + 1;
connect(currentEffect, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this , SLOT(slotUpdateEffectParams(const QDomElement, const QDomElement, int)));
connect(currentEffect, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)), this , SLOT(slotStartFilterJob(QString,QString,QString,QString,QString,QString)));
- connect(currentEffect, SIGNAL(deleteEffect(const QDomElement, int)), this , SLOT(slotDeleteEffect(const QDomElement, int)));
+ connect(currentEffect, SIGNAL(deleteEffect(const QDomElement)), this , SLOT(slotDeleteEffect(const QDomElement)));
connect(currentEffect, SIGNAL(reloadEffects()), this , SIGNAL(reloadEffects()));
connect(currentEffect, SIGNAL(resetEffect(int)), this , SLOT(slotResetEffect(int)));
connect(currentEffect, SIGNAL(changeEffectPosition(int,bool)), this , SLOT(slotMoveEffect(int , bool)));
void EffectStackView2::mouseMoveEvent(QMouseEvent * event)
{
if (m_draggedEffect && (event->buttons() & Qt::LeftButton) && (m_clickPoint != QPoint()) && ((event->globalPos() - m_clickPoint).manhattanLength() >= QApplication::startDragDistance())) {
- kDebug()<<"DRAGG: "<<event->pos()<<"/"<<m_clickPoint;
startDrag();
}
}
}
}
-void EffectStackView2::slotDeleteEffect(const QDomElement effect, int index)
+void EffectStackView2::slotDeleteEffect(const QDomElement effect)
{
if (m_effectMetaInfo.trackMode)
emit removeEffect(NULL, m_trackindex, effect);
void EffectStackView2::slotMoveEffect(int index, bool up)
{
- if (up && index <= 0) return;
- if (!up && index >= m_currentEffectList.count() - 1) return;
- int startPos;
+ if (up && index <= 1) return;
+ if (!up && index >= m_currentEffectList.count()) return;
int endPos;
if (up) {
- startPos = index + 1;
- endPos = index;
+ endPos = index - 1;
}
else {
- startPos = index + 1;
- endPos = index + 2;
+ endPos = index + 1;
}
- if (m_effectMetaInfo.trackMode) emit changeEffectPosition(NULL, m_trackindex, startPos, endPos);
- else emit changeEffectPosition(m_clipref, -1, startPos, endPos);
+ if (m_effectMetaInfo.trackMode) emit changeEffectPosition(NULL, m_trackindex, index, endPos);
+ else emit changeEffectPosition(m_clipref, -1, index, endPos);
}
void EffectStackView2::slotStartFilterJob(const QString&filterName, const QString&filterParams, const QString&finalFilterName, const QString&consumer, const QString&consumerParams, const QString&properties)
void EffectStackView2::slotResetEffect(int ix)
{
- QDomElement old = m_currentEffectList.at(ix);
+ QDomElement old = m_currentEffectList.itemFromIndex(ix);
QDomElement dom;
QString effectId = old.attribute("id");
QMap<QString, EffectsList*> effectLists;
void EffectStackView2::slotCreateGroup(int ix)
{
- QDomElement oldeffect = m_currentEffectList.at(ix);
+ QDomElement oldeffect = m_currentEffectList.itemFromIndex(ix);
QDomElement neweffect = oldeffect.cloneNode().toElement();
QString groupName = QString::number(m_groupIndex);
EffectInfo effectinfo;
}
QVBoxLayout *l = static_cast<QVBoxLayout *>(m_ui.container->widget()->layout());
- int groupPos = l->indexOf(m_effects.at(ix));
+ int groupPos = 0;
+
+ CollapsibleEffect *effectToMove = NULL;
+ for (int j = 0; j < l->count(); j++) {
+ CollapsibleEffect *gp = static_cast<CollapsibleEffect *>(l->itemAt(j)->widget());
+ if (gp->effectIndex() == ix) {
+ effectToMove = gp;
+ groupPos = l->indexOf(gp);
+ l->removeWidget(gp);
+ break;
+ }
+ }
CollapsibleEffect *group = new CollapsibleEffect(QDomElement(), QDomElement(), ItemInfo(), m_groupIndex, &m_effectMetaInfo, false, true, m_ui.container->widget());
m_groupIndex++;
connect(group, SIGNAL(moveEffect(int,CollapsibleEffect*,int)), this , SLOT(slotMoveEffectToGroup(int,CollapsibleEffect*,int)));
- CollapsibleEffect *w = static_cast<CollapsibleEffect*>(l->takeAt(groupPos)->widget());
+ connect(group, SIGNAL(unGroup(CollapsibleEffect*)), this , SLOT(slotUnGroup(CollapsibleEffect*)));
l->insertWidget(groupPos, group);
- group->addGroupEffect(w);
+ group->addGroupEffect(effectToMove);
}
-void EffectStackView2::slotMoveEffectToGroup(int ix, CollapsibleEffect* group, int lastEffectIndex)
+void EffectStackView2::slotMoveEffectToGroup(int effectIndex, CollapsibleEffect* group, int lastEffectIndex)
{
QVBoxLayout *l = static_cast<QVBoxLayout *>(m_ui.container->widget()->layout());
- CollapsibleEffect *effectToMove = getEffectByIndex(ix);
+ CollapsibleEffect *effectToMove = getEffectByIndex(effectIndex);
if (effectToMove == NULL) return;
l->removeWidget(effectToMove);
group->addGroupEffect(effectToMove);
- QDomElement oldeffect = m_currentEffectList.at(effectToMove->index());
+ QDomElement oldeffect = effectToMove->effect();
QDomElement neweffect = oldeffect.cloneNode().toElement();
EffectInfo effectinfo;
effectinfo.fromString(oldeffect.attribute("kdenlive_info"));
- effectinfo.groupIndex = group->index();
+ effectinfo.groupIndex = group->groupIndex();
neweffect.setAttribute("kdenlive_info", effectinfo.toString());
ItemInfo info;
}
}
+void EffectStackView2::slotUnGroup(CollapsibleEffect* group)
+{
+ QVBoxLayout *l = static_cast<QVBoxLayout *>(m_ui.container->widget()->layout());
+ int ix = l->indexOf(group);
+ group->removeGroup(ix, l);
+ group->deleteLater();
+}
#include "effectstackview2.moc"
void slotMoveEffect(int index, bool up);
/** @brief Delete an effect in the stack. */
- void slotDeleteEffect(const QDomElement effect, int index);
+ void slotDeleteEffect(const QDomElement effect);
/** @brief Pass position changes of the timeline cursor to the effects to keep their local timelines in sync. */
void slotRenderPos(int pos);
** @param group the effect group where the effect is moved
** @param lastEffectIndex the last effect index in the group, effect will be inserted after that index
*/
- void slotMoveEffectToGroup(int ix, CollapsibleEffect *group, int lastEffectIndex);
-
+ void slotMoveEffectToGroup(int effectIndex, CollapsibleEffect *group, int lastEffectIndex);
+ /** @brief Remove effects from a group */
+ void slotUnGroup(CollapsibleEffect* group);
signals:
void removeEffect(ClipItem*, int, QDomElement);
kWarning() << "Remove Track effect outisde of range";
return;
}
- QString index;
- QString toRemove = effect.attribute("kdenlive_ix");
+ int index;
+ int toRemove = effect.attribute("kdenlive_ix").toInt();
for (int i = 0; i < m_tracksList.at(ix).effectsList.count(); ++i) {
- index = m_tracksList.at(ix).effectsList.at(i).attribute("kdenlive_ix");
+ index = m_tracksList.at(ix).effectsList.at(i).attribute("kdenlive_ix").toInt();
if (toRemove == index) {
- m_tracksList[ix].effectsList.removeAt(i);
- i--;
- } else if (index.toInt() > toRemove.toInt()) {
- m_tracksList[ix].effectsList.item(i).setAttribute("kdenlive_ix", index.toInt() - 1);
+ m_tracksList[ix].effectsList.removeAt(toRemove);
+ break;
}
}
}
kWarning() << "Set Track effect outisde of range";
return;
}
- if (effectIndex < 0 || effectIndex > (m_tracksList.at(trackIndex).effectsList.count() - 1) || effect.isNull()) {
+ if (effectIndex <= 0 || effectIndex > (m_tracksList.at(trackIndex).effectsList.count()) || effect.isNull()) {
kDebug() << "Invalid effect index: " << effectIndex;
return;
}
- effect.setAttribute("kdenlive_ix", effectIndex + 1);
- m_tracksList[trackIndex].effectsList.replace(effectIndex, effect);
+ effect.setAttribute("kdenlive_ix", effectIndex);
+ m_tracksList[trackIndex].effectsList.updateEffect(effect);
}
const EffectsList KdenliveDoc::getTrackEffects(int ix)
return QDomElement();
}
EffectsList list = m_tracksList.at(trackIndex).effectsList;
- if (effectIndex > list.count() - 1 || effectIndex < 0 || list.at(effectIndex).isNull()) return QDomElement();
- return list.at(effectIndex).cloneNode().toElement();
+ if (effectIndex > list.count() || effectIndex < 1 || list.itemFromIndex(effectIndex).isNull()) return QDomElement();
+ return list.itemFromIndex(effectIndex).cloneNode().toElement();
}
bool KdenliveDoc::saveCustomEffects(QDomNodeList customeffects)