]> git.sesse.net Git - kdenlive/blob - src/kdenlivedoc.h
Fix several title clips problems, including:
[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, const 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     void setProducerDuration(const QString &id, int duration);
66     int getProducerDuration(const QString &id);
67     Render *renderer();
68     QDomDocument 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 deleteClip(const QString &clipId);
76     int getFramePos(QString duration);
77     DocClipBase *getBaseClip(const QString &clipId);
78     void updateClip(const QString &id);
79     void deleteProjectClip(QList <QString> ids);
80     /** Inform application of the audio thumbnails generation progress */
81     void setThumbsProgress(const QString &message, int progress);
82     const QString &profilePath() const;
83     MltVideoProfile mltProfile() const;
84     const QString description() const;
85     void setUrl(KUrl url);
86     void setProfilePath(QString path);
87     const QString getFreeClipId();
88     /** does the document need saving */
89     bool isModified() const;
90     /** Returns project folder, used to store project files (titles, effects,...) */
91     KUrl projectFolder() const;
92     /** Used to inform main app of the current document loading progress */
93     void loadingProgressed();
94     void syncGuides(QList <Guide *> guides);
95     void setZoom(int factor);
96     int zoom() const;
97     double dar();
98     double projectDuration() const;
99     bool saveSceneList(const QString &path, const QString &scene);
100     int tracksCount() const;
101     TrackInfo trackInfoAt(int ix) const;
102     void insertTrack(int ix, TrackInfo type);
103     void deleteTrack(int ix);
104     void setTrackType(int ix, TrackInfo type);
105     const QList <TrackInfo> tracksList() const;
106     QPoint getTracksCount() const;
107     void switchTrackVideo(int ix, bool hide);
108     void switchTrackAudio(int ix, bool hide);
109     void switchTrackLock(int ix, bool lock);
110     void cachePixmap(const QString &fileId, const QPixmap &pix) const;
111     void setProjectFolder(KUrl url);
112     QString getLadspaFile() const;
113     void setZone(int start, int end);
114     QPoint zone() const;
115     void setSceneList();
116     void updatePreviewSettings();
117     bool isTrackLocked(int ix) const;
118
119 private:
120     KUrl m_url;
121     QDomDocument m_document;
122     QString m_projectName;
123     double m_fps;
124     int m_zoom;
125     /** Cursor position at document opening */
126     int m_startPos;
127     int m_width;
128     int m_height;
129     Timecode m_timecode;
130     Render *m_render;
131     QUndoStack *m_commandStack;
132     ClipManager *m_clipManager;
133     MltVideoProfile m_profile;
134     QTimer *m_autoSaveTimer;
135     QString m_searchFolder;
136     /** tells whether current doc has been changed since last save event */
137     bool m_modified;
138     /** Project folder, used to store project files (titles, effects,...) */
139     KUrl m_projectFolder;
140     double m_documentLoadingStep;
141     double m_documentLoadingProgress;
142     bool m_abortLoading;
143     int m_zoneStart;
144     int m_zoneEnd;
145
146     QList <TrackInfo> m_tracksList;
147
148     bool convertDocument(double version);
149     QDomDocument createEmptyDocument(const int videotracks, const int audiotracks);
150     QString colorToString(const QColor& c);
151
152     void setNewClipResource(const QString &id, const QString &path);
153     QString searchFileRecursively(const QDir &dir, const QString &matchSize, const QString &matchHash) const;
154     void moveProjectData(KUrl url);
155
156 public slots:
157     void slotCreateTextClip(QString group, const QString &groupId);
158     /** Set to true if document needs saving, false otherwise */
159     void setModified(bool mod = true);
160     void checkProjectClips();
161
162 private slots:
163     void slotAutoSave();
164
165 signals:
166     void resetProjectList();
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     /** emitted 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