]> git.sesse.net Git - kdenlive/blob - src/effectstack/effectstackview2.cpp
Fix selected index in effect stack
[kdenlive] / src / effectstack / effectstackview2.cpp
1 /***************************************************************************
2                           effecstackview.cpp2  -  description
3                              -------------------
4     begin                : Feb 15 2008
5     copyright            : (C) 2008 by Marco Gittler
6     email                : g.marco@freenet.de
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18
19 #include "effectstackview2.h"
20 #include "effectslist.h"
21 #include "clipitem.h"
22 #include "mainwindow.h"
23 #include "docclipbase.h"
24 #include "projectlist.h"
25 #include "kthumb.h"
26 #include "monitoreditwidget.h"
27 #include "monitorscene.h"
28 #include "kdenlivesettings.h"
29
30 #include <KDebug>
31 #include <KLocale>
32 #include <KMessageBox>
33 #include <KStandardDirs>
34 #include <KFileDialog>
35 #include <KColorScheme>
36
37 #include <QMenu>
38 #include <QTextStream>
39 #include <QFile>
40 #include <QInputDialog>
41
42
43 EffectStackView2::EffectStackView2(Monitor *monitor, QWidget *parent) :
44         QWidget(parent),
45         m_clipref(NULL),
46         m_trackindex(-1),
47         m_draggedEffect(NULL),
48         m_groupIndex(0)
49 {
50     m_effectMetaInfo.trackMode = false;
51     m_effectMetaInfo.monitor = monitor;
52     m_effects = QList <CollapsibleEffect*>();
53
54     m_ui.setupUi(this);
55     setFont(KGlobalSettings::smallestReadableFont());
56     m_ui.checkAll->setToolTip(i18n("Enable/Disable all effects"));
57     m_ui.buttonShowComments->setIcon(KIcon("help-about"));
58     m_ui.buttonShowComments->setToolTip(i18n("Show additional information for the parameters"));
59
60
61     setEnabled(false);
62
63     QPalette p = palette();
64     KColorScheme scheme(p.currentColorGroup(), KColorScheme::View, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
65     QColor dark_bg = scheme.shade(KColorScheme::DarkShade);
66     QColor selected_bg = scheme.decoration(KColorScheme::FocusColor).color();
67     QColor hover_bg = scheme.decoration(KColorScheme::HoverColor).color();
68     QColor light_bg = scheme.shade(KColorScheme::LightShade);
69     
70     QString stylesheet(QString("QProgressBar:horizontal {border: 1px solid %1;border-radius:0px;border-top-left-radius: 4px;border-bottom-left-radius: 4px;border-right: 0px;background:%4;padding: 0px;text-align:left center}\
71                                 QProgressBar:horizontal#dragOnly {background: %1} QProgressBar:horizontal:hover#dragOnly {background: %3} QProgressBar:horizontal:hover {border: 1px solid %3;border-right: 0px;}\
72                                 QProgressBar::chunk:horizontal {background: %1;} QProgressBar::chunk:horizontal:hover {background: %3;}\
73                                 QProgressBar:horizontal[inTimeline=\"true\"] { border: 1px solid %2;border-right: 0px;background: %4;padding: 0px;text-align:left center } QProgressBar::chunk:horizontal[inTimeline=\"true\"] {background: %2;}\
74                                 QAbstractSpinBox#dragBox {border: 1px solid %1;border-top-right-radius: 4px;border-bottom-right-radius: 4px;padding-right:0px;} QAbstractSpinBox::down-button#dragBox {width:0px;padding:0px;}\
75                                 QAbstractSpinBox::up-button#dragBox {width:0px;padding:0px;} QAbstractSpinBox[inTimeline=\"true\"]#dragBox { border: 1px solid %2;} QAbstractSpinBox:hover#dragBox {border: 1px solid %3;} ")
76                                 .arg(dark_bg.name()).arg(selected_bg.name()).arg(hover_bg.name()).arg(light_bg.name()));
77     setStyleSheet(stylesheet);
78 }
79
80 EffectStackView2::~EffectStackView2()
81 {
82 }
83
84
85 void EffectStackView2::slotRenderPos(int pos)
86 {
87     if (m_effects.isEmpty()) return;
88     if (!m_effectMetaInfo.trackMode && m_clipref) pos = pos - m_clipref->startPos().frames(KdenliveSettings::project_fps());
89
90     for (int i = 0; i< m_effects.count(); i++)
91         m_effects.at(i)->slotSyncEffectsPos(pos);
92 }
93
94 void EffectStackView2::setMenu(QMenu *menu)
95 {
96     //m_ui.buttonNew->setMenu(menu);
97 }
98
99 void EffectStackView2::slotClipItemSelected(ClipItem* c, int ix)
100 {
101     if (c && !c->isEnabled()) return;
102     if (c && c == m_clipref) {
103         
104     } else {
105         m_clipref = c;
106         if (c) {
107             QString cname = m_clipref->clipName();
108             if (cname.length() > 30) {
109                 m_ui.checkAll->setToolTip(i18n("Effects for %1").arg(cname));
110                 cname.truncate(27);
111                 m_ui.checkAll->setText(i18n("Effects for %1").arg(cname) + "...");
112             } else {
113                 m_ui.checkAll->setToolTip(QString());
114                 m_ui.checkAll->setText(i18n("Effects for %1").arg(cname));
115             }
116             ix = c->selectedEffectIndex();
117             QString size = c->baseClip()->getProperty("frame_size");
118             double factor = c->baseClip()->getProperty("aspect_ratio").toDouble();
119             m_effectMetaInfo.frameSize = QPoint((int)(size.section('x', 0, 0).toInt() * factor + 0.5), size.section('x', 1, 1).toInt());
120         } else {
121             ix = 0;
122         }
123     }
124     if (m_clipref == NULL) {
125         //TODO: clear list, reset paramdesc and info
126         //ItemInfo info;
127         //m_effectedit->transferParamDesc(QDomElement(), info);
128         clear();
129         return;
130     }
131     setEnabled(true);
132     m_effectMetaInfo.trackMode = false;
133     m_currentEffectList = m_clipref->effectList();
134     setupListView(ix);
135 }
136
137 void EffectStackView2::slotTrackItemSelected(int ix, const TrackInfo info)
138 {
139     m_clipref = NULL;
140     m_effectMetaInfo.trackMode = true;
141     m_currentEffectList = info.effectsList;
142     m_trackInfo = info;
143     setEnabled(true);
144     m_ui.checkAll->setToolTip(QString());
145     m_ui.checkAll->setText(i18n("Effects for track %1").arg(info.trackName.isEmpty() ? QString::number(ix) : info.trackName));
146     m_trackindex = ix;
147     setupListView(0);
148 }
149
150
151 void EffectStackView2::setupListView(int ix)
152 {
153     //TODO: clear list
154
155     blockSignals(true);
156     m_draggedEffect = NULL;
157     disconnect(m_effectMetaInfo.monitor, SIGNAL(renderPosition(int)), this, SLOT(slotRenderPos(int)));
158     m_effects.clear();
159     m_groupIndex = 0;
160     QWidget *view = m_ui.container->takeWidget();
161     if (view) {
162         delete view;
163     }
164     blockSignals(false);
165     view = new QWidget(m_ui.container);
166     m_ui.container->setWidget(view);
167
168     QVBoxLayout *vbox1 = new QVBoxLayout(view);
169     vbox1->setContentsMargins(0, 0, 0, 0);
170     vbox1->setSpacing(0);
171
172     for (int i = 0; i < m_currentEffectList.count(); i++) {
173         QDomElement d = m_currentEffectList.at(i).cloneNode().toElement();
174         if (d.isNull()) {
175             kDebug() << " . . . . WARNING, NULL EFFECT IN STACK!!!!!!!!!";
176             continue;
177         }
178         
179         CollapsibleEffect *group = NULL;
180         EffectInfo effectInfo;
181         effectInfo.fromString(d.attribute("kdenlive_info"));
182         if (effectInfo.groupIndex >= 0) {
183             for (int j = 0; j < vbox1->count(); j++) {
184                 CollapsibleEffect *gp = static_cast<CollapsibleEffect *>(vbox1->itemAt(j)->widget());
185                 if (gp->groupIndex() == effectInfo.groupIndex) {
186                     group = gp;
187                     break;
188                 }
189             }
190             
191             if (group == NULL) {
192                 group = new CollapsibleEffect(QDomElement(), QDomElement(), ItemInfo(), effectInfo.groupIndex, &m_effectMetaInfo, false, true, m_ui.container->widget());
193                 if (!effectInfo.groupName.isEmpty()) group->title->setText(effectInfo.groupName);
194                 connect(group, SIGNAL(moveEffect(int,int,CollapsibleEffect*)), this, SLOT(slotMoveEffect(int,int,CollapsibleEffect*)));
195                 connect(group, SIGNAL(unGroup(CollapsibleEffect*)), this , SLOT(slotUnGroup(CollapsibleEffect*)));
196                 vbox1->addWidget(group);
197             }
198             if (effectInfo.groupIndex >= m_groupIndex) m_groupIndex = effectInfo.groupIndex + 1;
199         }
200
201         /*QDomDocument doc;
202         doc.appendChild(doc.importNode(d, true));
203         kDebug() << "IMPORTED STK: " << doc.toString();*/
204         
205         ItemInfo info;
206         if (m_effectMetaInfo.trackMode) { 
207             info.track = m_trackInfo.type;
208             info.cropDuration = GenTime(m_trackInfo.duration, KdenliveSettings::project_fps());
209             info.cropStart = GenTime(0);
210             info.startPos = GenTime(-1);
211             info.track = 0;
212         }
213         else info = m_clipref->info();
214
215         CollapsibleEffect *currentEffect = new CollapsibleEffect(d, m_currentEffectList.at(i), info, i, &m_effectMetaInfo, i == m_currentEffectList.count() - 1, false, view);
216         m_effects.append(currentEffect);
217         if (group) {
218             group->addGroupEffect(currentEffect);
219         } else {
220             vbox1->addWidget(currentEffect);
221         }
222         if (currentEffect->effectIndex() == ix) currentEffect->setActive(true);
223
224         // Check drag & drop
225         currentEffect->installEventFilter( this );
226
227         connect(currentEffect, SIGNAL(parameterChanged(const QDomElement, const QDomElement, int)), this , SLOT(slotUpdateEffectParams(const QDomElement, const QDomElement, int)));
228         connect(currentEffect, SIGNAL(startFilterJob(QString,QString,QString,QString,QString,QString)), this , SLOT(slotStartFilterJob(QString,QString,QString,QString,QString,QString)));
229         connect(currentEffect, SIGNAL(deleteEffect(const QDomElement)), this , SLOT(slotDeleteEffect(const QDomElement)));
230         connect(currentEffect, SIGNAL(reloadEffects()), this , SIGNAL(reloadEffects()));
231         connect(currentEffect, SIGNAL(resetEffect(int)), this , SLOT(slotResetEffect(int)));
232         connect(currentEffect, SIGNAL(changeEffectPosition(int,bool)), this , SLOT(slotMoveEffectUp(int , bool)));
233         connect(currentEffect, SIGNAL(effectStateChanged(bool, int)), this, SLOT(slotUpdateEffectState(bool, int)));
234         connect(currentEffect, SIGNAL(activateEffect(int)), this, SLOT(slotSetCurrentEffect(int)));
235         connect(currentEffect, SIGNAL(checkMonitorPosition(int)), this, SLOT(slotCheckMonitorPosition(int)));
236         connect(currentEffect, SIGNAL(seekTimeline(int)), this , SLOT(slotSeekTimeline(int)));
237         connect(currentEffect, SIGNAL(createGroup(int)), this , SLOT(slotCreateGroup(int)));
238         connect(currentEffect, SIGNAL(moveEffect(int,int,CollapsibleEffect*)), this , SLOT(slotMoveEffect(int,int,CollapsibleEffect*)));
239         connect(currentEffect, SIGNAL(addEffect(QDomElement)), this , SLOT(slotAddEffect(QDomElement)));
240         
241         //ui.title->setPixmap(icon.pixmap(QSize(12, 12)));
242     }
243     vbox1->addStretch(10);
244     connect(m_effectMetaInfo.monitor, SIGNAL(renderPosition(int)), this, SLOT(slotRenderPos(int)));
245 }
246
247 bool EffectStackView2::eventFilter( QObject * o, QEvent * e ) 
248 {
249     // Check if user clicked in an effect's top bar to start dragging it
250     if (e->type() == QEvent::MouseButtonPress)  {
251         m_draggedEffect = qobject_cast<CollapsibleEffect*>(o);
252         if (m_draggedEffect) {
253             QMouseEvent *me = static_cast<QMouseEvent *>(e);
254             if (me->button() == Qt::LeftButton && (m_draggedEffect->frame->underMouse() || m_draggedEffect->title->underMouse()))
255                 m_clickPoint = me->globalPos();
256             else {
257                 m_clickPoint = QPoint();
258                 m_draggedEffect = NULL;
259             }
260             e->accept();
261             return false;
262         }
263     }  
264     if (e->type() == QEvent::MouseMove)  {
265         if (qobject_cast<CollapsibleEffect*>(o)) {
266             QMouseEvent *me = static_cast<QMouseEvent *>(e);
267             if (me->buttons() != Qt::LeftButton) {
268                 e->accept();
269                 return false;
270             }
271             else {
272                 e->ignore();
273                 return true;
274             }
275         }
276     }
277     return QWidget::eventFilter(o, e);
278 }
279
280 void EffectStackView2::mouseMoveEvent(QMouseEvent * event)
281 {
282     if (m_draggedEffect && (event->buttons() & Qt::LeftButton) && (m_clickPoint != QPoint()) && ((event->globalPos() - m_clickPoint).manhattanLength() >= QApplication::startDragDistance())) {
283         startDrag();
284     }
285 }
286
287 void EffectStackView2::mouseReleaseEvent(QMouseEvent * event)
288 {
289     m_draggedEffect = NULL;
290     QWidget::mouseReleaseEvent(event);
291 }
292
293 void EffectStackView2::startDrag()
294 {
295     QDrag *drag = new QDrag(this);
296     // The data to be transferred by the drag and drop operation is contained in a QMimeData object
297     QDomElement effect = m_draggedEffect->effect().cloneNode().toElement();
298     QPixmap pixmap = QPixmap::grabWidget(m_draggedEffect->title);
299     drag->setPixmap(pixmap);
300     QDomDocument doc;
301     doc.appendChild(doc.importNode(effect, true));
302     QMimeData *mime = new QMimeData;
303     QByteArray data;
304     data.append(doc.toString().toUtf8());
305     mime->setData("kdenlive/effectslist", data);
306
307     // Assign ownership of the QMimeData object to the QDrag object.
308     drag->setMimeData(mime);
309     // Start the drag and drop operation
310     drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
311 }
312
313
314 void EffectStackView2::slotUpdateEffectState(bool disable, int index)
315 {
316     if (m_effectMetaInfo.trackMode)
317         emit changeEffectState(NULL, m_trackindex, index, disable);
318     else
319         emit changeEffectState(m_clipref, -1, index, disable);
320 }
321
322
323 void EffectStackView2::raiseWindow(QWidget* dock)
324 {
325     if ((m_clipref || m_effectMetaInfo.trackMode) && dock)
326         dock->raise();
327 }
328
329
330 void EffectStackView2::slotSeekTimeline(int pos)
331 {
332     if (m_effectMetaInfo.trackMode) {
333         emit seekTimeline(pos);
334     } else if (m_clipref) {
335         emit seekTimeline(m_clipref->startPos().frames(KdenliveSettings::project_fps()) + pos);
336     }
337 }
338
339
340 /*void EffectStackView2::slotRegionChanged()
341 {
342     if (!m_trackMode) emit updateClipRegion(m_clipref, m_ui.effectlist->currentRow(), m_ui.region_url->text());
343 }*/
344
345 void EffectStackView2::slotCheckMonitorPosition(int renderPos)
346 {
347     if (m_effectMetaInfo.trackMode || (m_clipref && renderPos >= m_clipref->startPos().frames(KdenliveSettings::project_fps()) && renderPos <= m_clipref->endPos().frames(KdenliveSettings::project_fps()))) {
348         if (!m_effectMetaInfo.monitor->getEffectEdit()->getScene()->views().at(0)->isVisible())
349             m_effectMetaInfo.monitor->slotEffectScene(true);
350     } else {
351         m_effectMetaInfo.monitor->slotEffectScene(false);
352     }
353 }
354
355 int EffectStackView2::isTrackMode(bool *ok) const
356 {
357     *ok = m_effectMetaInfo.trackMode;
358     return m_trackindex;
359 }
360
361 void EffectStackView2::clear()
362 {
363     m_effects.clear();
364     QWidget *view = m_ui.container->takeWidget();
365     if (view) {
366         delete view;
367     }
368     m_ui.checkAll->setToolTip(QString());
369     m_ui.checkAll->setText(QString());
370     setEnabled(false);
371 }
372
373 void EffectStackView2::updateProjectFormat(MltVideoProfile profile, Timecode t)
374 {
375     m_effectMetaInfo.profile = profile;
376     m_effectMetaInfo.timecode = t;
377 }
378
379 void EffectStackView2::slotItemDel()
380 {
381
382 }
383
384 void EffectStackView2::updateTimecodeFormat()
385 {
386     for (int i = 0; i< m_effects.count(); i++)
387         m_effects.at(i)->updateTimecodeFormat();
388 }
389
390 CollapsibleEffect *EffectStackView2::getEffectByIndex(int ix)
391 {
392     for (int i = 0; i< m_effects.count(); i++) {
393         if (m_effects.at(i)->effectIndex() == ix) {
394             return m_effects.at(i);
395         }
396     }
397     return NULL;
398 }
399
400 void EffectStackView2::slotUpdateEffectParams(const QDomElement old, const QDomElement e, int ix)
401 {
402     if (m_effectMetaInfo.trackMode)
403         emit updateEffect(NULL, m_trackindex, old, e, ix);
404     else if (m_clipref) {
405         emit updateEffect(m_clipref, -1, old, e, ix);
406         // Make sure the changed effect is currently displayed
407         slotSetCurrentEffect(ix);
408     }
409 }
410
411 void EffectStackView2::slotSetCurrentEffect(int ix)
412 {
413     if (m_clipref && ix != m_clipref->selectedEffectIndex())
414         m_clipref->setSelectedEffect(ix);
415     for (int i = 0; i < m_effects.count(); i++) {
416         m_effects.at(i)->setActive(m_effects.at(i)->effectIndex() == ix);
417     }
418 }
419
420 void EffectStackView2::slotDeleteEffect(const QDomElement effect)
421 {
422     if (m_effectMetaInfo.trackMode)
423         emit removeEffect(NULL, m_trackindex, effect);
424     else
425         emit removeEffect(m_clipref, -1, effect);
426 }
427
428 void EffectStackView2::slotAddEffect(QDomElement effect)
429 {
430     emit addEffect(m_clipref, effect);
431 }
432
433 void EffectStackView2::slotMoveEffectUp(int index, bool up)
434 {
435     if (up && index <= 1) return;
436     if (!up && index >= m_currentEffectList.count()) return;
437     int endPos;
438     if (up) {
439         endPos = index - 1;
440     }
441     else {
442         endPos =  index + 1;
443     }
444     if (m_effectMetaInfo.trackMode) emit changeEffectPosition(NULL, m_trackindex, index, endPos);
445     else emit changeEffectPosition(m_clipref, -1, index, endPos);
446 }
447
448 void EffectStackView2::slotStartFilterJob(const QString&filterName, const QString&filterParams, const QString&finalFilterName, const QString&consumer, const QString&consumerParams, const QString&properties)
449 {
450     if (!m_clipref) return;
451     emit startFilterJob(m_clipref->info(), m_clipref->clipProducer(), filterName, filterParams, finalFilterName, consumer, consumerParams, properties);
452 }
453
454 void EffectStackView2::slotResetEffect(int ix)
455 {
456     QDomElement old = m_currentEffectList.itemFromIndex(ix);
457     QDomElement dom;
458     QString effectId = old.attribute("id");
459     QMap<QString, EffectsList*> effectLists;
460     effectLists["audio"] = &MainWindow::audioEffects;
461     effectLists["video"] = &MainWindow::videoEffects;
462     effectLists["custom"] = &MainWindow::customEffects;
463     foreach(const QString &type, effectLists.keys()) {
464         EffectsList *list = effectLists[type];
465         dom = list->getEffectByTag(QString(), effectId).cloneNode().toElement();
466         if (!dom.isNull()) break;
467     }
468     if (!dom.isNull()) {
469         dom.setAttribute("kdenlive_ix", old.attribute("kdenlive_ix"));
470         if (m_effectMetaInfo.trackMode) {
471             EffectsList::setParameter(dom, "in", QString::number(0));
472             EffectsList::setParameter(dom, "out", QString::number(m_trackInfo.duration));
473             ItemInfo info;
474             info.track = m_trackInfo.type;
475             info.cropDuration = GenTime(m_trackInfo.duration, KdenliveSettings::project_fps());
476             info.cropStart = GenTime(0);
477             info.startPos = GenTime(-1);
478             info.track = 0;
479             m_effects.at(ix)->updateWidget(info, ix, dom, &m_effectMetaInfo);
480             emit updateEffect(NULL, m_trackindex, old, dom, ix);
481         } else {
482             m_clipref->initEffect(dom);
483             m_effects.at(ix)->updateWidget(m_clipref->info(), ix, dom, &m_effectMetaInfo);
484             //m_ui.region_url->setUrl(KUrl(dom.attribute("region")));
485             emit updateEffect(m_clipref, -1, old, dom, ix);
486         }
487     }
488
489     /*emit showComments(m_ui.buttonShowComments->isChecked());
490     m_ui.labelComment->setHidden(!m_ui.buttonShowComments->isChecked() || !m_ui.labelComment->text().count());*/
491 }
492
493
494 void EffectStackView2::slotCreateGroup(int ix)
495 {
496     QDomElement oldeffect = m_currentEffectList.itemFromIndex(ix);
497     QDomElement neweffect = oldeffect.cloneNode().toElement();
498     QString groupName = QString::number(m_groupIndex);
499     EffectInfo effectinfo;
500     effectinfo.fromString(oldeffect.attribute("kdenlive_info"));
501     effectinfo.groupIndex = m_groupIndex;
502     neweffect.setAttribute("kdenlive_info", effectinfo.toString());
503
504     ItemInfo info;
505     if (m_effectMetaInfo.trackMode) { 
506         info.track = m_trackInfo.type;
507         info.cropDuration = GenTime(m_trackInfo.duration, KdenliveSettings::project_fps());
508         info.cropStart = GenTime(0);
509         info.startPos = GenTime(-1);
510         info.track = 0;
511         emit updateEffect(NULL, m_trackindex, oldeffect, neweffect, ix);
512     } else {
513         emit updateEffect(m_clipref, -1, oldeffect, neweffect, ix);
514     }
515     
516     QVBoxLayout *l = static_cast<QVBoxLayout *>(m_ui.container->widget()->layout());
517     int groupPos = 0;
518     
519     CollapsibleEffect *effectToMove = NULL;
520     for (int j = 0; j < l->count(); j++) {
521         CollapsibleEffect *gp = static_cast<CollapsibleEffect *>(l->itemAt(j)->widget());
522         if (gp->effectIndex() == ix) {
523             effectToMove = gp;
524             groupPos = l->indexOf(gp);
525             l->removeWidget(gp);
526             break;
527         }
528     }
529     
530     CollapsibleEffect *group = new CollapsibleEffect(QDomElement(), QDomElement(), ItemInfo(), m_groupIndex, &m_effectMetaInfo, false, true, m_ui.container->widget());
531     m_groupIndex++;
532     connect(group, SIGNAL(moveEffect(int,int,CollapsibleEffect*)), this , SLOT(slotMoveEffect(int,int,CollapsibleEffect*)));
533     connect(group, SIGNAL(unGroup(CollapsibleEffect*)), this , SLOT(slotUnGroup(CollapsibleEffect*)));
534     l->insertWidget(groupPos, group);
535     group->addGroupEffect(effectToMove);
536 }
537
538 void EffectStackView2::slotMoveEffect(int currentIndex, int newIndex, CollapsibleEffect* target)
539 {
540     CollapsibleEffect *effectToMove = getEffectByIndex(currentIndex);
541     if (effectToMove == NULL) return;
542
543     QDomElement oldeffect = effectToMove->effect();
544     QDomElement neweffect = oldeffect.cloneNode().toElement();
545     
546     EffectInfo effectinfo;
547     effectinfo.fromString(oldeffect.attribute("kdenlive_info"));
548     effectinfo.groupIndex = target->groupIndex();
549     neweffect.setAttribute("kdenlive_info", effectinfo.toString());
550
551     ItemInfo info;
552     if (m_effectMetaInfo.trackMode) { 
553         info.track = m_trackInfo.type;
554         info.cropDuration = GenTime(m_trackInfo.duration, KdenliveSettings::project_fps());
555         info.cropStart = GenTime(0);
556         info.startPos = GenTime(-1);
557         info.track = 0;
558         emit updateEffect(NULL, m_trackindex, oldeffect, neweffect, effectToMove->index());
559     } else {
560         emit updateEffect(m_clipref, -1, oldeffect, neweffect, effectToMove->index());
561     }
562     
563     if (currentIndex == newIndex) return;
564     // Update effect index with new position
565     if (m_effectMetaInfo.trackMode) {
566         emit changeEffectPosition(NULL, m_trackindex, currentIndex, newIndex);
567     }
568     else {
569         emit changeEffectPosition(m_clipref, -1, currentIndex, newIndex);
570     }
571 }
572
573 void EffectStackView2::slotUnGroup(CollapsibleEffect* group)
574 {
575     QVBoxLayout *l = static_cast<QVBoxLayout *>(m_ui.container->widget()->layout());
576     int ix = l->indexOf(group);
577     group->removeGroup(ix, l);
578     group->deleteLater();
579 }
580
581 #include "effectstackview2.moc"