]> git.sesse.net Git - kdenlive/blobdiff - src/customtrackview.cpp
no ";" after Q_UNUSED
[kdenlive] / src / customtrackview.cpp
index 802c258b002aab4660de6932bfc3cc25b34765a3..9bc72157c5a5cc3ee2777ff6b049875b0afe8e67 100644 (file)
@@ -142,7 +142,7 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscen
 
     m_activeTrackBrush = KStatefulBrush(KColorScheme::View, KColorScheme::ActiveBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
 
-    pixmapCache = new KPixmapCache("kdenlive-thumbs");
+    m_pixmapCache = new KPixmapCache("kdenlive-thumbs");
 
     m_animationTimer = new QTimeLine(800);
     m_animationTimer->setFrameRange(0, 5);
@@ -188,6 +188,8 @@ CustomTrackView::~CustomTrackView()
     qDeleteAll(m_guides);
     m_guides.clear();
     m_waitingThumbs.clear();
+    delete m_pixmapCache;
+    delete m_animationTimer;
 }
 
 //virtual
@@ -334,7 +336,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();
@@ -373,6 +375,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);
 
@@ -594,11 +597,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) {
@@ -613,26 +619,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();
@@ -925,7 +945,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();
@@ -1118,6 +1137,7 @@ void CustomTrackView::resetSelectionGroup(bool selectItems)
                 children.at(i)->setSelected(selectItems);
             }
         }
+
         m_selectionGroup = NULL;
         KdenliveSettings::setSnaptopoints(snap);
     }
@@ -1430,6 +1450,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();
@@ -1481,6 +1505,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();
@@ -1813,8 +1841,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);
@@ -1997,8 +2028,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;
@@ -2011,17 +2040,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())
@@ -2036,8 +2080,9 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo
         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
 
@@ -2054,19 +2099,33 @@ 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;
@@ -2081,6 +2140,8 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo
             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()));
@@ -2245,6 +2306,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;
@@ -2338,7 +2400,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(clipInfo.track, addCommand);
+            updateTrackDuration(info.track, addCommand);
 
             if (item->baseClip()->isTransparent() && getTransitionItemAtStart(info.startPos, info.track) == NULL) {
                 // add transparency transition
@@ -2429,6 +2491,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;
@@ -2899,7 +2962,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;
@@ -3046,7 +3109,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);
 }
@@ -3067,7 +3130,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)
@@ -3169,7 +3232,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;
@@ -3438,6 +3500,7 @@ void CustomTrackView::mouseReleaseEvent(QMouseEvent * event)
                                 items.at(i)->parentItem()->setSelected(true);
                         }
                     }
+                    resetSelectionGroup();
                     groupSelectedItems();
                 } else {
                     rebuildGroup((AbstractGroupItem *)group);
@@ -3639,6 +3702,7 @@ void CustomTrackView::deleteClip(ItemInfo info, bool refresh)
         emit displayMessage(i18n("Error removing clip at %1 on track %2", m_document->timecode().getTimecodeFromFrames(info.startPos.frames(m_document->fps())), info.track), ErrorMessage);
         return;
     }
+    m_waitingThumbs.removeAll(item);
     if (item->isSelected()) emit clipItemSelected(NULL);
     item->baseClip()->removeReference();
     m_document->updateClip(item->baseClip()->getId());
@@ -3652,8 +3716,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();
@@ -3776,7 +3841,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);
@@ -3977,7 +4042,6 @@ void CustomTrackView::doGroupClips(QList <ItemInfo> clipInfos, QList <ItemInfo>
             clip->setSelected(true);
         }
     }
-
     groupSelectedItems(false, true);
     setDocumentModified();
 }
@@ -4045,11 +4109,10 @@ void CustomTrackView::slotUpdateClip(const QString &clipId, bool reload)
             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())) {
+                if (reload && !m_document->renderer()->mltUpdateClip(info, clip->xml(), clip->baseClip()->producer(info.track))) {
                     emit displayMessage(i18n("Cannot update clip (time: %1, track: %2)", info.startPos.frames(m_document->fps()), info.track), ErrorMessage);
                 }
-                clip->refreshClip(true);
-                clip->update();
+                clip->refreshClip(true, true);
             }
         }
     }
@@ -4474,7 +4537,7 @@ void CustomTrackView::prepareResizeClipStart(AbstractClipItem* item, ItemInfo ol
             }
 
             /*
-                TODO: cleanup the effect update process
+             * TODO: cleanup the effect update process
              */
             ClipItem *clip = static_cast < ClipItem * >(item);
 
@@ -4561,7 +4624,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
@@ -4570,6 +4632,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);
@@ -4638,6 +4701,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
@@ -4646,9 +4710,14 @@ 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)
@@ -4988,7 +5057,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));
     }
@@ -5591,7 +5661,7 @@ void CustomTrackView::slotUpdateAllThumbs()
                         item->slotSetEndThumb(pix);
                     }
                 }
-                item->refreshClip(false);
+                item->refreshClip(false, false);
             }
         }
     }
@@ -5711,6 +5781,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;
@@ -5813,8 +5884,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") {
@@ -6152,6 +6222,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);
@@ -6580,7 +6651,7 @@ void CustomTrackView::updateTrackNames(int track, bool added)
 
 void CustomTrackView::updateTrackDuration(int track, QUndoCommand *command)
 {
-    Q_UNUSED(command);
+    Q_UNUSED(command)
 
     QList<int> tracks;
     if (track >= 0) {
@@ -6610,4 +6681,16 @@ void CustomTrackView::updateTrackDuration(int track, QUndoCommand *command)
     }
 }
 
-
+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);
+            }
+        }
+    }
+}