From: Jean-Baptiste Mardelle Date: Sat, 5 Jan 2008 19:44:06 +0000 (+0000) Subject: Fix project view thumbnails X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=fef92ec8923f6fe591b0609021573175e1ae0898;p=kdenlive Fix project view thumbnails svn path=/branches/KDE4/; revision=1793 --- diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8befa8fc..2a51999b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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 > &))); } diff --git a/src/projectitem.cpp b/src/projectitem.cpp index 3c5dfc84..ba9b68ce 100644 --- a/src/projectitem.cpp +++ b/src/projectitem.cpp @@ -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(); diff --git a/src/projectlist.cpp b/src/projectlist.cpp index baeafea6..143b6ecc 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -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; } } - } diff --git a/src/projectlist.h b/src/projectlist.h index ced014da..f2a2d494 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -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 diff --git a/src/renderer.cpp b/src/renderer.cpp index 02f048ac..8bac2f46 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -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"< 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: "< &, 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);