#ifndef FORMPRODUCT_H
#define FORMPRODUCT_H

#include <QWidget>
#include "formbase.h"
#include "../src/elementtype.h"

namespace Ui
{
class formProduct;
}

class formProduct : public formBase
{
    Q_OBJECT

public:
    //explicit formProduct(QWidget *parent = 0);
    explicit formProduct(QString aID = "", int aEditMode = 0, QWidget *parent = nullptr);
    ~formProduct();

    void newDocument() override {}
    void openDocument(QString id) override;
    void closeDocument() override;
    void save() override;
    bool needsave() override { return mNeedSave; }
    void setEditMode(bool aMode) override {}

public slots:
    void on_ModelSetData(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
private slots:
    void on_editPC_valueChanged(double arg1);
    void on_editMargin_valueChanged(double arg1);
    void on_editPV_valueChanged(double arg1);
    void on_comboIVA_currentIndexChanged(const QString &arg1);
    void on_editPV_editingFinished();
    void on_buttonSave_released();

    void on_editPVIVA_valueChanged(const QString &arg1);

    void on_comboType2_currentIndexChanged(int index);

private:
    Ui::formProduct *ui;
    bool editMode;
    QStringList insertedElementCodes;

    void CalculatePrice();
    bool InsertElement(QString ID, QModelIndex index);
    void setLineType(QString type, QModelIndex index);
    void setCellText(QString val, QModelIndex index, int col);
    void setEditMode();
    void setComposeElement(bool val);
};

#endif // FORMPRODUCT_H