From: Jean-Baptiste Mardelle Date: Wed, 23 Feb 2011 22:53:28 +0000 (+0000) Subject: Save folder state (opened / close): X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=787f4f5c61761da7d96b3b9143ca28a7b1dd4e5c;p=kdenlive Save folder state (opened / close): http://kdenlive.org/mantis/view.php?id=2036 svn path=/trunk/kdenlive/; revision=5456 --- diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index d4eaa6da..cf065b7d 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -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" diff --git a/src/kdenlivedoc.h b/src/kdenlivedoc.h index 31dde8ea..f38051a8 100644 --- a/src/kdenlivedoc.h +++ b/src/kdenlivedoc.h @@ -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; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1b3ffe25..93fae7c4 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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 diff --git a/src/projectlist.cpp b/src/projectlist.cpp index 286121b3..83c1bcef 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -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 flist = doc->clipManager()->documentFolderList(); + QStringList openedFolders = doc->getExpandedFolders(); QMapIterator 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 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(*it); + result.append(item->clipId()); + } + ++it; + } + return result; +} + #include "projectlist.moc" diff --git a/src/projectlist.h b/src/projectlist.h index a39e84e9..64b7457d 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -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;