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:
@@ -22,7 +22,7 @@ DialogEditInstructor::DialogEditInstructor(bool adminMode, QWidget *parent) :
|
|||||||
ui->btnViewPassword->setObjectName("btnViewPassword");
|
ui->btnViewPassword->setObjectName("btnViewPassword");
|
||||||
ui->btnChangePassword->setObjectName("btnChangePassword");
|
ui->btnChangePassword->setObjectName("btnChangePassword");
|
||||||
|
|
||||||
ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this));
|
//ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this));
|
||||||
ui->editLogin->setValidator(new QRegExpValidator(QRegExp("[A-Za-z\\d]+"), this));
|
ui->editLogin->setValidator(new QRegExpValidator(QRegExp("[A-Za-z\\d]+"), this));
|
||||||
|
|
||||||
ui->editPassword->setEnabled(false);
|
ui->editPassword->setEnabled(false);
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ const QString InstructorsAndTraineesWidget::languageRUS = "ru_RU";
|
|||||||
|
|
||||||
InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
waitAnimationWidget(nullptr),
|
|
||||||
connectorToServer(nullptr),
|
connectorToServer(nullptr),
|
||||||
viewerTrainees(nullptr),
|
viewerTrainees(nullptr),
|
||||||
viewerInstructors(nullptr),
|
viewerInstructors(nullptr),
|
||||||
@@ -25,15 +24,12 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
|||||||
dlgTasksCommon(nullptr),
|
dlgTasksCommon(nullptr),
|
||||||
dlgSettings(nullptr),
|
dlgSettings(nullptr),
|
||||||
dlgAuthorization(nullptr),
|
dlgAuthorization(nullptr),
|
||||||
adminMode(false),
|
waitAnimationWidget(nullptr),
|
||||||
loginInstructorLoggedInLocal(QStringLiteral("")),
|
|
||||||
nameInstructorLoggedInLocal(QStringLiteral("")),
|
|
||||||
idInstructorLoggedInLocal("0"),
|
|
||||||
language(languageENG),
|
|
||||||
flSettingsServerIsChanged(false),
|
flSettingsServerIsChanged(false),
|
||||||
flTryConnectToServer(false),
|
flTryConnectToServer(false),
|
||||||
cntTryConnectToServer(0),
|
cntTryConnectToServer(0),
|
||||||
flTryLogin(false),
|
flTryLogin(false),
|
||||||
|
language(languageENG),
|
||||||
ui(new Ui::InstructorsAndTraineesWidget)
|
ui(new Ui::InstructorsAndTraineesWidget)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@@ -109,7 +105,7 @@ InstructorsAndTraineesWidget::InstructorsAndTraineesWidget(QWidget *parent) :
|
|||||||
InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
|
InstructorsAndTraineesWidget::~InstructorsAndTraineesWidget()
|
||||||
{
|
{
|
||||||
if(authorizationIsCompleted())
|
if(authorizationIsCompleted())
|
||||||
deAuthorizationInstructor(loginInstructorLoggedInLocal);
|
deAuthorizationInstructor(instructorLoggedInLocal.getLogin());
|
||||||
|
|
||||||
if(dlgTasksCommon)
|
if(dlgTasksCommon)
|
||||||
{
|
{
|
||||||
@@ -155,7 +151,7 @@ void InstructorsAndTraineesWidget::changeEvent(QEvent *event)
|
|||||||
{// переведём окно заново
|
{// переведём окно заново
|
||||||
ui->retranslateUi(this);
|
ui->retranslateUi(this);
|
||||||
|
|
||||||
updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal);
|
updateLabelLoggedInInstructor(instructorLoggedInLocal);
|
||||||
updateLabelServer();
|
updateLabelServer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,28 +206,28 @@ void InstructorsAndTraineesWidget::slot_checkLoginResult(ServerAuthorization *se
|
|||||||
{
|
{
|
||||||
if (serverAuth->Result)
|
if (serverAuth->Result)
|
||||||
{
|
{
|
||||||
loginInstructorLoggedInLocal = serverAuth->Login;
|
instructorLoggedInLocal.setLogin(serverAuth->Login);
|
||||||
nameInstructorLoggedInLocal = serverAuth->ClientName;
|
instructorLoggedInLocal.setName(serverAuth->ClientName);
|
||||||
idInstructorLoggedInLocal = serverAuth->Id;
|
instructorLoggedInLocal.setID(serverAuth->Id.toInt());
|
||||||
|
|
||||||
if(loginInstructorLoggedInLocal == QStringLiteral("admin"))
|
if(serverAuth->Login == QStringLiteral("admin"))
|
||||||
adminMode = true;
|
instructorLoggedInLocal.setIsAdmin(true);
|
||||||
else
|
else
|
||||||
adminMode = false;
|
instructorLoggedInLocal.setIsAdmin(false);
|
||||||
|
|
||||||
viewerInstructors->setAdminMode(adminMode);
|
viewerInstructors->setAdminMode(instructorLoggedInLocal.getIsAdmin());
|
||||||
viewerTrainees->setAdminMode(adminMode);
|
viewerTrainees->setAdminMode(instructorLoggedInLocal.getIsAdmin());
|
||||||
viewerInstructors->setAuthComplited(true);
|
viewerInstructors->setAuthComplited(true);
|
||||||
viewerTrainees->setAuthComplited(true);
|
viewerTrainees->setAuthComplited(true);
|
||||||
|
|
||||||
ui->btnEditorTrainees->setEnabled(true);
|
ui->btnEditorTrainees->setEnabled(true);
|
||||||
if(adminMode)
|
if(instructorLoggedInLocal.getIsAdmin())
|
||||||
ui->btnEditorInstructors->setEnabled(true);
|
ui->btnEditorInstructors->setEnabled(true);
|
||||||
|
|
||||||
emit signal_NeedUpdateUI(true, true);
|
emit signal_NeedUpdateUI(true, true);
|
||||||
|
|
||||||
updateLabelLoggedInInstructor(serverAuth->Login, serverAuth->ClientName);
|
updateLabelLoggedInInstructor(instructorLoggedInLocal);
|
||||||
connectorToServer->setLoginName(nameInstructorLoggedInLocal);
|
connectorToServer->setLoginName(instructorLoggedInLocal.getName());
|
||||||
|
|
||||||
messangerController->setUserLocalGUI_ID(serverAuth->Id.toInt());
|
messangerController->setUserLocalGUI_ID(serverAuth->Id.toInt());
|
||||||
|
|
||||||
@@ -256,12 +252,13 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization
|
|||||||
{
|
{
|
||||||
if (serverDeAuth->Result)
|
if (serverDeAuth->Result)
|
||||||
{
|
{
|
||||||
loginInstructorLoggedInLocal = QStringLiteral("");
|
instructorLoggedInLocal.setLogin(QStringLiteral(""));
|
||||||
nameInstructorLoggedInLocal = QStringLiteral("");
|
instructorLoggedInLocal.setName(QStringLiteral(""));
|
||||||
adminMode = false;
|
instructorLoggedInLocal.setIsAdmin(false);
|
||||||
|
instructorLoggedInLocal.setID(0);
|
||||||
|
|
||||||
viewerInstructors->setAdminMode(adminMode);
|
viewerInstructors->setAdminMode(instructorLoggedInLocal.getIsAdmin());
|
||||||
viewerTrainees->setAdminMode(adminMode);
|
viewerTrainees->setAdminMode(instructorLoggedInLocal.getIsAdmin());
|
||||||
viewerInstructors->setAuthComplited(false);
|
viewerInstructors->setAuthComplited(false);
|
||||||
viewerTrainees->setAuthComplited(false);
|
viewerTrainees->setAuthComplited(false);
|
||||||
|
|
||||||
@@ -269,7 +266,7 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization
|
|||||||
ui->btnEditorInstructors->setEnabled(false);
|
ui->btnEditorInstructors->setEnabled(false);
|
||||||
ui->btnPersonalCard->setEnabled(false);
|
ui->btnPersonalCard->setEnabled(false);
|
||||||
|
|
||||||
updateLabelLoggedInInstructor("","");
|
updateLabelLoggedInInstructor(instructorLoggedInLocal);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -337,7 +334,7 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
|
|||||||
|
|
||||||
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
ui->lblDBisConnected->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||||
|
|
||||||
updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal);
|
updateLabelLoggedInInstructor(instructorLoggedInLocal);
|
||||||
|
|
||||||
flTryConnectToServer = false;
|
flTryConnectToServer = false;
|
||||||
cntTryConnectToServer = 0;
|
cntTryConnectToServer = 0;
|
||||||
@@ -376,10 +373,12 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
|
|||||||
|
|
||||||
messangerController->deleteAllWidgets();
|
messangerController->deleteAllWidgets();
|
||||||
|
|
||||||
loginInstructorLoggedInLocal = "";
|
instructorLoggedInLocal.setLogin(QStringLiteral(""));
|
||||||
nameInstructorLoggedInLocal = "";
|
instructorLoggedInLocal.setName(QStringLiteral(""));
|
||||||
|
instructorLoggedInLocal.setIsAdmin(false);
|
||||||
|
instructorLoggedInLocal.setID(0);
|
||||||
|
|
||||||
updateLabelLoggedInInstructor(loginInstructorLoggedInLocal, nameInstructorLoggedInLocal);
|
updateLabelLoggedInInstructor(instructorLoggedInLocal);
|
||||||
|
|
||||||
|
|
||||||
if(flTryConnectToServer)
|
if(flTryConnectToServer)
|
||||||
@@ -447,7 +446,7 @@ void InstructorsAndTraineesWidget::slot_instructorSelected(int id_instructor)
|
|||||||
|
|
||||||
/*Messanger*/
|
/*Messanger*/
|
||||||
messangerController->deleteWidget(messangerWidget);
|
messangerController->deleteWidget(messangerWidget);
|
||||||
if(id_instructor && id_instructor != idInstructorLoggedInLocal.toInt())
|
if(id_instructor && id_instructor != instructorLoggedInLocal.getID())
|
||||||
{
|
{
|
||||||
Instructor instructor = connectorToServer->getInstructor(id_instructor);
|
Instructor instructor = connectorToServer->getInstructor(id_instructor);
|
||||||
if(instructor.getID())
|
if(instructor.getID())
|
||||||
@@ -523,7 +522,7 @@ bool InstructorsAndTraineesWidget::deAuthorizationInstructor(QString login)
|
|||||||
|
|
||||||
bool InstructorsAndTraineesWidget::authorizationIsCompleted()
|
bool InstructorsAndTraineesWidget::authorizationIsCompleted()
|
||||||
{
|
{
|
||||||
if(loginInstructorLoggedInLocal == QStringLiteral(""))
|
if(instructorLoggedInLocal.getLogin() == QStringLiteral(""))
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
@@ -562,7 +561,7 @@ void InstructorsAndTraineesWidget::on_btnAuthorizationInstructor_clicked()
|
|||||||
{//ДеАвторизация Инструктора локальная (Администратора)
|
{//ДеАвторизация Инструктора локальная (Администратора)
|
||||||
if(authorizationIsCompleted())
|
if(authorizationIsCompleted())
|
||||||
{
|
{
|
||||||
if(deAuthorizationInstructor(loginInstructorLoggedInLocal))
|
if(deAuthorizationInstructor(instructorLoggedInLocal.getLogin()))
|
||||||
{
|
{
|
||||||
disconnect(connectorToServer,&ConnectorToServer::signal_UpdateDB,viewerInstructors,&ViewerInstructors::slot_NeedUpdateUI);
|
disconnect(connectorToServer,&ConnectorToServer::signal_UpdateDB,viewerInstructors,&ViewerInstructors::slot_NeedUpdateUI);
|
||||||
disconnect(connectorToServer,&ConnectorToServer::signal_UpdateDB,viewerTrainees,&ViewerTrainees::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())
|
if(authorizationIsCompleted())
|
||||||
{
|
{
|
||||||
QString nameLoggedInInstructor = QString("%1 (%2)").arg(name, login);
|
QString nameLoggedInInstructor = QString("%1 (%2)").arg(instructor.getName(), instructor.getLogin());
|
||||||
ui->lblLoggedInInstructor->setText(nameLoggedInInstructor);
|
ui->lblLoggedInInstructor->setText(nameLoggedInInstructor);
|
||||||
if(loginInstructorLoggedInLocal == QStringLiteral("admin"))
|
if(instructor.getIsAdmin())
|
||||||
ui->lblLoggedIn->setPixmap(QPixmap(QStringLiteral(":/resources/icons/admin.png")));
|
ui->lblLoggedIn->setPixmap(QPixmap(QStringLiteral(":/resources/icons/admin.png")));
|
||||||
else
|
else
|
||||||
ui->lblLoggedIn->setPixmap(QPixmap(QStringLiteral(":/resources/icons/instructor.png")));
|
ui->lblLoggedIn->setPixmap(QPixmap(QStringLiteral(":/resources/icons/instructor.png")));
|
||||||
@@ -644,7 +643,7 @@ void InstructorsAndTraineesWidget::setLanguageInterfase()
|
|||||||
|
|
||||||
void InstructorsAndTraineesWidget::on_btnSettings_clicked()
|
void InstructorsAndTraineesWidget::on_btnSettings_clicked()
|
||||||
{
|
{
|
||||||
dlgSettings = new DialogSettings(connectorToServer, (loginInstructorLoggedInLocal != ""), this);
|
dlgSettings = new DialogSettings(connectorToServer, authorizationIsCompleted(), this);
|
||||||
dlgSettings->setWindowFlags(dlgSettings->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
dlgSettings->setWindowFlags(dlgSettings->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
|
|
||||||
connect(dlgSettings, &DialogSettings::signal_LanguageChanged, this, &InstructorsAndTraineesWidget::slot_LanguageChanged);
|
connect(dlgSettings, &DialogSettings::signal_LanguageChanged, this, &InstructorsAndTraineesWidget::slot_LanguageChanged);
|
||||||
@@ -663,7 +662,7 @@ void InstructorsAndTraineesWidget::on_btnSettings_clicked()
|
|||||||
flSettingsServerIsChanged = true;
|
flSettingsServerIsChanged = true;
|
||||||
|
|
||||||
if(authorizationIsCompleted())
|
if(authorizationIsCompleted())
|
||||||
deAuthorizationInstructor(loginInstructorLoggedInLocal);
|
deAuthorizationInstructor(instructorLoggedInLocal.getLogin());
|
||||||
|
|
||||||
connectorToServer->StopConnectToServer();
|
connectorToServer->StopConnectToServer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "dialogtaskscommon.h"
|
#include "dialogtaskscommon.h"
|
||||||
#include "dialogsettings.h"
|
#include "dialogsettings.h"
|
||||||
#include "dialogauthorization.h"
|
#include "dialogauthorization.h"
|
||||||
|
#include "instructor.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
@@ -86,13 +87,11 @@ private:
|
|||||||
bool authorizationInstructorDialog(QWidget* parent = nullptr);
|
bool authorizationInstructorDialog(QWidget* parent = nullptr);
|
||||||
bool deAuthorizationInstructor(QString login);
|
bool deAuthorizationInstructor(QString login);
|
||||||
bool authorizationIsCompleted();
|
bool authorizationIsCompleted();
|
||||||
void updateLabelLoggedInInstructor(QString login, QString name);
|
void updateLabelLoggedInInstructor(Instructor& instructor);
|
||||||
void updateLabelServer();
|
void updateLabelServer();
|
||||||
void setLanguageInterfase();
|
void setLanguageInterfase();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WaitAnimationWidget *waitAnimationWidget;
|
|
||||||
|
|
||||||
ConnectorToServer* connectorToServer;
|
ConnectorToServer* connectorToServer;
|
||||||
|
|
||||||
ViewerTrainees* viewerTrainees;
|
ViewerTrainees* viewerTrainees;
|
||||||
@@ -104,16 +103,10 @@ private:
|
|||||||
DialogSettings* dlgSettings;
|
DialogSettings* dlgSettings;
|
||||||
DialogAuthorization* dlgAuthorization;
|
DialogAuthorization* dlgAuthorization;
|
||||||
|
|
||||||
bool adminMode;
|
WaitAnimationWidget *waitAnimationWidget;
|
||||||
QString loginInstructorLoggedInLocal;
|
|
||||||
QString nameInstructorLoggedInLocal;
|
|
||||||
QString idInstructorLoggedInLocal;
|
|
||||||
|
|
||||||
Instructor instructorLoggedInLocal;
|
Instructor instructorLoggedInLocal;
|
||||||
|
|
||||||
QTranslator qtLanguageTranslator;
|
|
||||||
QString language;
|
|
||||||
|
|
||||||
bool flSettingsServerIsChanged;
|
bool flSettingsServerIsChanged;
|
||||||
|
|
||||||
bool flTryConnectToServer;
|
bool flTryConnectToServer;
|
||||||
@@ -121,6 +114,9 @@ private:
|
|||||||
|
|
||||||
bool flTryLogin;
|
bool flTryLogin;
|
||||||
|
|
||||||
|
QTranslator qtLanguageTranslator;
|
||||||
|
QString language;
|
||||||
|
|
||||||
Ui::InstructorsAndTraineesWidget *ui;
|
Ui::InstructorsAndTraineesWidget *ui;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ DialogEditGroup::DialogEditGroup(QWidget *parent) :
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
verify();
|
verify();
|
||||||
|
|
||||||
ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this));
|
//ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this));
|
||||||
|
|
||||||
ui->editName->setProperty("mandatoryField", true);
|
ui->editName->setProperty("mandatoryField", true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ DialogEditTrainee::DialogEditTrainee(bool adminMode, QWidget *parent) :
|
|||||||
ui->btnViewPassword->setObjectName("btnViewPassword");
|
ui->btnViewPassword->setObjectName("btnViewPassword");
|
||||||
ui->btnChangePassword->setObjectName("btnChangePassword");
|
ui->btnChangePassword->setObjectName("btnChangePassword");
|
||||||
|
|
||||||
ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this));
|
//ui->editName->setValidator(new QRegExpValidator(QRegExp("[A-Za-zА-Яа-я0-9 _\\d]+"), this));
|
||||||
ui->editLogin->setValidator(new QRegExpValidator(QRegExp("[A-Za-z\\d]+"), this));
|
ui->editLogin->setValidator(new QRegExpValidator(QRegExp("[A-Za-z\\d]+"), this));
|
||||||
|
|
||||||
ui->editPassword->setEnabled(false);
|
ui->editPassword->setEnabled(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user