diff --git a/DOCS/Андрей/Board.md b/DOCS/Андрей/Board.md index dbf485e..2a0faaf 100644 --- a/DOCS/Андрей/Board.md +++ b/DOCS/Андрей/Board.md @@ -12,6 +12,9 @@ kanban-plugin: board ## Completed +- [ ] При смене УЗ в ГУИ остается история переписки в мессенджере. При этом Имя инструктора в диалоге подменяется. (Путается только в ГУИ!) + [Возможно, поможет переинициализация мессенджера при переавторизации инструктора?] +- [ ] Отображать текущую версию data в статус баре - [ ] Сделать крутилку на начальную загрузку Сервера - [ ] Логин суперпользователя PostgreSQL предлагать по умолчанию postgres - [ ] Сделать несколько попыток подключения к серверу @@ -64,15 +67,12 @@ kanban-plugin: board ## GUI Messenger -- [ ] При смене УЗ в ГУИ остается история переписки в мессенджере. При этом Имя инструктора в диалоге подменяется. (Путается только в ГУИ!) - [Возможно, поможет переинициализация мессенджера при переавторизации инструктора?] - [ ] Не влазиют слишком большие сообщения - [ ] Не видно новых пришедших сообщений, если выбран другой Юзер ## GUI общие -- [ ] Отображать текущую версию data в статус баре - [ ] Текстовый поиск в задачах diff --git a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp index 8705ca1..043eb80 100644 --- a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp +++ b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp @@ -413,7 +413,7 @@ void RecognizeSystem::recognize(QTcpSocket *socket) QFile xmlInFile(xmlFileName); 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; } else diff --git a/InstructorsAndTrainees/instructors/editorinstructors.cpp b/InstructorsAndTrainees/instructors/editorinstructors.cpp index 8f0a7d4..0811638 100644 --- a/InstructorsAndTrainees/instructors/editorinstructors.cpp +++ b/InstructorsAndTrainees/instructors/editorinstructors.cpp @@ -6,7 +6,8 @@ EditorInstructors::EditorInstructors(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) : InstructorsView(connectorToServer, CommonView::TypeView::control, parent), ui(new Ui::EditorInstructors), - dlgEditInstructor(nullptr) + dlgEditInstructor(nullptr), + specialMessageBox(nullptr) { ui->setupUi(this); @@ -41,6 +42,13 @@ EditorInstructors::~EditorInstructors() dlgEditInstructor = nullptr; } + if(specialMessageBox) + { + specialMessageBox->close(); + delete specialMessageBox; + specialMessageBox = nullptr; + } + delete ui; } @@ -48,6 +56,9 @@ void EditorInstructors::closeEvent(QCloseEvent *event) { if(dlgEditInstructor) dlgEditInstructor->close(); + + if(specialMessageBox) + specialMessageBox->close(); } void EditorInstructors::on_btnNewInstructor_clicked() @@ -82,21 +93,39 @@ void EditorInstructors::on_btnDeleteInstructor_clicked() 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; } 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; } - 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(); 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)) {//Инструктор залогирован! - 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; } @@ -164,7 +199,13 @@ void EditorInstructors::on_btnEdit_clicked() 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; } @@ -270,19 +311,37 @@ bool EditorInstructors::verifyInstructor(Instructor instructor) if(instructor.getName() == QStringLiteral("")) {//Имя не корректно! - 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; } if(instructor.getLogin() == QStringLiteral("")) {//Логин не корректен! - 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; } if(instructor.getPassword() == QStringLiteral("")) {//Пароль не корректный! - 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; } @@ -291,7 +350,13 @@ bool EditorInstructors::verifyInstructor(Instructor instructor) int user_T = connectorToServer->getIdTraineeByLogin(instructor.getLogin()); 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; } diff --git a/InstructorsAndTrainees/instructors/editorinstructors.h b/InstructorsAndTrainees/instructors/editorinstructors.h index 02e9e14..9c3bfb0 100644 --- a/InstructorsAndTrainees/instructors/editorinstructors.h +++ b/InstructorsAndTrainees/instructors/editorinstructors.h @@ -5,6 +5,7 @@ #include #include "instructorsview.h" #include "dialogeditinstructor.h" +#include "specialmessagebox.h" class DialogEditInstructor; @@ -42,6 +43,7 @@ private: Ui::EditorInstructors *ui; DialogEditInstructor* dlgEditInstructor; + SpecMsgBox* specialMessageBox; }; #endif // DIALOGINSTRUCTORS_H diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp index ecd32f6..42b93cd 100644 --- a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp +++ b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp @@ -179,7 +179,7 @@ QString InstructorsAndTraineesWidget::loadStyleSheet() QFile styleSheetFile(fileName); 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(""); } else @@ -273,7 +273,7 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization else { 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(); 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!"); } - 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(!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 flSettingsServerIsChanged = false; @@ -654,7 +654,7 @@ void InstructorsAndTraineesWidget::on_btnSettings_clicked() 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; diff --git a/InstructorsAndTrainees/settings/dialogversioncontrol.cpp b/InstructorsAndTrainees/settings/dialogversioncontrol.cpp index c881502..a83e629 100644 --- a/InstructorsAndTrainees/settings/dialogversioncontrol.cpp +++ b/InstructorsAndTrainees/settings/dialogversioncontrol.cpp @@ -114,7 +114,7 @@ void DialogVersionControl::sendCopyEmit(QString newName) if (selectedVersion == nullptr) { QString text = tr("Version not selected"); - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); return; } @@ -127,7 +127,7 @@ void DialogVersionControl::on_createDuplicateButton_clicked() if (selectedVersion == nullptr) { QString text = tr("Version not selected"); - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); return; } @@ -160,7 +160,7 @@ void DialogVersionControl::on_deleteVersionButton_clicked() if (selectedVersion == nullptr) { QString text = tr("Version not selected"); - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); return; } @@ -172,7 +172,7 @@ void DialogVersionControl::on_switchServerVersionButton_clicked() if (selectedVersion == nullptr) { QString text = tr("Version not selected"); - SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); return; } diff --git a/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp b/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp index 659ae1c..0064b26 100644 --- a/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp +++ b/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp @@ -13,7 +13,7 @@ NotifyController::NotifyController(QWidget *parentWidget, QObject *parent) : void NotifyController::showWarning(QString text, QWidget *parentWidget) { if(parentWidget) - SpecialMessageBox(parentWidget, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox(parentWidget, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); else - SpecialMessageBox(this->parentWidget, SpecialMessageBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox(this->parentWidget, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); } diff --git a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp index 11ff87b..1ce64dd 100644 --- a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp +++ b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp @@ -2,7 +2,7 @@ #include "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), ui(new Ui::SpecialMessageBox) { @@ -22,14 +22,14 @@ SpecialMessageBox::SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const ui->btnNo->setVisible(false); 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"))); this->setWindowTitle(tr("Error!")); ui->btnNo->setVisible(false); 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"))); this->setWindowTitle(tr("Information")); @@ -40,17 +40,43 @@ SpecialMessageBox::SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const ui->lblText->setText(text); } -SpecialMessageBox::~SpecialMessageBox() +SpecMsgBox::~SpecMsgBox() { 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(); } -void SpecialMessageBox::on_btnNo_clicked() +void SpecMsgBox::on_btnNo_clicked() { this->reject(); } diff --git a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h index 4bbc082..c431a54 100644 --- a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h +++ b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h @@ -7,7 +7,7 @@ namespace Ui { class SpecialMessageBox; } -class SpecialMessageBox : public QDialog +class SpecMsgBox : public QDialog { Q_OBJECT @@ -15,13 +15,22 @@ public: enum TypeSpecMsgBox { warningYesNo, warningClose, - critical, - info + criticalClose, + infoOk }; public: - explicit SpecialMessageBox(QWidget *parent, TypeSpecMsgBox type, const QString& text); - ~SpecialMessageBox(); + explicit SpecMsgBox(QWidget *parent, TypeSpecMsgBox type, const QString& text); + ~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: void on_btnYes_clicked(); diff --git a/InstructorsAndTrainees/tasks/ammtaskswidget.cpp b/InstructorsAndTrainees/tasks/ammtaskswidget.cpp index 4dcee7c..013d784 100644 --- a/InstructorsAndTrainees/tasks/ammtaskswidget.cpp +++ b/InstructorsAndTrainees/tasks/ammtaskswidget.cpp @@ -329,7 +329,7 @@ void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode) lastSelectedTask.listSubProc.clear(); 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) { 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(); - 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) { 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(); - 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) { diff --git a/InstructorsAndTrainees/tasks/ammtaskswidget.h b/InstructorsAndTrainees/tasks/ammtaskswidget.h index b85ed5e..d89ed72 100644 --- a/InstructorsAndTrainees/tasks/ammtaskswidget.h +++ b/InstructorsAndTrainees/tasks/ammtaskswidget.h @@ -103,7 +103,7 @@ private: DialogListSubProc* dlgListSubProc; - SpecialMessageBox* specialMessageBox; + SpecMsgBox* specialMessageBox; bool flOnlyActive; //AMM diff --git a/InstructorsAndTrainees/tasks/checkertask.cpp b/InstructorsAndTrainees/tasks/checkertask.cpp index 77e44f8..668d89b 100644 --- a/InstructorsAndTrainees/tasks/checkertask.cpp +++ b/InstructorsAndTrainees/tasks/checkertask.cpp @@ -183,7 +183,7 @@ void CheckerTask::on_btnWrong_clicked() 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) { 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'"); } - specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, msgString); + specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, msgString); if(specialMessageBox->exec() == QDialog::Accepted) { connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status); diff --git a/InstructorsAndTrainees/tasks/checkertask.h b/InstructorsAndTrainees/tasks/checkertask.h index 5468af1..cbd76ad 100644 --- a/InstructorsAndTrainees/tasks/checkertask.h +++ b/InstructorsAndTrainees/tasks/checkertask.h @@ -48,7 +48,7 @@ private: ConnectorToServer* connectorToServer; FIMtasksWidget* fimTasksWidget; - SpecialMessageBox* specialMessageBox; + SpecMsgBox* specialMessageBox; bool flChanged; int id_task; diff --git a/InstructorsAndTrainees/tasks/fimtaskswidget.cpp b/InstructorsAndTrainees/tasks/fimtaskswidget.cpp index 733967e..57104b6 100644 --- a/InstructorsAndTrainees/tasks/fimtaskswidget.cpp +++ b/InstructorsAndTrainees/tasks/fimtaskswidget.cpp @@ -401,7 +401,7 @@ void FIMtasksWidget::on_btnDelete_clicked() 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) { waitAnimationWidget->showWithPlay(); @@ -451,7 +451,7 @@ void FIMtasksWidget::on_btnCheck_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) assignTaskFIMtoTrainee(); if(specialMessageBox) diff --git a/InstructorsAndTrainees/tasks/fimtaskswidget.h b/InstructorsAndTrainees/tasks/fimtaskswidget.h index 15347c2..c820eb3 100644 --- a/InstructorsAndTrainees/tasks/fimtaskswidget.h +++ b/InstructorsAndTrainees/tasks/fimtaskswidget.h @@ -92,7 +92,7 @@ private: DialogChekerTask* dlgCheckerTask; - SpecialMessageBox* specialMessageBox; + SpecMsgBox* specialMessageBox; QString userName; //FIM diff --git a/InstructorsAndTrainees/trainees/editortrainees.cpp b/InstructorsAndTrainees/trainees/editortrainees.cpp index a04829a..8efc54b 100644 --- a/InstructorsAndTrainees/trainees/editortrainees.cpp +++ b/InstructorsAndTrainees/trainees/editortrainees.cpp @@ -9,7 +9,8 @@ EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminM TraineesView(connectorToServer, CommonView::TypeView::control, parent), ui(new Ui::EditorTrainees), dlgEditTrainee(nullptr), - dlgEditGroup(nullptr) + dlgEditGroup(nullptr), + specialMessageBox(nullptr) { ui->setupUi(this); @@ -54,6 +55,8 @@ EditorTrainees::~EditorTrainees() dlgEditGroup = nullptr; } + //SpecMsgBox::CloseAndDelete(specialMessageBox); + delete ui; } @@ -64,6 +67,8 @@ void EditorTrainees::closeEvent(QCloseEvent *event) if(dlgEditGroup) dlgEditGroup->close(); + + //SpecMsgBox::CloseAndDelete(specialMessageBox); } void EditorTrainees::on_btnNewGroup_clicked() @@ -93,12 +98,12 @@ void EditorTrainees::on_btnDeleteGroup_clicked() 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; } 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(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_GROUP, id_group); @@ -149,11 +154,11 @@ void EditorTrainees::on_btnDeleteTrainee_clicked() 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; } - 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(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TRAINEE, id_trainee); @@ -188,7 +193,7 @@ void EditorTrainees::on_btnToOrFromArchiveTrainee_clicked() {//Не Архивный 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; } @@ -234,7 +239,7 @@ void EditorTrainees::on_btnEdit_clicked() 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; } @@ -403,7 +408,7 @@ bool EditorTrainees::verifyGroup(Group group) if(group.getName() == QStringLiteral("")) {//Имя не корректно! - 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; } @@ -413,7 +418,7 @@ bool EditorTrainees::verifyGroup(Group group) { 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; } } @@ -427,19 +432,19 @@ bool EditorTrainees::verifyTrainee(Trainee trainee) if(trainee.getName() == QStringLiteral("")) {//Имя не корректно! - 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; } if(trainee.getLogin() == QStringLiteral("")) {//Логин не корректен! - 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; } if(trainee.getPassword() == QStringLiteral("")) {//Пароль не корректный! - 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; } @@ -448,7 +453,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()))) {//Логин уже существует! - 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; } diff --git a/InstructorsAndTrainees/trainees/editortrainees.h b/InstructorsAndTrainees/trainees/editortrainees.h index ad4a22b..5255fb6 100644 --- a/InstructorsAndTrainees/trainees/editortrainees.h +++ b/InstructorsAndTrainees/trainees/editortrainees.h @@ -7,6 +7,7 @@ //#include "computersLocations.h" #include "dialogedittrainee.h" #include "dialogeditgroup.h" +#include "specialmessagebox.h" namespace Ui { class EditorTrainees; @@ -48,6 +49,7 @@ private: DialogEditTrainee* dlgEditTrainee; DialogEditGroup* dlgEditGroup; + SpecMsgBox* specialMessageBox; }; #endif // DIALOGTRAINEESGROUPS_H