SpecialMessageBox

This commit is contained in:
2025-09-15 18:20:39 +03:00
parent bffbd0fe81
commit 0e81d14566
19 changed files with 366 additions and 215 deletions

View File

@@ -3,6 +3,7 @@
#include "ui_editortrainees.h"
#include "dialogeditgroup.h"
#include "dialogedittrainee.h"
#include "specialmessagebox.h"
EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) :
TraineesView(connectorToServer, CommonView::TypeView::control, parent),
@@ -111,12 +112,12 @@ void EditorTrainees::on_btnDeleteGroup_clicked()
if(connectorToServer->getListTraineesInGroup(id_group).count() > 0)
{
QMessageBox::critical(this, tr("Editing error!"), tr("The group is not empty.\nIt is not possible to delete a non-empty group."));
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("The group is not empty.\nIt is not possible to delete a non-empty group.")).exec();
return;
}
else
{//Пустая группа
if(QMessageBox::warning(this, tr("Attention!"), tr("The deletion will be irrevocable.\nDelete anyway?"), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warning, tr("The deletion will be irrevocable.\nDelete it anyway?")).exec() == QDialog::Accepted)
{
waitAnimationWidget->showWithPlay();
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_GROUP, id_group);
@@ -216,11 +217,11 @@ void EditorTrainees::on_btnDeleteTrainee_clicked()
if(connectorToServer->isLoggedInTrainee(id_trainee))
{//Обучаемый залогирован!
QMessageBox::critical(this, tr("Error!"), tr("You cannot delete a logged-in trainee."));
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot delete a logged-in trainee.")).exec();
return;
}
if(QMessageBox::warning(this, tr("Attention!"), tr("The deletion will be irrevocable.\nDelete anyway?"), QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok)
if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warning, tr("The deletion will be irrevocable.\nDelete it anyway?")).exec() == QDialog::Accepted)
{
waitAnimationWidget->showWithPlay();
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TRAINEE, id_trainee);
@@ -255,7 +256,7 @@ void EditorTrainees::on_btnToOrFromArchiveTrainee_clicked()
{//Не Архивный
if(connectorToServer->isLoggedInTrainee(id_trainee))
{//Обучаемый залогирован!
QMessageBox::critical(this, tr("Error!"), tr("You cannot archive a logged-in trainee."));
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot archive a logged-in trainee.")).exec();
return;
}
@@ -301,7 +302,7 @@ void EditorTrainees::on_btnEdit_clicked()
if(connectorToServer->isLoggedInTrainee(id_trainee))
{//Обучаемый залогирован!
QMessageBox::critical(this, tr("Error!"), tr("You cannot edit a logged-in trainee."));
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot edit a logged-in trainee.")).exec();
return;
}
@@ -431,8 +432,7 @@ bool EditorTrainees::verifyGroup(Group group)
if(group.getName() == QStringLiteral("<group>"))
{//Имя не корректно!
QMessageBox::critical(this, tr("Editing error!"),
tr("Unacceptable group name has been entered.\nThe changes will not be accepted."));
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable group name has been entered.\nThe changes will not be accepted.")).exec();
return false;
}
@@ -442,8 +442,7 @@ bool EditorTrainees::verifyGroup(Group group)
{
if(group.getName() == exist_group.getName() && group.getID() != exist_group.getID())
{//Имя уже существует
QMessageBox::critical(this, tr("Editing error!"),
tr("An existing group name has been entered.\nThe changes will not be accepted."));
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("An existing group name has been entered.\nThe changes will not be accepted.")).exec();
return false;
}
}
@@ -457,22 +456,19 @@ bool EditorTrainees::verifyTrainee(Trainee trainee)
if(trainee.getName() == QStringLiteral("<name>"))
{//Имя не корректно!
QMessageBox::critical(this, tr("Editing error!"),
tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted."));
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted.")).exec();
return false;
}
if(trainee.getLogin() == QStringLiteral("<login>"))
{//Логин не корректен!
QMessageBox::critical(this, tr("Editing error!"),
tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted."));
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted.")).exec();
return false;
}
if(trainee.getPassword() == QStringLiteral("<password>"))
{//Пароль не корректный!
QMessageBox::critical(this, tr("Editing error!"),
tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted."));
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted.")).exec();
return false;
}
@@ -481,8 +477,7 @@ bool EditorTrainees::verifyTrainee(Trainee trainee)
int user_T = connectorToServer->getIdTraineeByLogin(trainee.getLogin());
if((user_I && (user_I != trainee.getID())) || (user_T && (user_T != trainee.getID())))
{//Логин уже существует!
QMessageBox::critical(this, tr("Editing error!"),
tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted."));
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")).exec();
return 0;
}