Commit 252c3e2d authored by Nicolas Carion's avatar Nicolas Carion
Browse files

remove parent parameter from treeitem construction and add tests

parent 712bd064
......@@ -34,7 +34,7 @@ AbstractTreeModel::AbstractTreeModel(QObject *parent)
std::shared_ptr<AbstractTreeModel> AbstractTreeModel::construct(QObject *parent)
{
std::shared_ptr<AbstractTreeModel> self(new AbstractTreeModel(parent));
self->rootItem.reset(new TreeItem(QList<QVariant>(), self, std::shared_ptr<TreeItem>()));
self->rootItem.reset(new TreeItem(QList<QVariant>(), self));
return self;
}
......@@ -185,3 +185,8 @@ std::shared_ptr<TreeItem> AbstractTreeModel::getItemById(int id) const
Q_ASSERT(m_allItems.count(id) > 0);
return m_allItems.at(id).lock();
}
std::shared_ptr<TreeItem> AbstractTreeModel::getRoot() const
{
return rootItem;
}
......@@ -50,30 +50,13 @@ public:
/* @brief Given an item from the hierarchy, construct the corresponding ModelIndex */
QModelIndex getIndexFromItem(const std::shared_ptr<TreeItem> &item) const;
/* @brief Send the appropriate notification related to a row that we are appending
@param item is the parent item to which row is appended
*/
void notifyRowAboutToAppend(const std::shared_ptr<TreeItem> &item);
/* @brief Send the appropriate notification related to a row that we have appended
@param row is the new element
*/
virtual void notifyRowAppended(const std::shared_ptr<TreeItem> &row);
/* @brief Send the appropriate notification related to a row that we are deleting
@param item is the parent of the row being deleted
@param row is the index of the row being deleted
*/
virtual void notifyRowAboutToDelete(std::shared_ptr<TreeItem> item, int row);
/* @brief Send the appropriate notification related to a row that we have appended
@param row is the old element
*/
void notifyRowDeleted();
/* @brief Return a ptr to an item given its id */
std::shared_ptr<TreeItem> getItemById(int id) const;
/* @brief Return a ptr to the root of the tree */
std::shared_ptr<TreeItem> getRoot() const;
QVariant data(const QModelIndex &index, int role) const override;
// This is reimplemented to prevent selection of the categories
Qt::ItemFlags flags(const QModelIndex &index) const override;
......@@ -96,6 +79,27 @@ protected:
/* @brief Returns the next valid id to give to a new element */
static int getNextId();
/* @brief Send the appropriate notification related to a row that we are appending
@param item is the parent item to which row is appended
*/
void notifyRowAboutToAppend(const std::shared_ptr<TreeItem> &item);
/* @brief Send the appropriate notification related to a row that we have appended
@param row is the new element
*/
virtual void notifyRowAppended(const std::shared_ptr<TreeItem> &row);
/* @brief Send the appropriate notification related to a row that we are deleting
@param item is the parent of the row being deleted
@param row is the index of the row being deleted
*/
virtual void notifyRowAboutToDelete(std::shared_ptr<TreeItem> item, int row);
/* @brief Send the appropriate notification related to a row that we have appended
@param row is the old element
*/
void notifyRowDeleted();
protected:
std::shared_ptr<TreeItem> rootItem;
......
......@@ -25,9 +25,8 @@
#include <numeric>
#include <utility>
TreeItem::TreeItem(const QList<QVariant> &data, const std::shared_ptr<AbstractTreeModel> &model, const std::shared_ptr<TreeItem> &parent, int id)
TreeItem::TreeItem(const QList<QVariant> &data, const std::shared_ptr<AbstractTreeModel> &model, int id)
: m_itemData(data)
, m_parentItem(parent)
, m_model(model)
, m_depth(0)
, m_id(id == -1 ? AbstractTreeModel::getNextId() : id)
......@@ -35,10 +34,9 @@ TreeItem::TreeItem(const QList<QVariant> &data, const std::shared_ptr<AbstractTr
{
}
std::shared_ptr<TreeItem> TreeItem::construct(const QList<QVariant> &data, std::shared_ptr<AbstractTreeModel> model, std::shared_ptr<TreeItem> parent, int id)
std::shared_ptr<TreeItem> TreeItem::construct(const QList<QVariant> &data, std::shared_ptr<AbstractTreeModel> model, int id)
{
std::shared_ptr<TreeItem> self(new TreeItem(data, std::move(model), std::move(parent), id));
id = self->m_id;
std::shared_ptr<TreeItem> self(new TreeItem(data, std::move(model), id));
baseFinishConstruct(self);
return self;
}
......@@ -68,7 +66,8 @@ std::shared_ptr<TreeItem> TreeItem::appendChild(const QList<QVariant> &data)
{
if (auto ptr = m_model.lock()) {
ptr->notifyRowAboutToAppend(shared_from_this());
auto child = construct(data, ptr, shared_from_this());
auto child = construct(data, ptr);
child->m_parentItem = shared_from_this();
qDebug() << "appending child" << child->getId() << "to " << m_id;
child->m_depth = m_depth + 1;
int id = child->getId();
......
......@@ -41,14 +41,13 @@ public:
@param id of the newly created item. If left to -1, the id is assigned automatically
@return a ptr to the constructed item
*/
static std::shared_ptr<TreeItem> construct(const QList<QVariant> &data, std::shared_ptr<AbstractTreeModel> model, std::shared_ptr<TreeItem> parent,
int id = -1);
static std::shared_ptr<TreeItem> construct(const QList<QVariant> &data, std::shared_ptr<AbstractTreeModel> model, int id = -1);
friend class AbstractTreeModel;
protected:
// This is protected. Call construct instead
explicit TreeItem(const QList<QVariant> &data, const std::shared_ptr<AbstractTreeModel> &model, const std::shared_ptr<TreeItem> &parent, int id = -1);
explicit TreeItem(const QList<QVariant> &data, const std::shared_ptr<AbstractTreeModel> &model, int id = -1);
public:
virtual ~TreeItem();
......
......@@ -29,9 +29,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QPainter>
#include <QVariant>
AbstractProjectItem::AbstractProjectItem(PROJECTITEMTYPE type, const QString &id, const std::shared_ptr<ProjectItemModel> &model,
const std::shared_ptr<AbstractProjectItem> &parent)
: TreeItem(QList<QVariant>(), std::static_pointer_cast<AbstractTreeModel>(model), std::static_pointer_cast<TreeItem>(parent))
AbstractProjectItem::AbstractProjectItem(PROJECTITEMTYPE type, const QString &id, const std::shared_ptr<ProjectItemModel> &model)
: TreeItem(QList<QVariant>(), std::static_pointer_cast<AbstractTreeModel>(model))
, m_name()
, m_description()
, m_thumbnail(QIcon())
......@@ -47,9 +46,8 @@ AbstractProjectItem::AbstractProjectItem(PROJECTITEMTYPE type, const QString &id
{
}
AbstractProjectItem::AbstractProjectItem(PROJECTITEMTYPE type, const QDomElement &description, const std::shared_ptr<ProjectItemModel> &model,
const std::shared_ptr<AbstractProjectItem> &parent)
: TreeItem(QList<QVariant>(), std::static_pointer_cast<AbstractTreeModel>(model), std::static_pointer_cast<TreeItem>(parent))
AbstractProjectItem::AbstractProjectItem(PROJECTITEMTYPE type, const QDomElement &description, const std::shared_ptr<ProjectItemModel> &model)
: TreeItem(QList<QVariant>(), std::static_pointer_cast<AbstractTreeModel>(model))
, m_name()
, m_description()
, m_thumbnail(QIcon())
......
......@@ -56,8 +56,7 @@ public:
* @brief Constructor.
* @param parent parent this item should be added to
*/
AbstractProjectItem(PROJECTITEMTYPE type, const QString &id, const std::shared_ptr<ProjectItemModel> &model,
const std::shared_ptr<AbstractProjectItem> &parent);
AbstractProjectItem(PROJECTITEMTYPE type, const QString &id, const std::shared_ptr<ProjectItemModel> &model);
/**
* @brief Creates a project item upon project load.
* @param description element for this item.
......@@ -66,8 +65,7 @@ public:
*
* We try to read the attributes "name" and "description"
*/
AbstractProjectItem(PROJECTITEMTYPE type, const QDomElement &description, const std::shared_ptr<ProjectItemModel> &model,
const std::shared_ptr<AbstractProjectItem> &parent);
AbstractProjectItem(PROJECTITEMTYPE type, const QDomElement &description, const std::shared_ptr<ProjectItemModel> &model);
bool operator==(const std::shared_ptr<AbstractProjectItem> &projectItem) const;
......
......@@ -1373,7 +1373,8 @@ void Bin::createClip(const QDomElement &xml)
}
}
}
auto newClip = ProjectClip::construct(xml, m_blankThumb, m_itemModel, parentFolder);
auto newClip = ProjectClip::construct(xml, m_blankThumb, m_itemModel);
parentFolder->appendChild(newClip);
}
QString Bin::slotAddFolder(const QString &folderName)
......@@ -1472,7 +1473,7 @@ void Bin::doAddFolder(const QString &id, const QString &name, const QString &par
qCDebug(KDENLIVE_LOG) << " / / ERROR IN PARENT FOLDER";
return;
}
std::shared_ptr<ProjectFolder> new_folder = ProjectFolder::construct(id, name, m_itemModel, parentFolder);
std::shared_ptr<ProjectFolder> new_folder = ProjectFolder::construct(id, name, m_itemModel);
parentFolder->appendChild(new_folder);
emit storeFolder(id, parentId, QString(), name);
}
......@@ -1494,14 +1495,14 @@ void Bin::slotLoadFolders(const QMap<QString, QString> &foldersData)
parentFolder = m_itemModel->getFolderByBinId(parentId);
if (parentFolder->depth() == 0) { // check if this is root
// parent folder not yet created, create unnamed placeholder
std::shared_ptr<ProjectFolder> newFolder = ProjectFolder::construct(parentId, QString(), m_itemModel, parentFolder);
std::shared_ptr<ProjectFolder> newFolder = ProjectFolder::construct(parentId, QString(), m_itemModel);
parentFolder->appendChild(newFolder);
parentFolder = newFolder;
} else if (parentFolder == nullptr) {
// Parent folder not yet created in hierarchy
if (iterations > maxIterations) {
// Give up, place folder in root
std::shared_ptr<ProjectFolder> newFolder = ProjectFolder::construct(parentId, i18n("Folder"), m_itemModel, m_itemModel->getRootFolder());
std::shared_ptr<ProjectFolder> newFolder = ProjectFolder::construct(parentId, i18n("Folder"), m_itemModel);
parentFolder->appendChild(newFolder);
parentFolder = newFolder;
} else {
......@@ -1525,7 +1526,7 @@ void Bin::slotLoadFolders(const QMap<QString, QString> &foldersData)
placeHolder->setName(foldersData.value(id));
} else {
// Create new folder
std::shared_ptr<ProjectFolder> newFolder = ProjectFolder::construct(folderId, foldersData.value(id), m_itemModel, parentFolder);
std::shared_ptr<ProjectFolder> newFolder = ProjectFolder::construct(folderId, foldersData.value(id), m_itemModel);
parentFolder->appendChild(newFolder);
}
}
......@@ -1713,7 +1714,7 @@ void Bin::slotInitView(QAction *action)
switch (m_listType) {
case BinIconView:
m_itemView = new MyListView(this);
m_folderUp = ProjectFolderUp::construct(m_itemModel, std::shared_ptr<AbstractProjectItem>());
m_folderUp = ProjectFolderUp::construct(m_itemModel);
m_showDate->setEnabled(false);
m_showDesc->setEnabled(false);
break;
......@@ -2192,7 +2193,8 @@ void Bin::slotProducerReady(const requestClipInfo &info, ClipController *control
parentFolder = m_itemModel->getRootFolder();
}
// TODO at this point, we shouldn't have a controller, but rather a bare producer
std::shared_ptr<ProjectClip> newClip = ProjectClip::construct(info.clipId, m_blankThumb, m_itemModel, controller->originalProducer(), parentFolder);
std::shared_ptr<ProjectClip> newClip = ProjectClip::construct(info.clipId, m_blankThumb, m_itemModel, controller->originalProducer());
parentFolder->appendChild(newClip);
emit producerReady(info.clipId);
ClipType t = newClip->clipType();
if (t == AV || t == Audio || t == Image || t == Video || t == Playlist) {
......
......@@ -53,9 +53,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QtConcurrent>
#include <utility>
ProjectClip::ProjectClip(const QString &id, const QIcon &thumb, std::shared_ptr<ProjectItemModel> model, std::shared_ptr<Mlt::Producer> producer,
std::shared_ptr<ProjectFolder> parent)
: AbstractProjectItem(AbstractProjectItem::ClipItem, id, model, parent)
ProjectClip::ProjectClip(const QString &id, const QIcon &thumb, std::shared_ptr<ProjectItemModel> model, std::shared_ptr<Mlt::Producer> producer)
: AbstractProjectItem(AbstractProjectItem::ClipItem, id, model)
, ClipController(pCore->binController(), producer)
, m_abortAudioThumb(false)
, m_thumbsProducer(nullptr)
......@@ -79,18 +78,17 @@ ProjectClip::ProjectClip(const QString &id, const QIcon &thumb, std::shared_ptr<
// static
std::shared_ptr<ProjectClip> ProjectClip::construct(const QString &id, const QIcon &thumb, std::shared_ptr<ProjectItemModel> model,
std::shared_ptr<Mlt::Producer> producer, std::shared_ptr<ProjectFolder> parent)
std::shared_ptr<Mlt::Producer> producer)
{
std::shared_ptr<ProjectClip> self(new ProjectClip(id, thumb, model, producer, parent));
std::shared_ptr<ProjectClip> self(new ProjectClip(id, thumb, model, producer));
baseFinishConstruct(self);
parent->appendChild(self);
model->loadSubClips(id, self->getPropertiesFromPrefix(QStringLiteral("kdenlive:clipzone.")));
self->createAudioThumbs();
return self;
}
ProjectClip::ProjectClip(const QDomElement &description, const QIcon &thumb, std::shared_ptr<ProjectItemModel> model, std::shared_ptr<ProjectFolder> parent)
: AbstractProjectItem(AbstractProjectItem::ClipItem, description, model, parent)
ProjectClip::ProjectClip(const QDomElement &description, const QIcon &thumb, std::shared_ptr<ProjectItemModel> model)
: AbstractProjectItem(AbstractProjectItem::ClipItem, description, model)
, ClipController(pCore->binController())
, m_abortAudioThumb(false)
, m_thumbsProducer(nullptr)
......@@ -119,12 +117,10 @@ ProjectClip::ProjectClip(const QDomElement &description, const QIcon &thumb, std
m_markerModel = std::make_shared<MarkerListModel>(m_binId, pCore->projectManager()->current()->commandStack());
}
std::shared_ptr<ProjectClip> ProjectClip::construct(const QDomElement &description, const QIcon &thumb, std::shared_ptr<ProjectItemModel> model,
std::shared_ptr<ProjectFolder> parent)
std::shared_ptr<ProjectClip> ProjectClip::construct(const QDomElement &description, const QIcon &thumb, std::shared_ptr<ProjectItemModel> model)
{
std::shared_ptr<ProjectClip> self(new ProjectClip(description, thumb, model, parent));
std::shared_ptr<ProjectClip> self(new ProjectClip(description, thumb, model));
baseFinishConstruct(self);
parent->appendChild(self);
return self;
}
......
......@@ -61,18 +61,16 @@ public:
* @brief Constructor; used when loading a project and the producer is already available.
*/
static std::shared_ptr<ProjectClip> construct(const QString &id, const QIcon &thumb, std::shared_ptr<ProjectItemModel> model,
std::shared_ptr<Mlt::Producer> producer, std::shared_ptr<ProjectFolder> parent);
std::shared_ptr<Mlt::Producer> producer);
/**
* @brief Constructor.
* @param description element describing the clip; the "id" attribute and "resource" property are used
*/
static std::shared_ptr<ProjectClip> construct(const QDomElement &description, const QIcon &thumb, std::shared_ptr<ProjectItemModel> model,
std::shared_ptr<ProjectFolder> parent);
static std::shared_ptr<ProjectClip> construct(const QDomElement &description, const QIcon &thumb, std::shared_ptr<ProjectItemModel> model);
protected:
ProjectClip(const QString &id, const QIcon &thumb, std::shared_ptr<ProjectItemModel> model, std::shared_ptr<Mlt::Producer> producer,
std::shared_ptr<ProjectFolder> parent);
ProjectClip(const QDomElement &description, const QIcon &thumb, std::shared_ptr<ProjectItemModel> model, std::shared_ptr<ProjectFolder> parent);
ProjectClip(const QString &id, const QIcon &thumb, std::shared_ptr<ProjectItemModel> model, std::shared_ptr<Mlt::Producer> producer);
ProjectClip(const QDomElement &description, const QIcon &thumb, std::shared_ptr<ProjectItemModel> model);
public:
virtual ~ProjectClip();
......
......@@ -30,25 +30,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KLocalizedString>
#include <QDomElement>
ProjectFolder::ProjectFolder(const QString &id, const QString &name, std::shared_ptr<ProjectItemModel> model, std::shared_ptr<ProjectFolder> parent)
: AbstractProjectItem(AbstractProjectItem::FolderItem, id, model, parent)
ProjectFolder::ProjectFolder(const QString &id, const QString &name, std::shared_ptr<ProjectItemModel> model)
: AbstractProjectItem(AbstractProjectItem::FolderItem, id, model)
{
m_name = name;
m_clipStatus = StatusReady;
m_thumbnail = KoIconUtils::themedIcon(QStringLiteral("folder"));
}
std::shared_ptr<ProjectFolder> ProjectFolder::construct(const QString &id, const QString &name, std::shared_ptr<ProjectItemModel> model,
std::shared_ptr<ProjectFolder> parent)
std::shared_ptr<ProjectFolder> ProjectFolder::construct(const QString &id, const QString &name, std::shared_ptr<ProjectItemModel> model)
{
std::shared_ptr<ProjectFolder> self(new ProjectFolder(id, name, model, parent));
std::shared_ptr<ProjectFolder> self(new ProjectFolder(id, name, model));
baseFinishConstruct(self);
return self;
}
ProjectFolder::ProjectFolder(std::shared_ptr<ProjectItemModel> model)
: AbstractProjectItem(AbstractProjectItem::FolderItem, QString::number(-1), model, std::shared_ptr<AbstractProjectItem>())
: AbstractProjectItem(AbstractProjectItem::FolderItem, QString::number(-1), model)
{
m_name = QStringLiteral("root");
}
......
......@@ -41,16 +41,14 @@ public:
/**
* @brief Creates the supplied folder and loads its children.
* @param description element describing the folder and its children
* @param parent parent folder
*/
static std::shared_ptr<ProjectFolder> construct(const QString &id, const QString &name, std::shared_ptr<ProjectItemModel> model,
std::shared_ptr<ProjectFolder> parent);
static std::shared_ptr<ProjectFolder> construct(const QString &id, const QString &name, std::shared_ptr<ProjectItemModel> model);
/** @brief Creates an empty root folder. */
static std::shared_ptr<ProjectFolder> construct(std::shared_ptr<ProjectItemModel> model);
protected:
ProjectFolder(const QString &id, const QString &name, std::shared_ptr<ProjectItemModel> model, std::shared_ptr<ProjectFolder> parent);
ProjectFolder(const QString &id, const QString &name, std::shared_ptr<ProjectItemModel> model);
explicit ProjectFolder(std::shared_ptr<ProjectItemModel> model);
......
......@@ -26,17 +26,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KLocalizedString>
#include <QDomElement>
ProjectFolderUp::ProjectFolderUp(std::shared_ptr<ProjectItemModel> model, std::shared_ptr<AbstractProjectItem> parent)
: AbstractProjectItem(AbstractProjectItem::FolderUpItem, QString(), model, parent)
ProjectFolderUp::ProjectFolderUp(std::shared_ptr<ProjectItemModel> model)
: AbstractProjectItem(AbstractProjectItem::FolderUpItem, QString(), model)
{
m_thumbnail = KoIconUtils::themedIcon(QStringLiteral("go-previous"));
m_name = i18n("Back");
changeParent(parent);
}
std::shared_ptr<ProjectFolderUp> ProjectFolderUp::construct(std::shared_ptr<ProjectItemModel> model, std::shared_ptr<AbstractProjectItem> parent)
std::shared_ptr<ProjectFolderUp> ProjectFolderUp::construct(std::shared_ptr<ProjectItemModel> model)
{
std::shared_ptr<ProjectFolderUp> self(new ProjectFolderUp(model, parent));
std::shared_ptr<ProjectFolderUp> self(new ProjectFolderUp(model));
baseFinishConstruct(self);
return self;
......
......@@ -39,12 +39,11 @@ public:
/**
* @brief Creates the supplied folder and loads its children.
* @param description element describing the folder and its children
* @param parent parent folder
*/
static std::shared_ptr<ProjectFolderUp> construct(std::shared_ptr<ProjectItemModel> model, std::shared_ptr<AbstractProjectItem> parent);
static std::shared_ptr<ProjectFolderUp> construct(std::shared_ptr<ProjectItemModel> model);
protected:
explicit ProjectFolderUp(std::shared_ptr<ProjectItemModel> model, std::shared_ptr<AbstractProjectItem> parent);
explicit ProjectFolderUp(std::shared_ptr<ProjectItemModel> model);
public:
~ProjectFolderUp();
......
......@@ -504,7 +504,7 @@ bool ProjectItemModel::requestAddFolder(QString &id, const QString &name, const
if (id.isEmpty()) {
id = QString::number(getFreeFolderId());
}
std::shared_ptr<ProjectFolder> new_folder = ProjectFolder::construct(id, name, std::static_pointer_cast<ProjectItemModel>(shared_from_this()), parentFolder);
std::shared_ptr<ProjectFolder> new_folder = ProjectFolder::construct(id, name, std::static_pointer_cast<ProjectItemModel>(shared_from_this()));
parentFolder->appendChild(new_folder);
int folderId = new_folder->getId();
Fun operation = [this, new_folder, parentId]() {
......
......@@ -32,7 +32,7 @@ class ClipController;
ProjectSubClip::ProjectSubClip(const std::shared_ptr<ProjectClip> &parent, const std::shared_ptr<ProjectItemModel> &model, int in, int out,
const QString &timecode, const QString &name)
: AbstractProjectItem(AbstractProjectItem::SubClipItem, parent->AbstractProjectItem::clipId(), model, parent)
: AbstractProjectItem(AbstractProjectItem::SubClipItem, parent->AbstractProjectItem::clipId(), model)
, m_masterClip(parent)
, m_in(in)
, m_out(out)
......@@ -56,8 +56,8 @@ ProjectSubClip::ProjectSubClip(const std::shared_ptr<ProjectClip> &parent, const
std::shared_ptr<ProjectSubClip> ProjectSubClip::construct(std::shared_ptr<ProjectClip> parent, std::shared_ptr<ProjectItemModel> model, int in, int out,
const QString &timecode, const QString &name)
{
std::shared_ptr<ProjectSubClip> self(new ProjectSubClip(std::move(parent), std::move(model), in, out, timecode, name));
std::shared_ptr<ProjectSubClip> self(new ProjectSubClip(parent, std::move(model), in, out, timecode, name));
parent->appendChild(self);
baseFinishConstruct(self);
return self;
}
......
......@@ -44,7 +44,7 @@ std::shared_ptr<EffectTreeModel> EffectTreeModel::construct(const QString &categ
<< "ID"
<< "Type"
<< "isFav";
self->rootItem = TreeItem::construct(rootData, self, std::shared_ptr<TreeItem>());
self->rootItem = TreeItem::construct(rootData, self);
QHash<QString, std::shared_ptr<TreeItem>> effectCategory; // category in which each effect should land.
......
......@@ -26,8 +26,8 @@
#include "core.h"
#include <utility>
AbstractEffectItem::AbstractEffectItem(const QList<QVariant> &data, const std::shared_ptr<AbstractTreeModel> &stack, const std::shared_ptr<TreeItem> &parent)
: TreeItem(data, stack, parent)
AbstractEffectItem::AbstractEffectItem(const QList<QVariant> &data, const std::shared_ptr<AbstractTreeModel> &stack)
: TreeItem(data, stack)
, m_enabled(true)
, m_effectStackEnabled(true)
{
......
......@@ -33,7 +33,7 @@ class AbstractEffectItem : public TreeItem
{
public:
AbstractEffectItem(const QList<QVariant> &data, const std::shared_ptr<AbstractTreeModel> &stack, const std::shared_ptr<TreeItem> &parent);
AbstractEffectItem(const QList<QVariant> &data, const std::shared_ptr<AbstractTreeModel> &stack);
/* @brief This function change the individual enabled state of the effect, creating an undo/redo entry*/
void markEnabled(const QString &name, bool enabled);
......
......@@ -25,19 +25,19 @@
#include <utility>
EffectGroupModel::EffectGroupModel(const QList<QVariant> &data, const QString &name,
const std::shared_ptr<AbstractTreeModel> &stack, const std::shared_ptr<TreeItem> &parent)
: AbstractEffectItem(data, stack, parent)
const std::shared_ptr<AbstractTreeModel> &stack)
: AbstractEffectItem(data, stack)
, m_name(name)
{
}
// static
std::shared_ptr<EffectGroupModel> EffectGroupModel::construct(const QString &name, std::shared_ptr<AbstractTreeModel> stack, std::shared_ptr<TreeItem> parent)
std::shared_ptr<EffectGroupModel> EffectGroupModel::construct(const QString &name, std::shared_ptr<AbstractTreeModel> stack)
{
QList<QVariant> data;
data << name << name;
std::shared_ptr<EffectGroupModel> self(new EffectGroupModel(data, name, std::move(stack), std::move(parent)));
std::shared_ptr<EffectGroupModel> self(new EffectGroupModel(data, name, std::move(stack)));
baseFinishConstruct(self);
......
......@@ -35,12 +35,12 @@ public:
/* This construct an effect of the given id
@param is a ptr to the model this item belongs to. This is required to send update signals
*/
static std::shared_ptr<EffectGroupModel> construct(const QString &name, std::shared_ptr<AbstractTreeModel> stack, std::shared_ptr<TreeItem> parent);
static std::shared_ptr<EffectGroupModel> construct(const QString &name, std::shared_ptr<AbstractTreeModel> stack);
protected:
EffectGroupModel(const QList<QVariant> &data, const QString &name,
const std::shared_ptr<AbstractTreeModel> &stack, const std::shared_ptr<TreeItem> &parent);
const std::shared_ptr<AbstractTreeModel> &stack);
void updateEnable() override;
......
......@@ -27,14 +27,14 @@
#include <utility>
EffectItemModel::EffectItemModel(const QList<QVariant> &data, Mlt::Properties *effect, const QDomElement &xml, const QString &effectId,
const std::shared_ptr<AbstractTreeModel> &stack, const std::shared_ptr<TreeItem> &parent)
: AbstractEffectItem(data, stack, parent)
const std::shared_ptr<AbstractTreeModel> &stack)
: AbstractEffectItem(data, stack)
, AssetParameterModel(effect, xml, effectId)
{
}
// static
std::shared_ptr<EffectItemModel> EffectItemModel::construct(const QString &effectId, std::shared_ptr<AbstractTreeModel> stack, std::shared_ptr<TreeItem> parent)
std::shared_ptr<EffectItemModel> EffectItemModel::construct(const QString &effectId, std::shared_ptr<AbstractTreeModel> stack)
{
Q_ASSERT(EffectsRepository::get()->exists(effectId));
QDomElement xml = EffectsRepository::get()->getXml(effectId);
......@@ -44,7 +44,7 @@ std::shared_ptr<EffectItemModel> EffectItemModel::construct(const QString &effec
QList<QVariant> data;
data << EffectsRepository::get()->getName(effectId) << effectId;
std::shared_ptr<EffectItemModel> self(new EffectItemModel(data, effect, xml, effectId, std::move(stack), std::move(parent)));
std::shared_ptr<EffectItemModel> self(new EffectItemModel(data, effect, xml, effectId, std::move(stack)));
baseFinishConstruct(self);
......
......@@ -37,7 +37,7 @@ public:
/* This construct an effect of the given id
@param is a ptr to the model this item belongs to. This is required to send update signals
*/
static std::shared_ptr<EffectItemModel> construct(const QString &effectId, std::shared_ptr<AbstractTreeModel> stack, std::shared_ptr<TreeItem> parent);
static std::shared_ptr<EffectItemModel> construct(const QString &effectId, std::shared_ptr<AbstractTreeModel> stack);
/* @brief This function plants the effect into the given service in last position
*/
......@@ -50,7 +50,7 @@ public:
protected:
EffectItemModel(const QList<QVariant> &data, Mlt::Properties *effect, const QDomElement &xml, const QString &effectId,
const std::shared_ptr<AbstractTreeModel> &stack, const std::shared_ptr<TreeItem> &parent);
const std::shared_ptr<AbstractTreeModel> &stack);
void updateEnable() override;
......
......@@ -36,7 +36,7 @@ EffectStackModel::EffectStackModel(std::weak_ptr<Mlt::Service> service)
std::shared_ptr<EffectStackModel> EffectStackModel::construct(std::weak_ptr<Mlt::Service> service)
{
std::shared_ptr<EffectStackModel> self(new EffectStackModel(std::move(service)));
self->rootItem = EffectGroupModel::construct(QStringLiteral("root"), self, std::shared_ptr<TreeItem>());
self->rootItem = EffectGroupModel::construct(QStringLiteral("root"), self);
return self;
}
......@@ -60,7 +60,8 @@ void EffectStackModel::copyEffect(std::shared_ptr<AbstractEffectItem>sourceItem,
}
std::shared_ptr<EffectItemModel> sourceEffect = std::static_pointer_cast<EffectItemModel>(sourceItem);
QString effectId = sourceEffect->getAssetId();
auto effect = EffectItemModel::construct(effectId, shared_from_this(), rootItem);