#ifndef BURNDATA_H
#define BURNDATA_H

#include "src/model/logicburndata.h"
#include "src/view/multiselectionfiledialog.h"
#include "src/process/processopenfile.h"
#include "inputchange.h"
#include "tipschange.h"
#include <QWidget>
#include <QMutex>
#include <QAction>
#include <QScopedPointer>

class MyMenu;

namespace Ui {
class BurnData;
}

class MyTreeView : public QTreeView
{
    Q_OBJECT
public:
    explicit MyTreeView(QWidget *parent = nullptr);

protected:
    void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
    void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE;

};

class BurnData : public QWidget
{
    Q_OBJECT
public:
    static BurnData *instance();
public:
    BurnData(const BurnData*)=delete;
    BurnData *operator =(const BurnData*)=delete;
public:
    void refresh();
public:
    void addFiles(QStringList);
    void updatePosition(QPoint);
protected:
    bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
    void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
    void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
    void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
private:
    explicit BurnData(QWidget *parent = nullptr);
    ~BurnData();
private:
    void initAction();
    void linkEntry(QModelIndex);
private slots:
    void slotsTip(bool);
    void slotsEntry(QModelIndex);
    void slotsLink();
    void slotsSize(unsigned long);
    void slotsSelectionChanged();
    void slotsAddFiles(bool);
    void slotsDeleteFiles(bool);
    void slotsCleanFiles(bool);
    void slotsNewFolder(bool);
    void slotsRangeChange(bool);
    void slotsFilterHidden(bool);
    void slotsFilterBroken(bool);
    void slotsRepleaceSymbolLinks(bool);
    void slotsParent();
    void slotsOpen();
    void slotsOpenLocal();
    void slotsRename();
    void slotsProperties();
    void slotsTreeMenuByRightKey(const QPoint &pos);
    void slotsTreeMenuByShortcutKey();
private:
    static BurnData          *m_oInstance;
    static QMutex             m_oMutex;
private:
    LogicBurnData            *m_oModel;
    MyMenu                    *m_oMenu;
    QAction                  *m_oParent;
    QAction                  *m_oOpen;
    QAction                  *m_oOpenLocal;
    QAction                  *m_oRename;
    QAction                  *m_oDelete;
    QAction                  *m_oNewFolder;
    QAction                  *m_oProperties;
    ProcessOpenFile          *m_oOpenFile;
    QModelIndex               m_oAddIndex;
    MultiSelectionFileDialog  m_oDialog;
    QList<QToolButton *>      m_oLinks;
    QModelIndexList           m_oIndexes;
    QPoint                    m_oPosition;
    InputChange              *inputchange;
private:
    Ui::BurnData *ui;
signals:
    void changeCurrentIndex(int);
    void busness(bool);
    void updateDisk(int, void *);
    void newNode(void *);
    void delData(int);
    void viewFileterFile(bool);
};
#define PAGE_BurnData BurnData::instance()
#endif // BURNDATA_H
