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"
50 class KdenliveDoc: public QObject
54 KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, QString profileName, const QPoint tracks, Render *render, KTextEdit *notes, MainWindow *parent = 0);
56 QDomNodeList producersList();
61 KAutoSaveFile *m_autosave;
62 Timecode timecode() const;
64 //void setRenderer(Render *render);
65 QUndoStack *commandStack();
66 QString producerName(const QString &id);
68 QDomDocument m_guidesXml;
69 QDomElement guidesXml() const;
70 ClipManager *clipManager();
72 /** @brief Adds a clip to the project tree.
73 * @return false if the user aborted the operation, true otherwise */
74 bool addClip(QDomElement elem, QString clipId, bool createClipItem = true);
76 /** @brief Updates information about a clip.
77 * @param elem the <kdenlive_producer />
78 * @param orig the potential <producer />
79 * @param clipId the producer id
80 * @return false if the user aborted the operation (in case the clip wasn't
81 * there yet), true otherwise
83 * If the clip wasn't added before, it tries to add it to the project. */
84 bool addClipInfo(QDomElement elem, QDomElement orig, QString clipId);
85 void slotAddClipFile(const KUrl url, const QString group, const QString &groupId = QString());
86 void slotAddClipList(const KUrl::List urls, const QString group, const QString &groupId = QString());
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 bool saveSceneList(const QString &path, const QString &scene);
115 int tracksCount() const;
116 TrackInfo trackInfoAt(int ix) const;
117 void insertTrack(int ix, TrackInfo type);
118 void deleteTrack(int ix);
119 void setTrackType(int ix, TrackInfo type);
120 const QList <TrackInfo> tracksList() const;
121 QPoint getTracksCount() const;
122 void switchTrackVideo(int ix, bool hide);
123 void switchTrackAudio(int ix, bool hide);
124 void switchTrackLock(int ix, bool lock);
125 void cachePixmap(const QString &fileId, const QPixmap &pix) const;
126 void setProjectFolder(KUrl url);
127 QString getLadspaFile() const;
128 void setZone(int start, int end);
131 void updatePreviewSettings();
132 bool isTrackLocked(int ix) const;
133 void setDocumentProperty(const QString &name, const QString &value);
134 const QString getDocumentProperty(const QString &name) const;
136 /** @brief Gets the list of renderer properties saved into the document. */
137 QMap <QString, QString> getRenderProperties() const;
138 void addTrackEffect(int ix, QDomElement effect);
139 void removeTrackEffect(int ix, QDomElement effect);
140 void setTrackEffect(int trackIndex, int effectIndex, QDomElement effect);
141 const EffectsList getTrackEffects(int ix);
142 QDomElement getTrackEffect(int trackIndex, int effectIndex) const;
146 QDomDocument m_document;
152 KTextEdit *m_notesWidget;
153 QUndoStack *m_commandStack;
154 ClipManager *m_clipManager;
155 MltVideoProfile m_profile;
156 QTimer *m_autoSaveTimer;
157 QString m_searchFolder;
159 /** @brief Tells whether the current document has been changed after being saved. */
162 /** @brief The project folder, used to store project files (titles, effects...). */
163 KUrl m_projectFolder;
164 QMap <QString, QString> m_documentProperties;
166 QList <TrackInfo> m_tracksList;
167 void setNewClipResource(const QString &id, const QString &path);
168 QString searchFileRecursively(const QDir &dir, const QString &matchSize, const QString &matchHash) const;
169 void moveProjectData(KUrl url);
170 bool checkDocumentClips(QDomNodeList infoproducers);
172 /** @brief Creates a new project. */
173 QDomDocument createEmptyDocument(int videotracks, int audiotracks);
174 QDomDocument createEmptyDocument(QList <TrackInfo> tracks);
175 /** @brief Saves effects embedded in project file.
176 * @return True if effects were imported. */
177 bool saveCustomEffects(QDomNodeList customeffects);
180 void slotCreateXmlClip(const QString &name, const QDomElement xml, QString group, const QString &groupId);
181 void slotCreateColorClip(const QString &name, const QString &color, const QString &duration, QString group, const QString &groupId);
182 void slotCreateSlideshowClipFile(const QString name, const QString path,
183 int count, const QString duration,
184 const bool loop, const bool crop,
185 const bool fade, const QString &luma_duration,
186 const QString &luma_file, const int softness,
187 const QString &animation, QString group,
188 const QString &groupId);
189 void slotCreateTextClip(QString group, const QString &groupId, const QString &templatePath = QString());
190 void slotCreateTextTemplateClip(QString group, const QString &groupId, KUrl path);
192 /** @brief Sets the document as modified or up to date.
193 * @param mod (optional) true if the document has to be saved */
194 void setModified(bool mod = true);
195 void checkProjectClips();
201 void resetProjectList();
202 void addProjectClip(DocClipBase *, bool getInfo = true);
203 void signalDeleteProjectClip(const QString &);
204 void updateClipDisplay(const QString&);
205 void deleteTimelineClip(const QString&);
206 void progressInfo(const QString &, int);
208 /** @brief Informs that the document status has been changed.
210 * If the document has been modified, it's called with true as an argument. */
211 void docModified(bool);
212 void selectLastAddedClip(const QString &);
213 void guidesUpdated();