]> git.sesse.net Git - kdenlive/commitdiff
Save folder state (opened / close):
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 23 Feb 2011 22:53:28 +0000 (22:53 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Wed, 23 Feb 2011 22:53:28 +0000 (22:53 +0000)
http://kdenlive.org/mantis/view.php?id=2036

svn path=/trunk/kdenlive/; revision=5456

src/kdenlivedoc.cpp
src/kdenlivedoc.h
src/mainwindow.cpp
src/projectlist.cpp
src/projectlist.h

index d4eaa6da10b21259885cc3948c26a552e28dbb89..cf065b7dea11777bcf1739a3d87593d546acd7aa 100644 (file)
@@ -166,12 +166,14 @@ KdenliveDoc::KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup
                                 }
                                 mlt.removeChild(tracksinfo);
                             }
-
+                            QStringList expandedFolders;
                             QDomNodeList folders = m_document.elementsByTagName("folder");
                             for (int i = 0; i < folders.count(); i++) {
                                 e = folders.item(i).cloneNode().toElement();
+                                if (e.hasAttribute("opened")) expandedFolders.append(e.attribute("id"));
                                 m_clipManager->addFolder(e.attribute("id"), e.attribute("name"));
                             }
+                            m_documentProperties["expandedfolders"] = expandedFolders.join(";");
 
                             const int infomax = infoproducers.count();
                             QDomNodeList producers = m_document.elementsByTagName("producer");
@@ -507,7 +509,7 @@ void KdenliveDoc::slotAutoSave()
             kDebug() << "ERROR; CANNOT CREATE AUTOSAVE FILE";
         }
         kDebug() << "// AUTOSAVE FILE: " << m_autosave->fileName();
-        saveSceneList(m_autosave->fileName(), m_render->sceneList());
+        saveSceneList(m_autosave->fileName(), m_render->sceneList(), QStringList());
     }
 }
 
@@ -533,7 +535,7 @@ QPoint KdenliveDoc::zone() const
     return QPoint(m_documentProperties.value("zonein").toInt(), m_documentProperties.value("zoneout").toInt());
 }
 
-bool KdenliveDoc::saveSceneList(const QString &path, const QString &scene)
+bool KdenliveDoc::saveSceneList(const QString &path, const QString &scene, const QStringList expandedFolders)
 {
     QDomDocument sceneList;
     sceneList.setContent(scene, true);
@@ -627,6 +629,7 @@ bool KdenliveDoc::saveSceneList(const QString &path, const QString &scene)
         QDomElement folder = sceneList.createElement("folder");
         folder.setAttribute("id", f.key());
         folder.setAttribute("name", f.value());
+        if (expandedFolders.contains(f.key())) folder.setAttribute("opened", "1");
         addedXml.appendChild(folder);
     }
 
@@ -1526,5 +1529,13 @@ void KdenliveDoc::updateProjectFolderPlacesEntry()
     }
 }
 
+QStringList KdenliveDoc::getExpandedFolders()
+{
+    QStringList result = m_documentProperties.value("expandedfolders").split(';');
+    // this property is only needed once when opening project, so clear it now
+    m_documentProperties.remove("expandedfolders");
+    return result;
+}
+
 #include "kdenlivedoc.moc"
 
index 31dde8ea0ca4425c055a6a44d7f25be855680a19..f38051a814c855c4760966ffc6bf430760542bf4 100644 (file)
@@ -112,7 +112,7 @@ Q_OBJECT public:
     QPoint zoom() const;
     double dar() const;
     double projectDuration() const;
-    bool saveSceneList(const QString &path, const QString &scene);
+    bool saveSceneList(const QString &path, const QString &scene, const QStringList expandedFolders);
     int tracksCount() const;
     TrackInfo trackInfoAt(int ix) const;
     void insertTrack(int ix, TrackInfo type);
@@ -154,7 +154,9 @@ Q_OBJECT public:
     void setTrackEffect(int trackIndex, int effectIndex, QDomElement effect);
     const EffectsList getTrackEffects(int ix);
     QDomElement getTrackEffect(int trackIndex, int effectIndex) const;
-
+    /** @brief Get a list of folder id's that were opened on last save. */
+    QStringList getExpandedFolders();
+    
 private:
     KUrl m_url;
     QDomDocument m_document;
index 1b3ffe253a6d9607550dbee84feba00c0c522f43..93fae7c466dc366e227a4561340620246967afaa 100644 (file)
@@ -1858,7 +1858,7 @@ bool MainWindow::saveFileAs(const QString &outputFileName)
     QString currentSceneList;
     m_monitorManager->stopActiveMonitor();
 
-    if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList()) == false)
+    if (m_activeDocument->saveSceneList(outputFileName, m_projectMonitor->sceneList(), m_projectList->expandedFolders()) == false)
         return false;
 
     // Save timeline thumbnails
index 286121b30e698b919fb959822601d808cf4b671d..83c1bcef13bae3d10383b4af44dffa797c25b300 100644 (file)
@@ -998,7 +998,6 @@ void ProjectList::slotAddClip(DocClipBase *clip, bool getProperties)
     connect(clip, SIGNAL(abortProxy(const QString)), this, SLOT(slotAbortProxy(const QString)));
     if (getProperties) {
         m_listView->processLayout();
-        m_refreshed = false;
         QDomElement e = clip->toXML().cloneNode().toElement();
         e.removeAttribute("file_hash");
         m_infoQueue.insert(clip->getId(), e);
@@ -1085,7 +1084,6 @@ void ProjectList::slotResetProjectList()
 
 void ProjectList::requestClipInfo(const QDomElement xml, const QString id)
 {
-    m_refreshed = false;
     m_infoQueue.insert(id, xml);
     //if (m_infoQueue.count() == 1 || ) QTimer::singleShot(300, this, SLOT(slotProcessNextClipInQueue()));
 }
@@ -1434,10 +1432,12 @@ void ProjectList::setDocument(KdenliveDoc *doc)
     m_proxyList.clear();
 
     QMap <QString, QString> flist = doc->clipManager()->documentFolderList();
+    QStringList openedFolders = doc->getExpandedFolders();
     QMapIterator<QString, QString> f(flist);
     while (f.hasNext()) {
         f.next();
-        (void) new FolderProjectItem(m_listView, QStringList() << f.value(), f.key());
+        FolderProjectItem *folder = new FolderProjectItem(m_listView, QStringList() << f.value(), f.key());
+        folder->setExpanded(openedFolders.contains(f.key()));
     }
 
     QList <DocClipBase*> list = doc->clipManager()->documentClipList();
@@ -1481,7 +1481,7 @@ QDomElement ProjectList::producersList()
 
 void ProjectList::slotCheckForEmptyQueue()
 {
-    if (!m_refreshed && m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) {
+    if (!m_refreshed && m_processingClips.isEmpty() && m_thumbnailQueue.isEmpty() && m_infoQueue.isEmpty()) {
         m_refreshed = true;
         emit loadingIsOver();
         emit displayMessage(QString(), -1);
@@ -1593,6 +1593,10 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
 {
     QString toReload;
     ProjectItem *item = getItemById(clipId);
+    if (!m_refreshed) {
+        // we are still finishing to load the document
+        selectClip = false;
+    }
     m_processingClips.removeAll(clipId);
     if (m_infoQueue.isEmpty() && m_processingClips.isEmpty()) m_listView->setEnabled(true);
     if (item && producer) {
@@ -2368,4 +2372,23 @@ void ProjectList::monitorItemEditing(bool enable)
     else disconnect(m_listView, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(slotItemEdited(QTreeWidgetItem *, int)));     
 }
 
+QStringList ProjectList::expandedFolders() const
+{
+    QStringList result;
+    FolderProjectItem *item;
+    QTreeWidgetItemIterator it(m_listView);
+    while (*it) {
+        if ((*it)->type() != PROJECTFOLDERTYPE) {
+            ++it;
+            continue;
+        }
+        if ((*it)->isExpanded()) {
+            item = static_cast<FolderProjectItem *>(*it);
+            result.append(item->clipId());
+        }
+        ++it;
+    }
+    return result;
+}
+
 #include "projectlist.moc"
index a39e84e9e42fffb6d0d1cf0e5cbbc9145e3977c9..64b7457dcc720d38b930ee89b0f3f889f58d9eb0 100644 (file)
@@ -204,6 +204,8 @@ public:
     bool generateProxy() const;
     /** @brief Should we automatically create proxy clips for newly added clips. */
     bool generateImageProxy() const;
+    /** @brief Returns a list of the expanded folder ids. */
+    QStringList expandedFolders() const;
 
 public slots:
     void setDocument(KdenliveDoc *doc);
@@ -255,6 +257,7 @@ private:
     QMenu *m_transcodeAction;
     KdenliveDoc *m_doc;
     ItemDelegate *m_listViewDelegate;
+    /** @brief True if we have not yet finished opening the document. */
     bool m_refreshed;
     QToolButton *m_addButton;
     QToolButton *m_deleteButton;