From: Jean-Baptiste Mardelle Date: Tue, 10 Jun 2008 21:35:28 +0000 (+0000) Subject: load & save guides X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=2117079e79767c3d63f7f116a47681b2180aacd3;p=kdenlive load & save guides svn path=/branches/KDE4/; revision=2245 --- diff --git a/src/customtrackview.cpp b/src/customtrackview.cpp index 8655f009..6bcf5642 100644 --- a/src/customtrackview.cpp +++ b/src/customtrackview.cpp @@ -1487,6 +1487,20 @@ void CustomTrackView::drawBackground(QPainter * painter, const QRectF & rect) { if (height() > lowerLimit) painter->fillRect(QRectF(rectInView.left(), lowerLimit, rectInView.width(), height() - lowerLimit), QBrush(base)); } + +QDomElement CustomTrackView::xmlInfo() { + QDomDocument doc; + QDomElement e; + QDomElement guides = doc.createElement("guides"); + for (int i = 0; i < m_guides.count(); i++) { + e = doc.createElement("guide"); + e.setAttribute("time", m_guides.at(i)->position().ms() / 1000); + e.setAttribute("comment", m_guides.at(i)->label()); + guides.appendChild(e); + } + return guides; +} + /* void CustomTrackView::drawForeground ( QPainter * painter, const QRectF & rect ) { diff --git a/src/customtrackview.h b/src/customtrackview.h index 11876517..01616086 100644 --- a/src/customtrackview.h +++ b/src/customtrackview.h @@ -82,6 +82,7 @@ public: void slotSeekToPreviousSnap(); void slotSeekToNextSnap(); double getSnapPointForPos(double pos); + QDomElement xmlInfo(); public slots: void setCursorPos(int pos, bool seek = true); @@ -100,6 +101,7 @@ public slots: void slotSwitchTrackVideo(int ix); void slotUpdateClip(int clipId); void slotAddClipMarker(int id, GenTime t, QString c); + void addGuide(const GenTime pos, const QString &comment); void slotAddGuide(); void slotDeleteGuide(); void editGuide(const GenTime oldPos, const GenTime pos, const QString &comment); @@ -158,7 +160,6 @@ private: /** Get the index of the video track that is just below current track */ int getPreviousVideoTrack(int track); void updateClipFade(ClipItem * item, bool updateFadeOut = false); - void addGuide(const GenTime pos, const QString &comment); signals: void cursorMoved(int, int); diff --git a/src/kdenlivedoc.cpp b/src/kdenlivedoc.cpp index 6e0d2e5f..624a3e93 100644 --- a/src/kdenlivedoc.cpp +++ b/src/kdenlivedoc.cpp @@ -312,7 +312,7 @@ void KdenliveDoc::convertDocument(double version) { //kDebug() << "///////////////// END CONVERTED DOC:"; } -QDomElement KdenliveDoc::documentInfoXml() { +QDomElement KdenliveDoc::documentInfoXml(QDomElement timelineInfo) { QDomDocument doc; QDomElement e; QDomElement addedXml = doc.createElement("kdenlivedoc"); @@ -335,6 +335,7 @@ QDomElement KdenliveDoc::documentInfoXml() { } } addedXml.appendChild(markers); + addedXml.appendChild(doc.importNode(timelineInfo, true)); //kDebug() << m_document.toString(); return addedXml; } diff --git a/src/kdenlivedoc.h b/src/kdenlivedoc.h index e6e972fa..463e4cda 100644 --- a/src/kdenlivedoc.h +++ b/src/kdenlivedoc.h @@ -84,7 +84,7 @@ Q_OBJECT public: /** Returns the document format: PAL or NTSC */ QString getDocumentStandard(); void setUrl(KUrl url); - QDomElement documentInfoXml(); + QDomElement documentInfoXml(QDomElement timelineInfo); void setProfilePath(QString path); /** Set to true if document needs saving, false otherwise */ void setModified(bool mod); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d9a62246..37a19f73 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -617,7 +617,7 @@ void MainWindow::slotRemoveTab() { } void MainWindow::saveFileAs(const QString &outputFileName) { - m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml()); + m_projectMonitor->saveSceneList(outputFileName, m_activeDocument->documentInfoXml(m_activeTimeline->projectView()->xmlInfo())); m_activeDocument->setUrl(KUrl(outputFileName)); setCaption(m_activeDocument->description()); m_timelineArea->setTabText(m_timelineArea->currentIndex(), m_activeDocument->description()); diff --git a/src/trackview.cpp b/src/trackview.cpp index c8f7266d..fe941cbb 100644 --- a/src/trackview.cpp +++ b/src/trackview.cpp @@ -233,6 +233,15 @@ void TrackView::parseDocument(QDomDocument doc) { } } + // Add guides + QDomNodeList guides = doc.elementsByTagName("guide"); + kDebug() << "//////////// OPENING PRJECT FILE, FOUND: " << guides.count() << " GUIDES$$$$$$$$$"; + for (int i = 0; i < guides.count(); i++) { + e = guides.item(i).toElement(); + const QString comment = e.attribute("comment"); + const GenTime pos = GenTime(e.attribute("time").toDouble()); + m_trackview->addGuide(pos, comment); + } m_trackview->setDuration(duration); kDebug() << "/////////// TOTAL PROJECT DURATION: " << duration;