+ emit updateEffect(m_clipref, -1, old, dom, ix,false);
+ }
+ }
+
+ emit showComments(m_ui.buttonShowComments->isChecked());
+ m_ui.labelComment->setHidden(!m_ui.buttonShowComments->isChecked() || m_ui.labelComment->text().isEmpty());
+}
+
+void EffectStackView2::slotShowComments()
+{
+ m_ui.labelComment->setHidden(!m_ui.buttonShowComments->isChecked() || m_ui.labelComment->text().isEmpty());
+ emit showComments(m_ui.buttonShowComments->isChecked());
+}
+
+void EffectStackView2::slotCreateRegion(int ix, KUrl url)
+{
+ QDomElement oldeffect = m_currentEffectList.itemFromIndex(ix);
+ QDomElement neweffect = oldeffect.cloneNode().toElement();
+ QDomElement region = MainWindow::videoEffects.getEffectByTag("region", "region").cloneNode().toElement();
+ region.appendChild(region.ownerDocument().importNode(neweffect, true));
+ region.setAttribute("kdenlive_ix", ix);
+ EffectsList::setParameter(region, "resource", url.path());
+ if (m_effectMetaInfo.trackMode)
+ emit updateEffect(NULL, m_trackindex, oldeffect, region, ix,false);
+ else if (m_clipref) {
+ emit updateEffect(m_clipref, -1, oldeffect, region, ix, false);
+ // Make sure the changed effect is currently displayed
+ //slotSetCurrentEffect(ix);
+ }
+ // refresh effect stack
+ ItemInfo info;
+ bool isSelected = false;
+ if (m_effectMetaInfo.trackMode) {
+ info.track = m_trackInfo.type;
+ info.cropDuration = GenTime(m_trackInfo.duration, KdenliveSettings::project_fps());
+ info.cropStart = GenTime(0);
+ info.startPos = GenTime(-1);
+ info.track = 0;
+ }
+ else if (m_clipref) {
+ info = m_clipref->info();
+ }
+ CollapsibleEffect *current = getEffectByIndex(ix);
+ m_effects.removeAll(current);
+ current->setEnabled(false);
+ m_currentEffectList.removeAt(ix);
+ m_currentEffectList.insert(region);
+ current->deleteLater();
+ CollapsibleEffect *currentEffect = new CollapsibleEffect(region, m_currentEffectList.itemFromIndex(ix), info, &m_effectMetaInfo, ix == m_currentEffectList.count() - 1, m_ui.container->widget());
+ connectEffect(currentEffect);
+
+ if (m_effectMetaInfo.trackMode) {
+ isSelected = currentEffect->effectIndex() == 1;
+ }
+ else if (m_clipref) {
+ isSelected = currentEffect->effectIndex() == m_clipref->selectedEffectIndex();
+ }
+ if (isSelected) currentEffect->setActive(true);
+ m_effects.append(currentEffect);
+ // TODO: region in group?
+ //if (group) {
+ // group->addGroupEffect(currentEffect);
+ //} else {
+ QVBoxLayout *vbox = static_cast <QVBoxLayout *> (m_ui.container->widget()->layout());
+ vbox->insertWidget(ix, currentEffect);
+ //}
+
+ // Check drag & drop
+ currentEffect->installEventFilter( this );
+
+ QTimer::singleShot(200, this, SLOT(slotCheckWheelEventFilter()));
+
+}
+
+void EffectStackView2::slotCreateGroup(int ix)
+{
+ QDomElement oldeffect = m_currentEffectList.itemFromIndex(ix);
+ QDomElement neweffect = oldeffect.cloneNode().toElement();
+ EffectInfo effectinfo;
+ effectinfo.fromString(oldeffect.attribute("kdenlive_info"));
+ effectinfo.groupIndex = m_groupIndex;
+ neweffect.setAttribute("kdenlive_info", effectinfo.toString());
+
+ ItemInfo info;
+ if (m_effectMetaInfo.trackMode) {
+ info.track = m_trackInfo.type;
+ info.cropDuration = GenTime(m_trackInfo.duration, KdenliveSettings::project_fps());
+ info.cropStart = GenTime(0);
+ info.startPos = GenTime(-1);
+ info.track = 0;
+ emit updateEffect(NULL, m_trackindex, oldeffect, neweffect, ix, false);
+ } else {
+ emit updateEffect(m_clipref, -1, oldeffect, neweffect, ix, false);
+ }
+
+ QVBoxLayout *l = static_cast<QVBoxLayout *>(m_ui.container->widget()->layout());
+ int groupPos = 0;
+ CollapsibleEffect *effectToMove = NULL;
+ for (int i = 0; i < m_effects.count(); ++i) {
+ if (m_effects.at(i)->effectIndex() == ix) {
+ effectToMove = m_effects.at(i);
+ groupPos = l->indexOf(effectToMove);
+ l->removeWidget(effectToMove);
+ break;
+ }
+ }
+
+ CollapsibleGroup *group = new CollapsibleGroup(m_groupIndex, ix == 1, ix == m_currentEffectList.count() - 2, effectinfo, m_ui.container->widget());
+ m_groupIndex++;
+ connectGroup(group);
+ l->insertWidget(groupPos, group);
+ group->installEventFilter( this );
+ if (effectToMove)
+ group->addGroupEffect(effectToMove);
+}
+
+void EffectStackView2::connectGroup(CollapsibleGroup *group)
+{
+ connect(group, SIGNAL(moveEffect(QList<int>,int,int,QString)), this , SLOT(slotMoveEffect(QList<int>,int,int,QString)));
+ connect(group, SIGNAL(addEffect(QDomElement)), this , SLOT(slotAddEffect(QDomElement)));
+ connect(group, SIGNAL(unGroup(CollapsibleGroup*)), this , SLOT(slotUnGroup(CollapsibleGroup*)));
+ connect(group, SIGNAL(groupRenamed(CollapsibleGroup*)), this , SLOT(slotRenameGroup(CollapsibleGroup*)));
+ connect(group, SIGNAL(reloadEffects()), this , SIGNAL(reloadEffects()));
+ connect(group, SIGNAL(deleteGroup(QDomDocument)), this , SLOT(slotDeleteGroup(QDomDocument)));
+ connect(group, SIGNAL(changeEffectPosition(QList<int>,bool)), this , SLOT(slotMoveEffectUp(QList<int>,bool)));
+}
+
+void EffectStackView2::slotMoveEffect(QList <int> currentIndexes, int newIndex, int groupIndex, QString groupName)
+{
+ if (currentIndexes.count() == 1) {
+ CollapsibleEffect *effectToMove = getEffectByIndex(currentIndexes.at(0));
+ if (effectToMove == NULL) return;
+
+ QDomElement oldeffect = effectToMove->effect();
+ QDomElement neweffect = oldeffect.cloneNode().toElement();
+
+ EffectInfo effectinfo;
+ effectinfo.fromString(oldeffect.attribute("kdenlive_info"));
+ effectinfo.groupIndex = groupIndex;
+ effectinfo.groupName = groupName;
+ neweffect.setAttribute("kdenlive_info", effectinfo.toString());
+
+ if (oldeffect.attribute("kdenlive_info") != effectinfo.toString()) {
+ // effect's group info or collapsed state changed
+ ItemInfo info;
+ if (m_effectMetaInfo.trackMode) {
+ info.track = m_trackInfo.type;
+ info.cropDuration = GenTime(m_trackInfo.duration, KdenliveSettings::project_fps());
+ info.cropStart = GenTime(0);
+ info.startPos = GenTime(-1);
+ info.track = 0;
+ emit updateEffect(NULL, m_trackindex, oldeffect, neweffect, effectToMove->effectIndex(),false);
+ } else {
+ emit updateEffect(m_clipref, -1, oldeffect, neweffect, effectToMove->effectIndex(),false);
+ }
+ }
+ }
+
+ // Update effect index with new position
+ if (m_effectMetaInfo.trackMode) {
+ emit changeEffectPosition(NULL, m_trackindex, currentIndexes, newIndex);
+ }
+ else {
+ emit changeEffectPosition(m_clipref, -1, currentIndexes, newIndex);
+ }
+}
+
+void EffectStackView2::slotUnGroup(CollapsibleGroup* group)
+{
+ QVBoxLayout *l = static_cast<QVBoxLayout *>(m_ui.container->widget()->layout());
+ int ix = l->indexOf(group);
+ group->removeGroup(ix, l);
+ group->deleteLater();
+}
+
+void EffectStackView2::slotRenameGroup(CollapsibleGroup *group)
+{
+ QList <CollapsibleEffect*> effects = group->effects();
+ for (int i = 0; i < effects.count(); ++i) {
+ QDomElement origin = effects.at(i)->effect();
+ QDomElement changed = origin.cloneNode().toElement();
+ changed.setAttribute("kdenlive_info", effects.at(i)->infoString());
+ if (m_effectMetaInfo.trackMode) {
+ emit updateEffect(NULL, m_trackindex, origin, changed, effects.at(i)->effectIndex(),false);
+ } else {
+ emit updateEffect(m_clipref, -1, origin, changed, effects.at(i)->effectIndex(),false);
+ }
+ }
+}
+
+void EffectStackView2::dragEnterEvent(QDragEnterEvent *event)
+{
+ if (event->mimeData()->hasFormat("kdenlive/effectslist")) {
+ event->acceptProposedAction();
+ }
+}
+
+void EffectStackView2::processDroppedEffect(QDomElement e, QDropEvent *event)
+{
+ 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) {
+ kDebug()<<"// ADDING EFFECT!!!";
+ // Adding a new group effect to the stack
+ event->setDropAction(Qt::CopyAction);
+ event->accept();
+ slotAddEffect(e);
+ return;