#ifndef CAMPWIZARD_H
#define CAMPWIZARD_H

#include <QWizard>
#include "data/camp-data.h"
#include <objectbinder.h>
#include <data/addressbookdata.h>
#include <data/accservice.h>
#include <core.h>

class AddressHelper : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QSharedPointer<QObject> address READ address WRITE setAddress)

public:
    AddressHelper(QObject *parent = NULL);

    QSharedPointer<QObject> address() const;
    void setAddress(const QSharedPointer<QObject> &address);

    AddressbookDataPtr addr() const;
    void setAddr(const AddressbookDataPtr &address);

    AddressbookDataPtr newAddress();
    AddressbookDataPtr copyAddress();

private:
    AddressbookDataPtr m_address;
    AddressbookDataPtr m_copyAddress;
};

class SaleHelper : public QObject
{
    Q_OBJECT
    Q_PROPERTY(QSharedPointer<QObject> sale READ sale WRITE setSale NOTIFY saleChanged)

public:
    SaleHelper(QObject *parent = NULL);

    SalePtr salePtr() const;
    void setSalePtr(const SalePtr &sale);

    QSharedPointer<QObject> sale() const;
    void setSale(const QSharedPointer<QObject> &sale);

signals:
    void saleChanged();

private:
    SalePtr m_sale;
};

namespace Ui {
class CampWizard;
}

class CampWizard : public QWizard
{
    Q_OBJECT

public:
    explicit CampWizard(QWidget *parent = 0);
    ~CampWizard();

    void setData(const CampDataPtr &data);
    void setNewRecord(bool newRecord);

private slots:
    void on_btnAdd_clicked();

    void on_address_currentIndexChanged(int index);

    void on_btnRemove_clicked();

    void on_btnOwner_clicked();

    void on_groupNew_clicked(bool checked);

    void on_CampWizard_currentIdChanged(int id);

    void on_btnAddService_clicked();

    void on_btnRemoveService_clicked();

    void on_checkSale_clicked();

    void applySale();

    void on_sale_currentIndexChanged(int index);

    void on_btnPrint_clicked();

private:
    Ui::CampWizard *ui;
    CampDataPtr m_data;
    ObjectBinder *m_dataBinder;
    ObjectBinder *m_addrHelperBinder;
    ObjectBinder *m_addressBinder;
    AddressHelper *m_addrHelper;
    ObjectBinder *m_saleBinder;
    SaleHelper *m_saleHelper;

    AutoTableModel<AddressItem> *m_peopleModel;
    AutoTableModel<AccService> *m_servicesModel;
    AutoTableModel<ServiceItem> *m_itemsModel;
    bool m_bindAddrCombo;
    bool m_newRecord;

    // QWizard interface
public:
    bool validateCurrentPage();

public slots:
    void accept();
};

#endif // CAMPWIZARD_H
