39 lines
903 B
C++
39 lines
903 B
C++
#ifndef PRODUCTSVIEWMODEL_H
|
|
#define PRODUCTSVIEWMODEL_H
|
|
|
|
#include <QObject>
|
|
|
|
#include "models/basemodel.h"
|
|
|
|
class SettingsService;
|
|
class ProductsViewModel : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QVariantList products READ products NOTIFY productsChanged)
|
|
Q_PROPERTY(QVariantList order READ order NOTIFY orderChanged)
|
|
Q_PROPERTY(float orderSum READ orderSum NOTIFY orderChanged)
|
|
|
|
public:
|
|
explicit ProductsViewModel(QObject *parent = nullptr);
|
|
|
|
QVariantList products() const;
|
|
QVariantList order() const;
|
|
float orderSum() const;
|
|
|
|
Q_INVOKABLE void setOrderValue(const QString &productId, float value);
|
|
Q_INVOKABLE void submitOrder();
|
|
|
|
signals:
|
|
void productsChanged();
|
|
void orderChanged();
|
|
|
|
private:
|
|
SettingsService *settings() const;
|
|
|
|
BaseModel m_productsModel = BaseModel("products", this);
|
|
QVariantMap m_order;
|
|
};
|
|
|
|
#endif // PRODUCTSVIEWMODEL_H
|