#ifndef DOCTASKSWIDGET_H
#define DOCTASKSWIDGET_H

#include <QWidget>
#include <QTreeWidget>
#include <QDomNode>
#include "module.h"

namespace Ui {
class DocTasksWidget;
}

class DocTasksWidget : public QWidget
{
    Q_OBJECT

private:
    enum ColumnsTree{
        clmn_PMorDM = 0,
        clmn_ID
    };

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

private Q_SLOTS:
    void on_treeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);

private:
    void domElementParser(QDomElement element, Module* moduleParent);
    void loadDocTasksFromXML();
    void deleteAllModuls();
    Module* searchModuleByID(int id);

    void preparationTreeWidget();
    void reSetHeadTreeWidget();
    void updateTreeWidget();
    void addModuleToTreeWidget(Module* module, QTreeWidgetItem* parentItem = nullptr);

private:
    Ui::DocTasksWidget *ui;
    QTreeWidget* treeWidget;

    QList<Module*> listAllModules;
};

#endif // DOCTASKSWIDGET_H
