#ifndef SHOPFORM_H
#define SHOPFORM_H

#include <QWidget>
#include <QList>
#include "data/shop-data.h"
#include <autotablemodel.h>

class ShopItem;
class IShopItem;

namespace Ui {
class ShopForm;
}

class ShopForm : public QWidget
{
    Q_OBJECT

public:
    explicit ShopForm(QWidget *parent = 0);
    ~ShopForm();
    void loadLast();
    void fillRaceiptCombo();

private slots:
    void on_directSale_clicked();

    void on_temporarySaveButton_clicked();

    void on_saveButton_clicked();

    void on_loadButton_clicked();

    void onCountChanged(int oldCount = 0);

    void on_receiptCombo_currentIndexChanged(int index);

    void on_payButton_clicked();

    void on_showPaiedButton_clicked();

    void on_btnAddItem_clicked();

    void on_commoditySearch_textChanged(const QString &text);

private:
    Ui::ShopForm *ui;
    QSharedPointer<Voucher> m_voucher;
    AutoTableModel<VoucherItem> *m_itemsModel;
    AutoTableModel<ShopItem> *m_commodityModel;

    void createVoucher();
    void doTempSave(bool comboChanged);
    void changeReceipt();
    void connectItemSignals();
    void createEmptyVoucher();
    void addItem(QSharedPointer<IShopItem> item, int count);
};

#endif // SHOPFORM_H
