Warning, file /multimedia/kdenlive/src/bin/abstractprojectitem.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2012 Till Theato <root@ttill.de> 0003 SPDX-FileCopyrightText: 2014 Jean-Baptiste Mardelle <jb@kdenlive.org> 0004 This file is part of Kdenlive. See www.kdenlive.org. 0005 0006 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0007 */ 0008 0009 #pragma once 0010 0011 #include "abstractmodel/treeitem.hpp" 0012 #include "undohelper.hpp" 0013 0014 #include <QDateTime> 0015 #include <QIcon> 0016 #include <QObject> 0017 #include <QReadWriteLock> 0018 0019 class ProjectClip; 0020 class ProjectFolder; 0021 class Bin; 0022 class QDomElement; 0023 class QDomDocument; 0024 class ProjectItemModel; 0025 0026 /** 0027 * @class AbstractProjectItem 0028 * @brief Base class for all project items (clips, folders, ...). 0029 * 0030 * Project items are stored in a tree like structure ... 0031 */ 0032 class AbstractProjectItem : public QObject, public TreeItem 0033 { 0034 Q_OBJECT 0035 0036 public: 0037 enum PROJECTITEMTYPE { FolderItem, ClipItem, SubClipItem }; 0038 0039 /** 0040 * @brief Constructor. 0041 * @param type is the type of the bin item 0042 * @param id is the binId 0043 * @param model is the ptr to the item model 0044 * @param isRoot is true if this is the topmost folder 0045 */ 0046 AbstractProjectItem(PROJECTITEMTYPE type, QString id, const std::shared_ptr<ProjectItemModel> &model, bool isRoot = false); 0047 0048 bool operator==(const std::shared_ptr<AbstractProjectItem> &projectItem) const; 0049 0050 /** @brief Returns a pointer to the parent item (or NULL). */ 0051 std::shared_ptr<AbstractProjectItem> parent() const; 0052 0053 /** @brief Returns the type of this item (folder, clip, subclip, etc). */ 0054 PROJECTITEMTYPE itemType() const; 0055 0056 /** @brief Used to search for a clip with a specific id. */ 0057 virtual std::shared_ptr<ProjectClip> clip(const QString &id) = 0; 0058 /** @brief Used to search for a folder with a specific id. */ 0059 virtual std::shared_ptr<ProjectFolder> folder(const QString &id) = 0; 0060 virtual std::shared_ptr<ProjectClip> clipAt(int ix) = 0; 0061 /** @brief Recursively disable/enable bin effects. */ 0062 virtual void setBinEffectsEnabled(bool enabled) = 0; 0063 /** @brief Returns true if item has both audio and video enabled. */ 0064 virtual bool hasAudioAndVideo() const = 0; 0065 0066 /** @brief This function executes what should be done when the item is deleted 0067 but without deleting effectively. 0068 For example, the item will deregister itself from the model and delete the 0069 clips from the timeline. 0070 However, the object is NOT actually deleted, and the tree structure is preserved. 0071 @param Undo,Redo are the lambdas accumulating the update. 0072 */ 0073 virtual bool selfSoftDelete(Fun &undo, Fun &redo); 0074 virtual Fun getAudio_lambda(); 0075 /** @brief Returns the clip's id. */ 0076 const QString &clipId() const; 0077 virtual QPoint zone() const; 0078 0079 // TODO refac : these ref counting are probably deprecated by smart ptrs 0080 /** @brief Set current usage count. */ 0081 void setRefCount(uint count, uint audioCount); 0082 /** @brief Returns clip's current usage count in timeline. */ 0083 uint refCount() const; 0084 /** @brief Increase usage count. */ 0085 void addRef(bool isAudio); 0086 /** @brief Decrease usage count. */ 0087 void removeRef(bool isAudio); 0088 0089 enum DataType { 0090 // display name of item 0091 DataName = Qt::DisplayRole, 0092 // image thumbnail 0093 DataThumbnail = Qt::DecorationRole, 0094 // Tooltip text,usually full path 0095 ClipToolTip = Qt::ToolTipRole, 0096 // unique id of the project clip / folder 0097 DataId = Qt::UserRole, 0098 // creation date 0099 DataDate, 0100 // Description for item (user editable) 0101 DataDescription, 0102 // Number of occurrences used in timeline 0103 UsageCount, 0104 AudioUsageCount, 0105 // Empty if clip has no effect, icon otherwise 0106 IconOverlay, 0107 // item type (clip, subclip, folder) 0108 ItemTypeRole, 0109 // Duration of the clip as displayabe string 0110 DataDuration, 0111 // Tag of the clip as colors 0112 DataTag, 0113 // Rating of the clip (0-5) 0114 DataRating, 0115 // Duration of the clip in frames 0116 ParentDuration, 0117 // Inpoint of the subclip (0 for clips) 0118 DataInPoint, 0119 // Outpoint of the subclip (0 for clips) 0120 DataOutPoint, 0121 // Current progress of the job 0122 JobProgress, 0123 // error message if job crashes (not fully implemented) 0124 JobSuccess, 0125 JobStatus, 0126 // Item status (ready or not, missing, waiting, ...) 0127 ClipStatus, 0128 ClipType, 0129 ClipHasAudioAndVideo 0130 }; 0131 0132 virtual void setClipStatus(FileStatus::ClipStatus status); 0133 FileStatus::ClipStatus clipStatus() const; 0134 bool statusReady() const; 0135 0136 /** @brief Returns the data that describes this item. 0137 * @param type type of data to return 0138 * 0139 * This function is necessary for interaction with ProjectItemModel. 0140 */ 0141 virtual QVariant getData(DataType type) const; 0142 0143 /** 0144 * @brief Returns the amount of different types of data this item supports. 0145 * 0146 * This base class supports only DataName and DataDescription, so the return value is always 2. 0147 * This function is necessary for interaction with ProjectItemModel. 0148 */ 0149 virtual int supportedDataCount() const; 0150 0151 /** @brief Returns the (displayable) name of this item. */ 0152 QString name() const; 0153 /** @brief Sets a new (displayable) name. */ 0154 virtual void setName(const QString &name); 0155 0156 /** @brief Returns the (displayable) description of this item. */ 0157 QString description() const; 0158 /** @brief Sets a new description. */ 0159 virtual void setDescription(const QString &description); 0160 0161 virtual QDomElement toXml(QDomDocument &document, bool includeMeta = false, bool includeProfile = true) = 0; 0162 virtual QString getToolTip() const = 0; 0163 virtual bool rename(const QString &name, int column) = 0; 0164 0165 /** @brief Return the bin id of the last parent that this element got, even if this 0166 parent has already been destroyed. 0167 Return the empty string if the element was parentless */ 0168 QString lastParentId() const; 0169 0170 /** @brief This is an overload of TreeItem::updateParent that tracks the id of the id of the parent */ 0171 void updateParent(std::shared_ptr<TreeItem> newParent) override; 0172 0173 /** @brief Returns a ptr to the enclosing dir, and nullptr if none is found. 0174 @param strict if set to false, the enclosing dir of a dir is itself, otherwise we try to find a "true" parent 0175 */ 0176 std::shared_ptr<AbstractProjectItem> getEnclosingFolder(bool strict = false); 0177 0178 /** @brief Returns true if a clip corresponding to this bin is inserted in a timeline. 0179 Note that this function does not account for children, use TreeItem::accumulate if you want to get that information as well. 0180 */ 0181 virtual bool isIncludedInTimeline() { return false; } 0182 virtual ClipType::ProducerType clipType() const = 0; 0183 uint rating() const; 0184 virtual void setRating(uint rating); 0185 const QString &tags() const; 0186 void setTags(const QString &tags); 0187 0188 signals: 0189 void childAdded(AbstractProjectItem *child); 0190 void aboutToRemoveChild(AbstractProjectItem *child); 0191 0192 protected: 0193 QString m_name; 0194 QString m_description; 0195 QIcon m_thumbnail; 0196 QString m_duration; 0197 int m_parentDuration; 0198 int m_inPoint; 0199 int m_outPoint; 0200 QDateTime m_date; 0201 QString m_binId; 0202 uint m_usage; 0203 uint m_AudioUsage; 0204 uint m_rating; 0205 QString m_tags; 0206 FileStatus::ClipStatus m_clipStatus; 0207 0208 PROJECTITEMTYPE m_itemType; 0209 0210 QString m_lastParentId; 0211 0212 /** @brief Returns a rounded border pixmap from the @param source pixmap. */ 0213 QPixmap roundedPixmap(const QPixmap &source); 0214 /** @brief This is a lock that ensures safety in case of concurrent access */ 0215 mutable QReadWriteLock m_lock; 0216 0217 private: 0218 bool m_isCurrent; 0219 };