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"
48 class KdenliveDoc: public QObject
52 KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, QString profileName, const QPoint tracks, Render *render, MainWindow *parent = 0);
54 QDomNodeList producersList();
59 KAutoSaveFile *m_autosave;
60 Timecode timecode() const;
62 //void setRenderer(Render *render);
63 QUndoStack *commandStack();
64 QString producerName(const QString &id);
66 QDomDocument m_guidesXml;
67 QDomElement guidesXml() const;
68 ClipManager *clipManager();
70 /** @brief Adds a clip to the project tree.
71 * @return false if the user aborted the operation, true otherwise */
72 bool addClip(QDomElement elem, QString clipId, bool createClipItem = true);
74 /** @brief Updates information about a clip.
75 * @param elem the <kdenlive_producer />
76 * @param orig the potential <producer />
77 * @param clipId the producer id
78 * @return false if the user aborted the operation (in case the clip wasn't
79 * there yet), true otherwise
81 * If the clip wasn't added before, it tries to add it to the project. */
82 bool addClipInfo(QDomElement elem, QDomElement orig, QString clipId);
83 void slotAddClipFile(const KUrl url, const QString group, const QString &groupId = QString());
84 void slotAddClipList(const KUrl::List urls, const QString group, const QString &groupId = QString());
85 void deleteClip(const QString &clipId);
86 int getFramePos(QString duration);
87 DocClipBase *getBaseClip(const QString &clipId);
88 void updateClip(const QString id);
90 /** @brief Informs Kdenlive of the audio thumbnails generation progress. */
91 void setThumbsProgress(const QString &message, int progress);
92 const QString &profilePath() const;
93 MltVideoProfile mltProfile() const;
94 const QString description() const;
95 void setUrl(KUrl url);
97 /** @brief Updates the project profile.
98 * @return true if frame rate was changed */
99 bool setProfilePath(QString path);
100 const QString getFreeClipId();
102 /** @brief Defines whether the document needs to be saved. */
103 bool isModified() const;
105 /** @brief Returns the project folder, used to store project files. */
106 KUrl projectFolder() const;
107 void syncGuides(QList <Guide *> guides);
108 void setZoom(int horizontal, int vertical);
111 double projectDuration() const;
112 bool saveSceneList(const QString &path, const QString &scene);
113 int tracksCount() const;
114 TrackInfo trackInfoAt(int ix) const;
115 void insertTrack(int ix, TrackInfo type);
116 void deleteTrack(int ix);
117 void setTrackType(int ix, TrackInfo type);
118 const QList <TrackInfo> tracksList() const;
119 QPoint getTracksCount() const;
120 void switchTrackVideo(int ix, bool hide);
121 void switchTrackAudio(int ix, bool hide);
122 void switchTrackLock(int ix, bool lock);
123 void cachePixmap(const QString &fileId, const QPixmap &pix) const;
124 void setProjectFolder(KUrl url);
125 QString getLadspaFile() const;
126 void setZone(int start, int end);
129 void updatePreviewSettings();
130 bool isTrackLocked(int ix) const;
131 void setDocumentProperty(const QString &name, const QString &value);
132 const QString getDocumentProperty(const QString &name) const;
134 /** @brief Gets the list of renderer properties saved into the document. */
135 QMap <QString, QString> getRenderProperties() const;
136 void addTrackEffect(int ix, QDomElement effect);
137 void removeTrackEffect(int ix, QDomElement effect);
138 void setTrackEffect(int trackIndex, int effectIndex, QDomElement effect);
139 const EffectsList getTrackEffects(int ix);
140 QDomElement getTrackEffect(int trackIndex, int effectIndex) const;
144 QDomDocument m_document;
150 QUndoStack *m_commandStack;
151 ClipManager *m_clipManager;
152 MltVideoProfile m_profile;
153 QTimer *m_autoSaveTimer;
154 QString m_searchFolder;
156 /** @brief Tells whether the current document has been changed after being saved. */
159 /** @brief The project folder, used to store project files (titles, effects...). */
160 KUrl m_projectFolder;
161 QMap <QString, QString> m_documentProperties;
163 QList <TrackInfo> m_tracksList;
164 void setNewClipResource(const QString &id, const QString &path);
165 QString searchFileRecursively(const QDir &dir, const QString &matchSize, const QString &matchHash) const;
166 void moveProjectData(KUrl url);
167 bool checkDocumentClips(QDomNodeList infoproducers);
169 /** @brief Creates a new project. */
170 QDomDocument createEmptyDocument(int videotracks, int audiotracks);
171 QDomDocument createEmptyDocument(QList <TrackInfo> tracks);
174 void slotCreateXmlClip(const QString &name, const QDomElement xml, QString group, const QString &groupId);
175 void slotCreateColorClip(const QString &name, const QString &color, const QString &duration, QString group, const QString &groupId);
176 void slotCreateSlideshowClipFile(const QString name, const QString path,
177 int count, const QString duration,
178 const bool loop, const bool crop,
179 const bool fade, const QString &luma_duration,
180 const QString &luma_file, const int softness,
181 const QString &animation, QString group,
182 const QString &groupId);
183 void slotCreateTextClip(QString group, const QString &groupId, const QString &templatePath = QString());
184 void slotCreateTextTemplateClip(QString group, const QString &groupId, KUrl path);
186 /** @brief Sets the document as modified or up to date.
187 * @param mod (optional) true if the document has to be saved */
188 void setModified(bool mod = true);
189 void checkProjectClips();
195 void resetProjectList();
196 void addProjectClip(DocClipBase *, bool getInfo = true);
197 void signalDeleteProjectClip(const QString &);
198 void updateClipDisplay(const QString&);
199 void deleteTimelineClip(const QString&);
200 void progressInfo(const QString &, int);
202 /** @brief Informs that the document status has been changed.
204 * If the document has been modified, it's called with true as an argument. */
205 void docModified(bool);
206 void selectLastAddedClip(const QString &);
207 void guidesUpdated();