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