File indexing completed on 2024-04-14 04:46:16

0001 /*
0002 SPDX-FileCopyrightText: 2015 Jean-Baptiste Mardelle <jb@kdenlive.org>
0003 This file is part of Kdenlive. See www.kdenlive.org.
0004 
0005 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006 */
0007 
0008 #pragma once
0009 
0010 #include "abstractprojectitem.h"
0011 #include "definitions.h"
0012 #include <memory>
0013 
0014 class ProjectFolder;
0015 class ProjectClip;
0016 class QDomElement;
0017 
0018 namespace Mlt {
0019 }
0020 
0021 /** @class ProjectSubClip
0022     @brief Represents a clip in the project (not timeline).
0023   */
0024 class ProjectSubClip : public AbstractProjectItem
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     /**
0030      * @brief Constructor; used when loading a project and the producer is already available.
0031      */
0032     static std::shared_ptr<ProjectSubClip> construct(const QString &id, const std::shared_ptr<ProjectClip> &parent,
0033                                                      const std::shared_ptr<ProjectItemModel> &model, int in, int out, const QString &timecode,
0034                                                      const QMap<QString, QString> &zoneProperties);
0035 
0036 protected:
0037     ProjectSubClip(const QString &id, const std::shared_ptr<ProjectClip> &parent, const std::shared_ptr<ProjectItemModel> &model, int in, int out,
0038                    const QString &timecode, const QMap<QString, QString> &zoneProperties);
0039 
0040 public:
0041     ~ProjectSubClip() override;
0042 
0043     std::shared_ptr<ProjectClip> clip(const QString &id) override;
0044     std::shared_ptr<ProjectFolder> folder(const QString &id) override;
0045     std::shared_ptr<ProjectSubClip> subClip(int in, int out);
0046     std::shared_ptr<ProjectClip> clipAt(int ix) override;
0047     /** @brief Recursively disable/enable bin effects. */
0048     void setBinEffectsEnabled(bool enabled) override;
0049     QDomElement toXml(QDomDocument &document, bool includeMeta = false, bool includeProfile = true) override;
0050 
0051     /** @brief Returns the clip's duration. */
0052     GenTime duration() const;
0053 
0054     /** @brief A string composed of: Clip id / in / out. */
0055     const QString cutClipId() const;
0056 
0057     /** @brief Sets thumbnail for this clip. */
0058     void setThumbnail(const QImage &);
0059     QPixmap thumbnail(int width, int height);
0060     /** @brief Sets a seeking thumbnail for this subclip. */
0061     void getThumbFromPercent(int percent);
0062 
0063     QPoint zone() const override;
0064     QString getToolTip() const override;
0065     bool rename(const QString &name, int column) override;
0066     /** @brief Returns true if item has both audio and video enabled. */
0067     bool hasAudioAndVideo() const override;
0068 
0069     /** @brief returns a pointer to the parent clip */
0070     std::shared_ptr<ProjectClip> getMasterClip() const;
0071 
0072     /** @brief Returns the clip type as defined in definitions.h */
0073     ClipType::ProducerType clipType() const override;
0074 
0075     /** @brief Set properties on this clip zone */
0076     void setProperties(const QMap<QString, QString> &properties);
0077 
0078     /** @brief Set rating on item */
0079     void setRating(uint rating) override;
0080 
0081 private:
0082     std::shared_ptr<ProjectClip> m_masterClip;
0083     QString m_parentClipId;
0084 
0085 private Q_SLOTS:
0086     void gotThumb(int pos, const QImage &img);
0087 };