]> 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 1f8cc7aadebfaeb29e0012f69cf8d0f9a79bb665..2378a79db50ceb21aeb835ec65ec1ef0daefe452 100644 (file)
@@ -130,7 +130,7 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscen
         m_commandStack = doc->commandStack();
     else
         m_commandStack = NULL;
-
+    m_ct = 0;
     setMouseTracking(true);
     setAcceptDrops(true);
     setFrameShape(QFrame::NoFrame);
@@ -142,12 +142,6 @@ CustomTrackView::CustomTrackView(KdenliveDoc *doc, CustomTrackScene* projectscen
 
     m_activeTrackBrush = KStatefulBrush(KColorScheme::View, KColorScheme::ActiveBackground, KSharedConfig::openConfig(KdenliveSettings::colortheme()));
 
-#if KDE_IS_VERSION(4,5,0)
-    m_pixmapCache = new KImageCache("kdenlive-thumbs", 1000000);
-#else
-    m_pixmapCache = new KPixmapCache("kdenlive-thumbs");
-#endif
-
     m_animationTimer = new QTimeLine(800);
     m_animationTimer->setFrameRange(0, 5);
     m_animationTimer->setUpdateInterval(100);
@@ -192,7 +186,6 @@ CustomTrackView::~CustomTrackView()
     qDeleteAll(m_guides);
     m_guides.clear();
     m_waitingThumbs.clear();
-    delete m_pixmapCache;
     delete m_animationTimer;
 }
 
@@ -708,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) {
@@ -736,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();
@@ -2099,9 +2090,6 @@ 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();
@@ -2158,9 +2146,6 @@ ClipItem *CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut, boo
         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);
@@ -3724,9 +3709,15 @@ 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);
@@ -3776,7 +3767,6 @@ void CustomTrackView::deleteSelectedClips()
     scene()->clearSelection();
     QUndoCommand *deleteSelected = new QUndoCommand();
 
-    bool resetGroup = false;
     int groupCount = 0;
     int clipCount = 0;
     int transitionCount = 0;
@@ -3787,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));
@@ -3813,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);
@@ -3821,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);
         }
@@ -3852,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;
@@ -4002,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();
@@ -5527,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();
@@ -5540,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(";"));
@@ -5654,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);
@@ -5693,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);
@@ -5822,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();
@@ -5830,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"));
         }
     }
@@ -5922,7 +5909,9 @@ 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);
                 }
             }
         }
@@ -5933,7 +5922,7 @@ void CustomTrackView::splitAudio()
     }
 }
 
-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) {
@@ -5978,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);
             }
         }
@@ -5999,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;
             }
         }
@@ -6544,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"));
@@ -6556,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);
@@ -6564,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(";"));
@@ -6596,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"));
             }
@@ -6608,23 +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())
-        emit clipItemSelected(item, item->selectedEffectIndex());
-}
-
 void CustomTrackView::updateTrackNames(int track, bool added)
 {
     QList <TrackInfo> tracks = m_document->tracksList();