File indexing completed on 2024-05-19 04:54:23

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 "abstracteffectitem.hpp"
0009 #include "abstractmodel/treeitem.hpp"
0010 #include "assets/model/assetparametermodel.hpp"
0011 #include <mlt++/MltFilter.h>
0012 
0013 class EffectStackModel;
0014 /** @brief This represents an effect of the effectstack
0015  */
0016 class EffectItemModel : public AbstractEffectItem, public AssetParameterModel
0017 {
0018 
0019 public:
0020     /** @brief This construct an effect of the given id
0021        @param is a ptr to the model this item belongs to. This is required to send update signals
0022      */
0023     static std::shared_ptr<EffectItemModel> construct(const QString &effectId, std::shared_ptr<AbstractTreeModel> stack, bool effectEnabled = true);
0024     /** @brief This construct an effect with an already existing filter
0025        Only used when loading an existing clip
0026      */
0027     static std::shared_ptr<EffectItemModel> construct(std::unique_ptr<Mlt::Properties> effect, std::shared_ptr<AbstractTreeModel> stack,
0028                                                       const QString &originalDecimalPoint);
0029 
0030     /** @brief This function plants the effect into the given service in last position
0031      */
0032     void plant(const std::weak_ptr<Mlt::Service> &service) override;
0033     void plantClone(const std::weak_ptr<Mlt::Service> &service) override;
0034     void loadClone(const std::weak_ptr<Mlt::Service> &service);
0035     /** @brief This function unplants (removes) the effect from the given service
0036      */
0037     void unplant(const std::weak_ptr<Mlt::Service> &service) override;
0038     void unplantClone(const std::weak_ptr<Mlt::Service> &service) override;
0039 
0040     Mlt::Filter &filter() const;
0041 
0042     /** @brief Return true if the effect applies only to audio */
0043     bool isAudio() const override;
0044     bool isUnique() const override;
0045 
0046     void setCollapsed(bool collapsed);
0047     bool isCollapsed() const;
0048     void setKeyframesHidden(bool hidden);
0049     bool isKeyframesHidden() const;
0050     bool keyframesHiddenUnset() const;
0051     bool hasForcedInOut() const;
0052     bool isValid() const;
0053     QPair<int, int> getInOut() const;
0054     void setInOut(const QString &effectName, QPair<int, int> bounds, bool enabled, bool withUndo);
0055 
0056 protected:
0057     EffectItemModel(const QList<QVariant> &effectData, std::unique_ptr<Mlt::Properties> effect, const QDomElement &xml, const QString &effectId,
0058                     const std::shared_ptr<AbstractTreeModel> &stack, bool isEnabled = true, QString originalDecimalPoint = QString());
0059     QMap<int, std::shared_ptr<EffectItemModel>> m_childEffects;
0060     void updateEnable(bool updateTimeline = true) override;
0061     int m_childId;
0062 };