mirror of
https://github.com/status-im/QtModelsToolkit.git
synced 2026-08-31 01:51:08 +00:00
43 lines
1000 B
C++
43 lines
1000 B
C++
#pragma once
|
|
|
|
#include <QJSValue>
|
|
#include <QObject>
|
|
#include <QVariant>
|
|
|
|
#include "qtmodelstoolkit/singleroleaggregator.h"
|
|
|
|
namespace qtmt {
|
|
|
|
class FunctionAggregator : public SingleRoleAggregator
|
|
{
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QVariant initialValue READ initialValue WRITE setInitialValue
|
|
NOTIFY initialValueChanged)
|
|
|
|
Q_PROPERTY(QJSValue aggregateFunction READ aggregateFunction
|
|
WRITE setAggregateFunction NOTIFY aggregateFunctionChanged)
|
|
|
|
public:
|
|
explicit FunctionAggregator(QObject* parent = nullptr);
|
|
|
|
const QVariant& initialValue() const;
|
|
void setInitialValue(const QVariant& initialValue);
|
|
|
|
const QJSValue& aggregateFunction() const;
|
|
void setAggregateFunction(const QJSValue& aggregateFunction);
|
|
|
|
signals:
|
|
void initialValueChanged();
|
|
void aggregateFunctionChanged();
|
|
|
|
protected slots:
|
|
QVariant calculateAggregation() override;
|
|
|
|
private:
|
|
QVariant m_initialValue;
|
|
QJSValue m_aggregateFunction;
|
|
};
|
|
|
|
} // namespace qtmt
|