]> git.sesse.net Git - kdenlive/blobdiff - src/customtrackview.cpp
Fix a couple of compile warnings because of unused and uninitialized variables.
[kdenlive] / src / customtrackview.cpp
index 734b525c24a5134397f822165e2b8388b1482e59..2378a79db50ceb21aeb835ec65ec1ef0daefe452 100644 (file)
@@ -126,48 +126,46 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscen
         m_selectedTrack(0),
         m_controlModifier(false)
 {
-    if (doc) m_commandStack = doc->commandStack();
-    else m_commandStack = NULL;
+    if (doc)
+        m_commandStack = doc->commandStack();
+    else
+        m_commandStack = NULL;
+    m_ct = 0;
     setMouseTracking(true);
     setAcceptDrops(true);
     setFrameShape(QFrame::NoFrame);
     setLineWidth(0);
     //setCacheMode(QGraphicsView::CacheBackground);
-    //setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
     setAutoFillBackground(false);
     setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
+    setContentsMargins(0, 0, 0, 0);
+
     m_activeTrackBrush = KStatefulBrush(KColorScheme::View, KColorScheme::ActiveBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
-    pixmapCache = new KPixmapCache("kdenlive-thumbs");
-    KdenliveSettings::setTrackheight(m_tracksHeight);
+
     m_animationTimer = new QTimeLine(800);
     m_animationTimer->setFrameRange(0, 5);
     m_animationTimer->setUpdateInterval(100);
     m_animationTimer->setLoopCount(0);
+
     m_tipColor = QColor(0, 192, 0, 200);
-    QColor border = QColor(255, 255, 255, 100);
-    m_tipPen.setColor(border);
+    m_tipPen.setColor(QColor(255, 255, 255, 100));
     m_tipPen.setWidth(3);
-    setContentsMargins(0, 0, 0, 0);
+
     const int maxHeight = m_tracksHeight * m_document->tracksCount();
     setSceneRect(0, 0, sceneRect().width(), maxHeight);
     verticalScrollBar()->setMaximum(maxHeight);
+    verticalScrollBar()->setTracking(true);
+    // repaint guides when using vertical scroll
+    connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(slotRefreshGuides()));
+
     m_cursorLine = projectscene->addLine(0, 0, 0, maxHeight);
     m_cursorLine->setZValue(1000);
-
     QPen pen1 = QPen();
     pen1.setWidth(1);
     pen1.setColor(palette().text().color());
     m_cursorLine->setPen(pen1);
     m_cursorLine->setFlag(QGraphicsItem::ItemIgnoresTransformations, true);
 
-    KIcon razorIcon("edit-cut");
-    m_razorCursor = QCursor(razorIcon.pixmap(22, 22));
-
-    KIcon spacerIcon("kdenlive-spacer-tool");
-    m_spacerCursor = QCursor(spacerIcon.pixmap(22, 22));
-    verticalScrollBar()->setTracking(true);
-    // Line below was supposed to scroll guides label with scrollbar, not implemented yet
-    //connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(slotRefreshGuides()));
     connect(&m_scrollTimer, SIGNAL(timeout()), this, SLOT(slotCheckMouseScrolling()));
     m_scrollTimer.setInterval(100);
     m_scrollTimer.setSingleShot(true);
@@ -176,8 +174,11 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscen
     m_thumbsTimer.setInterval(500);
     m_thumbsTimer.setSingleShot(true);
 
-    // repaint guides when using vertical scroll
-    connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(slotRefreshGuides()));
+    KIcon razorIcon("edit-cut");
+    m_razorCursor = QCursor(razorIcon.pixmap(22, 22));
+
+    KIcon spacerIcon("kdenlive-spacer-tool");
+    m_spacerCursor = QCursor(spacerIcon.pixmap(22, 22));
 }
 
 CustomTrackView::~CustomTrackView()
@@ -185,6 +186,7 @@ CustomTrackView::~CustomTrackView()
     qDeleteAll(m_guides);
     m_guides.clear();
     m_waitingThumbs.clear();
+    delete m_animationTimer;
 }
 
 //virtual
@@ -331,7 +333,7 @@ void CustomTrackView::slotFetchNextThumbs()
 {
     if (!m_waitingThumbs.isEmpty()) {
         ClipItem *item = m_waitingThumbs.takeFirst();
-        while ((item == NULL) && !m_waitingThumbs.isEmpty()) {
+        while (item == NULL && !m_waitingThumbs.isEmpty()) {
             item = m_waitingThumbs.takeFirst();
         }
         if (item) item->slotFetchThumbs();
@@ -370,6 +372,7 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
 {
     int pos = event->x();
     int mappedXPos = qMax((int)(mapToScene(event->pos()).x() + 0.5), 0);
+   
     double snappedPos = getSnapPointForPos(mappedXPos);
     emit mousePosition(mappedXPos);
 
@@ -591,11 +594,14 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
         }
         m_moveOpMode = opMode;
         setTipAnimation(clip, opMode, size);
+        ClipItem *ci = NULL;
+        if (item->type() == AVWIDGET)
+            ci = static_cast <ClipItem *>(item);
+        QString message;
         if (opMode == MOVE) {
             setCursor(Qt::OpenHandCursor);
-            if (item->type() == AVWIDGET) {
-                ClipItem *ci = static_cast <ClipItem *>(item);
-                QString message = ci->clipName() + i18n(":");
+            if (ci) {
+                message = ci->clipName() + i18n(":");
                 message.append(i18n(" Position:") + m_document->timecode().getDisplayTimecode(ci->info().startPos, KdenliveSettings::frametimecode()));
                 message.append(i18n(" Duration:") + m_document->timecode().getDisplayTimecode(ci->cropDuration(),  KdenliveSettings::frametimecode()));
                 if (clip->parentItem() && clip->parentItem()->type() == GROUPWIDGET) {
@@ -610,26 +616,40 @@ void CustomTrackView::mouseMoveEvent(QMouseEvent * event)
                         message.append(i18n(" Selection duration:") + m_document->timecode().getDisplayTimecode(parent2->duration(), KdenliveSettings::frametimecode()));
                     }
                 }
-                emit displayMessage(message, InformationMessage);
             }
         } else if (opMode == RESIZESTART) {
             setCursor(KCursor("left_side", Qt::SizeHorCursor));
+            if (ci)
+                message = i18n("Crop from start: ") + m_document->timecode().getDisplayTimecode(ci->cropStart(), KdenliveSettings::frametimecode());
             if (item->type() == AVWIDGET && item->parentItem() && item->parentItem() != m_selectionGroup)
-                emit displayMessage(i18n("Use Ctrl to resize only current item, otherwise all items in this group will be resized at once."), InformationMessage);
+                message.append(i18n("Use Ctrl to resize only current item, otherwise all items in this group will be resized at once."));
         } else if (opMode == RESIZEEND) {
             setCursor(KCursor("right_side", Qt::SizeHorCursor));
+            if (ci)
+                message = i18n("Duration: ") + m_document->timecode().getDisplayTimecode(ci->cropDuration(), KdenliveSettings::frametimecode());
             if (item->type() == AVWIDGET && item->parentItem() && item->parentItem() != m_selectionGroup)
-                emit displayMessage(i18n("Use Ctrl to resize only current item, otherwise all items in this group will be resized at once."), InformationMessage);
+                message.append(i18n("Use Ctrl to resize only current item, otherwise all items in this group will be resized at once."));
         } else if (opMode == FADEIN || opMode == FADEOUT) {
             setCursor(Qt::PointingHandCursor);
-            emit displayMessage(i18n("Drag to add or resize a fade effect."), InformationMessage);
+            if (ci && opMode == FADEIN && ci->fadeIn()) {
+                message = i18n("Fade in duration: ");
+                message.append(m_document->timecode().getDisplayTimecodeFromFrames(ci->fadeIn(), KdenliveSettings::frametimecode()));
+            } else if (ci && opMode == FADEOUT && ci->fadeOut()) {
+                message = i18n("Fade out duration: ");
+                message.append(m_document->timecode().getDisplayTimecodeFromFrames(ci->fadeOut(), KdenliveSettings::frametimecode()));
+            } else {
+                message = i18n("Drag to add or resize a fade effect.");
+            }
         } else if (opMode == TRANSITIONSTART || opMode == TRANSITIONEND) {
             setCursor(Qt::PointingHandCursor);
-            emit displayMessage(i18n("Click to add a transition."), InformationMessage);
+            message = i18n("Click to add a transition.");
         } else if (opMode == KEYFRAME) {
             setCursor(Qt::PointingHandCursor);
             emit displayMessage(i18n("Move keyframe above or below clip to remove it, double click to add a new one."), InformationMessage);
         }
+
+        if (!message.isEmpty())
+            emit displayMessage(message, InformationMessage);
     } // no clip under mouse
     else if (m_tool == RAZORTOOL) {
         event->accept();
@@ -681,7 +701,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
 
     m_blockRefresh = true;
     m_dragGuide = NULL;
-    bool collision = false;
 
     if (m_tool != RAZORTOOL) activateMonitor();
     else if (m_document->renderer()->playSpeed() != 0.0) {
@@ -709,7 +728,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
             m_dragGuide = (Guide *) collisionList.at(i);
             if (event->button() == Qt::LeftButton) { // move it
                 m_dragGuide->setFlag(QGraphicsItem::ItemIsMovable, true);
-                collision = true;
                 m_operationMode = MOVEGUIDE;
                 // deselect all clips so that only the guide will move
                 m_scene->clearSelection();
@@ -922,7 +940,6 @@ void CustomTrackView::mousePressEvent(QMouseEvent * event)
         } else resetSelectionGroup();
         dragGroup = NULL;
         if (m_dragItem->parentItem() && m_dragItem->parentItem()->type() == GROUPWIDGET) {
-            //kDebug()<<"// KLIK FOUND GRP: "<<m_dragItem->sceneBoundingRect();
             dragGroup = static_cast <AbstractGroupItem *>(m_dragItem->parentItem());
         }
         bool selected = !m_dragItem->isSelected();
@@ -1115,6 +1132,7 @@ void CustomTrackView::resetSelectionGroup(bool selectItems)
                 children.at(i)->setSelected(selectItems);
             }
         }
+
         m_selectionGroup = NULL;
         KdenliveSettings::setSnaptopoints(snap);
     }
@@ -1296,30 +1314,43 @@ void CustomTrackView::editItemDuration()
                 clipInfo.endPos = clipInfo.startPos + d.duration();
                 clipInfo.track = item->track();
                 MoveTransitionCommand *command = new MoveTransitionCommand(this, startInfo, clipInfo, true);
+                updateTrackDuration(clipInfo.track, command);
                 m_commandStack->push(command);
             } else {
                 // move and resize clip
+                ClipItem *clip = static_cast<ClipItem *>(item);
                 QUndoCommand *moveCommand = new QUndoCommand();
                 moveCommand->setText(i18n("Edit clip"));
                 if (d.duration() < item->cropDuration() || d.cropStart() != clipInfo.cropStart) {
                     // duration was reduced, so process it first
                     clipInfo.endPos = clipInfo.startPos + d.duration();
                     clipInfo.cropStart = d.cropStart();
-                    new ResizeClipCommand(this, startInfo, clipInfo, true, false, moveCommand);
+
+                    resizeClip(startInfo, clipInfo);
+                    new ResizeClipCommand(this, startInfo, clipInfo, false, true, moveCommand);
+                    adjustEffects(clip, startInfo, moveCommand);
+                    new ResizeClipCommand(this, startInfo, clipInfo, false, true, moveCommand);
                 }
+
                 if (d.startPos() != clipInfo.startPos) {
                     startInfo = clipInfo;
                     clipInfo.startPos = d.startPos();
                     clipInfo.endPos = item->endPos() + (clipInfo.startPos - startInfo.startPos);
                     new MoveClipCommand(this, startInfo, clipInfo, true, moveCommand);
                 }
+
                 if (d.duration() > item->cropDuration()) {
                     // duration was increased, so process it after move
                     startInfo = clipInfo;
                     clipInfo.endPos = clipInfo.startPos + d.duration();
                     clipInfo.cropStart = d.cropStart();
-                    new ResizeClipCommand(this, startInfo, clipInfo, true, false, moveCommand);
+
+                    resizeClip(startInfo, clipInfo);
+                    new ResizeClipCommand(this, startInfo, clipInfo, false, true, moveCommand);
+                    adjustEffects(clip, startInfo, moveCommand);
+                    new ResizeClipCommand(this, startInfo, clipInfo, false, true, moveCommand);
                 }
+                updateTrackDuration(clipInfo.track, moveCommand);
                 m_commandStack->push(moveCommand);
             }
         }
@@ -1404,6 +1435,7 @@ void CustomTrackView::insertClipCut(DocClipBase *clip, int in, int out)
     }
 
     AddTimelineClipCommand *command = new AddTimelineClipCommand(this, clip->toXML(), clip->getId(), pasteInfo, EffectsList(), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT, true, false);
+    updateTrackDuration(pasteInfo.track, command);
     m_commandStack->push(command);
 
     selectClip(true, false);
@@ -1424,6 +1456,10 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
             kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << list.at(0);
             return false;
         }
+        if (clip->producer() == NULL) {
+            emit displayMessage(i18n("Clip not ready"), ErrorMessage);
+            return false;
+        }
         QPointF framePos = mapToScene(pos);
         ItemInfo info;
         info.startPos = GenTime();
@@ -1475,6 +1511,10 @@ bool CustomTrackView::insertDropClips(const QMimeData *data, const QPoint pos)
                 kDebug() << " WARNING))))))))) CLIP NOT FOUND : " << ids.at(i);
                 return false;
             }
+            if (clip->producer() == NULL) {
+                emit displayMessage(i18n("Clip not ready"), ErrorMessage);
+                return false;
+            }
             ItemInfo info;
             info.startPos = start;
             info.cropDuration = clip->duration();
@@ -1661,11 +1701,14 @@ void CustomTrackView::slotAddGroupEffect(QDomElement effect, AbstractGroupItem *
                 continue;
             }
             item->initEffect(effect);
+
+            // Old LADSPA filter, deprecated
+            /*
             if (effect.attribute("tag") == "ladspa") {
                 QString ladpsaFile = m_document->getLadspaFile();
                 initEffects::ladspaEffectFile(ladpsaFile, effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
                 effect.setAttribute("src", ladpsaFile);
-            }
+            }*/
             new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), effect, true, effectCommand);
             count++;
         }
@@ -1738,12 +1781,13 @@ void CustomTrackView::slotAddEffect(QDomElement effect, GenTime pos, int track)
             } else {
                 item->initEffect(effect);
             }
-
-            if (effect.attribute("tag") == "ladspa") {
+            // Old LADSPA filter, deprecated
+            /* if (effect.attribute("tag") == "ladspa") {
                 QString ladpsaFile = m_document->getLadspaFile();
                 initEffects::ladspaEffectFile(ladpsaFile, effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
                 effect.setAttribute("src", ladpsaFile);
             }
+            */
             new AddEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), effect, true, effectCommand);
         }
     }
@@ -1807,8 +1851,11 @@ void CustomTrackView::slotDeleteEffect(ClipItem *clip, int track, QDomElement ef
                 }
             }
         }
-        if (delCommand->childCount() > 0) m_commandStack->push(delCommand);
-        else delete delCommand;
+        if (delCommand->childCount() > 0)
+            m_commandStack->push(delCommand);
+        else
+            delete delCommand;
+        setDocumentModified();
         return;
     }
     AddEffectCommand *command = new AddEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effect, false);
@@ -1827,15 +1874,16 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
     if (pos < GenTime()) {
         // editing a track effect
         EffectsParameterList effectParams = getEffectArgs(effect);
-        if (effect.attribute("tag") == "ladspa") {
+        // Old LADSPA filter, deprecated
+        /*if (effect.attribute("tag") == "ladspa") {
             // Update the ladspa affect file
             initEffects::ladspaEffectFile(effect.attribute("src"), effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
-        }
+        }*/
         // check if we are trying to reset a keyframe effect
-        if (effectParams.hasParam("keyframes") && effectParams.paramValue("keyframes").isEmpty()) {
-            //clip->initEffect(effect);
+        /*if (effectParams.hasParam("keyframes") && effectParams.paramValue("keyframes").isEmpty()) {
+            clip->initEffect(effect);
             effectParams = getEffectArgs(effect);
-        }
+        }*/
         if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - track, pos, effectParams))
             emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
         m_document->setTrackEffect(m_document->tracksCount() - track - 1, ix, effect);
@@ -1848,8 +1896,9 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
     if (clip) {
         // Special case: speed effect
         if (effect.attribute("id") == "speed") {
-            if (effect.attribute("disable") == "1") doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
-            else {
+            if (effect.attribute("disable") == "1") {
+                doChangeClipSpeed(clip->info(), clip->speedIndependantInfo(), 1.0, clip->speed(), 1, clip->baseClip()->getId());
+            } else {
                 double speed = EffectsList::parameter(effect, "speed").toDouble() / 100.0;
                 int strobe = EffectsList::parameter(effect, "strobe").toInt();
                 if (strobe == 0) strobe = 1;
@@ -1858,29 +1907,24 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
             clip->setEffectAt(ix, effect);
             if (ix == clip->selectedEffectIndex()) {
                 clip->setSelectedEffect(ix);
-                if (!triggeredByUser) emit clipItemSelected(clip, ix);
+                if (!triggeredByUser)
+                    emit clipItemSelected(clip, ix);
             }
             return;
         }
 
         EffectsParameterList effectParams = getEffectArgs(effect);
-        if (effect.attribute("tag") == "ladspa") {
+        // Old LADSPA filter, deprecated
+        /*if (effect.attribute("tag") == "ladspa") {
             // Update the ladspa affect file
             initEffects::ladspaEffectFile(effect.attribute("src"), effect.attribute("ladspaid").toInt(), getLadspaParams(effect));
-        }
+        }*/
         // check if we are trying to reset a keyframe effect
         if (effectParams.hasParam("keyframes") && effectParams.paramValue("keyframes").isEmpty()) {
             clip->initEffect(effect);
             effectParams = getEffectArgs(effect);
         }
-        if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - clip->track(), clip->startPos(), effectParams))
-            emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
 
-        clip->setEffectAt(ix, effect);
-        if (ix == clip->selectedEffectIndex()) {
-            clip->setSelectedEffect(ix);
-            if (!triggeredByUser) emit clipItemSelected(clip, ix);
-        }
         if (effect.attribute("tag") == "volume" || effect.attribute("tag") == "brightness") {
             // A fade effect was modified, update the clip
             if (effect.attribute("id") == "fadein" || effect.attribute("id") == "fade_from_black") {
@@ -1892,6 +1936,16 @@ void CustomTrackView::updateEffect(int track, GenTime pos, QDomElement insertedE
                 clip->setFadeOut(pos);
             }
         }
+
+        if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - clip->track(), clip->startPos(), effectParams))
+            emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
+
+        clip->setEffectAt(ix, effect);
+        if (ix == clip->selectedEffectIndex()) {
+            clip->setSelectedEffect(ix);
+            if (!triggeredByUser)
+                emit clipItemSelected(clip, ix);
+        }
     }
     setDocumentModified();
 }
@@ -1991,8 +2045,6 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo
             return NULL;
         }
 
-        kDebug() << "/////////  CUTTING CLIP : (" << item->startPos().frames(25) << "-" << item->endPos().frames(25) << "), INFO: (" << info.startPos.frames(25) << "-" << info.endPos.frames(25) << ")" << ", CUT: " << cutTime.frames(25);
-
         if (execute) m_document->renderer()->mltCutClip(m_document->tracksCount() - info.track, cutTime);
         int cutPos = (int) cutTime.frames(m_document->fps());
         ItemInfo newPos;
@@ -2005,17 +2057,32 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo
         bool snap = KdenliveSettings::snaptopoints();
         KdenliveSettings::setSnaptopoints(false);
         ClipItem *dup = item->clone(newPos);
-        // remove unwanted effects (fade in) from 2nd part of cutted clip
+
+        // remove unwanted effects
+        // fade in from 2nd part of the clip
         int ix = dup->hasEffect(QString(), "fadein");
         if (ix != -1) {
-            QDomElement oldeffect = item->effectAt(ix);
+            QDomElement oldeffect = dup->effectAt(ix);
             dup->deleteEffect(oldeffect.attribute("kdenlive_ix"));
         }
         ix = dup->hasEffect(QString(), "fade_from_black");
         if (ix != -1) {
-            QDomElement oldeffect = item->effectAt(ix);
+            QDomElement oldeffect = dup->effectAt(ix);
             dup->deleteEffect(oldeffect.attribute("kdenlive_ix"));
         }
+        // fade out from 1st part of the clip
+        ix = item->hasEffect(QString(), "fadeout");
+        if (ix != -1) {
+            QDomElement oldeffect = item->effectAt(ix);
+            item->deleteEffect(oldeffect.attribute("kdenlive_ix"));
+        }
+        ix = item->hasEffect(QString(), "fade_to_black");
+        if (ix != -1) {
+            QDomElement oldeffect = item->effectAt(ix);
+            item->deleteEffect(oldeffect.attribute("kdenlive_ix"));
+        }
+
+
         item->resizeEnd(cutPos);
         scene()->addItem(dup);
         if (item->checkKeyFrames())
@@ -2023,15 +2090,13 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo
         if (dup->checkKeyFrames())
             slotRefreshEffects(dup);
 
-        updatePanZoom(item);
-        updatePanZoom(dup, cutTime - item->startPos());
-
         item->baseClip()->addReference();
         m_document->updateClip(item->baseClip()->getId());
         setDocumentModified();
         KdenliveSettings::setSnaptopoints(snap);
+        if (execute && item->isSelected())
+            emit clipItemSelected(item);
         return dup;
-        //kDebug() << "/////////  CUTTING CLIP RESULT: (" << item->startPos().frames(25) << "-" << item->endPos().frames(25) << "), DUP: (" << dup->startPos().frames(25) << "-" << dup->endPos().frames(25) << ")" << ", CUT: " << cutTime.frames(25);
     } else {
         // uncut clip
 
@@ -2048,33 +2113,46 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo
             return NULL;
         }
 
-        /*kDebug() << "// UNCUTTING CLIPS: ITEM 1 (" << item->startPos().frames(25) << "x" << item->endPos().frames(25) << ")";
-        kDebug() << "// UNCUTTING CLIPS: ITEM 2 (" << dup->startPos().frames(25) << "x" << dup->endPos().frames(25) << ")";
-        kDebug() << "// UNCUTTING CLIPS, INFO (" << info.startPos.frames(25) << "x" << info.endPos.frames(25) << ") , CUT: " << cutTime.frames(25);;*/
-        //deleteClip(dup->info());
-
         bool snap = KdenliveSettings::snaptopoints();
         KdenliveSettings::setSnaptopoints(false);
 
-        if (dup->isSelected()) emit clipItemSelected(NULL);
+        // join fade effects again
+        int ix = dup->hasEffect(QString(), "fadeout");
+        if (ix != -1) {
+            QDomElement effect = dup->effectAt(ix);
+            item->addEffect(effect);
+        }
+        ix = dup->hasEffect(QString(), "fade_to_black");
+        if (ix != -1) {
+            QDomElement effect = dup->effectAt(ix);
+            item->addEffect(effect);
+        }
+
+        m_waitingThumbs.removeAll(dup);
+        bool selected = item->isSelected();
+        if (dup->isSelected()) {
+            selected = true;
+            item->setSelected(true);
+            emit clipItemSelected(NULL);
+        }
         dup->baseClip()->removeReference();
         m_document->updateClip(dup->baseClip()->getId());
         scene()->removeItem(dup);
         delete dup;
+        dup = NULL;
 
         ItemInfo clipinfo = item->info();
         clipinfo.track = m_document->tracksCount() - clipinfo.track;
         bool success = m_document->renderer()->mltResizeClipEnd(clipinfo, info.endPos - info.startPos);
         if (success) {
             item->resizeEnd((int) info.endPos.frames(m_document->fps()));
-
-            updatePanZoom(item);
-
             setDocumentModified();
         } else {
             emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
         }
         KdenliveSettings::setSnaptopoints(snap);
+        if (execute && selected)
+            emit clipItemSelected(item);
         return item;
     }
     //QTimer::singleShot(3000, this, SLOT(slotEnableRefresh()));
@@ -2227,6 +2305,7 @@ void CustomTrackView::slotTransitionUpdated(Transition *tr, QDomElement old)
         return;
     }
     EditTransitionCommand *command = new EditTransitionCommand(this, tr->track(), tr->startPos(), old, xml, false);
+    updateTrackDuration(tr->track(), command);
     m_commandStack->push(command);
     setDocumentModified();
 }
@@ -2238,6 +2317,7 @@ void CustomTrackView::updateTransition(int track, GenTime pos, QDomElement oldTr
         kWarning() << "Unable to find transition at pos :" << pos.frames(m_document->fps()) << ", ON track: " << track;
         return;
     }
+    
     bool force = false;
     if (oldTransition.attribute("transition_atrack") != transition.attribute("transition_atrack") || oldTransition.attribute("transition_btrack") != transition.attribute("transition_btrack"))
         force = true;
@@ -2331,6 +2411,7 @@ void CustomTrackView::dropEvent(QDropEvent * event)
             adjustTimelineClips(m_scene->editMode(), item, ItemInfo(), addCommand);
 
             new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), item->effectList(), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT, false, false, addCommand);
+            updateTrackDuration(info.track, addCommand);
 
             if (item->baseClip()->isTransparent() && getTransitionItemAtStart(info.startPos, info.track) == NULL) {
                 // add transparency transition
@@ -2372,7 +2453,7 @@ void CustomTrackView::dropEvent(QDropEvent * event)
             groupSelectedItems(true);
         } else if (items.count() == 1) {
             m_dragItem = static_cast <AbstractClipItem *>(items.at(0));
-            emit clipItemSelected((ClipItem*)m_dragItem);
+            emit clipItemSelected((ClipItem*)m_dragItem, -1, false);
         }
         event->setDropAction(Qt::MoveAction);
         event->accept();
@@ -2421,6 +2502,7 @@ void CustomTrackView::adjustTimelineClips(EDITMODE mode, ClipItem *item, ItemInf
                     }
                 } else if (clip->endPos() <= info.endPos) {
                     new AddTimelineClipCommand(this, clip->xml(), clip->clipProducer(), clip->info(), clip->effectList(), false, false, false, true, command);
+                    m_waitingThumbs.removeAll(clip);
                     scene()->removeItem(clip);
                     delete clip;
                     clip = NULL;
@@ -2650,9 +2732,9 @@ void CustomTrackView::removeTrack(int ix)
             clip->updateItem();
             ItemInfo clipinfo = clip->info();
             // We add a move clip command so that we get the correct producer for new track number
-            if (clip->clipType() == AV || clip->clipType() == AUDIO) {
+            if (clip->clipType() == AV || clip->clipType() == AUDIO || clip->clipType() == PLAYLIST) {
                 Mlt::Producer *prod = clip->getProducer(clipinfo.track);
-                if (!m_document->renderer()->mltUpdateClipProducer((int)(m_document->tracksCount() - clipinfo.track), clipinfo.startPos.frames(m_document->fps()), prod)) {
+                if (prod == NULL || !m_document->renderer()->mltUpdateClipProducer((int)(m_document->tracksCount() - clipinfo.track), clipinfo.startPos.frames(m_document->fps()), prod)) {
                     emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", clipinfo.startPos.frames(m_document->fps()), clipinfo.track), ErrorMessage);
                 }
             }
@@ -2871,6 +2953,7 @@ void CustomTrackView::slotRemoveSpace()
     }
 
     InsertSpaceCommand *command = new InsertSpaceCommand(this, clipsToMove, transitionsToMove, track, GenTime(-length, m_document->fps()), true);
+    updateTrackDuration(track, command);
     m_commandStack->push(command);
 }
 
@@ -2890,7 +2973,7 @@ void CustomTrackView::slotInsertSpace()
     track = d.selectedTrack();
 
     QList<QGraphicsItem *> items;
-    if (track > 0) {
+    if (track >= 0) {
         if (m_document->isTrackLocked(m_document->tracksCount() - track - 1)) {
             emit displayMessage(i18n("Cannot insert space in a locked track"), ErrorMessage);
             return;
@@ -2929,6 +3012,7 @@ void CustomTrackView::slotInsertSpace()
 
     if (!clipsToMove.isEmpty() || !transitionsToMove.isEmpty()) {
         InsertSpaceCommand *command = new InsertSpaceCommand(this, clipsToMove, transitionsToMove, track, spaceDuration, true);
+        updateTrackDuration(track, command);
         m_commandStack->push(command);
     }
 }
@@ -3023,8 +3107,12 @@ void CustomTrackView::deleteClip(const QString &clipId)
         }
     }
     deleteCommand->setText(i18np("Delete timeline clip", "Delete timeline clips", count));
-    if (count == 0) delete deleteCommand;
-    else m_commandStack->push(deleteCommand);
+    if (count == 0) {
+        delete deleteCommand;
+    } else {
+        updateTrackDuration(-1, deleteCommand);
+        m_commandStack->push(deleteCommand);
+    }
 }
 
 void CustomTrackView::setCursorPos(int pos, bool seek)
@@ -3032,7 +3120,7 @@ void CustomTrackView::setCursorPos(int pos, bool seek)
     if (pos == m_cursorPos) return;
     emit cursorMoved((int)(m_cursorPos), (int)(pos));
     m_cursorPos = pos;
-    if (seek) m_document->renderer()->seek(GenTime(m_cursorPos, m_document->fps()));
+    if (seek) m_document->renderer()->seek(m_cursorPos);
     else if (m_autoScroll) checkScrolling();
     m_cursorLine->setPos(m_cursorPos, 0);
 }
@@ -3053,7 +3141,7 @@ void CustomTrackView::moveCursorPos(int delta)
     emit cursorMoved((int)(m_cursorPos), (int)((m_cursorPos + delta)));
     m_cursorPos += delta;
     m_cursorLine->setPos(m_cursorPos, 0);
-    m_document->renderer()->seek(GenTime(m_cursorPos, m_document->fps()));
+    m_document->renderer()->seek(m_cursorPos);
 }
 
 void CustomTrackView::initCursorPos(int pos)
@@ -3144,6 +3232,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
             }
             if (!clipsToMove.isEmpty() || !transitionsToMove.isEmpty()) {
                 InsertSpaceCommand *command = new InsertSpaceCommand(this, clipsToMove, transitionsToMove, track, timeOffset, false);
+                updateTrackDuration(track, command);
                 m_commandStack->push(command);
                 if (track != -1) track = m_document->tracksCount() - track;
                 kDebug() << "SPACER TRACK:" << track;
@@ -3154,7 +3243,6 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
         resetSelectionGroup(false);
         m_operationMode = NONE;
     } else if (m_operationMode == RUBBERSELECTION) {
-        //kDebug() << "// END RUBBER SELECT";
         resetSelectionGroup();
         groupSelectedItems();
         m_operationMode = NONE;
@@ -3284,6 +3372,9 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
                             }
                         }
                     }
+                    updateTrackDuration(info.track, moveCommand);
+                    if (m_dragItemInfo.track != info.track)
+                        updateTrackDuration(m_dragItemInfo.track, moveCommand);
                     m_commandStack->push(moveCommand);
                     //checkTrackSequence(m_dragItem->track());
                 } else {
@@ -3307,6 +3398,9 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
                     moveCommand->setText(i18n("Move transition"));
                     adjustTimelineTransitions(m_scene->editMode(), transition, moveCommand);
                     new MoveTransitionCommand(this, m_dragItemInfo, info, false, moveCommand);
+                    updateTrackDuration(info.track, moveCommand);
+                    if (m_dragItemInfo.track != info.track)
+                        updateTrackDuration(m_dragItemInfo.track, moveCommand);
                     m_commandStack->push(moveCommand);
                     setDocumentModified();
                 }
@@ -3326,7 +3420,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
 
             GenTime timeOffset = GenTime(m_dragItem->scenePos().x(), m_document->fps()) - m_dragItemInfo.startPos;
             const int trackOffset = (int)(m_dragItem->scenePos().y() / m_tracksHeight) - m_dragItemInfo.track;
-            //kDebug() << "// MOVED SEVERAL CLIPS" << timeOffset.frames(25);
+
             QUndoCommand *moveGroup = new QUndoCommand();
             moveGroup->setText(i18n("Move group"));
             if (timeOffset != GenTime() || trackOffset != 0) {
@@ -3373,9 +3467,10 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
 
                     if (item->type() == AVWIDGET) {
                         ClipItem *clip = static_cast <ClipItem*>(item);
+                        int trackProducer = info.track;
                         info.track = m_document->tracksCount() - info.track;
                         adjustTimelineClips(m_scene->editMode(), clip, ItemInfo(), moveGroup);
-                        m_document->renderer()->mltInsertClip(info, clip->xml(), clip->getProducer(info.track), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT);
+                        m_document->renderer()->mltInsertClip(info, clip->xml(), clip->getProducer(trackProducer), m_scene->editMode() == OVERWRITEEDIT, m_scene->editMode() == INSERTEDIT);
                         for (int i = 0; i < clip->effectsCount(); i++) {
                             m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(clip->effectAt(i)), false);
                         }
@@ -3391,6 +3486,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
                     }
                 }
                 new MoveGroupCommand(this, clipsToMove, transitionsToMove, timeOffset, trackOffset, false, moveGroup);
+                updateTrackDuration(-1, moveGroup);
                 m_commandStack->push(moveGroup);
 
                 //QPointF top = group->sceneBoundingRect().topLeft();
@@ -3416,6 +3512,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
                                 items.at(i)->parentItem()->setSelected(true);
                         }
                     }
+                    resetSelectionGroup();
                     groupSelectedItems();
                 } else {
                     rebuildGroup((AbstractGroupItem *)group);
@@ -3467,6 +3564,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
                         ++itemcount;
                     }
                 }
+                updateTrackDuration(-1, resizeCommand);
                 m_commandStack->push(resizeCommand);
             }
         } else {
@@ -3611,11 +3709,18 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
 void CustomTrackView::deleteClip(ItemInfo info, bool refresh)
 {
     ClipItem *item = getClipItemAt((int) info.startPos.frames(m_document->fps()), info.track);
-
+    m_ct++;
+    if (!item) kDebug()<<"// PROBLEM FINDING CLIP ITEM TO REMOVVE!!!!!!!!!";
+    else kDebug()<<"// deleting CLIP: "<<info.startPos.frames(m_document->fps())<<", "<<item->baseClip()->fileURL();
+    //m_document->renderer()->saveSceneList(QString("/tmp/error%1.mlt").arg(m_ct), QDomElement());
     if (!item || m_document->renderer()->mltRemoveClip(m_document->tracksCount() - info.track, info.startPos) == false) {
         emit displayMessage(i18n("Error removing clip at %1 on track %2", m_document->timecode().getTimecodeFromFrames(info.startPos.frames(m_document->fps())), info.track), ErrorMessage);
+        kDebug()<<"CANNOT REMOVE: "<<info.startPos.frames(m_document->fps())<<", TK: "<<info.track;
+        //m_document->renderer()->saveSceneList(QString("/tmp/error%1.mlt").arg(m_ct), QDomElement());
+        exit(1);
         return;
     }
+    m_waitingThumbs.removeAll(item);
     if (item->isSelected()) emit clipItemSelected(NULL);
     item->baseClip()->removeReference();
     m_document->updateClip(item->baseClip()->getId());
@@ -3629,8 +3734,9 @@ void CustomTrackView::deleteClip(ItemInfo info, bool refresh)
             delete tr;
         }
     }*/
-    m_waitingThumbs.removeAll(item);
+
     if (m_dragItem == item) m_dragItem = NULL;
+
 #if QT_VERSION >= 0x040600
     // animate item deletion
     item->closeAnimation();
@@ -3661,7 +3767,6 @@ void CustomTrackView::deleteSelectedClips()
     scene()->clearSelection();
     QUndoCommand *deleteSelected = new QUndoCommand();
 
-    bool resetGroup = false;
     int groupCount = 0;
     int clipCount = 0;
     int transitionCount = 0;
@@ -3672,7 +3777,6 @@ void CustomTrackView::deleteSelectedClips()
             QList<QGraphicsItem *> children = itemList.at(i)->childItems();
             QList <ItemInfo> clipInfos;
             QList <ItemInfo> transitionInfos;
-            GenTime currentPos = GenTime(m_cursorPos, m_document->fps());
             for (int j = 0; j < children.count(); j++) {
                 if (children.at(j)->type() == AVWIDGET) {
                     AbstractClipItem *clip = static_cast <AbstractClipItem *>(children.at(j));
@@ -3698,7 +3802,6 @@ void CustomTrackView::deleteSelectedClips()
         if (itemList.at(i)->type() == AVWIDGET) {
             clipCount++;
             ClipItem *item = static_cast <ClipItem *>(itemList.at(i));
-            if (item->parentItem()) resetGroup = true;
             //kDebug()<<"// DELETE CLP AT: "<<item->info().startPos.frames(25);
             new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), item->effectList(), false, false, true, true, deleteSelected);
             emit clipItemSelected(NULL);
@@ -3706,7 +3809,6 @@ void CustomTrackView::deleteSelectedClips()
             transitionCount++;
             Transition *item = static_cast <Transition *>(itemList.at(i));
             //kDebug()<<"// DELETE TRANS AT: "<<item->info().startPos.frames(25);
-            if (item->parentItem()) resetGroup = true;
             new AddTransitionCommand(this, item->info(), item->transitionEndTrack(), item->toXML(), true, true, deleteSelected);
             emit transitionItemSelected(NULL);
         }
@@ -3718,6 +3820,7 @@ void CustomTrackView::deleteSelectedClips()
     else if (transitionCount > 0 && groupCount == 0 && clipCount == 0)
         deleteSelected->setText(i18np("Delete selected transition", "Delete selected transitions", transitionCount));
     else deleteSelected->setText(i18n("Delete selected items"));
+    updateTrackDuration(-1, deleteSelected);
     m_commandStack->push(deleteSelected);
 }
 
@@ -3736,7 +3839,6 @@ void CustomTrackView::changeClipSpeed()
     for (int i = 0; i < itemList.count(); i++) {
         if (itemList.at(i)->type() == AVWIDGET) {
             ClipItem *item = static_cast <ClipItem *>(itemList.at(i));
-            ItemInfo info = item->info();
             if (percent == -1) percent = QInputDialog::getInteger(this, i18n("Edit Clip Speed"), i18n("New speed (percents)"), item->speed() * 100, 1, 10000, 1, &ok);
             if (!ok) break;
             double speed = (double) percent / 100.0;
@@ -3752,7 +3854,7 @@ void CustomTrackView::changeClipSpeed()
 
 void CustomTrackView::doChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, const double speed, const double oldspeed, int strobe, const QString &id)
 {
-    Q_UNUSED(id);
+    Q_UNUSED(id)
     //DocClipBase *baseclip = m_document->clipManager()->getClipById(id);
 
     ClipItem *item = getClipItemAt((int) info.startPos.frames(m_document->fps()), info.track);
@@ -3886,7 +3988,6 @@ void CustomTrackView::groupClips(bool group)
     QList<QGraphicsItem *> itemList = scene()->selectedItems();
     QList <ItemInfo> clipInfos;
     QList <ItemInfo> transitionInfos;
-    GenTime currentPos = GenTime(m_cursorPos, m_document->fps());
 
     // Expand groups
     int max = itemList.count();
@@ -3953,7 +4054,6 @@ void CustomTrackView::doGroupClips(QList <ItemInfo> clipInfos, QList <ItemInfo>
             clip->setSelected(true);
         }
     }
-
     groupSelectedItems(false, true);
     setDocumentModified();
 }
@@ -3992,6 +4092,7 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i
     else if (xml.hasAttribute("video_only")) item->setVideoOnly(true);
     scene()->addItem(item);
 
+    int producerTrack = info.track;
     int tracknumber = m_document->tracksCount() - info.track - 1;
     bool isLocked = m_document->trackInfoAt(tracknumber).isLocked;
     if (isLocked) item->setItemLocked(true);
@@ -3999,7 +4100,7 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i
     baseclip->addReference();
     m_document->updateClip(baseclip->getId());
     info.track = m_document->tracksCount() - info.track;
-    m_document->renderer()->mltInsertClip(info, xml, item->getProducer(info.track), overwrite, push);
+    m_document->renderer()->mltInsertClip(info, xml, item->getProducer(producerTrack), overwrite, push);
     for (int i = 0; i < item->effectsCount(); i++) {
         m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(item->effectAt(i)), false);
     }
@@ -4014,21 +4115,26 @@ void CustomTrackView::addClip(QDomElement xml, const QString &clipId, ItemInfo i
 void CustomTrackView::slotUpdateClip(const QString &clipId, bool reload)
 {
     QList<QGraphicsItem *> list = scene()->items();
+    QList <ClipItem *>clipList;
     ClipItem *clip = NULL;
     for (int i = 0; i < list.size(); ++i) {
         if (list.at(i)->type() == AVWIDGET) {
             clip = static_cast <ClipItem *>(list.at(i));
             if (clip->clipProducer() == clipId) {
                 ItemInfo info = clip->info();
-                info.track = m_document->tracksCount() - clip->track();
-                if (reload && !m_document->renderer()->mltUpdateClip(info, clip->xml(), clip->baseClip()->producer())) {
+                Mlt::Producer *prod = NULL;
+                if (clip->isAudioOnly()) prod = clip->baseClip()->audioProducer(info.track);
+                else if (clip->isVideoOnly()) prod = clip->baseClip()->videoProducer();
+                else prod = clip->baseClip()->producer(info.track);
+                if (reload && !m_document->renderer()->mltUpdateClip(info, clip->xml(), prod)) {
                     emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage);
                 }
-                clip->refreshClip(true);
-                clip->update();
+                else clipList.append(clip);
             }
         }
     }
+    for (int i = 0; i < clipList.count(); i++)
+        clipList.at(i)->refreshClip(true, true);
 }
 
 ClipItem *CustomTrackView::getClipItemAtEnd(GenTime pos, int track)
@@ -4176,14 +4282,11 @@ void CustomTrackView::moveClip(const ItemInfo start, const ItemInfo end, bool re
         emit displayMessage(i18n("Cannot move clip to position %1", m_document->timecode().getTimecodeFromFrames(end.startPos.frames(m_document->fps()))), ErrorMessage);
     }
     if (refresh) m_document->renderer()->doRefresh();
-    //kDebug() << " // MOVED CLIP TO: " << end.startPos.frames(25) << ", ITEM START: " << item->startPos().frames(25);
 }
 
 void CustomTrackView::moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> startTransition, const GenTime offset, const int trackOffset, bool reverseMove)
 {
     // Group Items
-    /*kDebug() << "//GRP MOVE, REVERS:" << reverseMove;
-    kDebug() << "// GROUP MOV; OFFSET: " << offset.frames(25) << ", TK OFF: " << trackOffset;*/
     resetSelectionGroup();
     m_scene->clearSelection();
 
@@ -4196,7 +4299,6 @@ void CustomTrackView::moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> sta
             startClip[i].startPos = startClip.at(i).startPos - offset;
             startClip[i].track = startClip.at(i).track - trackOffset;
         }
-        //kDebug()<<"//LKING FR CLIP AT:"<<startClip.at(i).startPos.frames(25)<<", TK:"<<startClip.at(i).track;
         ClipItem *clip = getClipItemAt(startClip.at(i).startPos, startClip.at(i).track);
         if (clip) {
             clip->setItemLocked(false);
@@ -4267,8 +4369,9 @@ void CustomTrackView::moveGroup(QList <ItemInfo> startClip, QList <ItemInfo> sta
 
             if (item->type() == AVWIDGET) {
                 ClipItem *clip = static_cast <ClipItem*>(item);
+                int trackProducer = info.track;
                 info.track = m_document->tracksCount() - info.track;
-                m_document->renderer()->mltInsertClip(info, clip->xml(), clip->getProducer(info.track));
+                m_document->renderer()->mltInsertClip(info, clip->xml(), clip->getProducer(trackProducer));
                 for (int i = 0; i < clip->effectsCount(); i++) {
                     m_document->renderer()->mltAddEffect(info.track, info.startPos, getEffectArgs(clip->effectAt(i)), false);
                 }
@@ -4307,10 +4410,10 @@ void CustomTrackView::moveTransition(const ItemInfo start, const ItemInfo end, b
         kDebug() << "----------------  ERROR, CANNOT find transition to move... ";// << startPos.x() * m_scale * FRAME_SIZE + 1 << ", " << startPos.y() * m_tracksHeight + m_tracksHeight / 2;
         return;
     }
-    //kDebug() << "----------------  Move TRANSITION FROM: " << startPos.x() << ", END:" << endPos.x() << ",TRACKS: " << oldtrack << " TO " << newtrack;
+
     bool snap = KdenliveSettings::snaptopoints();
     KdenliveSettings::setSnaptopoints(false);
-    //kDebug()<<"///  RESIZE TRANS START: ("<< startPos.x()<<"x"<< startPos.y()<<") / ("<<endPos.x()<<"x"<< endPos.y()<<")";
+
     if (end.endPos - end.startPos == start.endPos - start.startPos) {
         // Transition was moved
         item->setPos((int) end.startPos.frames(m_document->fps()), (end.track) * m_tracksHeight + 1);
@@ -4364,23 +4467,23 @@ void CustomTrackView::resizeClip(const ItemInfo start, const ItemInfo end, bool
 
     bool snap = KdenliveSettings::snaptopoints();
     KdenliveSettings::setSnaptopoints(false);
+
     if (resizeClipStart) {
         ItemInfo clipinfo = item->info();
         clipinfo.track = m_document->tracksCount() - clipinfo.track;
         bool success = m_document->renderer()->mltResizeClipStart(clipinfo, end.startPos - clipinfo.startPos);
-        if (success) {
-            kDebug() << "RESIZE CLP STRAT TO:" << end.startPos.frames(m_document->fps()) << ", OLD ST: " << start.startPos.frames(25);
+        if (success)
             item->resizeStart((int) end.startPos.frames(m_document->fps()));
-            updatePositionEffects(item, clipinfo);
-        } else emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
+        else
+            emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
     } else {
         ItemInfo clipinfo = item->info();
         clipinfo.track = m_document->tracksCount() - clipinfo.track;
         bool success = m_document->renderer()->mltResizeClipEnd(clipinfo, end.endPos - clipinfo.startPos);
-        if (success) {
+        if (success)
             item->resizeEnd((int) end.endPos.frames(m_document->fps()));
-            updatePositionEffects(item, clipinfo);
-        } else emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
+        else
+            emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
     }
     if (!resizeClipStart && end.cropStart != start.cropStart) {
         kDebug() << "// RESIZE CROP, DIFF: " << (end.cropStart - start.cropStart).frames(25);
@@ -4452,44 +4555,16 @@ void CustomTrackView::prepareResizeClipStart(AbstractClipItem* item, ItemInfo ol
                     new MoveTransitionCommand(this, trInfo, newTrInfo, true, command);
             }
 
-            /*
-                TODO: cleanup the effect update process
-             */
             ClipItem *clip = static_cast < ClipItem * >(item);
 
-            updatePositionEffects(clip, oldInfo);
-
-            // check keyframes
-            QDomDocument doc;
-            QDomElement root = doc.createElement("list");
-            doc.appendChild(root);
-            QList <int> indexes;
-            for (int i = 0; i < clip->effectsCount(); i++) {
-                QDomElement effect = clip->effectAt(i);
-                if (EffectsList::hasKeyFrames(effect)) {
-                    doc.appendChild(doc.importNode(effect, true));
-                    indexes.append(i);
-                }
-            }
-
-            if (clip->checkEffectsKeyframesPos(oldInfo.cropStart.frames(m_document->fps()), clip->cropStart().frames(m_document->fps()), true)) {
-                // Keyframes were modified, updateClip
-                QDomNodeList effs = doc.elementsByTagName("effect");
-                // Hack:
-                // Since we must always resize clip before updating the keyframes, we
-                // put a resize command before & after checking keyframes so that
-                // we are sure the resize is performed before whenever we do or undo the action
-
-                new ResizeClipCommand(this, oldInfo, info, false, true, command);
-                for (int i = 0; i < indexes.count(); i++) {
-                    new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effs.at(i).cloneNode().toElement(), clip->effectAt(indexes.at(i)), indexes.at(i), false, command);
-                    updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(indexes.at(i)), indexes.at(i));
-                }
-                new ResizeClipCommand(this, oldInfo, info, false, true, command);
-                emit clipItemSelected(clip);
-            } else {
-                new ResizeClipCommand(this, oldInfo, info, false, false, command);
-            }
+            // Hack:
+            // Since we must always resize clip before updating the keyframes, we
+            // put a resize command before & after checking keyframes so that
+            // we are sure the resize is performed before whenever we do or undo the action
+            new ResizeClipCommand(this, oldInfo, info, false, true, command);
+            adjustEffects(clip, oldInfo, command);
+            new ResizeClipCommand(this, oldInfo, info, false, true, command);
+            emit clipItemSelected(clip);
         } else {
             KdenliveSettings::setSnaptopoints(false);
             item->resizeStart((int) oldInfo.startPos.frames(m_document->fps()));
@@ -4540,7 +4615,6 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI
         hasParentCommand = true;
     } else {
         command = new QUndoCommand();
-        command->setText(i18n("Resize clip end"));
     }
 
     // do this here, too, because otherwise undo won't update the group
@@ -4549,6 +4623,7 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI
 
     ItemInfo info = item->info();
     if (item->type() == AVWIDGET) {
+        if (!hasParentCommand) command->setText(i18n("Resize clip end"));
         ItemInfo resizeinfo = info;
         resizeinfo.track = m_document->tracksCount() - resizeinfo.track;
         bool success = m_document->renderer()->mltResizeClipEnd(resizeinfo, resizeinfo.cropDuration);
@@ -4577,39 +4652,14 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI
 
             ClipItem *clip = static_cast < ClipItem * >(item);
 
-            updatePositionEffects(clip, oldInfo);
-
-            // check keyframes
-            QDomDocument doc;
-            QDomElement root = doc.createElement("list");
-            doc.appendChild(root);
-            QList <int> indexes;
-            for (int i = 0; i < clip->effectsCount(); i++) {
-                QDomElement effect = clip->effectAt(i);
-                if (EffectsList::hasKeyFrames(effect)) {
-                    doc.appendChild(doc.importNode(effect, true));
-                    indexes.append(i);
-                }
-            }
-
-            if (clip->checkEffectsKeyframesPos((oldInfo.cropStart + oldInfo.endPos - oldInfo.startPos).frames(m_document->fps()) - 1, (clip->cropStart() + clip->cropDuration()).frames(m_document->fps()) - 1, false)) {
-                // Keyframes were modified, updateClip
-                QDomNodeList effs = doc.elementsByTagName("effect");
-                // Hack:
-                // Since we must always resize clip before updating the keyframes, we
-                // put a resize command before & after checking keyframes so that
-                // we are sure the resize is performed before whenever we do or undo the action
-
-                new ResizeClipCommand(this, oldInfo, info, false, true, command);
-                for (int i = 0; i < indexes.count(); i++) {
-                    new EditEffectCommand(this, m_document->tracksCount() - clip->track(), clip->startPos(), effs.at(i).cloneNode().toElement(), clip->effectAt(indexes.at(i)), indexes.at(i), false, command);
-                    updateEffect(m_document->tracksCount() - clip->track(), clip->startPos(), clip->effectAt(indexes.at(i)), indexes.at(i));
-                }
-                new ResizeClipCommand(this, oldInfo, info, false, true, command);
-                emit clipItemSelected(clip);
-            } else {
-                new ResizeClipCommand(this, oldInfo, info, false, false, command);
-            }
+            // Hack:
+            // Since we must always resize clip before updating the keyframes, we
+            // put a resize command before & after checking keyframes so that
+            // we are sure the resize is performed before whenever we do or undo the action
+            new ResizeClipCommand(this, oldInfo, info, false, true, command);
+            adjustEffects(clip, oldInfo, command);
+            new ResizeClipCommand(this, oldInfo, info, false, true, command);
+            emit clipItemSelected(clip);
         } else {
             KdenliveSettings::setSnaptopoints(false);
             item->resizeEnd((int) oldInfo.endPos.frames(m_document->fps()));
@@ -4617,6 +4667,7 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI
             emit displayMessage(i18n("Error when resizing clip"), ErrorMessage);
         }
     } else if (item->type() == TRANSITIONWIDGET) {
+        if (!hasParentCommand) command->setText(i18n("Resize transition end"));
         Transition *transition = static_cast <Transition *>(item);
         if (!m_document->renderer()->mltMoveTransition(transition->transitionTag(), (int)(m_document->tracksCount() - oldInfo.track), (int)(m_document->tracksCount() - oldInfo.track), transition->transitionEndTrack(), oldInfo.startPos, oldInfo.endPos, info.startPos, info.endPos)) {
             // Cannot resize transition
@@ -4625,26 +4676,33 @@ void CustomTrackView::prepareResizeClipEnd(AbstractClipItem* item, ItemInfo oldI
             KdenliveSettings::setSnaptopoints(true);
             emit displayMessage(i18n("Cannot resize transition"), ErrorMessage);
         } else {
-            MoveTransitionCommand *moveCommand = new MoveTransitionCommand(this, oldInfo, info, false, command);
-            if (command == NULL)
-                m_commandStack->push(moveCommand);
+            // Check transition keyframes
+            QDomElement old = transition->toXML();
+            if (transition->updateKeyframes()) {
+                QDomElement xml = transition->toXML();
+                m_document->renderer()->mltUpdateTransition(xml.attribute("tag"), xml.attribute("tag"), xml.attribute("transition_btrack").toInt(), m_document->tracksCount() - xml.attribute("transition_atrack").toInt(), transition->startPos(), transition->endPos(), xml);
+                new EditTransitionCommand(this, transition->track(), transition->startPos(), old, xml, false, command);
+            }
+            new MoveTransitionCommand(this, oldInfo, info, false, command);
         }
     }
     if (item->parentItem() && item->parentItem() != m_selectionGroup)
         new RebuildGroupCommand(this, item->info().track, item->startPos(), command);
 
-    if (!hasParentCommand)
+    if (!hasParentCommand) {
+        updateTrackDuration(oldInfo.track, command);
         m_commandStack->push(command);
+    }
 }
 
-void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
+void CustomTrackView::updatePositionEffects(ClipItem* item, ItemInfo info, bool standalone)
 {
     int end = item->fadeIn();
     if (end != 0) {
         // there is a fade in effect
         int effectPos = item->hasEffect("volume", "fadein");
         if (effectPos != -1) {
-            QDomElement oldeffect = item->effectAt(effectPos);
+            QDomElement effect = item->getEffectAt(effectPos);
             int start = item->cropStart().frames(m_document->fps());
             int max = item->cropDuration().frames(m_document->fps());
             if (end > max) {
@@ -4653,16 +4711,19 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
                 end = item->fadeIn();
             }
             end += start;
-            EffectsList::setParameter(oldeffect, "in", QString::number(start));
-            EffectsList::setParameter(oldeffect, "out", QString::number(end));
-            if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
-                emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
-            // if fade effect is displayed, update the effect edit widget with new clip duration
-            if (item->isSelected() && effectPos == item->selectedEffectIndex()) emit clipItemSelected(item, effectPos);
+            EffectsList::setParameter(effect, "in", QString::number(start));
+            EffectsList::setParameter(effect, "out", QString::number(end));
+            if (standalone) {
+                if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(effect)))
+                    emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
+                // if fade effect is displayed, update the effect edit widget with new clip duration
+                if (item->isSelected() && effectPos == item->selectedEffectIndex())
+                    emit clipItemSelected(item, effectPos);
+            }
         }
         effectPos = item->hasEffect("brightness", "fade_from_black");
         if (effectPos != -1) {
-            QDomElement oldeffect = item->effectAt(effectPos);
+            QDomElement effect = item->getEffectAt(effectPos);
             int start = item->cropStart().frames(m_document->fps());
             int max = item->cropDuration().frames(m_document->fps());
             if (end > max) {
@@ -4671,20 +4732,24 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
                 end = item->fadeIn();
             }
             end += start;
-            EffectsList::setParameter(oldeffect, "in", QString::number(start));
-            EffectsList::setParameter(oldeffect, "out", QString::number(end));
-            if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
-                emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
-            // if fade effect is displayed, update the effect edit widget with new clip duration
-            if (item->isSelected() && effectPos == item->selectedEffectIndex()) emit clipItemSelected(item, effectPos);
+            EffectsList::setParameter(effect, "in", QString::number(start));
+            EffectsList::setParameter(effect, "out", QString::number(end));
+            if (standalone) {
+                if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(effect)))
+                    emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
+                // if fade effect is displayed, update the effect edit widget with new clip duration
+                if (item->isSelected() && effectPos == item->selectedEffectIndex())
+                    emit clipItemSelected(item, effectPos);
+            }
         }
     }
+
     int start = item->fadeOut();
     if (start != 0) {
         // there is a fade out effect
         int effectPos = item->hasEffect("volume", "fadeout");
         if (effectPos != -1) {
-            QDomElement oldeffect = item->effectAt(effectPos);
+            QDomElement effect = item->getEffectAt(effectPos);
             int max = item->cropDuration().frames(m_document->fps());
             int end = max + item->cropStart().frames(m_document->fps());
             if (start > max) {
@@ -4693,16 +4758,19 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
                 start = item->fadeOut();
             }
             start = end - start;
-            EffectsList::setParameter(oldeffect, "in", QString::number(start));
-            EffectsList::setParameter(oldeffect, "out", QString::number(end));
-            if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
-                emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
-            // if fade effect is displayed, update the effect edit widget with new clip duration
-            if (item->isSelected() && effectPos == item->selectedEffectIndex()) emit clipItemSelected(item, effectPos);
+            EffectsList::setParameter(effect, "in", QString::number(start));
+            EffectsList::setParameter(effect, "out", QString::number(end));
+            if (standalone) {
+                if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(effect)))
+                    emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
+                // if fade effect is displayed, update the effect edit widget with new clip duration
+                if (item->isSelected() && effectPos == item->selectedEffectIndex())
+                    emit clipItemSelected(item, effectPos);
+            }
         }
         effectPos = item->hasEffect("brightness", "fade_to_black");
         if (effectPos != -1) {
-            QDomElement oldeffect = item->effectAt(effectPos);
+            QDomElement effect = item->getEffectAt(effectPos);
             int max = item->cropDuration().frames(m_document->fps());
             int end = max + item->cropStart().frames(m_document->fps());
             if (start > max) {
@@ -4711,12 +4779,15 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
                 start = item->fadeOut();
             }
             start = end - start;
-            EffectsList::setParameter(oldeffect, "in", QString::number(start));
-            EffectsList::setParameter(oldeffect, "out", QString::number(end));
-            if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(oldeffect)))
-                emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
-            // if fade effect is displayed, update the effect edit widget with new clip duration
-            if (item->isSelected() && effectPos == item->selectedEffectIndex()) emit clipItemSelected(item, effectPos);
+            EffectsList::setParameter(effect, "in", QString::number(start));
+            EffectsList::setParameter(effect, "out", QString::number(end));
+            if (standalone) {
+                if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(effect)))
+                    emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
+                // if fade effect is displayed, update the effect edit widget with new clip duration
+                if (item->isSelected() && effectPos == item->selectedEffectIndex())
+                    emit clipItemSelected(item, effectPos);
+            }
         }
     }
 
@@ -4728,13 +4799,13 @@ void CustomTrackView::updatePositionEffects(ClipItem * item, ItemInfo info)
         if (!eff.isNull() && diff != 0) {
             int freeze_pos = EffectsList::parameter(eff, "frame").toInt() + diff;
             EffectsList::setParameter(eff, "frame", QString::number(freeze_pos));
-            if (item->isSelected() && item->selectedEffect().attribute("id") == "freeze") {
-                emit clipItemSelected(item, item->selectedEffectIndex());
+            if (standalone) {
+                if (item->isSelected() && item->selectedEffect().attribute("id") == "freeze") {
+                    emit clipItemSelected(item, item->selectedEffectIndex());
+                }
             }
         }
     }
-
-    updatePanZoom(item);
 }
 
 double CustomTrackView::getSnapPointForPos(double pos)
@@ -4965,7 +5036,8 @@ void CustomTrackView::slotAddGuide(bool dialog)
     if (dialog) {
         MarkerDialog d(NULL, marker, m_document->timecode(), i18n("Add Guide"), this);
         if (d.exec() != QDialog::Accepted) return;
-        marker.setComment(d.newMarker().comment());
+        marker = d.newMarker();
+        
     } else {
         marker.setComment(m_document->timecode().getDisplayTimecodeFromFrames(m_cursorPos, false));
     }
@@ -5233,10 +5305,22 @@ bool CustomTrackView::canBePastedTo(ItemInfo info, int type) const
         // If we are in overwrite mode, always allow the move
         return true;
     }
-    QRectF rect((double) info.startPos.frames(m_document->fps()), (double)(info.track * m_tracksHeight + 1), (double)(info.endPos - info.startPos).frames(m_document->fps()), (double)(m_tracksHeight - 1));
+    int height = m_tracksHeight - 2;
+    int offset = 0;
+    if (type == TRANSITIONWIDGET) {
+        height = Transition::itemHeight();
+        offset = Transition::itemOffset();
+    }
+    else if (type == AVWIDGET) {
+        height = ClipItem::itemHeight();
+        offset = ClipItem::itemOffset();
+    }
+    QRectF rect((double) info.startPos.frames(m_document->fps()), (double)(info.track * m_tracksHeight + 1 + offset), (double)(info.endPos - info.startPos).frames(m_document->fps()), (double) height);
     QList<QGraphicsItem *> collisions = scene()->items(rect, Qt::IntersectsItemBoundingRect);
     for (int i = 0; i < collisions.count(); i++) {
-        if (collisions.at(i)->type() == type) return false;
+        if (collisions.at(i)->type() == type) {
+            return false;
+        }
     }
     return true;
 }
@@ -5369,6 +5453,7 @@ void CustomTrackView::pasteClip()
             } else emit displayMessage(i18n("Cannot paste transition to selected place"), ErrorMessage);
         }
     }
+    updateTrackDuration(-1, pasteClips);
     m_commandStack->push(pasteClips);
 }
 
@@ -5397,7 +5482,6 @@ void CustomTrackView::pasteClipEffects()
         }
     }
 
-
     for (int i = 0; i < clips.count(); ++i) {
         if (clips.at(i)->type() == AVWIDGET) {
             ClipItem *item = static_cast < ClipItem *>(clips.at(i));
@@ -5428,6 +5512,7 @@ void CustomTrackView::adjustKeyfames(GenTime oldstart, GenTime newstart, GenTime
     // parse parameters to check if we need to adjust to the new crop start
     int diff = (newstart - oldstart).frames(m_document->fps());
     int max = (newstart + duration).frames(m_document->fps());
+    QLocale locale;
     QDomNodeList params = xml.elementsByTagName("parameter");
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
@@ -5441,9 +5526,9 @@ void CustomTrackView::adjustKeyfames(GenTime oldstart, GenTime newstart, GenTime
                 double val = str.section(':', 1, 1).toDouble();
                 pos += diff;
                 if (pos > max) {
-                    newKeyFrames.append(QString::number(max) + ':' + QString::number(val));
+                    newKeyFrames.append(QString::number(max) + ':' + locale.toString(val));
                     break;
-                } else newKeyFrames.append(QString::number(pos) + ':' + QString::number(val));
+                } else newKeyFrames.append(QString::number(pos) + ':' + locale.toString(val));
             }
             //kDebug()<<"ORIGIN: "<<keys<<", FIXED: "<<newKeyFrames;
             e.setAttribute("keyframes", newKeyFrames.join(";"));
@@ -5555,8 +5640,8 @@ void CustomTrackView::slotUpdateAllThumbs()
                 } else {
                     QString startThumb = thumbBase + item->baseClip()->getClipHash() + '_';
                     QString endThumb = startThumb;
-                    startThumb.append(QString::number(item->speedIndependantCropStart().frames(m_document->fps())) + ".png");
-                    endThumb.append(QString::number((item->speedIndependantCropStart() + item->speedIndependantCropDuration()).frames(m_document->fps()) - 1) + ".png");
+                    startThumb.append(QString::number((int) item->speedIndependantCropStart().frames(m_document->fps())) + ".png");
+                    endThumb.append(QString::number((int) (item->speedIndependantCropStart() + item->speedIndependantCropDuration()).frames(m_document->fps()) - 1) + ".png");
                     if (QFile::exists(startThumb)) {
                         QPixmap pix(startThumb);
                         if (pix.isNull()) KIO::NetAccess::del(KUrl(startThumb), this);
@@ -5568,7 +5653,7 @@ void CustomTrackView::slotUpdateAllThumbs()
                         item->slotSetEndThumb(pix);
                     }
                 }
-                item->refreshClip(false);
+                item->refreshClip(false, false);
             }
         }
     }
@@ -5594,8 +5679,8 @@ void CustomTrackView::saveThumbnails()
                 } else {
                     QString startThumb = thumbBase + item->baseClip()->getClipHash() + '_';
                     QString endThumb = startThumb;
-                    startThumb.append(QString::number(item->speedIndependantCropStart().frames(m_document->fps())) + ".png");
-                    endThumb.append(QString::number((item->speedIndependantCropStart() + item->speedIndependantCropDuration()).frames(m_document->fps()) - 1) + ".png");
+                    startThumb.append(QString::number((int) item->speedIndependantCropStart().frames(m_document->fps())) + ".png");
+                    endThumb.append(QString::number((int) (item->speedIndependantCropStart() + item->speedIndependantCropDuration()).frames(m_document->fps()) - 1) + ".png");
                     if (!QFile::exists(startThumb)) {
                         QPixmap pix(item->startThumb());
                         pix.save(startThumb);
@@ -5623,6 +5708,7 @@ void CustomTrackView::slotInsertTrack(int ix)
         if (d.before_select->currentIndex() == 1)
             ix++;
         TrackInfo info;
+        info.duration = 0;
         info.isMute = false;
         info.isLocked = false;
         if (d.video_track->isChecked()) {
@@ -5687,6 +5773,7 @@ void CustomTrackView::deleteTimelineTrack(int ix, TrackInfo trackinfo)
         if (selection.at(i)->type() == AVWIDGET) {
             ClipItem *item =  static_cast <ClipItem *>(selection.at(i));
             new AddTimelineClipCommand(this, item->xml(), item->clipProducer(), item->info(), item->effectList(), false, false, false, true, deleteTrack);
+            m_waitingThumbs.removeAll(item);
             m_scene->removeItem(item);
             delete item;
             item = NULL;
@@ -5721,6 +5808,7 @@ void CustomTrackView::autoTransition()
 QStringList CustomTrackView::getLadspaParams(QDomElement effect) const
 {
     QStringList result;
+    QLocale locale;
     QDomNodeList params = effect.elementsByTagName("parameter");
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
@@ -5729,7 +5817,7 @@ QStringList CustomTrackView::getLadspaParams(QDomElement effect) const
                 double factor = e.attribute("factor").toDouble();
                 double value = e.attribute("value").toDouble();
                 value = value / factor;
-                result.append(QString::number(value));
+                result.append(locale.toString(value));
             } else result.append(e.attribute("value"));
         }
     }
@@ -5789,8 +5877,7 @@ void CustomTrackView::loadGroups(const QDomNodeList groups)
         QDomNodeList children = groups.at(i).childNodes();
         scene()->clearSelection();
         for (int nodeindex = 0; nodeindex < children.count(); nodeindex++) {
-            QDomNode n = children.item(nodeindex);
-            QDomElement elem = n.toElement();
+            QDomElement elem = children.item(nodeindex).toElement();
             int pos = elem.attribute("position").toInt();
             int track = elem.attribute("track").toInt();
             if (elem.tagName() == "clipitem") {
@@ -5822,16 +5909,20 @@ void CustomTrackView::splitAudio()
                 if (clip->parentItem()) {
                     emit displayMessage(i18n("Cannot split audio of grouped clips"), ErrorMessage);
                 } else {
-                    new SplitAudioCommand(this, clip->track(), clip->startPos(), splitCommand);
+                    EffectsList effects;
+                    effects.clone(clip->effectList());
+                    new SplitAudioCommand(this, clip->track(), clip->startPos(), effects, splitCommand);
                 }
             }
         }
     }
-    if (splitCommand->childCount() > 0)
+    if (splitCommand->childCount()) {
+        updateTrackDuration(-1, splitCommand);
         m_commandStack->push(splitCommand);
+    }
 }
 
-void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split)
+void CustomTrackView::doSplitAudio(const GenTime &pos, int track, EffectsList effects, bool split)
 {
     ClipItem *clip = getClipItemAt(pos, track);
     if (clip == NULL) {
@@ -5847,11 +5938,11 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split)
             return;
 
         for (; freetrack > 0; freetrack--) {
-            kDebug() << "// CHK DOC TRK:" << freetrack << ", DUR:" << m_document->renderer()->mltTrackDuration(freetrack);
+            //kDebug() << "// CHK DOC TRK:" << freetrack << ", DUR:" << m_document->renderer()->mltTrackDuration(freetrack);
             if (m_document->trackInfoAt(freetrack - 1).type == AUDIOTRACK && !m_document->trackInfoAt(freetrack - 1).isLocked) {
-                kDebug() << "// CHK DOC TRK:" << freetrack << ", DUR:" << m_document->renderer()->mltTrackDuration(freetrack);
+                //kDebug() << "// CHK DOC TRK:" << freetrack << ", DUR:" << m_document->renderer()->mltTrackDuration(freetrack);
                 if (m_document->renderer()->mltTrackDuration(freetrack) < start || m_document->renderer()->mltGetSpaceLength(pos, freetrack, false) >= clip->cropDuration().frames(m_document->fps())) {
-                    kDebug() << "FOUND SPACE ON TRK: " << freetrack;
+                    //kDebug() << "FOUND SPACE ON TRK: " << freetrack;
                     break;
                 }
             }
@@ -5876,6 +5967,20 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split)
                 }
                 audioClip->setSelected(true);
                 audioClip->setAudioOnly(true);
+
+                // keep video effects, move audio effects to audio clip
+                int videoIx = 0;
+                int audioIx = 0;
+                for (int i = 0; i < effects.count(); ++i) {
+                    if (effects.at(i).attribute("type") == "audio") {
+                        deleteEffect(m_document->tracksCount() - track, pos, clip->effectAt(videoIx));
+                        audioIx++;
+                    } else {
+                        deleteEffect(freetrack, pos, audioClip->effectAt(audioIx));
+                        videoIx++;
+                    }
+                }
+
                 groupSelectedItems(false, true);
             }
         }
@@ -5897,9 +6002,18 @@ void CustomTrackView::doSplitAudio(const GenTime &pos, int track, bool split)
                 ItemInfo info = clip->info();
                 deleteClip(clp->info());
                 clip->setVideoOnly(false);
+
                 if (!m_document->renderer()->mltUpdateClipProducer(m_document->tracksCount() - info.track, info.startPos.frames(m_document->fps()), clip->baseClip()->producer(info.track))) {
                     emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage);
                 }
+
+                // re-add audio effects
+                for (int i = 0; i < effects.count(); ++i) {
+                    if (effects.at(i).attribute("type") == "audio") {
+                        addEffect(m_document->tracksCount() - track, pos, effects.at(i));
+                    }
+                }
+
                 break;
             }
         }
@@ -6126,6 +6240,7 @@ void CustomTrackView::updateProjectFps()
             m_document->clipManager()->removeGroup(grp);
             m_scene->addItem(grp);
             scene()->destroyItemGroup(grp);
+            scene()->clearSelection();
             for (int j = 0; j < children.count(); j++) {
                 if (children.at(j)->type() == AVWIDGET || children.at(j)->type() == TRANSITIONWIDGET) {
                     //children.at(j)->setParentItem(0);
@@ -6246,10 +6361,15 @@ QStringList CustomTrackView::extractTransitionsLumas()
         if (itemList.at(i)->type() == TRANSITIONWIDGET) {
             transitionitem = static_cast <Transition*>(itemList.at(i));
             transitionXml = transitionitem->toXML();
+            // luma files in transitions can be in "resource" or "luma" property
             QString luma = EffectsList::parameter(transitionXml, "luma");
-            if (!luma.isEmpty()) urls << luma;
+            if (luma.isEmpty()) luma = EffectsList::parameter(transitionXml, "resource");
+            if (!luma.isEmpty()) urls << KUrl(luma).path();
         }
     }
+#if QT_VERSION >= 0x040500
+    urls.removeDuplicates();
+#endif
     return urls;
 }
 
@@ -6294,6 +6414,7 @@ void CustomTrackView::insertZoneOverwrite(QStringList data, int in)
     addCommand->setText(i18n("Insert clip"));
     adjustTimelineClips(OVERWRITEEDIT, NULL, info, addCommand);
     new AddTimelineClipCommand(this, clip->toXML(), clip->getId(), info, EffectsList(), true, false, true, false, addCommand);
+    updateTrackDuration(info.track, addCommand);
     m_commandStack->push(addCommand);
 
     selectClip(true, false, m_selectedTrack, in);
@@ -6435,6 +6556,7 @@ void CustomTrackView::slotAddTrackEffect(const QDomElement effect, int ix)
 EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect)
 {
     EffectsParameterList parameters;
+    QLocale locale;
     parameters.addParam("tag", effect.attribute("tag"));
     if (effect.hasAttribute("region")) parameters.addParam("region", effect.attribute("region"));
     parameters.addParam("kdenlive_ix", effect.attribute("kdenlive_ix"));
@@ -6447,7 +6569,10 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect)
     QDomNodeList params = effect.elementsByTagName("parameter");
     for (int i = 0; i < params.count(); i++) {
         QDomElement e = params.item(i).toElement();
-        //kDebug() << "/ / / /SENDING EFFECT PARAM: " << e.attribute("type") << ", NAME_ " << e.attribute("tag");
+        if (e.attribute("type") == "geometry" && !e.hasAttribute("fixed")) {
+            // effects with geometry param need in / out synced with the clip, request it...
+            parameters.addParam("_sync_in_out", "1");
+        }
         if (e.attribute("type") == "simplekeyframe") {
 
             QStringList values = e.attribute("keyframes").split(";", QString::SkipEmptyParts);
@@ -6455,7 +6580,7 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect)
             for (int j = 0; j < values.count(); j++) {
                 QString pos = values.at(j).section(':', 0, 0);
                 double val = values.at(j).section(':', 1, 1).toDouble() / factor;
-                values[j] = pos + "=" + QString::number(val);
+                values[j] = pos + "=" + locale.toString(val);
             }
             // kDebug() << "/ / / /SENDING KEYFR:" << values;
             parameters.addParam(e.attribute("name"), values.join(";"));
@@ -6487,10 +6612,10 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect)
         } else {
             if (e.attribute("factor", "1") != "1") {
                 double fact;
-                if (e.attribute("factor").startsWith('%')) {
+                if (e.attribute("factor").contains('%')) {
                     fact = ProfilesDialog::getStringEval(m_document->mltProfile(), e.attribute("factor"));
                 } else fact = e.attribute("factor", "1").toDouble();
-                parameters.addParam(e.attribute("name"), QString::number(e.attribute("value").toDouble() / fact));
+                parameters.addParam(e.attribute("name"), locale.toString(e.attribute("value").toDouble() / fact));
             } else {
                 parameters.addParam(e.attribute("name"), e.attribute("value"));
             }
@@ -6499,22 +6624,6 @@ EffectsParameterList CustomTrackView::getEffectArgs(const QDomElement effect)
     return parameters;
 }
 
-void CustomTrackView::updatePanZoom(ClipItem* item, GenTime cutPos)
-{
-    QList <int> effects = item->updatePanZoom(m_document->width(), m_document->height(), cutPos.frames(m_document->fps()));
-    for (int i = 0; i < effects.count(); ++i) {
-        if (!m_document->renderer()->mltEditEffect(m_document->tracksCount() - item->track(), item->startPos(), getEffectArgs(item->effectAt(effects.at(i)))))
-            emit displayMessage(i18n("Problem editing effect"), ErrorMessage);
-
-        // if effect is displayed, update the effect edit widget with new clip duration
-        /*if (item->isSelected() && effects.at(i) == item->selectedEffectIndex())
-            emit clipItemSelected(item, effects.at(i));*/
-    }
-    // update always, otherwise there might problems when resizing groups
-    if (effects.count() > 0)
-        emit clipItemSelected(item, item->selectedEffectIndex());
-}
-
 void CustomTrackView::updateTrackNames(int track, bool added)
 {
     QList <TrackInfo> tracks = m_document->tracksList();
@@ -6548,7 +6657,66 @@ void CustomTrackView::updateTrackNames(int track, bool added)
             }
         }
     }
-
     emit tracksChanged();
 }
 
+void CustomTrackView::updateTrackDuration(int track, QUndoCommand *command)
+{
+    Q_UNUSED(command)
+
+    QList<int> tracks;
+    if (track >= 0) {
+        tracks << m_document->tracksCount() - track - 1;
+    } else {
+        // negative track number -> update all tracks
+        for (int i = 0; i < m_document->tracksCount(); ++i)
+            tracks << i;
+    }
+    int t, duration;
+    for (int i = 0; i < tracks.count(); ++i) {
+        t = tracks.at(i);
+        // t + 1 because of black background track
+        duration = m_document->renderer()->mltTrackDuration(t + 1);
+        if (duration != m_document->trackDuration(t)) {
+            m_document->setTrackDuration(t, duration);
+
+            // update effects
+            EffectsList effects = m_document->getTrackEffects(t);
+            for (int j = 0; j < effects.count(); ++j) {
+                /* TODO
+                 * - lookout for keyframable parameters and update them so all keyframes are in the new range (0 - duration)
+                 * - update the effectstack if necessary
+                 */
+            }
+        }
+    }
+}
+
+void CustomTrackView::slotRefreshThumbs(const QString &id, bool resetThumbs)
+{
+    QList<QGraphicsItem *> list = scene()->items();
+    ClipItem *clip = NULL;
+    for (int i = 0; i < list.size(); ++i) {
+        if (list.at(i)->type() == AVWIDGET) {
+            clip = static_cast <ClipItem *>(list.at(i));
+            if (clip->clipProducer() == id) {
+                clip->refreshClip(true, resetThumbs);
+            }
+        }
+    }
+}
+
+void CustomTrackView::adjustEffects(ClipItem* item, ItemInfo oldInfo, QUndoCommand* command)
+{
+    QMap<int, QDomElement> effects = item->adjustEffectsToDuration(m_document->width(), m_document->height(), oldInfo);
+
+    if (effects.count()) {
+        QMap<int, QDomElement>::const_iterator i = effects.constBegin();
+        while (i != effects.constEnd()) {
+            new EditEffectCommand(this, m_document->tracksCount() - item->track(), item->startPos(), i.value(), item->effectAt(i.key()), i.key(), false, command);
+            ++i;
+        }
+    }
+}
+
+