]> git.sesse.net Git - kdenlive/blob - src/clipmanager.h
Fix crash when changing project profile
[kdenlive] / src / clipmanager.h
1 /***************************************************************************
2  *   Copyright (C) 2008 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  * @class ClipManager
22  * @brief Manages the list of clips in a document.
23  * @author Jean-Baptiste Mardelle
24  */
25
26 #ifndef CLIPMANAGER_H
27 #define CLIPMANAGER_H
28
29 #include <qdom.h>
30 #include <QPixmap>
31 #include <QObject>
32 #include <QTimer>
33
34 #include <KUrl>
35 #include <KUndoStack>
36 #include <KDirWatch>
37 #include <klocale.h>
38
39 #include "gentime.h"
40 #include "definitions.h"
41
42
43 class KdenliveDoc;
44 class DocClipBase;
45 class AbstractGroupItem;
46
47 namespace Mlt
48 {
49 class Producer;
50 };
51
52 class ClipManager: public QObject
53 {
54 Q_OBJECT public:
55
56     ClipManager(KdenliveDoc *doc);
57     virtual ~ ClipManager();
58     void addClip(DocClipBase *clip);
59     DocClipBase *getClipAt(int pos);
60     void deleteClip(const QString &clipId);
61
62     /** @brief Add a file to the project.
63      * @ref slotAddClipList
64      * @param url file to add
65      * @param group name of the group to insert the file in (can be empty)
66      * @param groupId id of the group (if any) */
67     void slotAddClipFile(const KUrl url, const QString group, const QString &groupId);
68
69     /** @brief Adds a list of files to the project.
70      * @param urls files to add
71      * @param group name of the group to insert the files in (can be empty)
72      * @param groupId id of the group (if any)
73      * It checks for duplicated items and asks to the user for instructions. */
74     void slotAddClipList(const KUrl::List urls, const QString group, const QString &groupId);
75     void slotAddTextClipFile(const QString titleName, int out, const QString xml, const QString group, const QString &groupId);
76     void slotAddTextTemplateClip(QString titleName, const KUrl path, const QString group, const QString &groupId);
77     void slotAddXmlClipFile(const QString name, const QDomElement xml, const QString group, const QString &groupId);
78     void slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group, const QString &groupId);
79     void slotAddSlideshowClipFile(const QString name, const QString path, int count, const QString duration,
80                                   const bool loop, const bool crop,const bool fade,
81                                   const QString &luma_duration, const QString &luma_file, const int softness,
82                                   const QString &animation, const QString group, const QString &groupId);
83     DocClipBase *getClipById(QString clipId);
84     const QList <DocClipBase *> getClipByResource(QString resource);
85     void slotDeleteClips(QStringList ids);
86     void setThumbsProgress(const QString &message, int progress);
87     void checkAudioThumbs();
88     QList <DocClipBase*> documentClipList() const;
89     QMap <QString, QString> documentFolderList() const;
90     int getFreeClipId();
91     int getFreeFolderId();
92     int lastClipId() const;
93     void startAudioThumbsGeneration();
94     void endAudioThumbsGeneration(const QString &requestedId);
95     void askForAudioThumb(const QString &id);
96     QString projectFolder() const;
97     void clearUnusedProducers();
98     void resetProducersList(const QList <Mlt::Producer *> prods, bool displayRatioChanged);
99     void addFolder(const QString&, const QString&);
100     void deleteFolder(const QString&);
101     void clear();
102     AbstractGroupItem *createGroup();
103     void removeGroup(AbstractGroupItem *group);
104     QDomElement groupsXml() const;
105     int clipsCount() const;
106
107 private slots:
108     /** A clip was externally modified, monitor for more changes and prepare for reload */
109     void slotClipModified(const QString &path);
110     void slotClipMissing(const QString &path);
111     void slotClipAvailable(const QString &path);
112     /** Check the list of externally modified clips, and process them if they were not modified in the last 1500 milliseconds */
113     void slotProcessModifiedClips();
114
115 private:   // Private attributes
116     /** the list of clips in the document */
117     QList <DocClipBase*> m_clipList;
118     /** the list of groups in the document */
119     QList <AbstractGroupItem *> m_groupsList;
120     QMap <QString, QString> m_folderList;
121     QList <QString> m_audioThumbsQueue;
122     /** the document undo stack*/
123     KdenliveDoc *m_doc;
124     int m_clipIdCounter;
125     int m_folderIdCounter;
126     QString m_generatingAudioId;
127     KDirWatch m_fileWatcher;
128     /** Timer used to reload clips when they have been externally modified */
129     QTimer m_modifiedTimer;
130     /** List of the clip IDs that need to be reloaded after being externally modified */
131     QMap <QString, QTime> m_modifiedClips;
132
133 signals:
134     void reloadClip(const QString &);
135     void modifiedClip(const QString &);
136     void missingClip(const QString &);
137     void availableClip(const QString &);
138     void checkAllClips(bool displayRatioChanged);
139 };
140
141 #endif