mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
refact
This commit is contained in:
@@ -15,8 +15,7 @@ const QString InstructorsAndTraineesWidget::languageRUS = "ru_RU";
|
||||
|
||||
|
||||
InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
waitAnimationWidget(nullptr),
|
||||
QWidget(parent),
|
||||
connectorToServer(nullptr),
|
||||
viewerTrainees(nullptr),
|
||||
viewerInstructors(nullptr),
|
||||
@@ -25,15 +24,12 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
dlgTasksCommon(nullptr),
|
||||
dlgSettings(nullptr),
|
||||
dlgAuthorization(nullptr),
|
||||
adminMode(false),
|
||||
loginInstructorLoggedInLocal(QStringLiteral("")),
|
||||
nameInstructorLoggedInLocal(QStringLiteral("")),
|
||||
idInstructorLoggedInLocal("0"),
|
||||
language(languageENG),
|
||||
waitAnimationWidget(nullptr),
|
||||
flSettingsServerIsChanged(false),
|
||||
flTryConnectToServer(false),
|
||||
cntTryConnectToServer(0),
|
||||
flTryLogin(false),
|
||||
language(languageENG),
|
||||
ui(new Ui::InstructorsAndTraineesWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -109,7 +105,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||
InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
|
||||
{
|
||||
if(authorizationIsCompleted())
|
||||
deAuthorizationInstructor(loginInstructorLoggedInLocal);
|
||||
deAuthorizationInstructor(instructorLoggedInLocal.getLogin());
|
||||
|
||||
if(dlgTasksCommon)
|
||||
{
|
||||
@@ -155,7 +151,7 @@ void InstructorsAndTraineesWidget::changeEvent(QEvent *event)
|
||||
{// переведём окно заново
|
||||
ui->retranslateUi(this);
|
||||
|
||||
updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal);
|
||||
updateLabelLoggedInInstructor(instructorLoggedInLocal);
|
||||
updateLabelServer();
|
||||
}
|
||||
}
|
||||
@@ -210,28 +206,28 @@ void InstructorsAndTraineesWidget::slot_checkLoginResult(ServerAuthorization *se
|
||||
{
|
||||
if (serverAuth->Result)
|
||||
{
|
||||
loginInstructorLoggedInLocal = serverAuth->Login;
|
||||
nameInstructorLoggedInLocal = serverAuth->ClientName;
|
||||
idInstructorLoggedInLocal = serverAuth->Id;
|
||||
instructorLoggedInLocal.setLogin(serverAuth->Login);
|
||||
instructorLoggedInLocal.setName(serverAuth->ClientName);
|
||||
instructorLoggedInLocal.setID(serverAuth->Id.toInt());
|
||||
|
||||
if(loginInstructorLoggedInLocal == QStringLiteral("admin"))
|
||||
adminMode = true;
|
||||
if(serverAuth->Login == QStringLiteral("admin"))
|
||||
instructorLoggedInLocal.setIsAdmin(true);
|
||||
else
|
||||
adminMode = false;
|
||||
instructorLoggedInLocal.setIsAdmin(false);
|
||||
|
||||
viewerInstructors->setAdminMode(adminMode);
|
||||
viewerTrainees->setAdminMode(adminMode);
|
||||
viewerInstructors->setAdminMode(instructorLoggedInLocal.getIsAdmin());
|
||||
viewerTrainees->setAdminMode(instructorLoggedInLocal.getIsAdmin());
|
||||
viewerInstructors->setAuthComplited(true);
|
||||
viewerTrainees->setAuthComplited(true);
|
||||
|
||||
ui->btnEditorTrainees->setEnabled(true);
|
||||
if(adminMode)
|
||||
if(instructorLoggedInLocal.getIsAdmin())
|
||||
ui->btnEditorInstructors->setEnabled(true);
|
||||
|
||||
emit signal_NeedUpdateUI(true, true);
|
||||
|
||||
updateLabelLoggedInInstructor(serverAuth->Login, serverAuth->ClientName);
|
||||
connectorToServer->setLoginName(nameInstructorLoggedInLocal);
|
||||
updateLabelLoggedInInstructor(instructorLoggedInLocal);
|
||||
connectorToServer->setLoginName(instructorLoggedInLocal.getName());
|
||||
|
||||
messangerController->setUserLocalGUI_ID(serverAuth->Id.toInt());
|
||||
|
||||
@@ -256,12 +252,13 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization
|
||||
{
|
||||
if (serverDeAuth->Result)
|
||||
{
|
||||
loginInstructorLoggedInLocal = QStringLiteral("");
|
||||
nameInstructorLoggedInLocal = QStringLiteral("");
|
||||
adminMode = false;
|
||||
instructorLoggedInLocal.setLogin(QStringLiteral(""));
|
||||
instructorLoggedInLocal.setName(QStringLiteral(""));
|
||||
instructorLoggedInLocal.setIsAdmin(false);
|
||||
instructorLoggedInLocal.setID(0);
|
||||
|
||||
viewerInstructors->setAdminMode(adminMode);
|
||||
viewerTrainees->setAdminMode(adminMode);
|
||||
viewerInstructors->setAdminMode(instructorLoggedInLocal.getIsAdmin());
|
||||
viewerTrainees->setAdminMode(instructorLoggedInLocal.getIsAdmin());
|
||||
viewerInstructors->setAuthComplited(false);
|
||||
viewerTrainees->setAuthComplited(false);
|
||||
|
||||
@@ -269,7 +266,7 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization
|
||||
ui->btnEditorInstructors->setEnabled(false);
|
||||
ui->btnPersonalCard->setEnabled(false);
|
||||
|
||||
updateLabelLoggedInInstructor("","");
|
||||
updateLabelLoggedInInstructor(instructorLoggedInLocal);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -337,7 +334,7 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
|
||||
|
||||
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
|
||||
updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal);
|
||||
updateLabelLoggedInInstructor(instructorLoggedInLocal);
|
||||
|
||||
flTryConnectToServer = false;
|
||||
cntTryConnectToServer = 0;
|
||||
@@ -376,10 +373,12 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
|
||||
|
||||
messangerController->deleteAllWidgets();
|
||||
|
||||
loginInstructorLoggedInLocal = "";
|
||||
nameInstructorLoggedInLocal = "";
|
||||
instructorLoggedInLocal.setLogin(QStringLiteral(""));
|
||||
instructorLoggedInLocal.setName(QStringLiteral(""));
|
||||
instructorLoggedInLocal.setIsAdmin(false);
|
||||
instructorLoggedInLocal.setID(0);
|
||||
|
||||
updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal);
|
||||
updateLabelLoggedInInstructor(instructorLoggedInLocal);
|
||||
|
||||
|
||||
if(flTryConnectToServer)
|
||||
@@ -447,7 +446,7 @@ void InstructorsAndTraineesWidget::slot_instructorSelected(int id_instructor)
|
||||
|
||||
/*Messanger*/
|
||||
messangerController->deleteWidget(messangerWidget);
|
||||
if(id_instructor && id_instructor != idInstructorLoggedInLocal.toInt())
|
||||
if(id_instructor && id_instructor != instructorLoggedInLocal.getID())
|
||||
{
|
||||
Instructor instructor = connectorToServer->getInstructor(id_instructor);
|
||||
if(instructor.getID())
|
||||
@@ -523,7 +522,7 @@ bool InstructorsAndTraineesWidget::deAuthorizationInstructor(QString login)
|
||||
|
||||
bool InstructorsAndTraineesWidget::authorizationIsCompleted()
|
||||
{
|
||||
if(loginInstructorLoggedInLocal == QStringLiteral(""))
|
||||
if(instructorLoggedInLocal.getLogin() == QStringLiteral(""))
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
@@ -562,7 +561,7 @@ void InstructorsAndTraineesWidget::on_btnAuthorizationInstructor_clicked()
|
||||
{//ДеАвторизация Инструктора локальная (Администратора)
|
||||
if(authorizationIsCompleted())
|
||||
{
|
||||
if(deAuthorizationInstructor(loginInstructorLoggedInLocal))
|
||||
if(deAuthorizationInstructor(instructorLoggedInLocal.getLogin()))
|
||||
{
|
||||
disconnect(connectorToServer,&ConnectorToServer::signal_UpdateDB,viewerInstructors,&ViewerInstructors::slot_NeedUpdateUI);
|
||||
disconnect(connectorToServer,&ConnectorToServer::signal_UpdateDB,viewerTrainees,&ViewerTrainees::slot_NeedUpdateUI);
|
||||
@@ -582,13 +581,13 @@ void InstructorsAndTraineesWidget::on_btnAuthorizationInstructor_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
void InstructorsAndTraineesWidget::updateLabelLoggedInInstructor(QString login, QString name)
|
||||
void InstructorsAndTraineesWidget::updateLabelLoggedInInstructor(Instructor& instructor)
|
||||
{
|
||||
if(authorizationIsCompleted())
|
||||
{
|
||||
QString nameLoggedInInstructor = QString("%1 (%2)").arg(name, login);
|
||||
QString nameLoggedInInstructor = QString("%1 (%2)").arg(instructor.getName(), instructor.getLogin());
|
||||
ui->lblLoggedInInstructor->setText(nameLoggedInInstructor);
|
||||
if(loginInstructorLoggedInLocal == QStringLiteral("admin"))
|
||||
if(instructor.getIsAdmin())
|
||||
ui->lblLoggedIn->setPixmap(QPixmap(QStringLiteral(":/resources/icons/admin.png")));
|
||||
else
|
||||
ui->lblLoggedIn->setPixmap(QPixmap(QStringLiteral(":/resources/icons/instructor.png")));
|
||||
@@ -644,7 +643,7 @@ void InstructorsAndTraineesWidget::setLanguageInterfase()
|
||||
|
||||
void InstructorsAndTraineesWidget::on_btnSettings_clicked()
|
||||
{
|
||||
dlgSettings = new DialogSettings(connectorToServer, (loginInstructorLoggedInLocal != ""), this);
|
||||
dlgSettings = new DialogSettings(connectorToServer, authorizationIsCompleted(), this);
|
||||
dlgSettings->setWindowFlags(dlgSettings->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
connect(dlgSettings, &DialogSettings::signal_LanguageChanged, this, &InstructorsAndTraineesWidget::slot_LanguageChanged);
|
||||
@@ -663,7 +662,7 @@ void InstructorsAndTraineesWidget::on_btnSettings_clicked()
|
||||
flSettingsServerIsChanged = true;
|
||||
|
||||
if(authorizationIsCompleted())
|
||||
deAuthorizationInstructor(loginInstructorLoggedInLocal);
|
||||
deAuthorizationInstructor(instructorLoggedInLocal.getLogin());
|
||||
|
||||
connectorToServer->StopConnectToServer();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user