]> git.sesse.net Git - kdenlive/blob - src/kdenlivedoc.h
Add option to remove unused clips from project tree:
[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     void addClip(QDomElement elem, QString clipId, bool createClipItem = true);
70     void addClipInfo(QDomElement elem, QDomElement orig, QString clipId);
71     void slotAddClipFile(const KUrl url, const QString group, const QString &groupId = QString());
72     void slotAddClipList(const KUrl::List urls, const QString group, const QString &groupId = QString());
73     void deleteClip(const QString &clipId);
74     int getFramePos(QString duration);
75     DocClipBase *getBaseClip(const QString &clipId);
76     void updateClip(const QString id);
77     void deleteProjectClip(QStringList ids);
78     /** Inform application of the audio thumbnails generation progress */
79     void setThumbsProgress(const QString &message, int progress);
80     const QString &profilePath() const;
81     MltVideoProfile mltProfile() const;
82     const QString description() const;
83     void setUrl(KUrl url);
84     /** update project profile, returns true if fps was changed */
85     bool setProfilePath(QString path);
86     const QString getFreeClipId();
87     /** does the document need saving */
88     bool isModified() const;
89     /** Returns project folder, used to store project files (titles, effects,...) */
90     KUrl projectFolder() const;
91     /** Used to inform main app of the current document loading progress */
92     void loadingProgressed();
93     void syncGuides(QList <Guide *> guides);
94     void setZoom(int horizontal, int vertical);
95     QPoint zoom() const;
96     double dar();
97     double projectDuration() const;
98     bool saveSceneList(const QString &path, const QString &scene);
99     int tracksCount() const;
100     TrackInfo trackInfoAt(int ix) const;
101     void insertTrack(int ix, TrackInfo type);
102     void deleteTrack(int ix);
103     void setTrackType(int ix, TrackInfo type);
104     const QList <TrackInfo> tracksList() const;
105     QPoint getTracksCount() const;
106     void switchTrackVideo(int ix, bool hide);
107     void switchTrackAudio(int ix, bool hide);
108     void switchTrackLock(int ix, bool lock);
109     void cachePixmap(const QString &fileId, const QPixmap &pix) const;
110     void setProjectFolder(KUrl url);
111     QString getLadspaFile() const;
112     void setZone(int start, int end);
113     QPoint zone() const;
114     int setSceneList();
115     void updatePreviewSettings();
116     bool isTrackLocked(int ix) const;
117     void setDocumentProperty(const QString &name, const QString &value);
118     const QString getDocumentProperty(const QString &name) const;
119
120 private:
121     KUrl m_url;
122     QDomDocument m_document;
123     double m_fps;
124     int m_width;
125     int m_height;
126     Timecode m_timecode;
127     Render *m_render;
128     QUndoStack *m_commandStack;
129     ClipManager *m_clipManager;
130     MltVideoProfile m_profile;
131     QTimer *m_autoSaveTimer;
132     QString m_searchFolder;
133     /** tells whether current doc has been changed since last save event */
134     bool m_modified;
135     /** Project folder, used to store project files (titles, effects,...) */
136     KUrl m_projectFolder;
137     double m_documentLoadingStep;
138     double m_documentLoadingProgress;
139     bool m_abortLoading;
140     QMap <QString, QString> m_documentProperties;
141
142     QList <TrackInfo> m_tracksList;
143     void setNewClipResource(const QString &id, const QString &path);
144     QString searchFileRecursively(const QDir &dir, const QString &matchSize, const QString &matchHash) const;
145     void moveProjectData(KUrl url);
146     bool checkDocumentClips(QDomNodeList infoproducers);
147     QDomDocument createEmptyDocument(int videotracks, int audiotracks);
148     QDomDocument createEmptyDocument(QList <TrackInfo> tracks);
149
150 public slots:
151     void slotCreateColorClip(const QString &name, const QString &color, const QString &duration, QString group, const QString &groupId);
152     void slotCreateSlideshowClipFile(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, QString group, const QString &groupId);
153     void slotCreateTextClip(QString group, const QString &groupId, const QString &templatePath = QString());
154     void slotCreateTextTemplateClip(QString group, const QString &groupId, KUrl path);
155     /** Set to true if document needs saving, false otherwise */
156     void setModified(bool mod = true);
157     void checkProjectClips();
158
159 private slots:
160     void slotAutoSave();
161
162 signals:
163     void resetProjectList();
164     void addProjectClip(DocClipBase *, bool getInfo = true);
165     void signalDeleteProjectClip(const QString &);
166     void updateClipDisplay(const QString&);
167     void deleteTimelineClip(const QString&);
168     void progressInfo(const QString &, int);
169     /** emitted when the document state has been modified (= needs saving or not) */
170     void docModified(bool);
171     void selectLastAddedClip(const QString &);
172     void guidesUpdated();
173 };
174
175 #endif