]> git.sesse.net Git - kdenlive/blob - src/kdenlivedoc.h
* Cleanup folder creation
[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 Q_OBJECT public:
50
51     KdenliveDoc(const KUrl &url, const KUrl &projectFolder, QUndoGroup *undoGroup, const QString &profileName, const QPoint tracks, Render *render, MainWindow *parent = 0);
52     ~KdenliveDoc();
53     QDomNodeList producersList();
54     double fps() const;
55     int width() const;
56     int height() const;
57     KUrl url() const;
58     KAutoSaveFile *m_autosave;
59     void backupMltPlaylist();
60     Timecode timecode() const;
61     QDomDocument toXml();
62     //void setRenderer(Render *render);
63     QUndoStack *commandStack();
64     QString producerName(const QString &id);
65     void setProducerDuration(const QString &id, int duration);
66     int getProducerDuration(const QString &id);
67     Render *renderer();
68     QDomElement m_guidesXml;
69     QDomElement guidesXml() const;
70     ClipManager *clipManager();
71     void addClip(QDomElement elem, QString clipId, bool createClipItem = true);
72     void addClipInfo(QDomElement elem, QDomElement orig, QString clipId);
73     void slotAddClipFile(const KUrl url, const QString group, const QString &groupId = QString());
74     void slotAddClipList(const KUrl::List urls, const QString group, const QString &groupId = QString());
75     void slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group, const QString &groupId = QString());
76     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());
77     void deleteClip(const QString &clipId);
78     int getFramePos(QString duration);
79     DocClipBase *getBaseClip(const QString &clipId);
80     void updateClip(const QString &id);
81     void deleteProjectClip(QList <QString> ids);
82     /** Inform application of the audio thumbnails generation progress */
83     void setThumbsProgress(const QString &message, int progress);
84     QString profilePath() const;
85     MltVideoProfile mltProfile() const;
86     QString description() const;
87     void setUrl(KUrl url);
88     void setProfilePath(QString path);
89     const QString &getFreeClipId();
90     /** does the document need saving */
91     bool isModified() const;
92     /** Returns project folder, used to store project files (titles, effects,...) */
93     KUrl projectFolder() const;
94     /** Used to inform main app of the current document loading progress */
95     void loadingProgressed();
96     void syncGuides(QList <Guide *> guides);
97     void setZoom(int factor);
98     int zoom() const;
99     const double dar();
100     double projectDuration() const;
101     bool saveSceneList(const QString &path, QDomDocument sceneList);
102     int tracksCount() const;
103     TrackInfo trackInfoAt(int ix) const;
104     void insertTrack(int ix, TrackInfo type);
105     void deleteTrack(int ix);
106     void setTrackType(int ix, TrackInfo type);
107     const QList <TrackInfo> tracksList() const;
108     QPoint getTracksCount() const;
109     QString getTracksInfo() const;
110     void switchTrackVideo(int ix, bool hide);
111     void switchTrackAudio(int ix, bool hide);
112     void cachePixmap(const QString &fileId, const QPixmap &pix) const;
113     void setProjectFolder(KUrl url);
114     QString getLadspaFile() const;
115     void setZone(int start, int end);
116     QPoint zone() const;
117     void setSceneList();
118     void updatePreviewSettings();
119
120 private:
121     KUrl m_url;
122     QDomDocument m_document;
123     QString m_projectName;
124     double m_fps;
125     int m_zoom;
126     /** Cursor position at document opening */
127     int m_startPos;
128     int m_width;
129     int m_height;
130     Timecode m_timecode;
131     Render *m_render;
132     QUndoStack *m_commandStack;
133     QDomDocument generateSceneList();
134     ClipManager *m_clipManager;
135     MltVideoProfile m_profile;
136     QString m_scenelist;
137     QTimer *m_autoSaveTimer;
138     QString m_searchFolder;
139     /** tells whether current doc has been changed since last save event */
140     bool m_modified;
141     /** Project folder, used to store project files (titles, effects,...) */
142     KUrl m_projectFolder;
143     double m_documentLoadingStep;
144     double m_documentLoadingProgress;
145     int m_zoneStart;
146     int m_zoneEnd;
147
148     QList <TrackInfo> m_tracksList;
149
150     bool convertDocument(double version);
151     QDomDocument createEmptyDocument(const int videotracks, const int audiotracks);
152     QString colorToString(const QColor& c);
153     void checkProjectClips();
154     void setNewClipResource(const QString &id, const QString &path);
155     QString searchFileRecursively(const QDir &dir, const QString &matchSize, const QString &matchHash) const;
156     void moveProjectData(KUrl url);
157
158 public slots:
159     void slotCreateTextClip(QString group, const QString &groupId);
160     /** Set to true if document needs saving, false otherwise */
161     void setModified(bool mod = true);
162
163 private slots:
164     void slotAutoSave();
165
166 signals:
167     void addProjectClip(DocClipBase *, bool getInfo = true);
168     void signalDeleteProjectClip(const QString &);
169     void updateClipDisplay(const QString&);
170     void deleteTimelineClip(const QString&);
171     void progressInfo(const QString &, int);
172     /** emited when the document state has been modified (= needs saving or not) */
173     void docModified(bool);
174     void selectLastAddedClip(const QString &);
175     void guidesUpdated();
176 };
177
178 #endif