]> git.sesse.net Git - kdenlive/blob - src/kdenlivedoc.h
Implement document notes:
[kdenlive] / src / kdenlivedoc.h
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
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.                                   *
8  *                                                                         *
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.                          *
13  *                                                                         *
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  ***************************************************************************/
19
20
21 #ifndef KDENLIVEDOC_H
22 #define KDENLIVEDOC_H
23
24 #include <qdom.h>
25 #include <QString>
26 #include <QMap>
27 #include <QList>
28 #include <QDir>
29 #include <QObject>
30 #include <QUndoGroup>
31 #include <QUndoStack>
32 #include <QTimer>
33
34 #include <KUrl>
35 #include <kautosavefile.h>
36
37 #include "gentime.h"
38 #include "timecode.h"
39 #include "definitions.h"
40 #include "guide.h"
41
42 class Render;
43 class ClipManager;
44 class DocClipBase;
45 class MainWindow;
46 class TrackInfo;
47
48 class KTextEdit;
49
50 class KdenliveDoc: public QObject
51 {
52 Q_OBJECT public:
53
54     KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, QString profileName, const QPoint tracks, Render *render, KTextEdit *notes, MainWindow *parent = 0);
55     ~KdenliveDoc();
56     QDomNodeList producersList();
57     double fps() const;
58     int width() const;
59     int height() const;
60     KUrl url() const;
61     KAutoSaveFile *m_autosave;
62     Timecode timecode() const;
63     QDomDocument toXml();
64     //void setRenderer(Render *render);
65     QUndoStack *commandStack();
66     QString producerName(const QString &id);
67     Render *renderer();
68     QDomDocument m_guidesXml;
69     QDomElement guidesXml() const;
70     ClipManager *clipManager();
71
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);
75
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
82      *
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);
91
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);
98
99     /** @brief Updates the project profile.
100      * @return true if frame rate was changed */
101     bool setProfilePath(QString path);
102     const QString getFreeClipId();
103
104     /** @brief Defines whether the document needs to be saved. */
105     bool isModified() const;
106
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);
111     QPoint zoom() const;
112     double dar() const;
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);
129     QPoint zone() const;
130     int setSceneList();
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;
135
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;
143
144 private:
145     KUrl m_url;
146     QDomDocument m_document;
147     double m_fps;
148     int m_width;
149     int m_height;
150     Timecode m_timecode;
151     Render *m_render;
152     KTextEdit *m_notesWidget;
153     QUndoStack *m_commandStack;
154     ClipManager *m_clipManager;
155     MltVideoProfile m_profile;
156     QTimer *m_autoSaveTimer;
157     QString m_searchFolder;
158
159     /** @brief Tells whether the current document has been changed after being saved. */
160     bool m_modified;
161
162     /** @brief The project folder, used to store project files (titles, effects...). */
163     KUrl m_projectFolder;
164     QMap <QString, QString> m_documentProperties;
165
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);
171
172     /** @brief Creates a new project. */
173     QDomDocument createEmptyDocument(int videotracks, int audiotracks);
174     QDomDocument createEmptyDocument(QList <TrackInfo> tracks);
175
176 public slots:
177     void slotCreateXmlClip(const QString &name, const QDomElement xml, QString group, const QString &groupId);
178     void slotCreateColorClip(const QString &name, const QString &color, const QString &duration, QString group, const QString &groupId);
179     void slotCreateSlideshowClipFile(const QString name, const QString path,
180                                      int count, const QString duration,
181                                      const bool loop, const bool crop,
182                                      const bool fade, const QString &luma_duration,
183                                      const QString &luma_file, const int softness,
184                                      const QString &animation, QString group,
185                                      const QString &groupId);
186     void slotCreateTextClip(QString group, const QString &groupId, const QString &templatePath = QString());
187     void slotCreateTextTemplateClip(QString group, const QString &groupId, KUrl path);
188
189     /** @brief Sets the document as modified or up to date.
190      * @param mod (optional) true if the document has to be saved */
191     void setModified(bool mod = true);
192     void checkProjectClips();
193
194 private slots:
195     void slotAutoSave();
196
197 signals:
198     void resetProjectList();
199     void addProjectClip(DocClipBase *, bool getInfo = true);
200     void signalDeleteProjectClip(const QString &);
201     void updateClipDisplay(const QString&);
202     void deleteTimelineClip(const QString&);
203     void progressInfo(const QString &, int);
204
205     /** @brief Informs that the document status has been changed.
206      *
207      * If the document has been modified, it's called with true as an argument. */
208     void docModified(bool);
209     void selectLastAddedClip(const QString &);
210     void guidesUpdated();
211 };
212
213 #endif