#include "commonview.h"
#include <QFile>
#include <QMessageBox>


CommonView::CommonView(ConnectorToServer* connectorToServer, TypeView type, QWidget *parent):
    QWidget(parent),
    connectorToServer(connectorToServer),
    treeWidget(nullptr),
    typeView(type),
    archiveVisible(false),
    notLoggedInVisible(true),
    adminMode(false),
    authComplited(false),
    lastCurrentID(0),
    typeObject(TypeObject::objInstructor),
    waitAnimationWidget(nullptr)
{
    treeWidget = new QTreeWidget();
    treeWidget->setFocusPolicy(Qt::FocusPolicy::NoFocus);

    waitAnimationWidget = new WaitAnimationWidget;
    QMovie *movie = new QMovie(":/resources/icons/762.gif");
    //waitAnimationWidget->setParent(this);
    waitAnimationWidget->initialize(movie,this);
}

CommonView::~CommonView()
{
    waitAnimationWidget->hideWithStop();
    delete waitAnimationWidget;
}

void CommonView::setItemColorArchive(QTreeWidgetItem *item)
{
    setItemColor(item,QColor(240, 240, 240));
}

void CommonView::setItemColorNoArchive(QTreeWidgetItem *item)
{
    setItemColor(item,QColor(255, 255, 255));
}

void CommonView::setItemColor(QTreeWidgetItem *item, QColor color)
{
    for (int i = 0; i < item->columnCount(); i++)
        item->setBackground(i, color);
}
