]> git.sesse.net Git - kdenlive/blob - src/kdenlivedoc.h
* new: crash recovery feature
[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.h>
26 #include <qmap.h>
27 #include <QList>
28 #include <QObject>
29 #include <QUndoGroup>
30 #include <QTimer>
31
32 #include <KUndoStack>
33 #include <kurl.h>
34
35 #include "gentime.h"
36 #include "timecode.h"
37 #include "definitions.h"
38 #include "guide.h"
39
40 class Render;
41 class ClipManager;
42 class DocClipBase;
43 class MainWindow;
44
45 class KdenliveDoc: public QObject {
46 Q_OBJECT public:
47
48     KdenliveDoc(const KUrl &url, const KUrl &projectFolder, MltVideoProfile profile, QUndoGroup *undoGroup, MainWindow *parent = 0);
49     ~KdenliveDoc();
50     QDomNodeList producersList();
51     double fps() const;
52     int width() const;
53     int height() const;
54     KUrl url() const;
55     void backupMltPlaylist();
56     Timecode timecode() const;
57     QDomDocument toXml() const;
58     void setRenderer(Render *render);
59     KUndoStack *commandStack();
60     QString producerName(int id);
61     void setProducerDuration(int id, int duration);
62     int getProducerDuration(int id);
63     Render *renderer();
64     QDomElement m_guidesXml;
65     ClipManager *clipManager();
66     void addClip(const QDomElement &elem, const int clipId);
67     void addFolder(const QString foldername, int clipId, bool edit);
68     void deleteFolder(const QString foldername, int clipId);
69     void slotAddClipFile(const KUrl url, const QString group, const int groupId = -1);
70     void slotAddTextClipFile(const QString path, const QString group, const int groupId = -1);
71     void editTextClip(QString path, int id);
72     void slotAddFolder(const QString folderName);
73     void slotDeleteFolder(const QString folderName, const int id);
74     void slotEditFolder(const QString folderName, const QString oldfolderName, int clipId);
75     void slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group, const int groupId = -1);
76     void slotAddSlideshowClipFile(const QString name, const QString path, int count, const QString duration, bool loop, const QString group, const int groupId = -1);
77     void deleteClip(const uint clipId);
78     int getFramePos(QString duration);
79     DocClipBase *getBaseClip(int clipId);
80     void updateClip(int id);
81     void deleteProjectClip(QList <int> ids);
82     void deleteProjectFolder(QMap <QString, int> map);
83     /** Inform application of the audio thumbnails generation progress */
84     void setThumbsProgress(const QString &message, int progress);
85     QString profilePath() const;
86     QString description() const;
87     /** Returns the document format: PAL or NTSC */
88     QString getDocumentStandard();
89     void setUrl(KUrl url);
90     QDomElement documentInfoXml();
91     void setProfilePath(QString path);
92     /** Set to true if document needs saving, false otherwise */
93     void setModified(bool mod);
94     int getFreeClipId();
95     /** does the document need saving */
96     bool isModified() const;
97     /** Returns project folder, used to store project files (titles, effects,...) */
98     KUrl projectFolder() const;
99     /** Used to inform main app of the current document loading progress */
100     void loadingProgressed();
101     void updateAllProjectClips();
102     void syncGuides(QList <Guide *> guides);
103
104 private:
105     KUrl m_url;
106     KUrl m_recoveryUrl;
107     QDomDocument m_document;
108     QString m_projectName;
109     double m_fps;
110     /** Cursor position at document opening */
111     int m_startPos;
112     int m_width;
113     int m_height;
114     Timecode m_timecode;
115     Render *m_render;
116     KUndoStack *m_commandStack;
117     QDomDocument generateSceneList();
118     ClipManager *m_clipManager;
119     MltVideoProfile m_profile;
120     QString m_scenelist;
121     QTimer *m_autoSaveTimer;
122     /** tells whether current doc has been changed since last save event */
123     bool m_modified;
124     /** Project folder, used to store project files (titles, effects,...) */
125     KUrl m_projectFolder;
126     double m_documentLoadingStep;
127     double m_documentLoadingProgress;
128     void convertDocument(double version);
129
130 public slots:
131     void slotCreateTextClip(QString group, int groupId);
132
133 private slots:
134     void slotAutoSave();
135
136 signals:
137     void addProjectClip(DocClipBase *);
138     void addProjectFolder(const QString, int, bool, bool edit = false);
139     void signalDeleteProjectClip(int);
140     void updateClipDisplay(int);
141     void deletTimelineClip(int);
142     void progressInfo(const QString &, int);
143     /** emited when the document state has been modified (= needs saving or not) */
144     void docModified(bool);
145     void refreshClipThumbnail(int);
146 };
147
148 #endif