1 /***************************************************************************
2 * Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
35 #include <kautosavefile.h>
39 #include "definitions.h"
49 class KProgressDialog;
51 class KdenliveDoc: public QObject
55 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 = 0, KProgressDialog *progressDialog = 0);
57 QDomNodeList producersList();
62 KAutoSaveFile *m_autosave;
63 Timecode timecode() const;
65 //void setRenderer(Render *render);
66 QUndoStack *commandStack();
67 QString producerName(const QString &id);
69 QDomDocument m_guidesXml;
70 QDomElement guidesXml() const;
71 ClipManager *clipManager();
73 /** @brief Adds a clip to the project tree.
74 * @return false if the user aborted the operation, true otherwise */
75 bool addClip(QDomElement elem, QString clipId, bool createClipItem = true);
77 /** @brief Updates information about a clip.
78 * @param elem the <kdenlive_producer />
79 * @param orig the potential <producer />
80 * @param clipId the producer id
81 * @return false if the user aborted the operation (in case the clip wasn't
82 * there yet), true otherwise
84 * If the clip wasn't added before, it tries to add it to the project. */
85 bool addClipInfo(QDomElement elem, QDomElement orig, QString clipId);
86 void slotAddClipList(const KUrl::List urls, stringMap data = stringMap());
87 void deleteClip(const QString &clipId);
88 int getFramePos(QString duration);
89 DocClipBase *getBaseClip(const QString &clipId);
90 void updateClip(const QString &id);
92 /** @brief Informs Kdenlive of the audio thumbnails generation progress. */
93 void setThumbsProgress(const QString &message, int progress);
94 const QString &profilePath() const;
95 MltVideoProfile mltProfile() const;
96 const QString description() const;
97 void setUrl(KUrl url);
99 /** @brief Updates the project profile.
100 * @return true if frame rate was changed */
101 bool setProfilePath(QString path);
102 const QString getFreeClipId();
104 /** @brief Defines whether the document needs to be saved. */
105 bool isModified() const;
107 /** @brief Returns the project folder, used to store project files. */
108 KUrl projectFolder() const;
109 void syncGuides(QList <Guide *> guides);
110 void setZoom(int horizontal, int vertical);
113 double projectDuration() const;
114 /** @brief Returns the project file xml. */
115 QDomDocument xmlSceneList(const QString &scene, const QStringList &expandedFolders);
116 /** @brief Saves the project file xml to a file. */
117 bool saveSceneList(const QString &path, const QString &scene, const QStringList &expandedFolders, bool autosave = false);
118 int tracksCount() const;
119 TrackInfo trackInfoAt(int ix) const;
120 void insertTrack(int ix, TrackInfo type);
121 void deleteTrack(int ix);
122 void setTrackType(int ix, TrackInfo type);
123 const QList <TrackInfo> tracksList() const;
125 /** @brief Gets the number of audio and video tracks and returns them as a QPoint with x = video, y = audio. */
126 QPoint getTracksCount() const;
128 void switchTrackVideo(int ix, bool hide);
129 void switchTrackAudio(int ix, bool hide);
130 void switchTrackLock(int ix, bool lock);
131 bool isTrackLocked(int ix) const;
133 /** @brief Sets the duration of track @param ix to @param duration.
134 * This does not! influence the actual track but only the value in its TrackInfo. */
135 void setTrackDuration(int ix, int duration);
137 /** @brief Returns the duration of track @param ix.
139 * The returned duration might differ from the actual track duration!
140 * It is the one stored in the track's TrackInfo. */
141 int trackDuration(int ix);
142 void cacheImage(const QString &fileId, const QImage &img) const;
143 void setProjectFolder(KUrl url);
144 void setZone(int start, int end);
147 void setDocumentProperty(const QString &name, const QString &value);
148 const QString getDocumentProperty(const QString &name) const;
150 /** @brief Gets the list of renderer properties saved into the document. */
151 QMap <QString, QString> getRenderProperties() const;
152 void addTrackEffect(int ix, QDomElement effect);
153 void removeTrackEffect(int ix, QDomElement effect);
154 void setTrackEffect(int trackIndex, int effectIndex, QDomElement effect);
155 const EffectsList getTrackEffects(int ix);
156 /** @brief Enable / disable an effect in Kdenlive's xml list. */
157 void enableTrackEffects(int trackIndex, QList <int> effectIndexes, bool disable);
158 QDomElement getTrackEffect(int trackIndex, int effectIndex) const;
159 /** @brief Check if a track already contains a specific effect. */
160 int hasTrackEffect(int trackIndex, const QString &tag, const QString &id) const;
161 /** @brief Get a list of folder id's that were opened on last save. */
162 QStringList getExpandedFolders();
163 /** @brief Read the display ratio from an xml project file. */
164 static double getDisplayRatio(const QString &path);
165 /** @brief Backup the project file */
166 void backupLastSavedVersion(const QString &path);
167 /** @brief Returns the document metadata (author, copyright, ...) */
168 const QMap <QString, QString> metadata() const;
169 /** @brief Set the document metadata (author, copyright, ...) */
170 void setMetadata(const QMap <QString, QString> meta);
174 QDomDocument m_document;
180 KTextEdit *m_notesWidget;
181 QUndoStack *m_commandStack;
182 ClipManager *m_clipManager;
183 MltVideoProfile m_profile;
184 QTimer *m_autoSaveTimer;
185 QString m_searchFolder;
187 /** @brief Tells whether the current document has been changed after being saved. */
190 /** @brief The project folder, used to store project files (titles, effects...). */
191 KUrl m_projectFolder;
192 QMap <QString, QString> m_documentProperties;
193 QMap <QString, QString> m_documentMetadata;
195 QList <TrackInfo> m_tracksList;
196 void setNewClipResource(const QString &id, const QString &path);
197 QString searchFileRecursively(const QDir &dir, const QString &matchSize, const QString &matchHash) const;
198 void moveProjectData(KUrl url);
199 bool checkDocumentClips(QDomNodeList infoproducers);
201 /** @brief Creates a new project. */
202 QDomDocument createEmptyDocument(int videotracks, int audiotracks);
203 QDomDocument createEmptyDocument(QList <TrackInfo> tracks);
204 /** @brief Saves effects embedded in project file.
205 * @return True if effects were imported. */
206 bool saveCustomEffects(QDomNodeList customeffects);
208 /** @brief Updates the project folder location entry in the kdenlive file dialogs to point to the current project folder. */
209 void updateProjectFolderPlacesEntry();
210 /** @brief Only keep some backup files, delete some */
211 void cleanupBackupFiles();
214 void slotCreateXmlClip(const QString &name, const QDomElement xml, QString group, const QString &groupId);
215 void slotCreateColorClip(const QString &name, const QString &color, const QString &duration, QString group, const QString &groupId);
216 void slotCreateSlideshowClipFile(QMap <QString, QString> properties, QString group, const QString &groupId);
217 void slotCreateTextClip(QString group, const QString &groupId, const QString &templatePath = QString());
218 void slotCreateTextTemplateClip(QString group, const QString &groupId, KUrl path);
220 /** @brief Sets the document as modified or up to date.
221 * @param mod (optional) true if the document has to be saved */
222 void setModified(bool mod = true);
223 void checkProjectClips(bool displayRatioChanged = false, bool fpsChanged = false);
224 void slotAddClipFile(const KUrl &url, stringMap data);
230 void resetProjectList();
231 void addProjectClip(DocClipBase *, bool getInfo = true);
232 void signalDeleteProjectClip(const QString &);
233 void updateClipDisplay(const QString&);
234 void progressInfo(const QString &, int);
236 /** @brief Informs that the document status has been changed.
238 * If the document has been modified, it's called with true as an argument. */
239 void docModified(bool);
240 void selectLastAddedClip(const QString &);
241 void guidesUpdated();
242 /** @brief When creating a backup file, also save a thumbnail of current timeline */
243 void saveTimelinePreview(const QString &path);