This commit is contained in:
2025-11-28 11:28:39 +03:00
parent c61066cfd1
commit 612fcc8aa7
23 changed files with 351 additions and 193 deletions

View File

@@ -1,12 +1,12 @@
#include <QMessageBox>
#include "editorinstructors.h"
#include "dialogeditinstructor.h"
#include "specialmessagebox.h"
#include "ui_editorinstructors.h"
EditorInstructors::EditorInstructors(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) :
InstructorsView(connectorToServer, CommonView::TypeView::control, parent),
ui(new Ui::EditorInstructors)
ui(new Ui::EditorInstructors),
dlgEditInstructor(nullptr)
{
ui->setupUi(this);
@@ -34,12 +34,20 @@ EditorInstructors::EditorInstructors(ConnectorToServer* connectorToServer, bool
EditorInstructors::~EditorInstructors()
{
if(dlgEditInstructor)
{
dlgEditInstructor->close();
delete dlgEditInstructor;
dlgEditInstructor = nullptr;
}
delete ui;
}
void EditorInstructors::closeEvent(QCloseEvent *event)
{
if(dlgEditInstructor)
dlgEditInstructor->close();
}
void EditorInstructors::on_btnNewInstructor_clicked()
@@ -292,22 +300,25 @@ bool EditorInstructors::verifyInstructor(Instructor instructor)
bool EditorInstructors::editInstructor(Instructor instructor, Instructor* instructor_edit)
{
DialogEditInstructor dlg(adminMode, this);
dlg.setWindowFlags(dlg.windowFlags() & ~Qt::WindowContextHelpButtonHint);
dlgEditInstructor = new DialogEditInstructor(adminMode, this);
dlgEditInstructor->setWindowFlags(dlgEditInstructor->windowFlags() & ~Qt::WindowContextHelpButtonHint);
dlg.setInstructor(instructor);
dlgEditInstructor->setInstructor(instructor);
while (true)
bool flStop = false;
bool res = false;
while (!flStop)
{
switch( dlg.exec() )
switch( dlgEditInstructor->exec() )
{
case QDialog::Accepted:
{
*instructor_edit = dlg.getInstructor();
*instructor_edit = dlgEditInstructor->getInstructor();
if(! verifyInstructor(*instructor_edit))
{
dlg.setInstructor(*instructor_edit);
dlgEditInstructor->setInstructor(*instructor_edit);
continue;
}
@@ -318,14 +329,28 @@ bool EditorInstructors::editInstructor(Instructor instructor, Instructor* instru
instructor_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(dlgEditInstructor)
{
delete dlgEditInstructor;
dlgEditInstructor = nullptr;
}
return res;
}