#pragma once
#include "RasterProcessToolWidgetAPI.h"
#include <QtWidgets/QMainWindow>
#include "QToolAbstract.h"
#include <QMenu>


namespace Ui {
    class ToolBoxWidget;
}

namespace LAMPMainWidget {
    class RasterMainWidget;
}


class QToolboxTreeWidgetItem  {
public:
    QToolboxTreeWidgetItem(QTreeWidget* treeWidgetToolBox,QTreeWidgetItem* parentItem,QToolAbstract* item);
    ~QToolboxTreeWidgetItem();
private:
    QTreeWidgetItem*    actionItem=nullptr;
    QPushButton*        button = nullptr;
    QToolAbstract*      item = nullptr;
    QTreeWidgetItem*    parentItem = nullptr;

public:
    QTreeWidgetItem*  getTreeWidgetItem();
    QPushButton*      getPushButton();
    QToolAbstract*    getToolAbstract();
    QTreeWidgetItem*    getParantTreeWidgetItem();
};



class RASTERPROCESSTOOLWIDGET_EXPORT ToolBoxWidget : public QWidget
{
    Q_OBJECT

public:
    ToolBoxWidget(LAMPMainWidget::RasterMainWidget* mainWindows=nullptr,QWidget *parent = nullptr);
    ~ToolBoxWidget();
public:
    void initMenu();
    void initToolbox(QString dlltoolPath);
private:
    QMenu* contextmenu;
    QList<QToolboxTreeWidgetItem> toollist;

signals:
    void addBoxToolItemSIGNAL(QToolAbstract* item);

public slots:
    void addBoxToolItemSLOT(QToolAbstract* item);
    QTreeWidgetItem* findOrCreateParentItem( QVector<QString>& path);
    QTreeWidgetItem* findOrCreateTopLevelItem( QString& name);
    QTreeWidgetItem* findChildItemByName(QTreeWidgetItem* parentItem,  QString& name);




public slots:
    // 打开工具箱管理界面
    void OpenToolboxManagerWidget();

private:
    Ui::ToolBoxWidget* ui;
    LAMPMainWidget::RasterMainWidget* _mainWindows;//主窗口
};
