#ifndef MPROGRAMMANAGER_H
#define MPROGRAMMANAGER_H

#include <QWidget>
#include <QStyleOption>
#include <QPainter>
#include <QFile>
#include <QAction>
#include <QTreeWidgetItem>
#include <QCheckBox>
#include <QPushButton>
#include <QDebug>
#include <QLabel>
#include <QDateTime>
#include <QList>
#include <QDir>
#include <QFile>
#include <QStandardPaths>
#include <QStringList>
#include <QJsonValue>
#include <QJsonObject>
#include <QJsonDocument>

#include "loappconfig.h"
#include <LoQClass/loqpushbutton.h>
#include <LoQClass/loqtreewidget.h>
#include <wProgramManager/wnewprogram.h>
#include <wProgramManager/weditprogram.h>
#include "wProgramManager/wprogramitem.h"
namespace Ui {
class mProgramManager;
}

class mProgramManager : public QWidget
{
    Q_OBJECT

public:
    explicit mProgramManager(QWidget *parent = nullptr);
    ~mProgramManager();

public:
    virtual void paintEvent(QPaintEvent *);
    void refreshLable();
    QTreeWidgetItem *m_headerItem=nullptr;
protected:
    bool checkIfNameRepeated(const QString &name, QTreeWidgetItem *skip = nullptr);

protected slots:
    void onCheckStateChanged(int f);
    void onNewClicked(bool f);
    void onEditClicked(bool f);
    void onDeleteClicked(bool f);
    void onImportClicked(bool f);
    void onExportClicked(bool f);
    void onRestoreProgram(const QJsonDocument &pro);
    void onCreateNewProgram(QString name, QSize res, QString remarks);
    void onCreateNewProgramOnOpenEditProgramWidget(QString name, QSize res, QString remarks);
    void onEditHead(const QString &name, QSize res, const QString &remarks);
//    void onDeleteProgram(QString strImportDir,QString strTip1);
    void onImportProgram(QString strImportDir,QString strTip1);
    void onExportProgram(QString strImportDir,QString strTip1);
    void FilterProgram(const QString &strtemp);

signals:
    void sigCheckAll(bool);

private slots:
    void OnClickColumn(int iColumn);


private:
    Ui::mProgramManager *ui;
    QString             m_strProgramItemPath;
    QList<wProgramItem *> m_pwPorgramItemList;
    void readSettings();
    void writeSettings();

};

#endif // MPROGRAMMANAGER_H
