#ifndef HOSTWIDGET_H
#define HOSTWIDGET_H

#include "fmp_window.h"
#include "global.h"
#include "fmp_settings.h"
#include <QWidget>
#include <QList>
#include <QTimer>
#include <QStringList>
#include <fmglobal.h>
#include <QDate>

class LabelsTimer;
class QMovie;
class QButtonGroup;
class QAbstractButton;

namespace Ui {
class HostWidget;
}

class HostWidget : public FMPWindow
{
    Q_OBJECT

public:

    explicit HostWidget(QWidget *parent = 0);
    ~HostWidget();
    void ShowUiWithRequest(QJsonObject requestObj);
    void ShowResponseMGS(ReqType type, bool flag, QString message = QString());
    void ShowQueryRespJson(bool flag, QJsonObject object, QString error);
    void setRuning(bool runing);
    void StopPay();
    void HideExit();

signals:

    void RequestWithType(ReqType type, QStringList list);
    void ExitWithMSG(QString code, QString message);
    void Exits();
    void Interrupt();

protected:
    void keyPressEvent(QKeyEvent *ke);

private slots:
    void on_btn_printagain_clicked();
    void on_btn_mananger_register_clicked();
    void on_btn_mananger_check_clicked();
    void on_btn_mananger_print_clicked();
    void on_btn_mananger_exit_clicked();
    void on_btn_pay_exit_clicked();
    void on_btn_find_exit_clicked();
    void on_btn_sign_exit_clicked();
    void on_btn_sign_sign_clicked();
    void on_TimeOut();
    void on_btn_find_check_clicked();
    void on_btn_find_next_clicked();
    void on_btn_find_up_clicked();
    void on_btn_wait_quit_clicked();
    void on_btn_pay_exitint_clicked();
    void onPaymentMethodBtnsToggled(QAbstractButton *, bool);
    void on_dateEdit_find_begin_dateChanged();
    void on_comBox_payment_method_currentTextChanged();

private:
    void ShowWidget(QWidget *showwidget);
    void InitWidget();
    void ShowPayWidget();
    void SetTableWidgetHeader();

private:
    Ui::HostWidget *ui;
    FMPSettings _setting;

    QList<QWidget *> _widgetlist;
    QWidget *_curr_show_widget;

    QJsonObject _posReqJsonObj;

    LabelsTimer *_label_pay_timer;
    LabelsTimer *_label_find_timer;
    LabelsTimer *_label_wait_timer;
	
    QTimer _intertime;

    QMovie *_label_pay_movie;

    int _line;
    bool _need_exit;
    bool _runing;
    ReqType _type;

    QMap<QString, QString> _paymentMethodsMapThird, _paymentMethodsMapCoupon;
    QString _queryPaymentMethod;
    QDate _queryPaymentDate;
    bool _queryConditionsIsChanged;
};

#endif // HOSTWIDGET_H
