#ifndef PROGITEM_H
#define PROGITEM_H

#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QDir>
#include <QDateTime>
#include <QJsonObject>
#include <QJsonDocument>
#include <QPushButton>
#include <base/loqtreewidget.h>
class ProgPanel;
class ProgItem : public QObject, public QTreeWidgetItem {
    Q_OBJECT
public:
    explicit ProgItem(const QString &progsDir, const QString &name, int w, int h, const QString & remarks, QList<int> &splitWidths, int, LoQTreeWidget *parent = nullptr, ProgPanel *pWnd=nullptr);
    explicit ProgItem(const QString &progsDir, const QJsonObject &json, LoQTreeWidget *parent = nullptr, ProgPanel *pWnd=nullptr);

    void save();
    void del();
    void refreshLable();

    QString mName;
    int mWidth;
    int mHeight;
    QString mRemark;
    QList<int> mSplitWidths;
    int mMaxWidth{0};
    QString mProgsDir;
    QString mProgDir;
    qint64 m_fsize{0};
    QDateTime m_last;
    QPushButton *m_bnName;
    ProgPanel *mProgPanel{0};

public slots:
    void onSetProgram();
    void onSendProgram();
    void onUsbExportProgram();
    void onUsbExportProgramPro(QString strPath,QString strPassword);

private:
    void init();
    QPushButton *m_bnExport;
    QPushButton *m_bnSend;
    QString       m_orgName;
    LoQTreeWidget *mTree;
};
enum ENUM_PROGRAMLISTHEADERITEM
{
    ENUM_PROGRAMLISTHEADERITEM_CHECK=0,
    ENUM_PROGRAMLISTHEADERITEM_NAME,
    ENUM_PROGRAMLISTHEADERITEM_RESOLUTION,
    ENUM_PROGRAMLISTHEADERITEM_SIZE,
    ENUM_PROGRAMLISTHEADERITEM_LASTTIME,
    ENUM_PROGRAMLISTHEADERITEM_USB_EXPORT,
    ENUM_PROGRAMLISTHEADERITEM_SEND,
    ENUM_PROGRAMLISTHEADERITEM_END
};

#endif // PROGITEM_H
