#ifndef WPAGELIST_H
#define WPAGELIST_H

#include <QWidget>
#include <QToolBar>
#include <QListWidget>
#include <QVBoxLayout>
#include <QAction>
#include <QGraphicsScene>
#include <QDate>
#include <QDir>
#include <QFile>
#include <QJsonArray>
#include <QJsonObject>
#include <QJsonDocument>
#include "loappconfig.h"
#include <QLabel>

class wPageItem;
class wPageList : public QWidget
{
    Q_OBJECT
public:
    explicit wPageList(const QString &pRoot, int w, int h, QWidget *parent = nullptr);
    virtual void keyReleaseEvent(QKeyEvent *event) override;

public:
    int load();
    void setRes(int w, int h);
    void save();
    void saveAs();
    void setting();
    int pageCount() { return m_wPageList->count(); }
    void Init();
    void setCurrentPage(int i) { m_wPageList->setCurrentRow(i); }
    QString     m_strProgramItemPath;
    bool IsChanged();

signals:
    void sigPageSelected(wPageItem*);
    void sigDeletePageItem(wPageItem*);


public slots:
    void onRestore(const QJsonDocument &json);
    void onAdd();
    void onCopy();
    void onDelete();
    void onGoUp();
    void onGoDown();
    void onCurrentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);

private:
    void save0();
    void save1();
    void save2();
    QString genNewPageName();
    void flashOrder();

private:
    QListWidget *m_wPageList;
    QLabel * m_ProgramListLable;
    int         m_width;
    int         m_height;
};

#endif // WPAGELIST_H
