]> git.sesse.net Git - kdenlive/commitdiff
Fix project view thumbnails
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 5 Jan 2008 19:44:06 +0000 (19:44 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Sat, 5 Jan 2008 19:44:06 +0000 (19:44 +0000)
svn path=/branches/KDE4/; revision=1793

src/mainwindow.cpp
src/projectitem.cpp
src/projectlist.cpp
src/projectlist.h
src/renderer.cpp
src/renderer.h

index 8befa8fc72e50b520484e20fece9e17c0baf88ab..2a51999b1e3b508e3b3cc0a1de9ddb7dbaf5f2a8 100644 (file)
@@ -106,11 +106,13 @@ void MainWindow::slotConnectMonitors()
 
   connect(m_projectList, SIGNAL(clipSelected(const QDomElement &)), m_clipMonitor, SLOT(slotSetXml(const QDomElement &)));
 
-  connect(m_projectList, SIGNAL(getFileProperties(const KUrl &, uint)), m_clipMonitor->render, SLOT(getFileProperties(const KUrl &, uint)));
+  connect(m_projectList, SIGNAL(getFileProperties(const QDomElement &, int)), m_clipMonitor->render, SLOT(getFileProperties(const QDomElement &, int)));
 
-  connect(m_clipMonitor->render, SIGNAL(replyGetImage(const KUrl &, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(const KUrl &, int, const QPixmap &, int, int)));
+  //connect(m_projectList, SIGNAL(getFileProperties(const KUrl &, uint)), m_clipMonitor->render, SLOT(getFileProperties(const KUrl &, uint)));
 
-  connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(const QMap < QString, QString > &, const QMap < QString, QString > &)));
+  connect(m_clipMonitor->render, SIGNAL(replyGetImage(int, int, const QPixmap &, int, int)), m_projectList, SLOT(slotReplyGetImage(int, int, const QPixmap &, int, int)));
+
+  connect(m_clipMonitor->render, SIGNAL(replyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)), m_projectList, SLOT(slotReplyGetFileProperties(int, const QMap < QString, QString > &, const QMap < QString, QString > &)));
 
 }
 
index 3c5dfc844a29f39aa9207b15390952033ffbabb4..ba9b68ce1e2c163bf91667fdc9173412ac32c06d 100644 (file)
@@ -123,9 +123,9 @@ void ProjectItem::setProperties(const QMap < QString, QString > &attributes, con
        if (m_element.isNull()) {
          QDomDocument doc;
          m_element = doc.createElement("producer");
-         m_element.setAttribute("resource", attributes["filename"]);
-         m_element.setAttribute("type", (int) m_clipType);
-        }
+       }
+       m_element.setAttribute("resource", attributes["filename"]);
+       m_element.setAttribute("type", (int) m_clipType);
 /*
        if (attributes.contains("height")) {
            m_height = attributes["height"].toInt();
index baeafea651e3364819168bdfca1b7a45473c2983..143b6ecc38df3d45d61b02355ce078ea2650ff4f 100644 (file)
@@ -155,8 +155,14 @@ void ProjectList::addClip(const QStringList &name, const QDomElement &elem, cons
   ProjectItem *item = new ProjectItem(listView, name, elem, clipId);
   if (!url.isEmpty()) {
     item->setData(1, FullPathRole, url.path());
-    emit getFileProperties(url, elem.attribute("frame_thumbnail", 0).toInt());
   }
+  if (elem.isNull() ) {
+    QDomDocument doc;
+    QDomElement element = doc.createElement("producer");
+    element.setAttribute("resource", url.path());
+    emit getFileProperties(element, clipId);
+  }
+  else emit getFileProperties(elem, clipId);
 }
 
 void ProjectList::deleteClip(const int clipId)
@@ -275,7 +281,8 @@ QDomElement ProjectList::producersList()
   return prods;
 }
 
-void ProjectList::slotReplyGetFileProperties(const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata)
+
+void ProjectList::slotReplyGetFileProperties(int clipId, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata)
 {
   QTreeWidgetItem *parent = 0;
   int count =
@@ -286,7 +293,7 @@ void ProjectList::slotReplyGetFileProperties(const QMap < QString, QString > &pr
     QTreeWidgetItem *item =
       parent ? parent->child(i) : listView->topLevelItem(i);
 
-    if (item->data(1, FullPathRole).toString() == properties["filename"]) {
+    if (((ProjectItem *)item)->clipId() == clipId) {
       ((ProjectItem *) item)->setProperties(properties, metadata);
       break;
     }
@@ -294,7 +301,8 @@ void ProjectList::slotReplyGetFileProperties(const QMap < QString, QString > &pr
 }
 
 
-void ProjectList::slotReplyGetImage(const KUrl &url, int pos, const QPixmap &pix, int w, int h)
+
+void ProjectList::slotReplyGetImage(int clipId, int pos, const QPixmap &pix, int w, int h)
 {
   QTreeWidgetItem *parent = 0;
   int count =
@@ -305,12 +313,11 @@ void ProjectList::slotReplyGetImage(const KUrl &url, int pos, const QPixmap &pix
     QTreeWidgetItem *item =
       parent ? parent->child(i) : listView->topLevelItem(i);
 
-    if (item->data(1, FullPathRole).toString() == url.path()) {
-      item->setIcon(0, pix);
+      if (((ProjectItem *)item)->clipId() == clipId) {
+       item->setIcon(0, pix);
       break;
     }
   }
-
 }
 
 
index ced014da7b766279f9bef716063f2a77bcb36e66..f2a2d494ba5ba94956b1cb7070f9b8d368712596 100644 (file)
@@ -29,8 +29,8 @@ class ProjectList : public QWidget
   public slots:
     void setDocument(KdenliveDoc *doc);
     void addProducer(QDomElement producer);
-    void slotReplyGetImage(const KUrl &url, int pos, const QPixmap &pix, int w, int h);
-    void slotReplyGetFileProperties(const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata);
+    void slotReplyGetImage(int clipId, int pos, const QPixmap &pix, int w, int h);
+    void slotReplyGetFileProperties(int clipId, const QMap < QString, QString > &properties, const QMap < QString, QString > &metadata);
 
 
   private:
@@ -52,7 +52,7 @@ class ProjectList : public QWidget
 
   signals:
     void clipSelected(const QDomElement &);
-    void getFileProperties(const KUrl &, uint);
+    void getFileProperties(const QDomElement&, int);
 };
 
 #endif
index 02f048ac75efb3cdeb40d80f94ddc427726b8a13..8bac2f4670b0f1b3ad42ae9a1f03cf09b8eef319 100644 (file)
@@ -292,7 +292,7 @@ QPixmap Render::getVideoThumbnail(QString file, int frame_position, int width, i
     return pix;
 }
 
-
+/*
 void Render::getImage(KUrl url, int frame_position, QPoint size)
 {
     char *tmp = decodedString(url.path());
@@ -313,10 +313,10 @@ void Render::getImage(KUrl url, int frame_position, QPoint size)
        delete frame;
        emit replyGetImage(url, frame_position, pix, size.x(), size.y());
     }
-}
+}*/
 
 /* Create thumbnail for color */
-void Render::getImage(int id, QString color, QPoint size)
+/*void Render::getImage(int id, QString color, QPoint size)
 {
     QPixmap pixmap(size.x() - 2, size.y() - 2);
     color = color.replace(0, 2, "#");
@@ -327,10 +327,10 @@ void Render::getImage(int id, QString color, QPoint size)
     //copyBlt(&result, 1, 1, &pixmap, 0, 0, size.x() - 2, size.y() - 2);
     emit replyGetImage(id, result, size.x(), size.y());
 
-}
+}*/
 
 /* Create thumbnail for image */
-void Render::getImage(KUrl url, QPoint size)
+/*void Render::getImage(KUrl url, QPoint size)
 {
     QImage im;
     QPixmap pixmap;
@@ -356,7 +356,7 @@ void Render::getImage(KUrl url, QPoint size)
     result.fill(Qt::black);
     //copyBlt(&result, 1, 1, &pixmap, 0, 0, size.x() - 2, size.y() - 2);
     emit replyGetImage(url, 1, result, size.x(), size.y());
-}
+}*/
 
 
 double Render::consumerRatio() const
@@ -388,26 +388,34 @@ bool Render::isValid(KUrl url)
     return true;
 }
 
-
-void Render::getFileProperties(const KUrl &url, uint framenb)
+void Render::getFileProperties(const QDomElement &xml, int clipId)
 {
         int height = 40;
         int width = height * 16/9.0; //KdenliveSettings::displayratio();
-       char *tmp = decodedString(url.path());
-       Mlt::Producer producer(tmp);
+       QDomDocument doc;
+       QDomElement westley = doc.createElement("westley");
+       doc.appendChild(westley);
+       westley.appendChild(doc.importNode(xml, true));
+       kDebug()<<"////////////\n"<<doc.toString()<<"////////////////\n";
+       char *tmp = decodedString(doc.toString());
+
+       Mlt::Producer producer("westley-xml", tmp);
        delete[] tmp;
+
        if (producer.is_blank()) {
            return;
        }
-       producer.seek( framenb );
+       int frameNumber = xml.attribute( "frame_thumbnail", 0).toInt();
+       if ( frameNumber != 0 ) producer.seek( frameNumber );
        mlt_properties properties = MLT_PRODUCER_PROPERTIES( producer.get_producer() );
 
        QMap < QString, QString > filePropertyMap;
         QMap < QString, QString > metadataPropertyMap;
 
+       KUrl url = xml.attribute("resource", QString::null);
        filePropertyMap["filename"] = url.path();
        filePropertyMap["duration"] = QString::number(producer.get_playtime());
-        
+
         Mlt::Filter m_convert("avcolour_space");
         m_convert.set("forced", mlt_image_rgb24a);
         producer.attach(m_convert);
@@ -470,15 +478,15 @@ void Render::getFileProperties(const KUrl &url, uint framenb)
                 // Generate thumbnail for this frame
                QPixmap pixmap = frameThumbnail(frame, width, height, true);
 
-                emit replyGetImage(url, 0, pixmap, width, height);
+                emit replyGetImage(clipId, 0, pixmap, width, height);
 
            } else if (frame->get_int("test_audio") == 0) {
                 QPixmap pixmap(KStandardDirs::locate("appdata", "graphics/music.png"));
-                emit replyGetImage(url, 0, pixmap, width, height);
+                emit replyGetImage(clipId, 0, pixmap, width, height);
                filePropertyMap["type"] = "audio";
             }
        }
-       emit replyGetFileProperties(filePropertyMap, metadataPropertyMap);
+       emit replyGetFileProperties(clipId, filePropertyMap, metadataPropertyMap);
        kDebug()<<"REquested fuile info for: "<<url.path();
        delete frame;
 }
index 7e00c8ac92eb8acb1904284b1f35906e937d32e8..7f3c6b64f49c35919a4634c683761e28d5d990db 100644 (file)
@@ -79,18 +79,19 @@ class Render:public QObject {
     QPixmap getImageThumbnail(KUrl url, int width, int height);
 
        /** Return thumbnail for color clip */
-    void getImage(int id, QString color, QPoint size);
+    //void getImage(int id, QString color, QPoint size);
 
     static QPixmap frameThumbnail(Mlt::Frame *frame, int width, int height, bool border = false);
     
     /** Return thumbnail for image clip */
-    void getImage(KUrl url, QPoint size);
+    //void getImage(KUrl url, QPoint size);
 
        /** Requests a particular frame from the given file. 
         * 
         * The pixmap will be returned by emitting the replyGetImage() signal.
         * */
-    void getImage(KUrl url, int frame, QPoint size);
+    //void getImage(KUrl url, int frame, QPoint size);
+
 
        /** Wraps the VEML command of the same name. Sets the current scene list to
        be list. */
@@ -215,10 +216,10 @@ class Render:public QObject {
        /** This signal is emitted once a reply to createVideoXWidow() has been recieved. */
     void replyCreateVideoXWindow(WId);
        /** emitted when the renderer recieves a reply to a getFileProperties request. */
-    void replyGetFileProperties(const QMap < QString, QString > &, const QMap < QString, QString > &);
+    void replyGetFileProperties(int clipId, const QMap < QString, QString > &, const QMap < QString, QString > &);
 
        /** emitted when the renderer recieves a reply to a getImage request. */
-    void replyGetImage(const KUrl &, int, const QPixmap &, int, int);
+    void replyGetImage(int , int, const QPixmap &, int, int);
     void replyGetImage(int, const QPixmap &, int, int);
 
        /** Emitted when the renderer stops, either playing or rendering. */
@@ -252,7 +253,7 @@ class Render:public QObject {
        /** Wraps the VEML command of the same name. Requests the file properties
     for the specified url from the renderer. Upon return, the result will be emitted
     via replyGetFileProperties(). */
-    void getFileProperties(const KUrl &url, uint framenb = 0);
+    void getFileProperties(const QDomElement &xml, int clipId);
     
     void exportFileToFirewire(QString srcFileName, int port, GenTime startTime, GenTime endTime);
     static char *decodedString(QString str);