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