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

@@ -3,7 +3,7 @@
#include <QDialog>
#include "instructor.h"
#include "ui_dialogeditinstructor.h"
//#include "ui_dialogeditinstructor.h"
namespace Ui {
class DialogEditInstructor;

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;
}

View File

@@ -4,6 +4,9 @@
#include <QDialog>
#include <QTreeWidget>
#include "instructorsview.h"
#include "dialogeditinstructor.h"
class DialogEditInstructor;
namespace Ui {
class EditorInstructors;
@@ -35,8 +38,10 @@ private:
bool editInstructor(Instructor instructor, Instructor* instructor_edit);
private:
private:
Ui::EditorInstructors *ui;
DialogEditInstructor* dlgEditInstructor;
};
#endif // DIALOGINSTRUCTORS_H

View File

@@ -51,7 +51,7 @@
<string>New instructor</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/addInstructor.png</normaloff>:/resources/icons/addInstructor.png</iconset>
</property>
<property name="iconSize">
@@ -89,7 +89,7 @@
<string>Delete instructor</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/deleteInstructor.png</normaloff>:/resources/icons/deleteInstructor.png</iconset>
</property>
<property name="iconSize">
@@ -127,7 +127,7 @@
<string>To archive</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/instructorArchive.png</normaloff>:/resources/icons/instructorArchive.png</iconset>
</property>
<property name="iconSize">
@@ -165,7 +165,7 @@
<string>Edit</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/edit.png</normaloff>:/resources/icons/edit.png</iconset>
</property>
<property name="iconSize">
@@ -216,7 +216,7 @@
<string>Show archive</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/archive.png</normaloff>:/resources/icons/archive.png</iconset>
</property>
<property name="iconSize">
@@ -240,7 +240,7 @@
</layout>
</widget>
<resources>
<include location="../resources.qrc"/>
<include location="../InstructorsAndTrainees.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -25,7 +25,11 @@ ViewerInstructors::ViewerInstructors(ConnectorToServer* connectorToServer, QWidg
ViewerInstructors::~ViewerInstructors()
{
if(dlgRedactor)
{
dlgRedactor->close();
delete dlgRedactor;
dlgRedactor = nullptr;
}
delete ui;
}
@@ -38,7 +42,11 @@ void ViewerInstructors::setAuthComplited(bool authComplited)
void ViewerInstructors::deactivate()
{
if(dlgRedactor)
{
dlgRedactor->close();
delete dlgRedactor;
dlgRedactor = nullptr;
}
CommonView::deactivate();
updateButtons();

View File

@@ -44,7 +44,7 @@
<string>Editor of Instructors</string>
</property>
<property name="icon">
<iconset resource="../resources.qrc">
<iconset resource="../InstructorsAndTrainees.qrc">
<normaloff>:/resources/icons/DB-instructors.png</normaloff>:/resources/icons/DB-instructors.png</iconset>
</property>
<property name="iconSize">
@@ -67,7 +67,7 @@
</layout>
</widget>
<resources>
<include location="../resources.qrc"/>
<include location="../InstructorsAndTrainees.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -1,7 +1,8 @@
#include "dialogeditgroup.h"
#include "computersLocations.h"
#include <QPushButton>
#include <QRegExpValidator>
#include "dialogeditgroup.h"
#include "computersLocations.h"
#include "ui_dialogeditgroup.h"
DialogEditGroup::DialogEditGroup(QWidget *parent) :
QDialog(parent),

View File

@@ -2,7 +2,7 @@
#define DIALOGEDITGROUP_H
#include <QDialog>
#include "ui_dialogeditgroup.h"
//#include "ui_dialogeditgroup.h"
#include "computersLocations.h"
#include "group.h"

View File

@@ -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;
}

View File

@@ -5,6 +5,8 @@
#include <QTreeWidget>
#include "traineesview.h"
//#include "computersLocations.h"
#include "dialogedittrainee.h"
#include "dialogeditgroup.h"
namespace Ui {
class EditorTrainees;
@@ -43,6 +45,9 @@ private:
private:
Ui::EditorTrainees *ui;
DialogEditTrainee* dlgEditTrainee;
DialogEditGroup* dlgEditGroup;
};
#endif // DIALOGTRAINEESGROUPS_H

View File

@@ -49,7 +49,11 @@ ViewerTrainees::~ViewerTrainees()
}
if(dlgRedactor)
{
dlgRedactor->close();
delete dlgRedactor;
dlgRedactor = nullptr;
}
if(dlgCardTrainee)
dlgCardTrainee->close();
@@ -66,7 +70,11 @@ void ViewerTrainees::setAuthComplited(bool authComplited)
void ViewerTrainees::deactivate()
{
if(dlgRedactor)
{
dlgRedactor->close();
delete dlgRedactor;
dlgRedactor = nullptr;
}
if(dlgCardTrainee)
dlgCardTrainee->close();

View File

@@ -971,7 +971,17 @@ Delete it anyway?</source>
<translation>Сервер: </translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.ui" line="424"/>
<location filename="../instructorsandtraineeswidget.ui" line="386"/>
<source>Version of materials: </source>
<translation>Версия материалов: </translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.ui" line="393"/>
<source>...</source>
<translation></translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.ui" line="448"/>
<source> Instructor: </source>
<translation> Инструктор: </translation>
</message>
@@ -991,85 +1001,85 @@ Delete it anyway?</source>
<translation>Инструкторы</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.ui" line="369"/>
<location filename="../instructorsandtraineeswidget.ui" line="443"/>
<location filename="../instructorsandtraineeswidget.cpp" line="587"/>
<location filename="../instructorsandtraineeswidget.ui" line="375"/>
<location filename="../instructorsandtraineeswidget.ui" line="467"/>
<location filename="../instructorsandtraineeswidget.cpp" line="594"/>
<source>none</source>
<translation>нет</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="181"/>
<location filename="../instructorsandtraineeswidget.cpp" line="182"/>
<source>The file could not be opened </source>
<translation>Файл не может быть открыт </translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="287"/>
<location filename="../instructorsandtraineeswidget.cpp" line="319"/>
<location filename="../instructorsandtraineeswidget.cpp" line="288"/>
<location filename="../instructorsandtraineeswidget.cpp" line="320"/>
<source>Instructor authorization.</source>
<translation>Авторизация инструктора.</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="275"/>
<location filename="../instructorsandtraineeswidget.cpp" line="276"/>
<source>Instructor deauthorization</source>
<translation>Деавторизация инструктора</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="275"/>
<location filename="../instructorsandtraineeswidget.cpp" line="276"/>
<source>Error!</source>
<translation>Ошибка!</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="287"/>
<location filename="../instructorsandtraineeswidget.cpp" line="288"/>
<source>Server blocked!</source>
<translation>Сервер заблокирован!</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="304"/>
<location filename="../instructorsandtraineeswidget.cpp" line="305"/>
<source>Database error!</source>
<translation>Ошибка базы данных!</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="308"/>
<location filename="../instructorsandtraineeswidget.cpp" line="309"/>
<source>The user is archived!</source>
<translation>Пользователь является архивным!</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="312"/>
<location filename="../instructorsandtraineeswidget.cpp" line="313"/>
<source>The user is already logged in!</source>
<translation>Пользователь уже в сети!</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="316"/>
<location filename="../instructorsandtraineeswidget.cpp" line="317"/>
<source>Login or password error!</source>
<translation>Ошибка логина или пароля!</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="402"/>
<location filename="../instructorsandtraineeswidget.cpp" line="409"/>
<source>The server is not available!</source>
<translation>Сервер недоступен!</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="599"/>
<location filename="../instructorsandtraineeswidget.cpp" line="606"/>
<source>Connection attempt</source>
<translation>Попытка соединения</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="606"/>
<location filename="../instructorsandtraineeswidget.cpp" line="613"/>
<source>connected</source>
<translation>подключен</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="609"/>
<location filename="../instructorsandtraineeswidget.cpp" line="616"/>
<source>not connected</source>
<translation>не подключен</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="650"/>
<location filename="../instructorsandtraineeswidget.cpp" line="657"/>
<source>Server settings have been changed. Please reconnect to the server.</source>
<translation>Настройки сервера изменены. Выполните переподключение к серверу.</translation>
</message>
<message>
<location filename="../instructorsandtraineeswidget.cpp" line="462"/>
<location filename="../instructorsandtraineeswidget.cpp" line="469"/>
<source>Instructor authorization</source>
<translation>Авторизация инструктора</translation>
</message>