]> git.sesse.net Git - kdenlive/blobdiff - src/kdenlivedoc.cpp
Start caching of project tree thumbnails for faster project opening
[kdenlive] / src / kdenlivedoc.cpp
index e239cf7d40f0b4122f65bdc7c3418febb8c6be5f..77899a60e334f0aea8e280e4f54ad5bf01ac6e67 100644 (file)
@@ -58,6 +58,9 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
             if (!infoXmlNode.isNull()) {
                 QDomElement infoXml = infoXmlNode.toElement();
                 QString profilePath = infoXml.attribute("profile");
+                QString projectFolderPath = infoXml.attribute("projectfolder");
+                if (!projectFolderPath.isEmpty()) m_projectFolder = KUrl(projectFolderPath);
+                if (m_projectFolder.isEmpty()) m_projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
                 m_startPos = infoXml.attribute("position").toInt();
                 m_zoom = infoXml.attribute("zoom", "7").toInt();
                 setProfilePath(profilePath);
@@ -155,12 +158,17 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
         m_document = createEmptyDocument(tracks.x(), tracks.y());
         setProfilePath(profileName);
     }
+    if (m_projectFolder.isEmpty()) m_projectFolder = KUrl(KdenliveSettings::defaultprojectfolder());
+
+    // make sure that the necessary folders exist
+    KStandardDirs::makeDir(m_projectFolder.path() + "/titles/");
+    KStandardDirs::makeDir(m_projectFolder.path() + "/thumbs/");
+
     m_scenelist = m_document.toString();
     kDebug() << "KDEnnlive document, init timecode: " << m_fps;
     if (m_fps == 30000.0 / 1001.0) m_timecode.setFormat(30, true);
     else m_timecode.setFormat((int) m_fps);
 
-
     connect(m_autoSaveTimer, SIGNAL(timeout()), this, SLOT(slotAutoSave()));
 }
 
@@ -335,6 +343,8 @@ void KdenliveDoc::convertDocument(double version) {
         // TODO: convert 0.7 files to the new document format.
         return;
     }
+
+    QString tracksOrder;
     QDomNode westley = m_document.elementsByTagName("westley").at(1);
     QDomNode tractor = m_document.elementsByTagName("tractor").at(0);
     QDomNode kdenlivedoc = m_document.elementsByTagName("kdenlivedoc").at(0);
@@ -358,7 +368,11 @@ void KdenliveDoc::convertDocument(double version) {
         QDomElement pl = n.toElement();
         QDomElement track = m_document.createElement("track");
         QString trackType = pl.attribute("hide");
-        if (!trackType.isEmpty()) track.setAttribute("hide", trackType);
+        if (!trackType.isEmpty()) {
+            track.setAttribute("hide", trackType);
+            if (trackType == "video") tracksOrder.append('a');
+            else tracksOrder.append('v');
+        } else tracksOrder.append('v');
         QString playlist_id =  pl.attribute("id");
         if (playlist_id.isEmpty()) {
             playlist_id = "black_track";
@@ -643,6 +657,7 @@ void KdenliveDoc::convertDocument(double version) {
     westley0.removeChild(kdenlivedoc);
     QDomElement kdenlivedoc_new = m_document.createElement("kdenlivedoc");
     kdenlivedoc_new.setAttribute("profile", profile);
+    kdenlivedoc_new.setAttribute("tracks", tracksOrder);
     // Add all the producers that has a ressource in westley
     QDomElement westley_element = westley0.toElement();
     if (westley_element.isNull()) {
@@ -803,6 +818,7 @@ bool KdenliveDoc::saveSceneList(const QString &path, QDomDocument sceneList) {
     addedXml.setAttribute("version", "0.8");
     addedXml.setAttribute("profile", profilePath());
     addedXml.setAttribute("position", m_render->seekPosition().frames(m_fps));
+    addedXml.setAttribute("projectfolder", m_projectFolder.path());
     addedXml.setAttribute("tracks", getTracksInfo());
     addedXml.setAttribute("zoom", m_zoom);
 
@@ -844,7 +860,7 @@ ClipManager *KdenliveDoc::clipManager() {
 }
 
 KUrl KdenliveDoc::projectFolder() const {
-    if (m_projectFolder.isEmpty()) return KUrl(KStandardDirs::locateLocal("appdata", "/projects/"));
+    //if (m_projectFolder.isEmpty()) return KUrl(KStandardDirs::locateLocal("appdata", "/projects/"));
     return m_projectFolder;
 }
 
@@ -1178,7 +1194,7 @@ void KdenliveDoc::addClipInfo(QDomElement elem, QString clipId) {
             kDebug() << attrname << " = " << attributes.item(i).nodeValue();
         }
         clip->setProperties(properties);
-        emit addProjectClip(clip);
+        emit addProjectClip(clip, false);
     }
 }
 
@@ -1302,6 +1318,12 @@ void KdenliveDoc::deleteTrack(int ix) {
     m_tracksList.removeAt(ix);
 }
 
+void KdenliveDoc::setTrackType(int ix, TrackInfo type) {
+    m_tracksList[ix].type = type.type;
+    m_tracksList[ix].isMute = type.isMute;
+    m_tracksList[ix].isBlind = type.isBlind;
+}
+
 const QList <TrackInfo> KdenliveDoc::tracksList() const {
     return m_tracksList;
 }
@@ -1325,5 +1347,10 @@ QString KdenliveDoc::getTracksInfo() const {
     return result;
 }
 
+void KdenliveDoc::cachePixmap(const QString &fileId, const QPixmap &pix) const {
+    pix.save(m_projectFolder.path() + "/thumbs/" + fileId + ".png");
+}
+
+
 #include "kdenlivedoc.moc"