Commit 2c7000be authored by Nicolas Carion's avatar Nicolas Carion

effect list name filtering

parent a38ff2f6
......@@ -37,6 +37,8 @@ EffectListWidget::EffectListWidget(QWidget *parent)
m_proxyModel = new EffectFilter(this);
m_proxyModel->setSourceModel(m_model.get());
m_proxyModel->setSortRole(EffectTreeModel::NameRole);
m_proxyModel->sort(0, Qt::AscendingOrder);
KDeclarative::KDeclarative kdeclarative;
kdeclarative.setDeclarativeEngine(engine());
......@@ -62,3 +64,8 @@ QString EffectListWidget::getDescription(const QModelIndex& index) const
{
return m_model->getDescription(m_proxyModel->mapToSource(index));
}
void EffectListWidget::setFilterName(const QString& pattern)
{
m_proxyModel->setFilterName(!pattern.isEmpty(), pattern);
}
......@@ -41,6 +41,7 @@ public:
Q_INVOKABLE QString getName(const QModelIndex& index) const;
Q_INVOKABLE QString getDescription(const QModelIndex& index) const;
Q_INVOKABLE void setFilterName(const QString& pattern);
private:
std::unique_ptr<EffectTreeModel> m_model;
EffectFilter *m_proxyModel;
......
......@@ -24,6 +24,7 @@ import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Window 2.2
import QtQuick.Layouts 1.3
import QtQml.Models 2.2
Rectangle {
id: listRoot
......@@ -114,7 +115,15 @@ Rectangle {
NumberAnimation { properties: "opacity" }
}
]
onTextChanged: {
effectlist.setFilterName(text)
}
}
ItemSelectionModel {
id: sel
model: effectListModel
}
TreeView {
id: treeView
Layout.fillHeight: true
......@@ -134,6 +143,7 @@ Rectangle {
TableViewColumn { role: "id"; title: "Name"; width: 200 }
model: effectListModel
selection: sel
onClicked:{
effectDescription.text = effectlist.getDescription(index)
}
......@@ -150,4 +160,5 @@ Rectangle {
}
}
}
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