]> git.sesse.net Git - kdenlive/blob - src/kdenlivedoc.h
Improve profile autodetection
[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 KdenliveDoc: public QObject
49 {
50 Q_OBJECT public:
51
52     KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, QString profileName, const QPoint tracks, Render *render, MainWindow *parent = 0);
53     ~KdenliveDoc();
54     QDomNodeList producersList();
55     double fps() const;
56     int width() const;
57     int height() const;
58     KUrl url() const;
59     KAutoSaveFile *m_autosave;
60     Timecode timecode() const;
61     QDomDocument toXml();
62     //void setRenderer(Render *render);
63     QUndoStack *commandStack();
64     QString producerName(const QString &id);
65     Render *renderer();
66     QDomDocument m_guidesXml;
67     QDomElement guidesXml() const;
68     ClipManager *clipManager();
69
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);
73
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
80      *
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);
89
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);
96
97     /** @brief Updates the project profile.
98      * @return true if frame rate was changed */
99     bool setProfilePath(QString path);
100     const QString getFreeClipId();
101
102     /** @brief Defines whether the document needs to be saved. */
103     bool isModified() const;
104
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);
109     QPoint zoom() const;
110     double dar() const;
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);
127     QPoint zone() const;
128     int setSceneList();
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;
133
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;
141
142 private:
143     KUrl m_url;
144     QDomDocument m_document;
145     double m_fps;
146     int m_width;
147     int m_height;
148     Timecode m_timecode;
149     Render *m_render;
150     QUndoStack *m_commandStack;
151     ClipManager *m_clipManager;
152     MltVideoProfile m_profile;
153     QTimer *m_autoSaveTimer;
154     QString m_searchFolder;
155
156     /** @brief Tells whether the current document has been changed after being saved. */
157     bool m_modified;
158
159     /** @brief The project folder, used to store project files (titles, effects...). */
160     KUrl m_projectFolder;
161     QMap <QString, QString> m_documentProperties;
162
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);
168
169     /** @brief Creates a new project. */
170     QDomDocument createEmptyDocument(int videotracks, int audiotracks);
171     QDomDocument createEmptyDocument(QList <TrackInfo> tracks);
172
173 public slots:
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);
185
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();
190
191 private slots:
192     void slotAutoSave();
193
194 signals:
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);
201
202     /** @brief Informs that the document status has been changed.
203      *
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();
208 };
209
210 #endif