#ifndef WDEVICESMANAGER_H
#define WDEVICESMANAGER_H
#include <QObject>
#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QDir>
#include <QDateTime>
#include <QJsonObject>
#include <QJsonDocument>
#include <QPushButton>
#include <LoQClass/loqpushbutton.h>
#include <LoQClass/loqtreewidget.h>
#include <wDevicesManager/ledcard.h>
#include <communication/hpptclient.h>
#include <QLabel>
#include <QMap>
#include <LoUIClass/loemptydialog.h>
class wDevicesItem : public QObject, public QTreeWidgetItem
{
    Q_OBJECT
   // Q_PROPERTY(LedCard objLedCard    MEMBER m_LedCard   NOTIFY LedCardChanged   )
public:
    explicit wDevicesItem(LedCard *pLedCard, LoQTreeWidget *parent = nullptr,QWidget *pWnd=nullptr);
     ~wDevicesItem();
    void HttpPostByTypeJsonObject(QJsonObject json);
    void OnControlTcpSend(int iProgramIndex);
private:
    void init();

public:
    void refreshLable();
    QString GetLedCardId();
    void ChangeHttpGetResponsePro(LedCard *p);
    void OnStopAllItemPostHeartBeat(bool b);
    void onClearHeartbeatFlagByUdp();
    void SetMainTabWidgetIndex(int index);
//http获取控制卡信息的函数
    void HttpGetLedCardWidthHeight();
    void HttpGetLedCardRemarkName();
    QPixmap Base64_To_Image(QByteArray bytearray,QString SavePath);

signals:
    void sigOutputInfo(QString);
    void sigSetTipTextContent(QString);

public slots:
    void DeletePostingDlg();
    void onAttrChanged();
    void OnProHttpResponse(QString url, QString postMD5, QByteArray data);
    void DeviceItemHttpPost();
    LedCard *GetLedCardPoint();
protected slots:
    void onGetCardDetailInfo();
    void onReadbackPic();
    void onVerifyLockPassword();
    void onInputPasswordPro(QString strPassword);
    void onSendHeartbeat();
    void OnSyncFirmware();
    void slotUploadFinished();
    void slotUploadProgress(qint64 A,qint64 B);
private:
    LedCard   *m_pLedCard = nullptr;
    int m_intIndexFlagOfInfoOrControl=0;
    void SetPasswordItem(LedCard *p);
    void SetDetailInfoItem(LedCard *p);
//    void UpLoadForm(QString Path,QFile *uploadFile,QString newFileName);
 //   void UpLoadForm(QString Path,QMap<QString , QString> params,QString fileFormName,QFile *uploadFile,QString newFileName);
    void UpLoadForm(QString Path,QMap<QString,QString> params,QString fileFormName,QFile *uploadFile,QString newFileName,int iType);
//    void UpLoadFile(QString strFilePath);
    bool compare (const QString& x, const QString& y);
    QString b64ToQs(QString b64qs1);
private:
    QPushButton *m_bnCardDetailInfo = nullptr;//
    QPushButton *m_bnReadbackPic = nullptr;//
    QPushButton *m_bnLock = nullptr;//
    QLabel *m_ImageOnline=nullptr;


    LoQTreeWidget *m_parent = nullptr;
    HpptClient *pHpptClient = nullptr;
    QString m_strUrl="";
    QWidget *m_pWnd=nullptr;
    QTimer *m_HeartbeatTimer=nullptr;
    int m_HeartbeatCount=0;
    LoEmptyDialog * m_PostingDlg=nullptr;
    QTimer *m_pGetAskTimer=nullptr;
    void SendAnycastCmd(QString strIp,int iIndex);


};
enum ENUM_DEVICEHEADERITEM
{
    ENUM_DEVICEHEADE_CHECK=0,
    ENUM_DEVICEHEADE_SCREEN_ID,
    ENUM_DEVICEHEADE_ONLINE,
    ENUM_DEVICEHEADE_SCREEN_IP,
    ENUM_DEVICEHEADE_SCREEN_SIZE,
    ENUM_DEVICEHEADE_REMARK_NAME,
    ENUM_DEVICEHEADE_BRIGHTNESS,
    ENUM_DEVICEHEADE_POWER,
    ENUM_DEVICEHEADE_PASSWORD,
    ENUM_DEVICEHEADE_MORE_INFO,
    ENUM_DEVICEHEADE_PIC_READBACK,
    ENUM_DEVICEHEADE_END,
};



#endif // WDEVICESMANAGER_H
