File indexing completed on 2024-04-14 04:46:10
0001 /* 0002 SPDX-FileCopyrightText: 2017 Nicolas Carion 0003 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 #pragma once 0007 0008 #include "definitions.h" 0009 #include <QObject> 0010 #include <QUuid> 0011 #include <memory> 0012 #include <unordered_set> 0013 0014 class AbstractProjectItem; 0015 namespace Mlt { 0016 class Playlist; 0017 class Producer; 0018 class Tractor; 0019 } // namespace Mlt 0020 0021 class MarkerListModel; 0022 0023 /** @class BinPlaylist 0024 @brief This class is a wrapper around a melt playlist that allows one to store the Bin. 0025 Clips that are in the bin must be added into this playlist so that they are savedn in the project's xml even if not inserted in the actual timeline. 0026 The folder structure is also saved as properties. 0027 */ 0028 class BinPlaylist : public QObject 0029 { 0030 0031 public: 0032 BinPlaylist(const QUuid &uuid); 0033 virtual ~BinPlaylist(); 0034 0035 /** @brief This function updates the underlying binPlaylist object to reflect deletion of a bin item 0036 @param binElem is the bin item deleted. Note that exceptionnally, this function takes a raw pointer instead of a smart one. 0037 This is because the function will be called in the middle of the element's destructor, so no smart pointer is available at that time. 0038 */ 0039 void manageBinItemDeletion(AbstractProjectItem *binElem); 0040 0041 /** @brief This function updates the underlying binPlaylist object to reflect insertion of a bin item 0042 @param binElem is the bin item inserted 0043 */ 0044 void manageBinItemInsertion(const std::shared_ptr<AbstractProjectItem> &binElem); 0045 0046 /** @brief This function stores a renamed folder in bin playlise 0047 */ 0048 void manageBinFolderRename(const std::shared_ptr<AbstractProjectItem> &binElem); 0049 0050 /** @brief Make sure bin playlist is saved in given tractor. 0051 This has a side effect on the tractor 0052 */ 0053 void setRetainIn(Mlt::Tractor *modelTractor); 0054 0055 /** @brief Save document properties in MLT's bin playlist */ 0056 void saveDocumentProperties(const QMap<QString, QString> &props, const QMap<QString, QString> &metadata); 0057 0058 /** @brief Save a property to main bin */ 0059 void saveProperty(const QString &name, const QString &value); 0060 0061 /** @brief Retrieve a list of proxy/original urls */ 0062 QMap<QString, QString> getProxies(const QString &root); 0063 0064 /** @brief Retrieve the Bin clip id from a sequence uuid */ 0065 const QString getSequenceId(const QUuid &uuid); 0066 /** @brief Returns trus if we already have a sequence with this uuid */ 0067 bool hasSequenceId(const QUuid &uuid) const; 0068 0069 /** @brief The number of clips in the Bin Playlist */ 0070 int count() const; 0071 0072 /** @brief id of the mlt object */ 0073 static QString binPlaylistId; 0074 0075 /** @brief Returns uuid / bin id of all sequence clips in the project */ 0076 QMap<QUuid, QString> getAllSequenceClips() const; 0077 0078 /** @brief Get MLT ids of all producers in main bin */ 0079 const QStringList getAllMltIds(); 0080 0081 protected: 0082 /** @brief This is an helper function that removes a clip from the playlist given its id 0083 */ 0084 void removeBinClip(const QString &id); 0085 0086 /** @brief This handles the fact that a clip has changed its producer (for example, loading is done) 0087 It should be called directly as a slot of ClipController's signal, so you probably don't want to call this directly. 0088 @param id: binId of the producer 0089 @param producer : new producer 0090 */ 0091 void changeProducer(const QString &id, Mlt::Producer producer); 0092 0093 private: 0094 /** @brief The MLT playlist holding our Producers */ 0095 std::unique_ptr<Mlt::Playlist> m_binPlaylist; 0096 QUuid m_uuid; 0097 /** @brief Set of the bin inserted */ 0098 std::unordered_set<QString> m_allClips; 0099 QMap<QUuid, QString> m_sequenceClips; 0100 };