#ifndef COMMONVIEW_H
#define COMMONVIEW_H

#include <QTreeWidget>
#include <QTranslator>
#include <QMutex>
#include "instructorsAndTrainees_global.h"
#include "connectortoserver.h"

//Родительский класс представления БД Инструкторов/Обучаемых (самого верхнего уровня)

class CommonView : public QWidget
{
    Q_OBJECT

public:
    enum TypeView
    {
        onlyView,
        control
    };

    enum TypeObject
    {
        objInstructor,
        objTrainee,
        objGroup
    };

public:
    CommonView(ConnectorToServer* connectorToServer, TypeView type, QWidget *parent = nullptr);

public:
    void setAdminMode(bool adminMode)
    {
        this->adminMode = adminMode;
    }    
    void clearTree()
    {
        treeWidget->clear();
    }

protected:
    void setArchiveVisible(bool archiveVisible)
    {
        this->archiveVisible = archiveVisible;
    }
    void setNotLoggedInVisible(bool notLoggedInVisible)
    {
        this->notLoggedInVisible = notLoggedInVisible;
    }

    void setItemColorArchive(QTreeWidgetItem* item);
    void setItemColorNoArchive(QTreeWidgetItem* item);

    void setItemColor(QTreeWidgetItem* item, QColor color);

protected:
    ConnectorToServer* connectorToServer;
    QTreeWidget* treeWidget;
    QMutex mtxTreeWidget;
    TypeView typeView;
    bool archiveVisible;
    bool notLoggedInVisible;
    bool adminMode;
    bool authComplited;
    int lastCurrentID;
    TypeObject typeObject;
};

#endif // COMMONVIEW_H
