]> git.sesse.net Git - kdenlive/commitdiff
Fix clip count & duration on document opening
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 28 Jun 2008 13:48:58 +0000 (13:48 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 28 Jun 2008 13:48:58 +0000 (13:48 +0000)
svn path=/branches/KDE4/; revision=2287

src/clipitem.cpp
src/customtrackview.cpp
src/docclipbase.cpp
src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/mainwindow.cpp
src/projectlist.h
src/trackview.cpp

index 28b428c2c3dd6a56102ebfab549c0ace2bcc88ea..c502264b91bf8b06149df53640576d337bf1712e 100644 (file)
@@ -776,7 +776,7 @@ void ClipItem::checkEffectsKeyframesPos(const int previous, const int current, b
             }
         }
     }
-    setSelectedEffect(m_selectedEffect);
+    if (m_selectedEffect >= 0) setSelectedEffect(m_selectedEffect);
 }
 
 
index e1730613a552774aefdb62fd1d6956af1db0fa22..f41344dd8451e4a8ebfb1f2a8e0ba06a3f96257d 100644 (file)
@@ -735,21 +735,32 @@ void CustomTrackView::cutClip(ItemInfo info, GenTime cutTime, bool cut) {
     if (cut) {
         // cut clip
         ClipItem *item = getClipItemAt((int) info.startPos.frames(m_document->fps()), info.track);
+        if (!item) {
+            emit displayMessage(i18n("Cannot find clip to cut"), ErrorMessage);
+            return;
+        }
         int cutPos = (int) cutTime.frames(m_document->fps());
         ItemInfo newPos;
         newPos.startPos = cutTime;
         newPos.endPos = info.endPos;
         newPos.track = info.track;
-        ClipItem *dup = new ClipItem(item->baseClip(), newPos, item->cropStart(), m_scale, m_document->fps());
-        dup->setCropStart(dup->cropStart() + (cutTime - info.startPos));
         item->resizeEnd(cutPos, m_scale);
+        ClipItem *dup = new ClipItem(item->baseClip(), newPos, item->cropStart() + (cutTime - info.startPos), m_scale, m_document->fps());
         scene()->addItem(dup);
         m_document->renderer()->mltCutClip(m_tracksList.count() - info.track, cutTime);
+        item->baseClip()->addReference();
+        m_document->updateClip(item->baseClip()->getId());
     } else {
         // uncut clip
         ClipItem *item = getClipItemAt((int) info.startPos.frames(m_document->fps()), info.track);
         ClipItem *dup = getClipItemAt((int) cutTime.frames(m_document->fps()), info.track);
+        if (!item || !dup) {
+            emit displayMessage(i18n("Cannot find clip to uncut"), ErrorMessage);
+            return;
+        }
         delete dup;
+        item->baseClip()->removeReference();
+        m_document->updateClip(item->baseClip()->getId());
         item->resizeEnd((int) info.endPos.frames(m_document->fps()), m_scale);
         m_document->renderer()->mltRemoveClip(m_tracksList.count() - info.track, cutTime);
         m_document->renderer()->mltResizeClipEnd(m_tracksList.count() - info.track, info.startPos, item->cropStart(), item->cropStart() + info.endPos - info.startPos);
index ed0a33fc87efeaeaef4a5f489f88339c8cbcb23c..467fb9a225e0250628c02cfc96a223a32d0c0192 100644 (file)
@@ -38,7 +38,9 @@ DocClipBase::DocClipBase(ClipManager *clipManager, QDomElement xml, uint id):
     int out = xml.attribute("out").toInt();
     if (out != 0) {
         setDuration(GenTime(out, KdenliveSettings::project_fps()));
-        //m_properties.insert("out", QString::number(out));
+    } else {
+        out = xml.attribute("duration").toInt();
+        if (out != 0) setDuration(GenTime(out, KdenliveSettings::project_fps()));
     }
     if (m_name.isEmpty()) m_name = url.fileName();
 
index ca12bc7754a6084c767f24ef5ab10ebc02ae1ae5..c9b8be8f5e7ff4c43673ddf3d5ced7c399d661f8 100644 (file)
@@ -401,6 +401,12 @@ void KdenliveDoc::updateClip(int id) {
     emit updateClipDisplay(id);
 }
 
+void KdenliveDoc::updateAllProjectClips() {
+    QList <DocClipBase*> list = m_clipManager->documentClipList();
+    for (int i = 0; i < list.count(); i++)
+        emit updateClipDisplay(list.at(i)->getId());
+}
+
 int KdenliveDoc::getFramePos(QString duration) {
     return m_timecode.getFrameCount(duration, m_fps);
 }
index 463e4cda78af699bdd5c0642ee2d995d2bde7446..084b92d690e20a7432185ecba1ffd0bf29494d9c 100644 (file)
@@ -95,6 +95,8 @@ Q_OBJECT public:
     KUrl projectFolder() const;
     /** Used to inform main app of the current document loading progress */
     void loadingProgressed();
+    void updateAllProjectClips();
+
 private:
     KUrl m_url;
     QDomDocument m_document;
index bbaa9455df684d000241c617334549ad653ad46f..037bcab5463048fe5a8397fa7192cf6f4d1b0dda 100644 (file)
@@ -943,6 +943,9 @@ void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) { //cha
     m_monitorManager->setTimecode(doc->timecode());
     doc->setRenderer(m_projectMonitor->render);
     m_commandStack->setActiveStack(doc->commandStack());
+
+    doc->updateAllProjectClips();
+
     if (m_commandStack->isClean()) kDebug() << "////////////  UNDO STACK IS CLEAN";
     else  kDebug() << "////////////  UNDO STACK IS NOT CLEAN*******************";
 
index c6176c4b840909d8549b19978882c56c35def8df..99a16114f4cf03939710c61762c8779490626eab 100644 (file)
@@ -60,7 +60,6 @@ public:
       extendItem(w,
     }
     */
-
     void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
         if (index.column() == 1) {
             const bool hover = option.state & (QStyle::State_Selected);
@@ -73,7 +72,6 @@ public:
                 painter->fillRect(r1, QBrush(backgroundColor));
             }
             QFont font = painter->font();
-            font.setPointSize(font.pointSize());
             font.setBold(true);
             painter->setFont(font);
             int mid = (int)((r1.height() / 2));
@@ -87,6 +85,7 @@ public:
             QString subText = index.data(DurationRole).toString();
             int usage = index.data(UsageRole).toInt();
             if (usage != 0) subText.append(QString(" (%1)").arg(usage));
+            painter->setPen(option.palette.color(QPalette::Mid));
             painter->drawText(r2, Qt::AlignLeft | Qt::AlignVCenter , subText);
             painter->restore();
         } else {
index 257d182251c548b1aa92aca037c7367681945844..8cf99e9d5e6ad4d294a01cfe66eb7957bebda536 100644 (file)
@@ -347,6 +347,7 @@ int TrackView::slotAddProjectTrack(int ix, QDomElement xml, bool videotrack) {
                 //kDebug() << "// INSERTING CLIP: " << in << "x" << out << ", track: " << ix << ", ID: " << id << ", SCALE: " << m_scale << ", FPS: " << m_doc->fps();
                 ClipItem *item = new ClipItem(clip, clipinfo, GenTime(in, m_doc->fps()), m_scale, m_doc->fps());
                 m_scene->addItem(item);
+                clip->addReference();
                 position += (out - in);
 
                 // parse clip effects