SpecMsgBox в процессе исправления

This commit is contained in:
2025-11-28 21:01:33 +03:00
parent 8ad6d06f18
commit fb493aca9f
17 changed files with 169 additions and 60 deletions

View File

@@ -12,6 +12,9 @@ kanban-plugin: board
## Completed ## Completed
- [ ] При смене УЗ в ГУИ остается история переписки в мессенджере. При этом Имя инструктора в диалоге подменяется. (Путается только в ГУИ!)
[Возможно, поможет переинициализация мессенджера при переавторизации инструктора?]
- [ ] Отображать текущую версию data в статус баре
- [ ] Сделать крутилку на начальную загрузку Сервера - [ ] Сделать крутилку на начальную загрузку Сервера
- [ ] Логин суперпользователя PostgreSQL предлагать по умолчанию postgres - [ ] Логин суперпользователя PostgreSQL предлагать по умолчанию postgres
- [ ] Сделать несколько попыток подключения к серверу - [ ] Сделать несколько попыток подключения к серверу
@@ -64,15 +67,12 @@ kanban-plugin: board
## GUI Messenger ## GUI Messenger
- [ ] При смене УЗ в ГУИ остается история переписки в мессенджере. При этом Имя инструктора в диалоге подменяется. (Путается только в ГУИ!)
[Возможно, поможет переинициализация мессенджера при переавторизации инструктора?]
- [ ] Не влазиют слишком большие сообщения - [ ] Не влазиют слишком большие сообщения
- [ ] Не видно новых пришедших сообщений, если выбран другой Юзер - [ ] Не видно новых пришедших сообщений, если выбран другой Юзер
## GUI общие ## GUI общие
- [ ] Отображать текущую версию data в статус баре
- [ ] Текстовый поиск в задачах - [ ] Текстовый поиск в задачах

View File

@@ -413,7 +413,7 @@ void RecognizeSystem::recognize(QTcpSocket *socket)
QFile xmlInFile(xmlFileName); QFile xmlInFile(xmlFileName);
if (!xmlInFile.open(QFile::ReadOnly | QFile::Text)) if (!xmlInFile.open(QFile::ReadOnly | QFile::Text))
{ {
SpecialMessageBox(nullptr, SpecialMessageBox::TypeSpecMsgBox::critical, tr("The file could not be opened ") + xmlFileName).exec(); SpecMsgBox(nullptr, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("The file could not be opened ") + xmlFileName).exec();
return; return;
} }
else else

View File

@@ -6,7 +6,8 @@
EditorInstructors::EditorInstructors(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) : EditorInstructors::EditorInstructors(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) :
InstructorsView(connectorToServer, CommonView::TypeView::control, parent), InstructorsView(connectorToServer, CommonView::TypeView::control, parent),
ui(new Ui::EditorInstructors), ui(new Ui::EditorInstructors),
dlgEditInstructor(nullptr) dlgEditInstructor(nullptr),
specialMessageBox(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -41,6 +42,13 @@ EditorInstructors::~EditorInstructors()
dlgEditInstructor = nullptr; dlgEditInstructor = nullptr;
} }
if(specialMessageBox)
{
specialMessageBox->close();
delete specialMessageBox;
specialMessageBox = nullptr;
}
delete ui; delete ui;
} }
@@ -48,6 +56,9 @@ void EditorInstructors::closeEvent(QCloseEvent *event)
{ {
if(dlgEditInstructor) if(dlgEditInstructor)
dlgEditInstructor->close(); dlgEditInstructor->close();
if(specialMessageBox)
specialMessageBox->close();
} }
void EditorInstructors::on_btnNewInstructor_clicked() void EditorInstructors::on_btnNewInstructor_clicked()
@@ -82,21 +93,39 @@ void EditorInstructors::on_btnDeleteInstructor_clicked()
if(connectorToServer->isAdminInstructor(id)) if(connectorToServer->isAdminInstructor(id))
{//Это Админ! {//Это Админ!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot delete the Administrator.")).exec(); specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot delete the Administrator."));
specialMessageBox->exec();
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
return; return;
} }
if(connectorToServer->isLoggedInInstructor(id)) if(connectorToServer->isLoggedInInstructor(id))
{//Инструктор залогирован! {//Инструктор залогирован!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot delete a logged-in instructor.")).exec(); specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot delete a logged-in instructor."));
specialMessageBox->exec();
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
return; return;
} }
if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")).exec() == QDialog::Accepted) specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?"));
if(specialMessageBox->exec() == QDialog::Accepted)
{ {
waitAnimationWidget->showWithPlay(); waitAnimationWidget->showWithPlay();
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_INSTRUCTOR, id); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_INSTRUCTOR, id);
} }
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
} }
} }
} }
@@ -127,7 +156,13 @@ void EditorInstructors::on_btnToOrFromArchive_clicked()
{//Не Архивный {//Не Архивный
if(connectorToServer->isLoggedInInstructor(id)) if(connectorToServer->isLoggedInInstructor(id))
{//Инструктор залогирован! {//Инструктор залогирован!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot archive a logged-in instructor.")).exec(); specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot archive a logged-in instructor."));
specialMessageBox->exec();
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
return; return;
} }
@@ -164,7 +199,13 @@ void EditorInstructors::on_btnEdit_clicked()
if(connectorToServer->isLoggedInInstructor(id)) if(connectorToServer->isLoggedInInstructor(id))
{//Инструктор залогирован! {//Инструктор залогирован!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot edit a logged-in instructor.")).exec(); specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot edit a logged-in instructor."));
specialMessageBox->exec();
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
return; return;
} }
@@ -270,19 +311,37 @@ bool EditorInstructors::verifyInstructor(Instructor instructor)
if(instructor.getName() == QStringLiteral("<name>")) if(instructor.getName() == QStringLiteral("<name>"))
{//Имя не корректно! {//Имя не корректно!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted.")).exec(); specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted."));
specialMessageBox->exec();
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
return false; return false;
} }
if(instructor.getLogin() == QStringLiteral("<login>")) if(instructor.getLogin() == QStringLiteral("<login>"))
{//Логин не корректен! {//Логин не корректен!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable instructor login has been entered.\nThe changes will not be accepted.")).exec(); specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("Unacceptable instructor login has been entered.\nThe changes will not be accepted."));
specialMessageBox->exec();
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
return false; return false;
} }
if(instructor.getPassword() == QStringLiteral("<password>")) if(instructor.getPassword() == QStringLiteral("<password>"))
{//Пароль не корректный! {//Пароль не корректный!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable instructor password has been entered.\nThe changes will not be accepted.")).exec(); specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("Unacceptable instructor password has been entered.\nThe changes will not be accepted."));
specialMessageBox->exec();
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
return false; return false;
} }
@@ -291,7 +350,13 @@ bool EditorInstructors::verifyInstructor(Instructor instructor)
int user_T = connectorToServer->getIdTraineeByLogin(instructor.getLogin()); int user_T = connectorToServer->getIdTraineeByLogin(instructor.getLogin());
if((user_I && (user_I != instructor.getID())) || (user_T && (user_T != instructor.getID()))) if((user_I && (user_I != instructor.getID())) || (user_T && (user_T != instructor.getID())))
{//Логин уже существует! {//Логин уже существует!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")).exec(); specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted."));
specialMessageBox->exec();
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
return 0; return 0;
} }

View File

@@ -5,6 +5,7 @@
#include <QTreeWidget> #include <QTreeWidget>
#include "instructorsview.h" #include "instructorsview.h"
#include "dialogeditinstructor.h" #include "dialogeditinstructor.h"
#include "specialmessagebox.h"
class DialogEditInstructor; class DialogEditInstructor;
@@ -42,6 +43,7 @@ private:
Ui::EditorInstructors *ui; Ui::EditorInstructors *ui;
DialogEditInstructor* dlgEditInstructor; DialogEditInstructor* dlgEditInstructor;
SpecMsgBox* specialMessageBox;
}; };
#endif // DIALOGINSTRUCTORS_H #endif // DIALOGINSTRUCTORS_H

View File

@@ -179,7 +179,7 @@ QString InstructorsAndTraineesWidget::loadStyleSheet()
QFile styleSheetFile(fileName); QFile styleSheetFile(fileName);
if (!styleSheetFile.open(QFile::ReadOnly | QFile::Text)) if (!styleSheetFile.open(QFile::ReadOnly | QFile::Text))
{ {
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("The file could not be opened ") + fileName).exec(); SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("The file could not be opened ") + fileName).exec();
return QStringLiteral(""); return QStringLiteral("");
} }
else else
@@ -273,7 +273,7 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization
else else
{ {
ui->btnAuthorizationInstructor->setChecked(true); ui->btnAuthorizationInstructor->setChecked(true);
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Instructor deauthorization") + "\n" + tr("Error!")).exec(); SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("Instructor deauthorization") + "\n" + tr("Error!")).exec();
} }
} }
@@ -285,7 +285,7 @@ void InstructorsAndTraineesWidget::slot_ServerBlocked()
waitAnimationWidget->hideWithStop(); waitAnimationWidget->hideWithStop();
ui->btnAuthorizationInstructor->setChecked(false); ui->btnAuthorizationInstructor->setChecked(false);
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("Instructor authorization.") + "\n" + tr("Server blocked!")).exec(); SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, tr("Instructor authorization.") + "\n" + tr("Server blocked!")).exec();
} }
} }
@@ -317,7 +317,7 @@ void InstructorsAndTraineesWidget::slot_ErrorAuth(QString error)
errorTextMsg = tr("Login or password error!"); errorTextMsg = tr("Login or password error!");
} }
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("Instructor authorization.") + "\n" + errorTextMsg).exec(); SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, tr("Instructor authorization.") + "\n" + errorTextMsg).exec();
} }
} }
@@ -406,7 +406,7 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state)
if(!flSettingsServerIsChanged) if(!flSettingsServerIsChanged)
{ {
if(!flTryConnectToServer) if(!flTryConnectToServer)
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("The server is not available!")).exec(); SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, tr("The server is not available!")).exec();
} }
else else
flSettingsServerIsChanged = false; flSettingsServerIsChanged = false;
@@ -654,7 +654,7 @@ void InstructorsAndTraineesWidget::on_btnSettings_clicked()
if(dlgSettings->settingsServerIsChanged()) if(dlgSettings->settingsServerIsChanged())
{ {
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, tr("Server settings have been changed. Please reconnect to the server.")).exec(); SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, tr("Server settings have been changed. Please reconnect to the server.")).exec();
flSettingsServerIsChanged = true; flSettingsServerIsChanged = true;

View File

@@ -114,7 +114,7 @@ void DialogVersionControl::sendCopyEmit(QString newName)
if (selectedVersion == nullptr) if (selectedVersion == nullptr)
{ {
QString text = tr("Version not selected"); QString text = tr("Version not selected");
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec();
return; return;
} }
@@ -127,7 +127,7 @@ void DialogVersionControl::on_createDuplicateButton_clicked()
if (selectedVersion == nullptr) if (selectedVersion == nullptr)
{ {
QString text = tr("Version not selected"); QString text = tr("Version not selected");
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec();
return; return;
} }
@@ -160,7 +160,7 @@ void DialogVersionControl::on_deleteVersionButton_clicked()
if (selectedVersion == nullptr) if (selectedVersion == nullptr)
{ {
QString text = tr("Version not selected"); QString text = tr("Version not selected");
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec();
return; return;
} }
@@ -172,7 +172,7 @@ void DialogVersionControl::on_switchServerVersionButton_clicked()
if (selectedVersion == nullptr) if (selectedVersion == nullptr)
{ {
QString text = tr("Version not selected"); QString text = tr("Version not selected");
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec();
return; return;
} }

View File

@@ -13,7 +13,7 @@ NotifyController::NotifyController(QWidget *parentWidget, QObject *parent) :
void NotifyController::showWarning(QString text, QWidget *parentWidget) void NotifyController::showWarning(QString text, QWidget *parentWidget)
{ {
if(parentWidget) if(parentWidget)
SpecialMessageBox(parentWidget, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); SpecMsgBox(parentWidget, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec();
else else
SpecialMessageBox(this->parentWidget, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); SpecMsgBox(this->parentWidget, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec();
} }

View File

@@ -2,7 +2,7 @@
#include "specialmessagebox.h" #include "specialmessagebox.h"
#include "ui_specialmessagebox.h" #include "ui_specialmessagebox.h"
SpecialMessageBox::SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const QString& text) : SpecMsgBox::SpecMsgBox(QWidget *parent, TypeSpecMsgBox type, const QString& text) :
QDialog(parent), QDialog(parent),
ui(new Ui::SpecialMessageBox) ui(new Ui::SpecialMessageBox)
{ {
@@ -22,14 +22,14 @@ SpecialMessageBox::SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const
ui->btnNo->setVisible(false); ui->btnNo->setVisible(false);
ui->btnYes->setText(tr("Close")); ui->btnYes->setText(tr("Close"));
} }
else if(type == TypeSpecMsgBox::critical) else if(type == TypeSpecMsgBox::criticalClose)
{ {
ui->lbl_icon->setPixmap(QPixmap(QStringLiteral(":/resources/icons/critical.png"))); ui->lbl_icon->setPixmap(QPixmap(QStringLiteral(":/resources/icons/critical.png")));
this->setWindowTitle(tr("Error!")); this->setWindowTitle(tr("Error!"));
ui->btnNo->setVisible(false); ui->btnNo->setVisible(false);
ui->btnYes->setText(tr("Close")); ui->btnYes->setText(tr("Close"));
} }
else if(type == TypeSpecMsgBox::info) else if(type == TypeSpecMsgBox::infoOk)
{ {
ui->lbl_icon->setPixmap(QPixmap(QStringLiteral(":/resources/icons/info.png"))); ui->lbl_icon->setPixmap(QPixmap(QStringLiteral(":/resources/icons/info.png")));
this->setWindowTitle(tr("Information")); this->setWindowTitle(tr("Information"));
@@ -40,17 +40,43 @@ SpecialMessageBox::SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const
ui->lblText->setText(text); ui->lblText->setText(text);
} }
SpecialMessageBox::~SpecialMessageBox() SpecMsgBox::~SpecMsgBox()
{ {
delete ui; delete ui;
} }
void SpecialMessageBox::on_btnYes_clicked() int SpecMsgBox::WarningYesNo(SpecMsgBox *msgBox, QWidget *parent, const QString &text)
{
return SpecMsgBox::work(msgBox, parent, TypeSpecMsgBox::warningYesNo, text);
}
int SpecMsgBox::WarningClose(SpecMsgBox *msgBox, QWidget *parent, const QString &text)
{
return SpecMsgBox::work(msgBox, parent, TypeSpecMsgBox::warningClose, text);
}
int SpecMsgBox::CriticalClose(SpecMsgBox *msgBox, QWidget *parent, const QString &text)
{
return SpecMsgBox::work(msgBox, parent, TypeSpecMsgBox::criticalClose, text);
}
int SpecMsgBox::InfoOk(SpecMsgBox *msgBox, QWidget *parent, const QString &text)
{
return SpecMsgBox::work(msgBox, parent, TypeSpecMsgBox::infoOk, text);
}
int SpecMsgBox::work(SpecMsgBox *msgBox, QWidget *parent, TypeSpecMsgBox type, const QString& text)
{
msgBox = new SpecMsgBox(parent, type, text);
return msgBox->exec();
}
void SpecMsgBox::on_btnYes_clicked()
{ {
this->accept(); this->accept();
} }
void SpecialMessageBox::on_btnNo_clicked() void SpecMsgBox::on_btnNo_clicked()
{ {
this->reject(); this->reject();
} }

View File

@@ -7,7 +7,7 @@ namespace Ui {
class SpecialMessageBox; class SpecialMessageBox;
} }
class SpecialMessageBox : public QDialog class SpecMsgBox : public QDialog
{ {
Q_OBJECT Q_OBJECT
@@ -15,13 +15,22 @@ public:
enum TypeSpecMsgBox { enum TypeSpecMsgBox {
warningYesNo, warningYesNo,
warningClose, warningClose,
critical, criticalClose,
info infoOk
}; };
public: public:
explicit SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const QString& text); explicit SpecMsgBox(QWidget *parent, TypeSpecMsgBox type, const QString& text);
~SpecialMessageBox(); ~SpecMsgBox();
public:
static int WarningYesNo(SpecMsgBox* msgBox, QWidget *parent, const QString& text);
static int WarningClose(SpecMsgBox* msgBox, QWidget *parent, const QString& text);
static int CriticalClose(SpecMsgBox* msgBox, QWidget *parent, const QString& text);
static int InfoOk(SpecMsgBox* msgBox, QWidget *parent, const QString& text);
private:
static int work(SpecMsgBox* msgBox, QWidget *parent, TypeSpecMsgBox type, const QString& text);
private slots: private slots:
void on_btnYes_clicked(); void on_btnYes_clicked();

View File

@@ -329,7 +329,7 @@ void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode)
lastSelectedTask.listSubProc.clear(); lastSelectedTask.listSubProc.clear();
dlgListSubProc->getListCheckedSubProc(&lastSelectedTask.listSubProc); dlgListSubProc->getListCheckedSubProc(&lastSelectedTask.listSubProc);
specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?"));
if(specialMessageBox->exec() == QDialog::Accepted) if(specialMessageBox->exec() == QDialog::Accepted)
{ {
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_AMM_TO_TRAINEE, idTraineeSelected, &lastSelectedTask); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_AMM_TO_TRAINEE, idTraineeSelected, &lastSelectedTask);
@@ -357,7 +357,7 @@ void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode)
{ {
lastSelectedTask.listSubProc.clear(); lastSelectedTask.listSubProc.clear();
specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?"));
if(specialMessageBox->exec() == QDialog::Accepted) if(specialMessageBox->exec() == QDialog::Accepted)
{ {
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_AMM_TO_TRAINEE, idTraineeSelected, &lastSelectedTask); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_AMM_TO_TRAINEE, idTraineeSelected, &lastSelectedTask);
@@ -520,7 +520,7 @@ void AMMtasksWidget::on_btnDelete_clicked()
int id = treeItemCurrent->text(ColumnsTreeAMM::clmnAMM_ID).toInt(); int id = treeItemCurrent->text(ColumnsTreeAMM::clmnAMM_ID).toInt();
specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")); specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?"));
if(specialMessageBox->exec() == QDialog::Accepted) if(specialMessageBox->exec() == QDialog::Accepted)
{ {

View File

@@ -103,7 +103,7 @@ private:
DialogListSubProc* dlgListSubProc; DialogListSubProc* dlgListSubProc;
SpecialMessageBox* specialMessageBox; SpecMsgBox* specialMessageBox;
bool flOnlyActive; //AMM bool flOnlyActive; //AMM

View File

@@ -183,7 +183,7 @@ void CheckerTask::on_btnWrong_clicked()
msgString = tr("Change task status?\nThe status will be set:\n'new'"); msgString = tr("Change task status?\nThe status will be set:\n'new'");
} }
specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, msgString); specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, msgString);
if(specialMessageBox->exec() == QDialog::Accepted) if(specialMessageBox->exec() == QDialog::Accepted)
{ {
connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status); connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status);
@@ -216,7 +216,7 @@ void CheckerTask::on_btnRight_clicked()
msgString = tr("Change task status?\nThe status will be set:\n'completed'"); msgString = tr("Change task status?\nThe status will be set:\n'completed'");
} }
specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, msgString); specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, msgString);
if(specialMessageBox->exec() == QDialog::Accepted) if(specialMessageBox->exec() == QDialog::Accepted)
{ {
connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status); connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status);

View File

@@ -48,7 +48,7 @@ private:
ConnectorToServer* connectorToServer; ConnectorToServer* connectorToServer;
FIMtasksWidget* fimTasksWidget; FIMtasksWidget* fimTasksWidget;
SpecialMessageBox* specialMessageBox; SpecMsgBox* specialMessageBox;
bool flChanged; bool flChanged;
int id_task; int id_task;

View File

@@ -401,7 +401,7 @@ void FIMtasksWidget::on_btnDelete_clicked()
int id = treeItemCurrent->text(ColumnsTreeFIM::clmnFIM_ID).toInt(); int id = treeItemCurrent->text(ColumnsTreeFIM::clmnFIM_ID).toInt();
specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")); specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?"));
if(specialMessageBox->exec() == QDialog::Accepted) if(specialMessageBox->exec() == QDialog::Accepted)
{ {
waitAnimationWidget->showWithPlay(); waitAnimationWidget->showWithPlay();
@@ -451,7 +451,7 @@ void FIMtasksWidget::on_btnCheck_clicked()
void FIMtasksWidget::on_btnAssignTask_clicked() void FIMtasksWidget::on_btnAssignTask_clicked()
{ {
specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?"));
if(specialMessageBox->exec() == QDialog::Accepted) if(specialMessageBox->exec() == QDialog::Accepted)
assignTaskFIMtoTrainee(); assignTaskFIMtoTrainee();
if(specialMessageBox) if(specialMessageBox)

View File

@@ -92,7 +92,7 @@ private:
DialogChekerTask* dlgCheckerTask; DialogChekerTask* dlgCheckerTask;
SpecialMessageBox* specialMessageBox; SpecMsgBox* specialMessageBox;
QString userName; //FIM QString userName; //FIM

View File

@@ -9,7 +9,8 @@ EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminM
TraineesView(connectorToServer, CommonView::TypeView::control, parent), TraineesView(connectorToServer, CommonView::TypeView::control, parent),
ui(new Ui::EditorTrainees), ui(new Ui::EditorTrainees),
dlgEditTrainee(nullptr), dlgEditTrainee(nullptr),
dlgEditGroup(nullptr) dlgEditGroup(nullptr),
specialMessageBox(nullptr)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -54,6 +55,8 @@ EditorTrainees::~EditorTrainees()
dlgEditGroup = nullptr; dlgEditGroup = nullptr;
} }
//SpecMsgBox::CloseAndDelete(specialMessageBox);
delete ui; delete ui;
} }
@@ -64,6 +67,8 @@ void EditorTrainees::closeEvent(QCloseEvent *event)
if(dlgEditGroup) if(dlgEditGroup)
dlgEditGroup->close(); dlgEditGroup->close();
//SpecMsgBox::CloseAndDelete(specialMessageBox);
} }
void EditorTrainees::on_btnNewGroup_clicked() void EditorTrainees::on_btnNewGroup_clicked()
@@ -93,12 +98,12 @@ void EditorTrainees::on_btnDeleteGroup_clicked()
if(connectorToServer->getListTraineesInGroup(id_group).count() > 0) if(connectorToServer->getListTraineesInGroup(id_group).count() > 0)
{ {
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("The group is not empty.\nIt is not possible to delete a non-empty group.")).exec(); SpecMsgBox::CriticalClose(specialMessageBox, this, tr("The group is not empty.\nIt is not possible to delete a non-empty group."));
return; return;
} }
else else
{//Пустая группа {//Пустая группа
if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")).exec() == QDialog::Accepted) if(SpecMsgBox::WarningYesNo(specialMessageBox, this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted)
{ {
waitAnimationWidget->showWithPlay(); waitAnimationWidget->showWithPlay();
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_GROUP, id_group); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_GROUP, id_group);
@@ -149,11 +154,11 @@ void EditorTrainees::on_btnDeleteTrainee_clicked()
if(connectorToServer->isLoggedInTrainee(id_trainee)) if(connectorToServer->isLoggedInTrainee(id_trainee))
{//Обучаемый залогирован! {//Обучаемый залогирован!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot delete a logged-in trainee.")).exec(); SpecMsgBox::CriticalClose(specialMessageBox, this, tr("You cannot delete a logged-in trainee."));
return; return;
} }
if(SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")).exec() == QDialog::Accepted) if(SpecMsgBox::WarningYesNo(specialMessageBox, this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted)
{ {
waitAnimationWidget->showWithPlay(); waitAnimationWidget->showWithPlay();
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TRAINEE, id_trainee); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TRAINEE, id_trainee);
@@ -188,7 +193,7 @@ void EditorTrainees::on_btnToOrFromArchiveTrainee_clicked()
{//Не Архивный {//Не Архивный
if(connectorToServer->isLoggedInTrainee(id_trainee)) if(connectorToServer->isLoggedInTrainee(id_trainee))
{//Обучаемый залогирован! {//Обучаемый залогирован!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot archive a logged-in trainee.")).exec(); SpecMsgBox::CriticalClose(specialMessageBox, this, tr("You cannot archive a logged-in trainee."));
return; return;
} }
@@ -234,7 +239,7 @@ void EditorTrainees::on_btnEdit_clicked()
if(connectorToServer->isLoggedInTrainee(id_trainee)) if(connectorToServer->isLoggedInTrainee(id_trainee))
{//Обучаемый залогирован! {//Обучаемый залогирован!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("You cannot edit a logged-in trainee.")).exec(); SpecMsgBox::CriticalClose(specialMessageBox, this, tr("You cannot edit a logged-in trainee."));
return; return;
} }
@@ -403,7 +408,7 @@ bool EditorTrainees::verifyGroup(Group group)
if(group.getName() == QStringLiteral("<group>")) if(group.getName() == QStringLiteral("<group>"))
{//Имя не корректно! {//Имя не корректно!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable group name has been entered.\nThe changes will not be accepted.")).exec(); SpecMsgBox::CriticalClose(specialMessageBox, this, tr("Unacceptable group name has been entered.\nThe changes will not be accepted."));
return false; return false;
} }
@@ -413,7 +418,7 @@ bool EditorTrainees::verifyGroup(Group group)
{ {
if(group.getName() == exist_group.getName() && group.getID() != exist_group.getID()) if(group.getName() == exist_group.getName() && group.getID() != exist_group.getID())
{//Имя уже существует {//Имя уже существует
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("An existing group name has been entered.\nThe changes will not be accepted.")).exec(); SpecMsgBox::CriticalClose(specialMessageBox, this, tr("An existing group name has been entered.\nThe changes will not be accepted."));
return false; return false;
} }
} }
@@ -427,19 +432,19 @@ bool EditorTrainees::verifyTrainee(Trainee trainee)
if(trainee.getName() == QStringLiteral("<name>")) if(trainee.getName() == QStringLiteral("<name>"))
{//Имя не корректно! {//Имя не корректно!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted.")).exec(); SpecMsgBox::CriticalClose(specialMessageBox, this, tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted."));
return false; return false;
} }
if(trainee.getLogin() == QStringLiteral("<login>")) if(trainee.getLogin() == QStringLiteral("<login>"))
{//Логин не корректен! {//Логин не корректен!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted.")).exec(); SpecMsgBox::CriticalClose(specialMessageBox, this, tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted."));
return false; return false;
} }
if(trainee.getPassword() == QStringLiteral("<password>")) if(trainee.getPassword() == QStringLiteral("<password>"))
{//Пароль не корректный! {//Пароль не корректный!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted.")).exec(); SpecMsgBox::CriticalClose(specialMessageBox, this, tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted."));
return false; return false;
} }
@@ -448,7 +453,7 @@ bool EditorTrainees::verifyTrainee(Trainee trainee)
int user_T = connectorToServer->getIdTraineeByLogin(trainee.getLogin()); int user_T = connectorToServer->getIdTraineeByLogin(trainee.getLogin());
if((user_I && (user_I != trainee.getID())) || (user_T && (user_T != trainee.getID()))) if((user_I && (user_I != trainee.getID())) || (user_T && (user_T != trainee.getID())))
{//Логин уже существует! {//Логин уже существует!
SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::critical, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")).exec(); SpecMsgBox::CriticalClose(specialMessageBox, this, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted."));
return 0; return 0;
} }

View File

@@ -7,6 +7,7 @@
//#include "computersLocations.h" //#include "computersLocations.h"
#include "dialogedittrainee.h" #include "dialogedittrainee.h"
#include "dialogeditgroup.h" #include "dialogeditgroup.h"
#include "specialmessagebox.h"
namespace Ui { namespace Ui {
class EditorTrainees; class EditorTrainees;
@@ -48,6 +49,7 @@ private:
DialogEditTrainee* dlgEditTrainee; DialogEditTrainee* dlgEditTrainee;
DialogEditGroup* dlgEditGroup; DialogEditGroup* dlgEditGroup;
SpecMsgBox* specialMessageBox;
}; };
#endif // DIALOGTRAINEESGROUPS_H #endif // DIALOGTRAINEESGROUPS_H