Update effectstack widget on effect add

parent 228babca
......@@ -53,7 +53,6 @@ AssetPanel::AssetPanel(QWidget *parent)
void AssetPanel::showTransition(std::shared_ptr<AssetParameterModel> transitionModel)
{
qDebug() << "Show transition signal";
clear();
QString transitionId = transitionModel->getAssetId();
QString transitionName = TransitionsRepository::get()->getName(transitionId);
......@@ -62,11 +61,12 @@ void AssetPanel::showTransition(std::shared_ptr<AssetParameterModel> transitionM
m_transitionWidget->setModel(transitionModel);
}
void AssetPanel::showEffectStack(std::shared_ptr<EffectStackModel> effectsModel)
void AssetPanel::showEffectStack(int cid, std::shared_ptr<EffectStackModel> effectsModel)
{
clear();
m_assetTitle->setText(i18n("Properties of clip ..."));
m_effectStackWidget->setVisible(true);
m_effectStackWidget->setProperty("clipId", cid);
m_effectStackWidget->setModel(effectsModel);
}
......@@ -75,6 +75,7 @@ void AssetPanel::clear()
m_transitionWidget->setVisible(false);
m_transitionWidget->unsetModel();
m_effectStackWidget->setVisible(false);
m_effectStackWidget->setProperty("clipId", QVariant());
m_effectStackWidget->unsetModel();
m_assetTitle->setText(QString());
}
......
......@@ -47,7 +47,7 @@ public:
void showTransition(std::shared_ptr<AssetParameterModel> transition_model);
/* @brief Shows the parameters of the given effect stack model */
void showEffectStack(std::shared_ptr<EffectStackModel> effectsModel);
void showEffectStack(int cid, std::shared_ptr<EffectStackModel> effectsModel);
/* @brief Clear the panel so that it doesn't display anything */
void clear();
......
......@@ -44,6 +44,8 @@ void EffectStackModel::appendEffect(const QString &effectId)
effect->setEffectStackEnabled(m_effectStackEnabled);
effect->plant(m_service);
rootItem->appendChild(effect);
QModelIndex ix = getIndexFromItem(effect);
emit dataChanged(ix, ix, QVector<int>());
}
void EffectStackModel::setEffectStackEnabled(bool enabled)
......
......@@ -46,10 +46,23 @@ void EffectStackView::setModel(std::shared_ptr<EffectStackModel>model)
m_lay->addWidget(view);
m_widgets.push_back(view);
}
connect(m_model.get(), &EffectStackModel::dataChanged, this, &EffectStackView::refresh);
m_lay->addStretch();
}
void EffectStackView::unsetModel()
void EffectStackView::refresh(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
{
unsetModel(false);
int max = m_model->rowCount();
for (int i = 0; i < max; i++) {
CollapsibleEffectView *view = new CollapsibleEffectView(m_model->effect(i), this);
m_lay->addWidget(view);
m_widgets.push_back(view);
}
m_lay->addStretch();
}
void EffectStackView::unsetModel(bool reset)
{
// clear layout
m_widgets.clear();
......@@ -60,7 +73,9 @@ void EffectStackView::unsetModel()
}
// Release ownership of smart pointer
m_model.reset();
if (reset) {
m_model.reset();
}
}
......@@ -38,7 +38,7 @@ Q_OBJECT
public:
EffectStackView(QWidget *parent = nullptr);
void setModel(std::shared_ptr<EffectStackModel>model);
void unsetModel();
void unsetModel(bool reset = true);
private:
QVBoxLayout *m_lay;
......@@ -46,6 +46,9 @@ private:
std::vector<CollapsibleEffectView *> m_widgets;
const QString getStyleSheet();
private slots:
void refresh(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
};
#endif
......
......@@ -389,7 +389,7 @@ void TimelineController::showAsset(int id)
if (m_model->isComposition(id)) {
emit showTransitionModel(m_model->getCompositionParameterModel(id));
} else if (m_model->isClip(id)) {
emit showClipEffectStack(m_model->getClipEffectStackModel(id));
emit showClipEffectStack(id, m_model->getClipEffectStackModel(id));
}
}
......
......@@ -249,7 +249,7 @@ signals:
void zoneMoved(const QPoint &zone);
/* @brief Requests that a given parameter model is displayed in the asset panel */
void showTransitionModel(std::shared_ptr<AssetParameterModel>);
void showClipEffectStack(std::shared_ptr<EffectStackModel>);
void showClipEffectStack(int cid, std::shared_ptr<EffectStackModel>);
};
#endif
......@@ -72,7 +72,7 @@ signals:
/* @brief Requests that a given parameter model is displayed in the asset panel */
void showTransitionModel(std::shared_ptr<AssetParameterModel>);
/* @brief Requests that a given effectstack model is displayed in the asset panel */
void showClipEffectStack(std::shared_ptr<EffectStackModel>);
void showClipEffectStack(int cid, std::shared_ptr<EffectStackModel>);
private:
TimelineWidget *m_mainTimeline;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment