]> git.sesse.net Git - kdenlive/blobdiff - src/kdenlivedoc.cpp
Merge branch 'master' of git://anongit.kde.org/kdenlive
[kdenlive] / src / kdenlivedoc.cpp
index fced33349963a9128fc6abb3380ea7b6cb06f8f5..fa243560202db0cea7625c85cb25214de39f4e94 100644 (file)
@@ -28,7 +28,7 @@
 #include "mainwindow.h"
 #include "documentchecker.h"
 #include "documentvalidator.h"
-#include "kdenlive-config.h"
+#include "config-kdenlive.h"
 #include "initeffects.h"
 
 #include <KDebug>
@@ -58,7 +58,7 @@
 
 const double DOCUMENTVERSION = 0.88;
 
-KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, QString profileName, QMap <QString, QString> properties, const QPoint tracks, Render *render, KTextEdit *notes, bool *openBackup, MainWindow *parent, KProgressDialog *progressDialog) :
+KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, QString profileName, QMap <QString, QString> properties, QMap <QString, QString> metadata, const QPoint &tracks, Render *render, KTextEdit *notes, bool *openBackup, MainWindow *parent, KProgressDialog *progressDialog) :
     QObject(parent),
     m_autosave(NULL),
     m_url(url),
@@ -68,9 +68,22 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
     m_modified(false),
     m_projectFolder(projectFolder)
 {
+    // init m_profile struct
+    m_profile.frame_rate_num = 0;
+    m_profile.frame_rate_den = 0;
+    m_profile.width = 0;
+    m_profile.height = 0;
+    m_profile.progressive = 0;
+    m_profile.sample_aspect_num = 0;
+    m_profile.sample_aspect_den = 0;
+    m_profile.display_aspect_num = 0;
+    m_profile.display_aspect_den = 0;
+    m_profile.colorspace = 0;
+
     m_clipManager = new ClipManager(this);
     m_autoSaveTimer = new QTimer(this);
     m_autoSaveTimer->setSingleShot(true);
+    connect(m_clipManager, SIGNAL(displayMessage(QString, int)), parent, SLOT(slotGotProgressInfo(QString,int)));
     bool success = false;
 
     // init default document properties
@@ -98,8 +111,15 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
         i.next();
         m_documentProperties[i.key()] = i.value();
     }
+    
+    // Load metadata
+    QMapIterator<QString, QString> j(metadata);
+    while (j.hasNext()) {
+        j.next();
+        m_documentMetadata[j.key()] = j.value();
+    }
 
-    if (QLocale() != QLocale::system()) {
+    if (QLocale().decimalPoint() != QLocale::system().decimalPoint()) {
         setlocale(LC_NUMERIC, "");
         QLocale systemLocale = QLocale::system();
         systemLocale.setNumberOptions(QLocale::OmitGroupSeparator);
@@ -273,6 +293,10 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
                                 QDomNamedNodeMap props = docproperties.attributes();
                                 for (int i = 0; i < props.count(); i++)
                                     m_documentProperties.insert(props.item(i).nodeName(), props.item(i).nodeValue());
+                                docproperties = infoXml.firstChildElement("documentmetadata");
+                                props = docproperties.attributes();
+                                for (int i = 0; i < props.count(); i++)
+                                    m_documentMetadata.insert(props.item(i).nodeName(), props.item(i).nodeValue());
 
                                 if (validator.isModified()) setModified(true);
                                 kDebug() << "Reading file: " << url.path() << ", found clips: " << producers.count();
@@ -568,7 +592,7 @@ QPoint KdenliveDoc::zone() const
     return QPoint(m_documentProperties.value("zonein").toInt(), m_documentProperties.value("zoneout").toInt());
 }
 
-QDomDocument KdenliveDoc::xmlSceneList(const QString &scene, const QStringList expandedFolders)
+QDomDocument KdenliveDoc::xmlSceneList(const QString &scene, const QStringList &expandedFolders)
 {
     QDomDocument sceneList;
     sceneList.setContent(scene, true);
@@ -631,6 +655,14 @@ QDomDocument KdenliveDoc::xmlSceneList(const QString &scene, const QStringList e
     }
     docproperties.setAttribute("position", m_render->seekPosition().frames(m_fps));
     addedXml.appendChild(docproperties);
+    
+    QDomElement docmetadata = sceneList.createElement("documentmetadata");
+    QMapIterator<QString, QString> j(m_documentMetadata);
+    while (j.hasNext()) {
+        j.next();
+        docmetadata.setAttribute(j.key(), j.value());
+    }
+    addedXml.appendChild(docmetadata);
 
     QDomElement docnotes = sceneList.createElement("documentnotes");
     QDomText value = sceneList.createTextNode(m_notesWidget->toHtml());
@@ -705,7 +737,7 @@ QDomDocument KdenliveDoc::xmlSceneList(const QString &scene, const QStringList e
     return sceneList;
 }
 
-bool KdenliveDoc::saveSceneList(const QString &path, const QString &scene, const QStringList expandedFolders, bool autosave)
+bool KdenliveDoc::saveSceneList(const QString &path, const QString &scene, const QStringList &expandedFolders, bool autosave)
 {
     QDomDocument sceneList = xmlSceneList(scene, expandedFolders);
     if (sceneList.isNull()) {
@@ -911,7 +943,7 @@ Render *KdenliveDoc::renderer()
     return m_render;
 }
 
-void KdenliveDoc::updateClip(const QString id)
+void KdenliveDoc::updateClip(const QString &id)
 {
     emit updateClipDisplay(id);
 }
@@ -1180,7 +1212,7 @@ void KdenliveDoc::deleteClip(const QString &clipId)
     emit signalDeleteProjectClip(clipId);
 }
 
-void KdenliveDoc::slotAddClipList(const KUrl::List urls, const QString group, const QString &groupId)
+void KdenliveDoc::slotAddClipList(const KUrl::List urls, const QString &group, const QString &groupId)
 {
     m_clipManager->slotAddClipList(urls, group, groupId);
     //emit selectLastAddedClip(QString::number(m_clipManager->lastClipId()));
@@ -1188,9 +1220,9 @@ void KdenliveDoc::slotAddClipList(const KUrl::List urls, const QString group, co
 }
 
 
-void KdenliveDoc::slotAddClipFile(const KUrl url, const QString group, const QString &groupId)
+void KdenliveDoc::slotAddClipFile(const KUrl &url, const QString &group, const QString &groupId, const QString &comment)
 {
-    m_clipManager->slotAddClipFile(url, group, groupId);
+    m_clipManager->slotAddClipFile(url, group, groupId, comment);
     emit selectLastAddedClip(QString::number(m_clipManager->lastClipId()));
     setModified(true);
 }
@@ -1219,7 +1251,7 @@ void KdenliveDoc::slotCreateColorClip(const QString &name, const QString &color,
     emit selectLastAddedClip(QString::number(m_clipManager->lastClipId()));
 }
 
-void KdenliveDoc::slotCreateSlideshowClipFile(const QString name, const QString path, int count, const QString duration,
+void KdenliveDoc::slotCreateSlideshowClipFile(const QString &name, const QString &path, int count, const QString &duration,
         const bool loop, const bool crop, const bool fade,
         const QString &luma_duration, const QString &luma_file, const int softness,
         const QString &animation, QString group, const QString &groupId)
@@ -1364,9 +1396,9 @@ QPoint KdenliveDoc::getTracksCount() const
     return QPoint(video, audio);
 }
 
-void KdenliveDoc::cachePixmap(const QString &fileId, const QPixmap &pix) const
+void KdenliveDoc::cacheImage(const QString &fileId, const QImage &img) const
 {
-    pix.save(m_projectFolder.path(KUrl::AddTrailingSlash) + "thumbs/" + fileId + ".png");
+    img.save(m_projectFolder.path(KUrl::AddTrailingSlash) + "thumbs/" + fileId + ".png");
 }
 
 bool KdenliveDoc::checkDocumentClips(QDomNodeList infoproducers)
@@ -1562,7 +1594,9 @@ void KdenliveDoc::updateProjectFolderPlacesEntry()
 
     const QString file = KStandardDirs::locateLocal("data", "kfileplaces/bookmarks.xml");
     KBookmarkManager *bookmarkManager = KBookmarkManager::managerForFile(file, "kfilePlaces");
+    if (!bookmarkManager) return;
     KBookmarkGroup root = bookmarkManager->root();
+    
     KBookmark bookmark = root.first();
 
     QString kdenliveName = KGlobal::mainComponent().componentName();
@@ -1747,5 +1781,15 @@ void KdenliveDoc::cleanupBackupFiles()
     }
 }
 
+const QMap <QString, QString> KdenliveDoc::metadata() const
+{
+    return m_documentMetadata;
+}
+
+void KdenliveDoc::setMetadata(const QMap <QString, QString> meta)
+{
+    m_documentMetadata = meta;
+}
+
 #include "kdenlivedoc.moc"