]> git.sesse.net Git - kdenlive/blob - src/clipmanager.h
Fix audio thumbs not displayed on project opening and abortion if audio thumbs creation
[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
33 #include <KUrl>
34 #include <KUndoStack>
35 #include <KDirWatch>
36 #include <klocale.h>
37
38 #include "gentime.h"
39 #include "definitions.h"
40
41
42 class KdenliveDoc;
43 class DocClipBase;
44 class AbstractGroupItem;
45
46 namespace Mlt
47 {
48 class Producer;
49 };
50
51 class ClipManager: public QObject
52 {
53 Q_OBJECT public:
54
55     ClipManager(KdenliveDoc *doc);
56     virtual ~ ClipManager();
57     void addClip(DocClipBase *clip);
58     DocClipBase *getClipAt(int pos);
59     void deleteClip(const QString &clipId);
60
61     /** @brief Add a file to the project.
62      * @ref slotAddClipList
63      * @param url file to add
64      * @param group name of the group to insert the file in (can be empty)
65      * @param groupId id of the group (if any) */
66     void slotAddClipFile(const KUrl url, const QString group, const QString &groupId);
67
68     /** @brief Adds a list of files to the project.
69      * @param urls files to add
70      * @param group name of the group to insert the files in (can be empty)
71      * @param groupId id of the group (if any)
72      * It checks for duplicated items and asks to the user for instructions. */
73     void slotAddClipList(const KUrl::List urls, const QString group, const QString &groupId);
74     void slotAddTextClipFile(const QString titleName, int out, const QString xml, const QString group, const QString &groupId);
75     void slotAddTextTemplateClip(QString titleName, const KUrl path, const QString group, const QString &groupId);
76     void slotAddColorClipFile(const QString name, const QString color, QString duration, const QString group, const QString &groupId);
77     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);
78     DocClipBase *getClipById(QString clipId);
79     const QList <DocClipBase *> getClipByResource(QString resource);
80     void slotDeleteClips(QStringList ids);
81     void setThumbsProgress(const QString &message, int progress);
82     void checkAudioThumbs();
83     QList <DocClipBase*> documentClipList() const;
84     QMap <QString, QString> documentFolderList() const;
85     int getFreeClipId();
86     int getFreeFolderId();
87     int lastClipId() const;
88     void startAudioThumbsGeneration();
89     void endAudioThumbsGeneration(const QString &requestedId);
90     void askForAudioThumb(const QString &id);
91     QString projectFolder() const;
92     void clearUnusedProducers();
93     void resetProducersList(const QList <Mlt::Producer *> prods);
94     void addFolder(const QString&, const QString&);
95     void deleteFolder(const QString&);
96     void clear();
97     AbstractGroupItem *createGroup();
98     void removeGroup(AbstractGroupItem *group);
99     QDomElement groupsXml() const;
100     int clipsCount() const;
101
102 public slots:
103     void updatePreviewSettings();
104
105 private slots:
106     void slotClipModified(const QString &path);
107     void slotClipMissing(const QString &path);
108     void slotClipAvailable(const QString &path);
109
110 private:   // Private attributes
111     /** the list of clips in the document */
112     QList <DocClipBase*> m_clipList;
113     /** the list of groups in the document */
114     QList <AbstractGroupItem *> m_groupsList;
115     QMap <QString, QString> m_folderList;
116     QList <QString> m_audioThumbsQueue;
117     /** the document undo stack*/
118     KdenliveDoc *m_doc;
119     int m_clipIdCounter;
120     int m_folderIdCounter;
121     QString m_generatingAudioId;
122     KDirWatch m_fileWatcher;
123
124 signals:
125     void reloadClip(const QString &);
126     void missingClip(const QString &);
127     void availableClip(const QString &);
128     void checkAllClips();
129 };
130
131 #endif