Commit 21fbe7e9 authored by Nicolas Carion's avatar Nicolas Carion

Bring back effect description in EffectList

parent 07e1a050
......@@ -113,6 +113,20 @@ QString EffectTreeModel::getName(const QModelIndex& index) const
}
}
QString EffectTreeModel::getDescription(const QModelIndex& index) const
{
if (!index.isValid()) {
return QString();
}
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
if (item->depth() == 1) {
return QString();
} else {
auto id = item->data(EffectTreeModel::idCol).toString();
return EffectsRepository::get()->getEffectDescription(id);
}
}
QVariant EffectTreeModel::data(const QModelIndex &index, int role) const
{
......
......@@ -43,6 +43,8 @@ public:
//Helper function to retrieve name
QString getName(const QModelIndex& index) const;
//Helper function to retrieve description
QString getDescription(const QModelIndex& index) const;
QHash<int, QByteArray> roleNames() const override;
QVariant data(const QModelIndex &index, int role) const override;
......
......@@ -57,3 +57,8 @@ QString EffectListWidget::getName(const QModelIndex& index) const
{
return m_model->getName(m_proxyModel->mapToSource(index));
}
QString EffectListWidget::getDescription(const QModelIndex& index) const
{
return m_model->getDescription(m_proxyModel->mapToSource(index));
}
......@@ -40,6 +40,7 @@ public:
EffectListWidget(QWidget *parent = Q_NULLPTR);
Q_INVOKABLE QString getName(const QModelIndex& index) const;
Q_INVOKABLE QString getDescription(const QModelIndex& index) const;
private:
std::unique_ptr<EffectTreeModel> m_model;
EffectFilter *m_proxyModel;
......
......@@ -134,6 +134,20 @@ Rectangle {
TableViewColumn { role: "id"; title: "Name"; width: 200 }
model: effectListModel
onClicked:{
effectDescription.text = effectlist.getDescription(index)
}
}
TextArea {
id: effectDescription
text: ""
visible: false
Layout.fillWidth: true
states: State {
name: "hasDescription"; when: effectDescription.text != ''
PropertyChanges { target: effectDescription; visible: true }
}
}
}
}
......@@ -254,6 +254,11 @@ QString EffectsRepository::getEffectName(const QString& effectId) const
Q_ASSERT(m_effects.count(effectId) > 0);
return m_effects.at(effectId).name;
}
QString EffectsRepository::getEffectDescription(const QString& effectId) const
{
Q_ASSERT(m_effects.count(effectId) > 0);
return m_effects.at(effectId).description;
}
bool EffectsRepository::isFavorite(const QString& effectId) const
{
//TODO
......
......@@ -65,6 +65,9 @@ public:
/* @brief Return name of effect */
QString getEffectName(const QString& effectId) const;
/* @brief Return description of effect */
QString getEffectDescription(const QString& effectId) const;
/* @brief Check whether a given effect is favorite */
bool isFavorite(const QString& effectId) const;
......
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