1 /***************************************************************************
2 * Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org) *
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. *
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. *
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 ***************************************************************************/
22 * @brief Manages the list of clips in a document.
23 * @author Jean-Baptiste Mardelle
40 #include "definitions.h"
45 class AbstractGroupItem;
52 class ClipManager: public QObject
56 ClipManager(KdenliveDoc *doc);
57 virtual ~ ClipManager();
58 void addClip(DocClipBase *clip);
59 DocClipBase *getClipAt(int pos);
60 void deleteClip(const QString &clipId);
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);
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;
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);
99 void addFolder(const QString&, const QString&);
100 void deleteFolder(const QString&);
102 AbstractGroupItem *createGroup();
103 void removeGroup(AbstractGroupItem *group);
104 QDomElement groupsXml() const;
105 int clipsCount() const;
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();
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*/
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;
134 void reloadClip(const QString &);
135 void modifiedClip(const QString &);
136 void missingClip(const QString &);
137 void availableClip(const QString &);
138 void checkAllClips();