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, const QPoint tracks, Render *render, KTextEdit *notes, 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 slotAddClipFile(const KUrl url, const QString group, const QString &groupId = QString());
87 void slotAddClipList(const KUrl::List urls, const QString group, const QString &groupId = QString());
88 void deleteClip(const QString &clipId);
89 int getFramePos(QString duration);
90 DocClipBase *getBaseClip(const QString &clipId);
91 void updateClip(const QString id);
93 /** @brief Informs Kdenlive of the audio thumbnails generation progress. */
94 void setThumbsProgress(const QString &message, int progress);
95 const QString &profilePath() const;
96 MltVideoProfile mltProfile() const;
97 const QString description() const;
98 void setUrl(KUrl url);
100 /** @brief Updates the project profile.
101 * @return true if frame rate was changed */
102 bool setProfilePath(QString path);
103 const QString getFreeClipId();
105 /** @brief Defines whether the document needs to be saved. */
106 bool isModified() const;
108 /** @brief Returns the project folder, used to store project files. */
109 KUrl projectFolder() const;
110 void syncGuides(QList <Guide *> guides);
111 void setZoom(int horizontal, int vertical);
114 double projectDuration() const;
115 bool saveSceneList(const QString &path, const QString &scene);
116 int tracksCount() const;
117 TrackInfo trackInfoAt(int ix) const;
118 void insertTrack(int ix, TrackInfo type);
119 void deleteTrack(int ix);
120 void setTrackType(int ix, TrackInfo type);
121 const QList <TrackInfo> tracksList() const;
123 /** @brief Gets the number of audio and video tracks and returns them as a QPoint with x = video, y = audio. */
124 QPoint getTracksCount() const;
126 void switchTrackVideo(int ix, bool hide);
127 void switchTrackAudio(int ix, bool hide);
128 void switchTrackLock(int ix, bool lock);
129 bool isTrackLocked(int ix) const;
131 /** @brief Sets the duration of track @param ix to @param duration.
132 * This does not! influence the actual track but only the value in its TrackInfo. */
133 void setTrackDuration(int ix, int duration);
135 /** @brief Returns the duration of track @param ix.
137 * The returned duration might differ from the actual track duration!
138 * It is the one stored in the track's TrackInfo. */
139 int trackDuration(int ix);
141 void cachePixmap(const QString &fileId, const QPixmap &pix) const;
142 void setProjectFolder(KUrl url);
143 QString getLadspaFile() const;
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 QDomElement getTrackEffect(int trackIndex, int effectIndex) const;
160 QDomDocument m_document;
166 KTextEdit *m_notesWidget;
167 QUndoStack *m_commandStack;
168 ClipManager *m_clipManager;
169 MltVideoProfile m_profile;
170 QTimer *m_autoSaveTimer;
171 QString m_searchFolder;
173 /** @brief Tells whether the current document has been changed after being saved. */
176 /** @brief The project folder, used to store project files (titles, effects...). */
177 KUrl m_projectFolder;
178 QMap <QString, QString> m_documentProperties;
180 QList <TrackInfo> m_tracksList;
181 void setNewClipResource(const QString &id, const QString &path);
182 QString searchFileRecursively(const QDir &dir, const QString &matchSize, const QString &matchHash) const;
183 void moveProjectData(KUrl url);
184 bool checkDocumentClips(QDomNodeList infoproducers);
186 /** @brief Creates a new project. */
187 QDomDocument createEmptyDocument(int videotracks, int audiotracks);
188 QDomDocument createEmptyDocument(QList <TrackInfo> tracks);
189 /** @brief Saves effects embedded in project file.
190 * @return True if effects were imported. */
191 bool saveCustomEffects(QDomNodeList customeffects);
193 /** @brief Updates the project folder location entry in the kdenlive file dialogs to point to the current project folder. */
194 void updateProjectFolderPlacesEntry();
197 void slotCreateXmlClip(const QString &name, const QDomElement xml, QString group, const QString &groupId);
198 void slotCreateColorClip(const QString &name, const QString &color, const QString &duration, QString group, const QString &groupId);
199 void slotCreateSlideshowClipFile(const QString name, const QString path,
200 int count, const QString duration,
201 const bool loop, const bool crop,
202 const bool fade, const QString &luma_duration,
203 const QString &luma_file, const int softness,
204 const QString &animation, QString group,
205 const QString &groupId);
206 void slotCreateTextClip(QString group, const QString &groupId, const QString &templatePath = QString());
207 void slotCreateTextTemplateClip(QString group, const QString &groupId, KUrl path);
209 /** @brief Sets the document as modified or up to date.
210 * @param mod (optional) true if the document has to be saved */
211 void setModified(bool mod = true);
212 void checkProjectClips();
218 void resetProjectList();
219 void addProjectClip(DocClipBase *, bool getInfo = true);
220 void signalDeleteProjectClip(const QString &);
221 void updateClipDisplay(const QString&);
222 void deleteTimelineClip(const QString&);
223 void progressInfo(const QString &, int);
225 /** @brief Informs that the document status has been changed.
227 * If the document has been modified, it's called with true as an argument. */
228 void docModified(bool);
229 void selectLastAddedClip(const QString &);
230 void guidesUpdated();