From d129fbded0fd57c3e4d929161fae1fcd0a305e93 Mon Sep 17 00:00:00 2001 From: krivoshein Date: Sun, 30 Nov 2025 19:28:08 +0300 Subject: [PATCH] =?UTF-8?q?notifyController=20=D1=83=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/recognizesystem.cpp | 8 +- .../connectorToServer/Core/recognizesystem.h | 2 +- .../connectorToServer/connectortoserver.cpp | 11 +-- .../connectorToServer/connectortoserver.h | 5 +- .../instructors/editorinstructors.cpp | 85 +++---------------- .../instructors/editorinstructors.h | 1 - .../instructorsandtraineeswidget.cpp | 12 +-- .../settings/dialogversioncontrol.cpp | 14 ++- .../settings/dialogversioncontrol.h | 1 + .../specialmessagebox/notifycontroller.cpp | 4 +- .../specialmessagebox/specialmessagebox.cpp | 20 ++--- .../specialmessagebox/specialmessagebox.h | 13 +-- .../tasks/ammtaskswidget.cpp | 28 +----- InstructorsAndTrainees/tasks/ammtaskswidget.h | 2 - InstructorsAndTrainees/tasks/checkertask.cpp | 25 +----- InstructorsAndTrainees/tasks/checkertask.h | 2 - .../tasks/fimtaskswidget.cpp | 21 +---- InstructorsAndTrainees/tasks/fimtaskswidget.h | 2 - .../trainees/editortrainees.cpp | 31 +++---- .../trainees/editortrainees.h | 1 - 20 files changed, 82 insertions(+), 206 deletions(-) diff --git a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp index 043eb80..ea1e1cd 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)) { - SpecMsgBox(nullptr, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("The file could not be opened ") + xmlFileName).exec(); + SpecMsgBox::CriticalClose(nullptr, tr("The file could not be opened ") + xmlFileName); return; } else @@ -490,17 +490,17 @@ void RecognizeSystem::xmlParser(QByteArray array) if (value == "BASEDELETETRY") { - emit sigNotify(tr("You cannot delete the basic version!")); + emit sigNotifyVersionControl(tr("You cannot delete the basic version!")); } if (value == "TRYACTIVEDELETE") { - emit sigNotify(tr("You cannot delete the active version")); + emit sigNotifyVersionControl(tr("You cannot delete the active version")); } if (value == "DUPLICATEVERNAME") { - emit sigNotify(tr("This name already exists")); + emit sigNotifyVersionControl(tr("This name already exists")); } } } diff --git a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.h b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.h index f679249..d731718 100644 --- a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.h +++ b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.h @@ -56,7 +56,7 @@ signals: void sigAnswerQueryTasksXML_AMM(QByteArray array); void sigShowServerDataList(QList *versions); void sigSetVersion(StreamingVersionData* serverVersion); - void sigNotify(QString text, QWidget *parentWidget = nullptr); + void sigNotifyVersionControl(QString text); void sigAnimationActivated(bool flag); void sigHashReady(); void sigAnswerQuerySubProc(QList listSubProc, QString parentTask_dmCode); diff --git a/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp b/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp index 839809e..0dbae16 100644 --- a/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp +++ b/InstructorsAndTrainees/connectorToServer/connectortoserver.cpp @@ -9,7 +9,6 @@ ConnectorToServer::ConnectorToServer(QWidget* parentWidget, QObject *parent) : dataParser(nullptr), sendSystem(nullptr), recognizeSystem(nullptr), - notifyController(nullptr), fl_GetedOfflineMessages(false), nameInstructorLoggedInLocal("") { @@ -19,7 +18,6 @@ ConnectorToServer::ConnectorToServer(QWidget* parentWidget, QObject *parent) : ConnectorToServer::~ConnectorToServer() { delete client; - delete notifyController; delete recognizeSystem; delete sendSystem; delete dataParser; @@ -115,6 +113,11 @@ void ConnectorToServer::slot_getVersion() emit signal_SendGetVersion(); } +void ConnectorToServer::slot_NotifyVersionControl(QString text) +{ + emit signal_NotifyVersionControl(text); +} + void ConnectorToServer::initialize() { createObjects(); @@ -159,7 +162,7 @@ void ConnectorToServer::bindConnection() connect(client,&TCPClient::signal_ConnectedToServer,this,&ConnectorToServer::signal_ConnectedToServer,Qt::AutoConnection); - connect(recognizeSystem,&RecognizeSystem::sigNotify,notifyController,&NotifyController::showWarning,Qt::AutoConnection); + connect(recognizeSystem,&RecognizeSystem::sigNotifyVersionControl,this,&ConnectorToServer::slot_NotifyVersionControl,Qt::AutoConnection); connect(recognizeSystem,&RecognizeSystem::sigHashReady,this,&ConnectorToServer::slot_HashReady); @@ -190,8 +193,6 @@ void ConnectorToServer::createObjects() recognizeSystem = new RecognizeSystem; recognizeSystem->moveToThread(connectionThread); - notifyController = new NotifyController(parentWidget); - connectionThread->start(); connectionThread->setPriority(QThread::HighestPriority); } diff --git a/InstructorsAndTrainees/connectorToServer/connectortoserver.h b/InstructorsAndTrainees/connectorToServer/connectortoserver.h index be5d2db..9e07b7e 100644 --- a/InstructorsAndTrainees/connectorToServer/connectortoserver.h +++ b/InstructorsAndTrainees/connectorToServer/connectortoserver.h @@ -116,6 +116,8 @@ public slots: void slot_getVersion(); + void slot_NotifyVersionControl(QString text); + signals: void sigSetConnect(ServerSettings* serverSettings,QThread *thread); void sigStopConnect(); @@ -157,6 +159,8 @@ signals: void signal_showServerList(QList *serverList); void signal_SendGetVersion(); + void signal_NotifyVersionControl(QString text); + private: void initialize(); void bindConnection(); @@ -169,7 +173,6 @@ private: DataParser *dataParser; SendSystem *sendSystem; RecognizeSystem *recognizeSystem; - NotifyController *notifyController; //Списочная модель БД СУО QMutex mtxAccess; diff --git a/InstructorsAndTrainees/instructors/editorinstructors.cpp b/InstructorsAndTrainees/instructors/editorinstructors.cpp index 0811638..223358a 100644 --- a/InstructorsAndTrainees/instructors/editorinstructors.cpp +++ b/InstructorsAndTrainees/instructors/editorinstructors.cpp @@ -6,8 +6,7 @@ EditorInstructors::EditorInstructors(ConnectorToServer* connectorToServer, bool adminMode, QWidget *parent) : InstructorsView(connectorToServer, CommonView::TypeView::control, parent), ui(new Ui::EditorInstructors), - dlgEditInstructor(nullptr), - specialMessageBox(nullptr) + dlgEditInstructor(nullptr) { ui->setupUi(this); @@ -42,13 +41,6 @@ EditorInstructors::~EditorInstructors() dlgEditInstructor = nullptr; } - if(specialMessageBox) - { - specialMessageBox->close(); - delete specialMessageBox; - specialMessageBox = nullptr; - } - delete ui; } @@ -56,9 +48,6 @@ void EditorInstructors::closeEvent(QCloseEvent *event) { if(dlgEditInstructor) dlgEditInstructor->close(); - - if(specialMessageBox) - specialMessageBox->close(); } void EditorInstructors::on_btnNewInstructor_clicked() @@ -93,39 +82,21 @@ void EditorInstructors::on_btnDeleteInstructor_clicked() if(connectorToServer->isAdminInstructor(id)) {//Это Админ! - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot delete the Administrator.")); - specialMessageBox->exec(); - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } + SpecMsgBox::CriticalClose(this, tr("You cannot delete the Administrator.")); return; } if(connectorToServer->isLoggedInInstructor(id)) {//Инструктор залогирован! - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot delete a logged-in instructor.")); - specialMessageBox->exec(); - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } + SpecMsgBox::CriticalClose(this, tr("You cannot delete a logged-in instructor.")); return; } - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")); - if(specialMessageBox->exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted) { waitAnimationWidget->showWithPlay(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_INSTRUCTOR, id); } - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } } } } @@ -156,13 +127,7 @@ void EditorInstructors::on_btnToOrFromArchive_clicked() {//Не Архивный if(connectorToServer->isLoggedInInstructor(id)) {//Инструктор залогирован! - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot archive a logged-in instructor.")); - specialMessageBox->exec(); - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } + SpecMsgBox::CriticalClose(this, tr("You cannot archive a logged-in instructor.")); return; } @@ -199,13 +164,7 @@ void EditorInstructors::on_btnEdit_clicked() if(connectorToServer->isLoggedInInstructor(id)) {//Инструктор залогирован! - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot edit a logged-in instructor.")); - specialMessageBox->exec(); - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } + SpecMsgBox::CriticalClose(this, tr("You cannot edit a logged-in instructor.")); return; } @@ -311,37 +270,19 @@ bool EditorInstructors::verifyInstructor(Instructor instructor) if(instructor.getName() == QStringLiteral("")) {//Имя не корректно! - 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; - } + SpecMsgBox::CriticalClose(this, tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted.")); return false; } if(instructor.getLogin() == QStringLiteral("")) {//Логин не корректен! - 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; - } + SpecMsgBox::CriticalClose(this, tr("Unacceptable instructor login has been entered.\nThe changes will not be accepted.")); return false; } if(instructor.getPassword() == QStringLiteral("")) {//Пароль не корректный! - 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; - } + SpecMsgBox::CriticalClose(this, tr("Unacceptable instructor password has been entered.\nThe changes will not be accepted.")); return false; } @@ -350,13 +291,7 @@ 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 = 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; - } + SpecMsgBox::CriticalClose(this, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")); return 0; } diff --git a/InstructorsAndTrainees/instructors/editorinstructors.h b/InstructorsAndTrainees/instructors/editorinstructors.h index 9c3bfb0..fa0c280 100644 --- a/InstructorsAndTrainees/instructors/editorinstructors.h +++ b/InstructorsAndTrainees/instructors/editorinstructors.h @@ -43,7 +43,6 @@ private: Ui::EditorInstructors *ui; DialogEditInstructor* dlgEditInstructor; - SpecMsgBox* specialMessageBox; }; #endif // DIALOGINSTRUCTORS_H diff --git a/InstructorsAndTrainees/instructorsandtraineeswidget.cpp b/InstructorsAndTrainees/instructorsandtraineeswidget.cpp index 42b93cd..07c4027 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)) { - SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("The file could not be opened ") + fileName).exec(); + SpecMsgBox::CriticalClose(this, tr("The file could not be opened ") + fileName); return QStringLiteral(""); } else @@ -273,7 +273,7 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization else { ui->btnAuthorizationInstructor->setChecked(true); - SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("Instructor deauthorization") + "\n" + tr("Error!")).exec(); + SpecMsgBox::CriticalClose(this, tr("Instructor deauthorization") + "\n" + tr("Error!")); } } @@ -285,7 +285,7 @@ void InstructorsAndTraineesWidget::slot_ServerBlocked() waitAnimationWidget->hideWithStop(); ui->btnAuthorizationInstructor->setChecked(false); - SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, tr("Instructor authorization.") + "\n" + tr("Server blocked!")).exec(); + SpecMsgBox::WarningClose(this, tr("Instructor authorization.") + "\n" + tr("Server blocked!")); } } @@ -317,7 +317,7 @@ void InstructorsAndTraineesWidget::slot_ErrorAuth(QString error) errorTextMsg = tr("Login or password error!"); } - SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, tr("Instructor authorization.") + "\n" + errorTextMsg).exec(); + SpecMsgBox::WarningClose(this, tr("Instructor authorization.") + "\n" + errorTextMsg); } } @@ -406,7 +406,7 @@ void InstructorsAndTraineesWidget::slot_ConnectedToServer(bool state) if(!flSettingsServerIsChanged) { if(!flTryConnectToServer) - SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, tr("The server is not available!")).exec(); + SpecMsgBox::WarningClose(this, tr("The server is not available!")); } else flSettingsServerIsChanged = false; @@ -654,7 +654,7 @@ void InstructorsAndTraineesWidget::on_btnSettings_clicked() if(dlgSettings->settingsServerIsChanged()) { - SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, tr("Server settings have been changed. Please reconnect to the server.")).exec(); + SpecMsgBox::WarningClose(this, tr("Server settings have been changed.\nPlease reconnect to the server.")); flSettingsServerIsChanged = true; diff --git a/InstructorsAndTrainees/settings/dialogversioncontrol.cpp b/InstructorsAndTrainees/settings/dialogversioncontrol.cpp index a83e629..070e5d0 100644 --- a/InstructorsAndTrainees/settings/dialogversioncontrol.cpp +++ b/InstructorsAndTrainees/settings/dialogversioncontrol.cpp @@ -57,6 +57,7 @@ void DialogVersionControl::initialize(QString authorName) connect(connectorToServer, &ConnectorToServer::signal_AnimationActivated, this, &DialogVersionControl::slot_activateLoadAnimation); connect(connectorToServer, &ConnectorToServer::signal_showServerList, this, &DialogVersionControl::slot_showServerList); + connect(connectorToServer, &ConnectorToServer::signal_NotifyVersionControl, this, &DialogVersionControl::slot_NotifyVersionControl); connect(this, &DialogVersionControl::sigSendSwitchVersion, connectorToServer, &ConnectorToServer::slot_SendSwitchVersion); connect(this, &DialogVersionControl::sigSendCopyVersion, connectorToServer, &ConnectorToServer::slot_SendCopyVersion); @@ -114,7 +115,7 @@ void DialogVersionControl::sendCopyEmit(QString newName) if (selectedVersion == nullptr) { QString text = tr("Version not selected"); - SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox::WarningClose(this, text); return; } @@ -127,7 +128,7 @@ void DialogVersionControl::on_createDuplicateButton_clicked() if (selectedVersion == nullptr) { QString text = tr("Version not selected"); - SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox::WarningClose(this, text); return; } @@ -160,7 +161,7 @@ void DialogVersionControl::on_deleteVersionButton_clicked() if (selectedVersion == nullptr) { QString text = tr("Version not selected"); - SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox::WarningClose(this, text); return; } @@ -172,7 +173,7 @@ void DialogVersionControl::on_switchServerVersionButton_clicked() if (selectedVersion == nullptr) { QString text = tr("Version not selected"); - SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox::WarningClose(this, text); return; } @@ -209,6 +210,11 @@ void DialogVersionControl::slot_SetVersion(StreamingVersionData *serverVersion) flGetVersion = true; } +void DialogVersionControl::slot_NotifyVersionControl(QString text) +{ + SpecMsgBox::WarningClose(this, text); +} + void DialogVersionControl::resizeEvent(QResizeEvent *event) { QSize size = event->size(); diff --git a/InstructorsAndTrainees/settings/dialogversioncontrol.h b/InstructorsAndTrainees/settings/dialogversioncontrol.h index 146f1fb..fe697d9 100644 --- a/InstructorsAndTrainees/settings/dialogversioncontrol.h +++ b/InstructorsAndTrainees/settings/dialogversioncontrol.h @@ -39,6 +39,7 @@ private slots: void slot_activateLoadAnimation(bool flag); void slot_showServerList(QList *serverList); void slot_SetVersion(StreamingVersionData* serverVersion); + void slot_NotifyVersionControl(QString text); signals: void sigSendDeleteVersion(StreamingVersionData *streaming); diff --git a/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp b/InstructorsAndTrainees/specialmessagebox/notifycontroller.cpp index 0064b26..b4022a6 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) - SpecMsgBox(parentWidget, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox::WarningClose(parentWidget, text); else - SpecMsgBox(this->parentWidget, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); + SpecMsgBox::WarningClose(this->parentWidget, text); } diff --git a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp index 1ce64dd..68da470 100644 --- a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp +++ b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.cpp @@ -45,29 +45,29 @@ SpecMsgBox::~SpecMsgBox() delete ui; } -int SpecMsgBox::WarningYesNo(SpecMsgBox *msgBox, QWidget *parent, const QString &text) +int SpecMsgBox::WarningYesNo(QWidget *parent, const QString &text) { - return SpecMsgBox::work(msgBox, parent, TypeSpecMsgBox::warningYesNo, text); + return SpecMsgBox::work(parent, TypeSpecMsgBox::warningYesNo, text); } -int SpecMsgBox::WarningClose(SpecMsgBox *msgBox, QWidget *parent, const QString &text) +int SpecMsgBox::WarningClose(QWidget *parent, const QString &text) { - return SpecMsgBox::work(msgBox, parent, TypeSpecMsgBox::warningClose, text); + return SpecMsgBox::work(parent, TypeSpecMsgBox::warningClose, text); } -int SpecMsgBox::CriticalClose(SpecMsgBox *msgBox, QWidget *parent, const QString &text) +int SpecMsgBox::CriticalClose(QWidget *parent, const QString &text) { - return SpecMsgBox::work(msgBox, parent, TypeSpecMsgBox::criticalClose, text); + return SpecMsgBox::work(parent, TypeSpecMsgBox::criticalClose, text); } -int SpecMsgBox::InfoOk(SpecMsgBox *msgBox, QWidget *parent, const QString &text) +int SpecMsgBox::InfoOk(QWidget *parent, const QString &text) { - return SpecMsgBox::work(msgBox, parent, TypeSpecMsgBox::infoOk, text); + return SpecMsgBox::work(parent, TypeSpecMsgBox::infoOk, text); } -int SpecMsgBox::work(SpecMsgBox *msgBox, QWidget *parent, TypeSpecMsgBox type, const QString& text) +int SpecMsgBox::work(QWidget *parent, TypeSpecMsgBox type, const QString& text) { - msgBox = new SpecMsgBox(parent, type, text); + SpecMsgBox *msgBox = new SpecMsgBox(parent, type, text); return msgBox->exec(); } diff --git a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h index c431a54..a0789c0 100644 --- a/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h +++ b/InstructorsAndTrainees/specialmessagebox/specialmessagebox.h @@ -19,18 +19,19 @@ public: infoOk }; -public: +private: explicit SpecMsgBox(QWidget *parent, TypeSpecMsgBox type, const QString& text); +public: ~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); + static int WarningYesNo(QWidget *parent, const QString& text); + static int WarningClose(QWidget *parent, const QString& text); + static int CriticalClose(QWidget *parent, const QString& text); + static int InfoOk(QWidget *parent, const QString& text); private: - static int work(SpecMsgBox* msgBox, QWidget *parent, TypeSpecMsgBox type, const QString& text); + static int work(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 013d784..d662450 100644 --- a/InstructorsAndTrainees/tasks/ammtaskswidget.cpp +++ b/InstructorsAndTrainees/tasks/ammtaskswidget.cpp @@ -22,7 +22,6 @@ AMMtasksWidget::AMMtasksWidget(ConnectorToServer* connectorToServer, TypeListTre waitAnimationWidget(nullptr), dlgCheckerTask(nullptr), dlgListSubProc(nullptr), - specialMessageBox(nullptr), flOnlyActive(false), lastCurrentID(0) { @@ -157,8 +156,6 @@ void AMMtasksWidget::closeChildDlg() dlgCheckerTask->close(); if(dlgListSubProc) dlgListSubProc->close(); - if(specialMessageBox) - specialMessageBox->close(); } void AMMtasksWidget::changeEvent(QEvent *event) @@ -329,16 +326,10 @@ void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode) lastSelectedTask.listSubProc.clear(); dlgListSubProc->getListCheckedSubProc(&lastSelectedTask.listSubProc); - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); - if(specialMessageBox->exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("Assign this task?")) == QDialog::Accepted) { connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_AMM_TO_TRAINEE, idTraineeSelected, &lastSelectedTask); } - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } break; } case QDialog::Rejected: @@ -357,16 +348,10 @@ void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode) { lastSelectedTask.listSubProc.clear(); - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); - if(specialMessageBox->exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("Assign this task?")) == QDialog::Accepted) { connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_AMM_TO_TRAINEE, idTraineeSelected, &lastSelectedTask); } - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } } } } @@ -520,18 +505,11 @@ void AMMtasksWidget::on_btnDelete_clicked() int id = treeItemCurrent->text(ColumnsTreeAMM::clmnAMM_ID).toInt(); - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")); - - if(specialMessageBox->exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted) { waitAnimationWidget->showWithPlay(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TASK_AMM_TO_TRAINEE, id); } - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } } } } diff --git a/InstructorsAndTrainees/tasks/ammtaskswidget.h b/InstructorsAndTrainees/tasks/ammtaskswidget.h index d89ed72..32bba57 100644 --- a/InstructorsAndTrainees/tasks/ammtaskswidget.h +++ b/InstructorsAndTrainees/tasks/ammtaskswidget.h @@ -103,8 +103,6 @@ private: DialogListSubProc* dlgListSubProc; - SpecMsgBox* specialMessageBox; - bool flOnlyActive; //AMM int lastCurrentID; diff --git a/InstructorsAndTrainees/tasks/checkertask.cpp b/InstructorsAndTrainees/tasks/checkertask.cpp index 668d89b..a4af13e 100644 --- a/InstructorsAndTrainees/tasks/checkertask.cpp +++ b/InstructorsAndTrainees/tasks/checkertask.cpp @@ -8,7 +8,6 @@ CheckerTask::CheckerTask(ConnectorToServer* connectorToServer, QString type, QWi ui(new Ui::CheckerTask), connectorToServer(connectorToServer), fimTasksWidget(nullptr), - specialMessageBox(nullptr), flChanged(false), id_task(0), type("fim") @@ -49,19 +48,13 @@ CheckerTask::~CheckerTask() delete fimTasksWidget; fimTasksWidget = nullptr; } - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } delete ui; } void CheckerTask::closeEvent(QCloseEvent *event) { - if(specialMessageBox) - specialMessageBox->close(); + } void CheckerTask::setTask(TaskAmmFim* task) @@ -183,18 +176,12 @@ void CheckerTask::on_btnWrong_clicked() msgString = tr("Change task status?\nThe status will be set:\n'new'"); } - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, msgString); - if(specialMessageBox->exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, msgString) == QDialog::Accepted) { connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status); this->parentWidget()->close(); flChanged = true; } - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } } void CheckerTask::on_btnRight_clicked() @@ -216,16 +203,10 @@ void CheckerTask::on_btnRight_clicked() msgString = tr("Change task status?\nThe status will be set:\n'completed'"); } - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, msgString); - if(specialMessageBox->exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, msgString) == QDialog::Accepted) { connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status); this->parentWidget()->close(); flChanged = true; } - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } } diff --git a/InstructorsAndTrainees/tasks/checkertask.h b/InstructorsAndTrainees/tasks/checkertask.h index cbd76ad..639e55c 100644 --- a/InstructorsAndTrainees/tasks/checkertask.h +++ b/InstructorsAndTrainees/tasks/checkertask.h @@ -48,8 +48,6 @@ private: ConnectorToServer* connectorToServer; FIMtasksWidget* fimTasksWidget; - SpecMsgBox* specialMessageBox; - bool flChanged; int id_task; QString type; diff --git a/InstructorsAndTrainees/tasks/fimtaskswidget.cpp b/InstructorsAndTrainees/tasks/fimtaskswidget.cpp index 57104b6..70e58b5 100644 --- a/InstructorsAndTrainees/tasks/fimtaskswidget.cpp +++ b/InstructorsAndTrainees/tasks/fimtaskswidget.cpp @@ -22,7 +22,6 @@ FIMtasksWidget::FIMtasksWidget(ConnectorToServer* connectorToServer, TypeListTre taskTreePreparation(nullptr), waitAnimationWidget(nullptr), dlgCheckerTask(nullptr), - specialMessageBox(nullptr), userName(""), lastCurrentID(0) { @@ -103,8 +102,6 @@ FIMtasksWidget::~FIMtasksWidget() if(dlgCheckerTask) dlgCheckerTask->close(); - if(specialMessageBox) - specialMessageBox->close(); delete ui; } @@ -140,8 +137,6 @@ void FIMtasksWidget::closeChildDlg() { if(dlgCheckerTask) dlgCheckerTask->close(); - if(specialMessageBox) - specialMessageBox->close(); } void FIMtasksWidget::changeEvent(QEvent *event) @@ -401,17 +396,11 @@ void FIMtasksWidget::on_btnDelete_clicked() int id = treeItemCurrent->text(ColumnsTreeFIM::clmnFIM_ID).toInt(); - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")); - if(specialMessageBox->exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted) { waitAnimationWidget->showWithPlay(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TASK_FIM_TO_TRAINEE, id); } - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } } } } @@ -451,14 +440,8 @@ void FIMtasksWidget::on_btnCheck_clicked() void FIMtasksWidget::on_btnAssignTask_clicked() { - specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); - if(specialMessageBox->exec() == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("Assign this task?")) == QDialog::Accepted) assignTaskFIMtoTrainee(); - if(specialMessageBox) - { - delete specialMessageBox; - specialMessageBox = nullptr; - } } void FIMtasksWidget::updateTaskItem(QTreeWidgetItem *itemTask) diff --git a/InstructorsAndTrainees/tasks/fimtaskswidget.h b/InstructorsAndTrainees/tasks/fimtaskswidget.h index c820eb3..0e60bd0 100644 --- a/InstructorsAndTrainees/tasks/fimtaskswidget.h +++ b/InstructorsAndTrainees/tasks/fimtaskswidget.h @@ -92,8 +92,6 @@ private: DialogChekerTask* dlgCheckerTask; - SpecMsgBox* specialMessageBox; - QString userName; //FIM int lastCurrentID; diff --git a/InstructorsAndTrainees/trainees/editortrainees.cpp b/InstructorsAndTrainees/trainees/editortrainees.cpp index 8efc54b..e613087 100644 --- a/InstructorsAndTrainees/trainees/editortrainees.cpp +++ b/InstructorsAndTrainees/trainees/editortrainees.cpp @@ -9,8 +9,7 @@ EditorTrainees::EditorTrainees(ConnectorToServer* connectorToServer, bool adminM TraineesView(connectorToServer, CommonView::TypeView::control, parent), ui(new Ui::EditorTrainees), dlgEditTrainee(nullptr), - dlgEditGroup(nullptr), - specialMessageBox(nullptr) + dlgEditGroup(nullptr) { ui->setupUi(this); @@ -55,8 +54,6 @@ EditorTrainees::~EditorTrainees() dlgEditGroup = nullptr; } - //SpecMsgBox::CloseAndDelete(specialMessageBox); - delete ui; } @@ -67,8 +64,6 @@ void EditorTrainees::closeEvent(QCloseEvent *event) if(dlgEditGroup) dlgEditGroup->close(); - - //SpecMsgBox::CloseAndDelete(specialMessageBox); } void EditorTrainees::on_btnNewGroup_clicked() @@ -98,12 +93,12 @@ void EditorTrainees::on_btnDeleteGroup_clicked() if(connectorToServer->getListTraineesInGroup(id_group).count() > 0) { - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("The group is not empty.\nIt is not possible to delete a non-empty group.")); + SpecMsgBox::CriticalClose(this, tr("The group is not empty.\nIt is not possible to delete a non-empty group.")); return; } else {//Пустая группа - if(SpecMsgBox::WarningYesNo(specialMessageBox, this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted) { waitAnimationWidget->showWithPlay(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_GROUP, id_group); @@ -154,11 +149,11 @@ void EditorTrainees::on_btnDeleteTrainee_clicked() if(connectorToServer->isLoggedInTrainee(id_trainee)) {//Обучаемый залогирован! - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("You cannot delete a logged-in trainee.")); + SpecMsgBox::CriticalClose(this, tr("You cannot delete a logged-in trainee.")); return; } - if(SpecMsgBox::WarningYesNo(specialMessageBox, this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted) + if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted) { waitAnimationWidget->showWithPlay(); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TRAINEE, id_trainee); @@ -193,7 +188,7 @@ void EditorTrainees::on_btnToOrFromArchiveTrainee_clicked() {//Не Архивный if(connectorToServer->isLoggedInTrainee(id_trainee)) {//Обучаемый залогирован! - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("You cannot archive a logged-in trainee.")); + SpecMsgBox::CriticalClose(this, tr("You cannot archive a logged-in trainee.")); return; } @@ -239,7 +234,7 @@ void EditorTrainees::on_btnEdit_clicked() if(connectorToServer->isLoggedInTrainee(id_trainee)) {//Обучаемый залогирован! - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("You cannot edit a logged-in trainee.")); + SpecMsgBox::CriticalClose(this, tr("You cannot edit a logged-in trainee.")); return; } @@ -408,7 +403,7 @@ bool EditorTrainees::verifyGroup(Group group) if(group.getName() == QStringLiteral("")) {//Имя не корректно! - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("Unacceptable group name has been entered.\nThe changes will not be accepted.")); + SpecMsgBox::CriticalClose(this, tr("Unacceptable group name has been entered.\nThe changes will not be accepted.")); return false; } @@ -418,7 +413,7 @@ bool EditorTrainees::verifyGroup(Group group) { if(group.getName() == exist_group.getName() && group.getID() != exist_group.getID()) {//Имя уже существует - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("An existing group name has been entered.\nThe changes will not be accepted.")); + SpecMsgBox::CriticalClose(this, tr("An existing group name has been entered.\nThe changes will not be accepted.")); return false; } } @@ -432,19 +427,19 @@ bool EditorTrainees::verifyTrainee(Trainee trainee) if(trainee.getName() == QStringLiteral("")) {//Имя не корректно! - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted.")); + SpecMsgBox::CriticalClose(this, tr("Unacceptable trainee name has been entered.\nThe changes will not be accepted.")); return false; } if(trainee.getLogin() == QStringLiteral("")) {//Логин не корректен! - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted.")); + SpecMsgBox::CriticalClose(this, tr("Unacceptable trainee login has been entered.\nThe changes will not be accepted.")); return false; } if(trainee.getPassword() == QStringLiteral("")) {//Пароль не корректный! - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted.")); + SpecMsgBox::CriticalClose(this, tr("Unacceptable trainee password has been entered.\nThe changes will not be accepted.")); return false; } @@ -453,7 +448,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()))) {//Логин уже существует! - SpecMsgBox::CriticalClose(specialMessageBox, this, tr("An existing instructor or trainee login has been entered.\nThe changes will not be accepted.")); + SpecMsgBox::CriticalClose(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 5255fb6..5ce19ac 100644 --- a/InstructorsAndTrainees/trainees/editortrainees.h +++ b/InstructorsAndTrainees/trainees/editortrainees.h @@ -49,7 +49,6 @@ private: DialogEditTrainee* dlgEditTrainee; DialogEditGroup* dlgEditGroup; - SpecMsgBox* specialMessageBox; }; #endif // DIALOGTRAINEESGROUPS_H