/ proxyroles / expressionrole.h
expressionrole.h
 1  #ifndef EXPRESSIONROLE_H
 2  #define EXPRESSIONROLE_H
 3  
 4  #include "singlerole.h"
 5  #include <QQmlScriptString>
 6  
 7  class QQmlExpression;
 8  
 9  namespace qqsfpm {
10  
11  class ExpressionRole : public SingleRole
12  {
13      Q_OBJECT
14      Q_PROPERTY(QQmlScriptString expression READ expression WRITE setExpression NOTIFY expressionChanged)
15  
16  public:
17      using SingleRole::SingleRole;
18  
19      const QQmlScriptString& expression() const;
20      void setExpression(const QQmlScriptString& scriptString);
21  
22      void proxyModelCompleted(const QQmlSortFilterProxyModel& proxyModel) override;
23  
24  Q_SIGNALS:
25      void expressionChanged();
26  
27  private:
28      QVariant data(const QModelIndex& sourceIndex, const QQmlSortFilterProxyModel& proxyModel) override;
29      void updateContext(const QQmlSortFilterProxyModel& proxyModel);
30      void updateExpression();
31  
32      QQmlScriptString m_scriptString;
33      QQmlExpression* m_expression = nullptr;
34      QQmlContext* m_context = nullptr;
35  };
36  
37  }
38  
39  #endif // EXPRESSIONROLE_H