Рефакт

This commit is contained in:
2025-09-11 12:55:28 +03:00
parent d65776ff98
commit 6bcf8a60ba
116 changed files with 179 additions and 250 deletions

View File

@@ -5,6 +5,11 @@
#include "dialogauthorizationinstructor.h"
#include "dialogsettings.h"
const QString InstructorsAndTraineesWidget::languageENG = "en_EN";
const QString InstructorsAndTraineesWidget::languageRUS = "ru_RU";
InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
QWidget(parent),
connectorToServer(nullptr),
@@ -15,18 +20,13 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
adminMode(false),
loginInstructorLoggedInLocal(QStringLiteral("")),
nameInstructorLoggedInLocal(QStringLiteral("")),
language("ENG"),
idInstructorLoggedInLocal("0"),
language(languageENG),
ui(new Ui::InstructorsAndTraineesWidget)
{
ui->setupUi(this);
ui->btnSettings->setObjectName("btnSettings");
ui->widget_Control->setObjectName("widgetTop");
ui->groupBox_Trainees->setObjectName("groupBox_Trainees");
#ifndef PROJECT_TYPE_DEBUG
//ui->btnUpdateStyleSheet->setVisible(false);
#endif
ui->widget_Control->setObjectName("widgetControl");
registerMetaType();
@@ -37,8 +37,8 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
setLanguageInterfase();
connectorToServer = new ConnectorToServer(this);
connect(connectorToServer,&ConnectorToServer::sigLoginResult,this,&InstructorsAndTraineesWidget::slot_checkLoginResult);
connect(connectorToServer,&ConnectorToServer::sigDeLoginResult,this,&InstructorsAndTraineesWidget::slot_checkDeLoginResult);
connect(connectorToServer, &ConnectorToServer::sigLoginResult, this, &InstructorsAndTraineesWidget::slot_checkLoginResult);
connect(connectorToServer, &ConnectorToServer::sigDeLoginResult, this, &InstructorsAndTraineesWidget::slot_checkDeLoginResult);
messangerController = new MessangerController(connectorToServer, this);
@@ -49,12 +49,11 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
connect(viewerInstructors, &ViewerInstructors::signal_BlockAutorization, this, &InstructorsAndTraineesWidget::signal_BlockAutorization);
connect(viewerTrainees, &ViewerTrainees::signal_BlockAutorization, this, &InstructorsAndTraineesWidget::signal_BlockAutorization);
connect(connectorToServer,&ConnectorToServer::signal_ConnectedToServer,this,&InstructorsAndTraineesWidget::slot_ConnectedToServer);
connect(connectorToServer, &ConnectorToServer::signal_ConnectedToServer, this, &InstructorsAndTraineesWidget::slot_ConnectedToServer);
connect(viewerTrainees, &ViewerTrainees::signal_traineeSelected, this, &InstructorsAndTraineesWidget::slot_traineeSelected);
connect(viewerInstructors, &ViewerInstructors::signal_instructorSelected, this, &InstructorsAndTraineesWidget::slot_instructorSelected);
viewerTrainees->clearSelection();
viewerInstructors->clearSelection();
@@ -62,7 +61,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
ui->verticalLayout_Trainees->addWidget(viewerTrainees);
ui->verticalLayout_Instructors->addWidget(viewerInstructors);
ui->groupBox_Messenger->setMinimumHeight(500);
ui->groupBox_Messenger->setMinimumHeight(900);
ui->groupBox_Messenger->setMaximumWidth(500);
ui->groupBox_Messenger->setMinimumWidth(500);
@@ -94,6 +93,11 @@ InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
delete ui;
}
QString InstructorsAndTraineesWidget::getLanguage()
{
return language;
}
void InstructorsAndTraineesWidget::changeEvent(QEvent *event)
{
// В случае получения события изменения языка приложения
@@ -114,11 +118,6 @@ void InstructorsAndTraineesWidget::updateMyStyleSheet()
this->setStyleSheet(styleSheet);
}
QString InstructorsAndTraineesWidget::getLanguage()
{
return language;
}
QString InstructorsAndTraineesWidget::loadStyleSheet()
{
QString fileName = "./resources/css/styleSheetMain.css";
@@ -177,6 +176,7 @@ void InstructorsAndTraineesWidget::slot_checkLoginResult(ServerAuthorization *se
updateLabelLoggedInInstructor(serverAuth->Login, serverAuth->ClientName);
connectorToServer->setLoginName(nameInstructorLoggedInLocal);
messangerController->setGUIclientId(serverAuth->Id);
connectorToServer->sendQueryTasksXML("fim");
@@ -252,33 +252,33 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal);
updateLabelServer();
QMessageBox::warning(this, tr("Warning!"), tr("The server is disabled"));
QMessageBox::warning(this, tr("Warning!"), tr("The server is not available"));
}
}
void InstructorsAndTraineesWidget::slot_traineeSelected(QString login)
void InstructorsAndTraineesWidget::slot_traineeSelected(int id_trainee)
{
viewerInstructors->clearSelection();
/* Messanger*/
/*Messanger*/
messangerController->deleteWidget(messangerWidget);
if(login != "")
if(id_trainee)
{
Trainee trainee = connectorToServer->getTrainee(connectorToServer->getIdTraineeByLogin(login));
Trainee trainee = connectorToServer->getTrainee(id_trainee);
if(trainee.getID())
messangerWidget = messangerController->newWidget(this, &trainee, ui->verticalLayout_Messenger);
}
}
void InstructorsAndTraineesWidget::slot_instructorSelected(QString login)
void InstructorsAndTraineesWidget::slot_instructorSelected(int id_instructor)
{
viewerTrainees->clearSelection();
/* Messanger*/
/*Messanger*/
messangerController->deleteWidget(messangerWidget);
if(login != "" && login != loginInstructorLoggedInLocal)
if(id_instructor && id_instructor != idInstructorLoggedInLocal.toInt())
{
Instructor instructor = connectorToServer->getInstructor(connectorToServer->getIdInstructorByLogin(login));
Instructor instructor = connectorToServer->getInstructor(id_instructor);
if(instructor.getID())
messangerWidget = messangerController->newWidget(this, &instructor, ui->verticalLayout_Messenger);
}
@@ -407,13 +407,13 @@ void InstructorsAndTraineesWidget::setLanguageInterfase()
if(settings.Language == "ENG")
{
qtLanguageTranslator.load(QString("translations/InstructorsAndTraineesWidget_") + "en_EN", ".");
language = "en_EN";
qtLanguageTranslator.load(QString("translations/InstructorsAndTraineesWidget_") + languageENG, ".");
language = languageENG;
}
else
{
qtLanguageTranslator.load(QString("translations/InstructorsAndTraineesWidget_") + "ru_RU", ".");
language = "ru_RU";
qtLanguageTranslator.load(QString("translations/InstructorsAndTraineesWidget_") + languageRUS, ".");
language = languageRUS;
}
qApp->installTranslator(&qtLanguageTranslator);