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:
@@ -7,7 +7,9 @@
|
||||
|
||||
EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) :
|
||||
TraineesView(connectorToServer, CommonView::TypeView::control, parent),
|
||||
ui(new Ui::EditorTrainees)
|
||||
ui(new Ui::EditorTrainees),
|
||||
dlgEditTrainee(nullptr),
|
||||
dlgEditGroup(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
@@ -38,12 +40,30 @@ EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminM
|
||||
|
||||
EditorTrainees::~EditorTrainees()
|
||||
{
|
||||
if(dlgEditTrainee)
|
||||
{
|
||||
dlgEditTrainee->close();
|
||||
delete dlgEditTrainee;
|
||||
dlgEditTrainee = nullptr;
|
||||
}
|
||||
|
||||
if(dlgEditGroup)
|
||||
{
|
||||
dlgEditGroup->close();
|
||||
delete dlgEditGroup;
|
||||
dlgEditGroup = nullptr;
|
||||
}
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void EditorTrainees::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
if(dlgEditTrainee)
|
||||
dlgEditTrainee->close();
|
||||
|
||||
if(dlgEditGroup)
|
||||
dlgEditGroup->close();
|
||||
}
|
||||
|
||||
void EditorTrainees::on_btnNewGroup_clicked()
|
||||
@@ -437,53 +457,73 @@ bool EditorTrainees::verifyTrainee(Trainee trainee)
|
||||
|
||||
bool EditorTrainees::editGroup(Group group, Group *group_edit)
|
||||
{
|
||||
DialogEditGroup dlg(this);
|
||||
dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
dlgEditGroup = new DialogEditGroup(this);
|
||||
dlgEditGroup->setWindowFlags(dlgEditGroup->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
dlg.setGroup(group);
|
||||
dlgEditGroup->setGroup(group);
|
||||
|
||||
while (true)
|
||||
bool flStop = false;
|
||||
bool res = false;
|
||||
|
||||
while (!flStop)
|
||||
{
|
||||
switch( dlg.exec() )
|
||||
switch( dlgEditGroup->exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
*group_edit = dlg.getGroup();
|
||||
*group_edit = dlgEditGroup->getGroup();
|
||||
|
||||
if(! verifyGroup(*group_edit))
|
||||
{
|
||||
dlg.setGroup(*group_edit);
|
||||
dlgEditGroup->setGroup(*group_edit);
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
flStop = true;
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
return false;
|
||||
flStop = true;
|
||||
res = false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
flStop = true;
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(dlgEditGroup)
|
||||
{
|
||||
delete dlgEditGroup;
|
||||
dlgEditGroup = nullptr;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool EditorTrainees::editTrainee(Trainee trainee, Trainee *trainee_edit)
|
||||
{
|
||||
DialogEditTrainee dlg(adminMode, this);
|
||||
dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
dlgEditTrainee = new DialogEditTrainee(adminMode, this);
|
||||
dlgEditTrainee->setWindowFlags(dlgEditTrainee->windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
dlg.setTrainee(trainee);
|
||||
dlgEditTrainee->setTrainee(trainee);
|
||||
|
||||
while (true)
|
||||
bool flStop = false;
|
||||
bool res = false;
|
||||
|
||||
while (!flStop)
|
||||
{
|
||||
switch( dlg.exec() )
|
||||
switch( dlgEditTrainee->exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
*trainee_edit = dlg.getTrainee();
|
||||
*trainee_edit = dlgEditTrainee->getTrainee();
|
||||
|
||||
if(! verifyTrainee(*trainee_edit))
|
||||
{
|
||||
dlg.setTrainee(*trainee_edit);
|
||||
dlgEditTrainee->setTrainee(*trainee_edit);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -494,14 +534,28 @@ bool EditorTrainees::editTrainee(Trainee trainee, Trainee *trainee_edit)
|
||||
trainee_edit->setNeedSetPassword(false);
|
||||
}
|
||||
|
||||
return true;
|
||||
flStop = true;
|
||||
res = true;
|
||||
break;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
return false;
|
||||
flStop = true;
|
||||
res = false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
flStop = true;
|
||||
res = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(dlgEditTrainee)
|
||||
{
|
||||
delete dlgEditTrainee;
|
||||
dlgEditTrainee = nullptr;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user