notifyController убрал

This commit is contained in:
2025-11-30 19:28:08 +03:00
parent fb493aca9f
commit d129fbded0
20 changed files with 82 additions and 206 deletions

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))
{ {
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; return;
} }
else else
@@ -490,17 +490,17 @@ void RecognizeSystem::xmlParser(QByteArray array)
if (value == "BASEDELETETRY") if (value == "BASEDELETETRY")
{ {
emit sigNotify(tr("You cannot delete the basic version!")); emit sigNotifyVersionControl(tr("You cannot delete the basic version!"));
} }
if (value == "TRYACTIVEDELETE") if (value == "TRYACTIVEDELETE")
{ {
emit sigNotify(tr("You cannot delete the active version")); emit sigNotifyVersionControl(tr("You cannot delete the active version"));
} }
if (value == "DUPLICATEVERNAME") if (value == "DUPLICATEVERNAME")
{ {
emit sigNotify(tr("This name already exists")); emit sigNotifyVersionControl(tr("This name already exists"));
} }
} }
} }

View File

@@ -56,7 +56,7 @@ signals:
void sigAnswerQueryTasksXML_AMM(QByteArray array); void sigAnswerQueryTasksXML_AMM(QByteArray array);
void sigShowServerDataList(QList<StreamingVersionData*> *versions); void sigShowServerDataList(QList<StreamingVersionData*> *versions);
void sigSetVersion(StreamingVersionData* serverVersion); void sigSetVersion(StreamingVersionData* serverVersion);
void sigNotify(QString text, QWidget *parentWidget = nullptr); void sigNotifyVersionControl(QString text);
void sigAnimationActivated(bool flag); void sigAnimationActivated(bool flag);
void sigHashReady(); void sigHashReady();
void sigAnswerQuerySubProc(QList<SubProc> listSubProc, QString parentTask_dmCode); void sigAnswerQuerySubProc(QList<SubProc> listSubProc, QString parentTask_dmCode);

View File

@@ -9,7 +9,6 @@ ConnectorToServer::ConnectorToServer(QWidget* parentWidget, QObject *parent) :
dataParser(nullptr), dataParser(nullptr),
sendSystem(nullptr), sendSystem(nullptr),
recognizeSystem(nullptr), recognizeSystem(nullptr),
notifyController(nullptr),
fl_GetedOfflineMessages(false), fl_GetedOfflineMessages(false),
nameInstructorLoggedInLocal("") nameInstructorLoggedInLocal("")
{ {
@@ -19,7 +18,6 @@ ConnectorToServer::ConnectorToServer(QWidget* parentWidget, QObject *parent) :
ConnectorToServer::~ConnectorToServer() ConnectorToServer::~ConnectorToServer()
{ {
delete client; delete client;
delete notifyController;
delete recognizeSystem; delete recognizeSystem;
delete sendSystem; delete sendSystem;
delete dataParser; delete dataParser;
@@ -115,6 +113,11 @@ void ConnectorToServer::slot_getVersion()
emit signal_SendGetVersion(); emit signal_SendGetVersion();
} }
void ConnectorToServer::slot_NotifyVersionControl(QString text)
{
emit signal_NotifyVersionControl(text);
}
void ConnectorToServer::initialize() void ConnectorToServer::initialize()
{ {
createObjects(); createObjects();
@@ -159,7 +162,7 @@ void ConnectorToServer::bindConnection()
connect(client,&TCPClient::signal_ConnectedToServer,this,&ConnectorToServer::signal_ConnectedToServer,Qt::AutoConnection); 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); connect(recognizeSystem,&RecognizeSystem::sigHashReady,this,&ConnectorToServer::slot_HashReady);
@@ -190,8 +193,6 @@ void ConnectorToServer::createObjects()
recognizeSystem = new RecognizeSystem; recognizeSystem = new RecognizeSystem;
recognizeSystem->moveToThread(connectionThread); recognizeSystem->moveToThread(connectionThread);
notifyController = new NotifyController(parentWidget);
connectionThread->start(); connectionThread->start();
connectionThread->setPriority(QThread::HighestPriority); connectionThread->setPriority(QThread::HighestPriority);
} }

View File

@@ -116,6 +116,8 @@ public slots:
void slot_getVersion(); void slot_getVersion();
void slot_NotifyVersionControl(QString text);
signals: signals:
void sigSetConnect(ServerSettings* serverSettings,QThread *thread); void sigSetConnect(ServerSettings* serverSettings,QThread *thread);
void sigStopConnect(); void sigStopConnect();
@@ -157,6 +159,8 @@ signals:
void signal_showServerList(QList<StreamingVersionData*> *serverList); void signal_showServerList(QList<StreamingVersionData*> *serverList);
void signal_SendGetVersion(); void signal_SendGetVersion();
void signal_NotifyVersionControl(QString text);
private: private:
void initialize(); void initialize();
void bindConnection(); void bindConnection();
@@ -169,7 +173,6 @@ private:
DataParser *dataParser; DataParser *dataParser;
SendSystem *sendSystem; SendSystem *sendSystem;
RecognizeSystem *recognizeSystem; RecognizeSystem *recognizeSystem;
NotifyController *notifyController;
//Списочная модель БД СУО //Списочная модель БД СУО
QMutex mtxAccess; QMutex mtxAccess;

View File

@@ -6,8 +6,7 @@
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);
@@ -42,13 +41,6 @@ EditorInstructors::~EditorInstructors()
dlgEditInstructor = nullptr; dlgEditInstructor = nullptr;
} }
if(specialMessageBox)
{
specialMessageBox->close();
delete specialMessageBox;
specialMessageBox = nullptr;
}
delete ui; delete ui;
} }
@@ -56,9 +48,6 @@ 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()
@@ -93,39 +82,21 @@ void EditorInstructors::on_btnDeleteInstructor_clicked()
if(connectorToServer->isAdminInstructor(id)) if(connectorToServer->isAdminInstructor(id))
{//Это Админ! {//Это Админ!
specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot delete the Administrator.")); SpecMsgBox::CriticalClose(this, 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 = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot delete a logged-in instructor.")); SpecMsgBox::CriticalClose(this, tr("You cannot delete a logged-in instructor."));
specialMessageBox->exec();
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
return; return;
} }
specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("The deletion will be irrevocable.\nDelete it anyway?")); if(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted)
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;
}
} }
} }
} }
@@ -156,13 +127,7 @@ void EditorInstructors::on_btnToOrFromArchive_clicked()
{//Не Архивный {//Не Архивный
if(connectorToServer->isLoggedInInstructor(id)) if(connectorToServer->isLoggedInInstructor(id))
{//Инструктор залогирован! {//Инструктор залогирован!
specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot archive a logged-in instructor.")); SpecMsgBox::CriticalClose(this, tr("You cannot archive a logged-in instructor."));
specialMessageBox->exec();
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
return; return;
} }
@@ -199,13 +164,7 @@ void EditorInstructors::on_btnEdit_clicked()
if(connectorToServer->isLoggedInInstructor(id)) if(connectorToServer->isLoggedInInstructor(id))
{//Инструктор залогирован! {//Инструктор залогирован!
specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("You cannot edit a logged-in instructor.")); SpecMsgBox::CriticalClose(this, tr("You cannot edit a logged-in instructor."));
specialMessageBox->exec();
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
return; return;
} }
@@ -311,37 +270,19 @@ bool EditorInstructors::verifyInstructor(Instructor instructor)
if(instructor.getName() == QStringLiteral("<name>")) if(instructor.getName() == QStringLiteral("<name>"))
{//Имя не корректно! {//Имя не корректно!
specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("Unacceptable instructor name has been entered.\nThe changes will not be accepted.")); SpecMsgBox::CriticalClose(this, 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 = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("Unacceptable instructor login has been entered.\nThe changes will not be accepted.")); SpecMsgBox::CriticalClose(this, 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 = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, tr("Unacceptable instructor password has been entered.\nThe changes will not be accepted.")); SpecMsgBox::CriticalClose(this, 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;
} }
@@ -350,13 +291,7 @@ 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 = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::criticalClose, 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."));
specialMessageBox->exec();
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
return 0; return 0;
} }

View File

@@ -43,7 +43,6 @@ 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))
{ {
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(""); return QStringLiteral("");
} }
else else
@@ -273,7 +273,7 @@ void InstructorsAndTraineesWidget::slot_checkDeLoginResult(ServerDeAuthorization
else else
{ {
ui->btnAuthorizationInstructor->setChecked(true); 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(); waitAnimationWidget->hideWithStop();
ui->btnAuthorizationInstructor->setChecked(false); 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!"); 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(!flSettingsServerIsChanged)
{ {
if(!flTryConnectToServer) if(!flTryConnectToServer)
SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, tr("The server is not available!")).exec(); SpecMsgBox::WarningClose(this, tr("The server is not available!"));
} }
else else
flSettingsServerIsChanged = false; flSettingsServerIsChanged = false;
@@ -654,7 +654,7 @@ void InstructorsAndTraineesWidget::on_btnSettings_clicked()
if(dlgSettings->settingsServerIsChanged()) 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; flSettingsServerIsChanged = true;

View File

@@ -57,6 +57,7 @@ void DialogVersionControl::initialize(QString authorName)
connect(connectorToServer, &ConnectorToServer::signal_AnimationActivated, this, &DialogVersionControl::slot_activateLoadAnimation); connect(connectorToServer, &ConnectorToServer::signal_AnimationActivated, this, &DialogVersionControl::slot_activateLoadAnimation);
connect(connectorToServer, &ConnectorToServer::signal_showServerList, this, &DialogVersionControl::slot_showServerList); 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::sigSendSwitchVersion, connectorToServer, &ConnectorToServer::slot_SendSwitchVersion);
connect(this, &DialogVersionControl::sigSendCopyVersion, connectorToServer, &ConnectorToServer::slot_SendCopyVersion); connect(this, &DialogVersionControl::sigSendCopyVersion, connectorToServer, &ConnectorToServer::slot_SendCopyVersion);
@@ -114,7 +115,7 @@ void DialogVersionControl::sendCopyEmit(QString newName)
if (selectedVersion == nullptr) if (selectedVersion == nullptr)
{ {
QString text = tr("Version not selected"); QString text = tr("Version not selected");
SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); SpecMsgBox::WarningClose(this, text);
return; return;
} }
@@ -127,7 +128,7 @@ void DialogVersionControl::on_createDuplicateButton_clicked()
if (selectedVersion == nullptr) if (selectedVersion == nullptr)
{ {
QString text = tr("Version not selected"); QString text = tr("Version not selected");
SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); SpecMsgBox::WarningClose(this, text);
return; return;
} }
@@ -160,7 +161,7 @@ void DialogVersionControl::on_deleteVersionButton_clicked()
if (selectedVersion == nullptr) if (selectedVersion == nullptr)
{ {
QString text = tr("Version not selected"); QString text = tr("Version not selected");
SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); SpecMsgBox::WarningClose(this, text);
return; return;
} }
@@ -172,7 +173,7 @@ void DialogVersionControl::on_switchServerVersionButton_clicked()
if (selectedVersion == nullptr) if (selectedVersion == nullptr)
{ {
QString text = tr("Version not selected"); QString text = tr("Version not selected");
SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); SpecMsgBox::WarningClose(this, text);
return; return;
} }
@@ -209,6 +210,11 @@ void DialogVersionControl::slot_SetVersion(StreamingVersionData *serverVersion)
flGetVersion = true; flGetVersion = true;
} }
void DialogVersionControl::slot_NotifyVersionControl(QString text)
{
SpecMsgBox::WarningClose(this, text);
}
void DialogVersionControl::resizeEvent(QResizeEvent *event) void DialogVersionControl::resizeEvent(QResizeEvent *event)
{ {
QSize size = event->size(); QSize size = event->size();

View File

@@ -39,6 +39,7 @@ private slots:
void slot_activateLoadAnimation(bool flag); void slot_activateLoadAnimation(bool flag);
void slot_showServerList(QList<StreamingVersionData*> *serverList); void slot_showServerList(QList<StreamingVersionData*> *serverList);
void slot_SetVersion(StreamingVersionData* serverVersion); void slot_SetVersion(StreamingVersionData* serverVersion);
void slot_NotifyVersionControl(QString text);
signals: signals:
void sigSendDeleteVersion(StreamingVersionData *streaming); void sigSendDeleteVersion(StreamingVersionData *streaming);

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)
SpecMsgBox(parentWidget, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); SpecMsgBox::WarningClose(parentWidget, text);
else else
SpecMsgBox(this->parentWidget, SpecMsgBox::TypeSpecMsgBox::warningClose, text).exec(); SpecMsgBox::WarningClose(this->parentWidget, text);
} }

View File

@@ -45,29 +45,29 @@ SpecMsgBox::~SpecMsgBox()
delete ui; 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(); return msgBox->exec();
} }

View File

@@ -19,18 +19,19 @@ public:
infoOk infoOk
}; };
public: private:
explicit SpecMsgBox(QWidget *parent, TypeSpecMsgBox type, const QString& text); explicit SpecMsgBox(QWidget *parent, TypeSpecMsgBox type, const QString& text);
public:
~SpecMsgBox(); ~SpecMsgBox();
public: public:
static int WarningYesNo(SpecMsgBox* msgBox, QWidget *parent, const QString& text); static int WarningYesNo(QWidget *parent, const QString& text);
static int WarningClose(SpecMsgBox* msgBox, QWidget *parent, const QString& text); static int WarningClose(QWidget *parent, const QString& text);
static int CriticalClose(SpecMsgBox* msgBox, QWidget *parent, const QString& text); static int CriticalClose(QWidget *parent, const QString& text);
static int InfoOk(SpecMsgBox* msgBox, QWidget *parent, const QString& text); static int InfoOk(QWidget *parent, const QString& text);
private: 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: private slots:
void on_btnYes_clicked(); void on_btnYes_clicked();

View File

@@ -22,7 +22,6 @@ AMMtasksWidget::AMMtasksWidget(ConnectorToServer* connectorToServer, TypeListTre
waitAnimationWidget(nullptr), waitAnimationWidget(nullptr),
dlgCheckerTask(nullptr), dlgCheckerTask(nullptr),
dlgListSubProc(nullptr), dlgListSubProc(nullptr),
specialMessageBox(nullptr),
flOnlyActive(false), flOnlyActive(false),
lastCurrentID(0) lastCurrentID(0)
{ {
@@ -157,8 +156,6 @@ void AMMtasksWidget::closeChildDlg()
dlgCheckerTask->close(); dlgCheckerTask->close();
if(dlgListSubProc) if(dlgListSubProc)
dlgListSubProc->close(); dlgListSubProc->close();
if(specialMessageBox)
specialMessageBox->close();
} }
void AMMtasksWidget::changeEvent(QEvent *event) void AMMtasksWidget::changeEvent(QEvent *event)
@@ -329,16 +326,10 @@ void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode)
lastSelectedTask.listSubProc.clear(); lastSelectedTask.listSubProc.clear();
dlgListSubProc->getListCheckedSubProc(&lastSelectedTask.listSubProc); dlgListSubProc->getListCheckedSubProc(&lastSelectedTask.listSubProc);
specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); if(SpecMsgBox::WarningYesNo(this, tr("Assign this task?")) == 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);
} }
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
break; break;
} }
case QDialog::Rejected: case QDialog::Rejected:
@@ -357,16 +348,10 @@ void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode)
{ {
lastSelectedTask.listSubProc.clear(); lastSelectedTask.listSubProc.clear();
specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); if(SpecMsgBox::WarningYesNo(this, tr("Assign this task?")) == 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);
} }
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
} }
} }
} }
@@ -520,18 +505,11 @@ void AMMtasksWidget::on_btnDelete_clicked()
int id = treeItemCurrent->text(ColumnsTreeAMM::clmnAMM_ID).toInt(); 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(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted)
if(specialMessageBox->exec() == QDialog::Accepted)
{ {
waitAnimationWidget->showWithPlay(); waitAnimationWidget->showWithPlay();
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TASK_AMM_TO_TRAINEE, id); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TASK_AMM_TO_TRAINEE, id);
} }
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
} }
} }
} }

View File

@@ -103,8 +103,6 @@ private:
DialogListSubProc* dlgListSubProc; DialogListSubProc* dlgListSubProc;
SpecMsgBox* specialMessageBox;
bool flOnlyActive; //AMM bool flOnlyActive; //AMM
int lastCurrentID; int lastCurrentID;

View File

@@ -8,7 +8,6 @@ CheckerTask::CheckerTask(ConnectorToServer* connectorToServer, QString type, QWi
ui(new Ui::CheckerTask), ui(new Ui::CheckerTask),
connectorToServer(connectorToServer), connectorToServer(connectorToServer),
fimTasksWidget(nullptr), fimTasksWidget(nullptr),
specialMessageBox(nullptr),
flChanged(false), flChanged(false),
id_task(0), id_task(0),
type("fim") type("fim")
@@ -49,19 +48,13 @@ CheckerTask::~CheckerTask()
delete fimTasksWidget; delete fimTasksWidget;
fimTasksWidget = nullptr; fimTasksWidget = nullptr;
} }
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
delete ui; delete ui;
} }
void CheckerTask::closeEvent(QCloseEvent *event) void CheckerTask::closeEvent(QCloseEvent *event)
{ {
if(specialMessageBox)
specialMessageBox->close();
} }
void CheckerTask::setTask(TaskAmmFim* task) 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'"); msgString = tr("Change task status?\nThe status will be set:\n'new'");
} }
specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, msgString); if(SpecMsgBox::WarningYesNo(this, msgString) == QDialog::Accepted)
if(specialMessageBox->exec() == QDialog::Accepted)
{ {
connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status); connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status);
this->parentWidget()->close(); this->parentWidget()->close();
flChanged = true; flChanged = true;
} }
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
} }
void CheckerTask::on_btnRight_clicked() 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'"); msgString = tr("Change task status?\nThe status will be set:\n'completed'");
} }
specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, msgString); if(SpecMsgBox::WarningYesNo(this, msgString) == QDialog::Accepted)
if(specialMessageBox->exec() == QDialog::Accepted)
{ {
connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status); connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status);
this->parentWidget()->close(); this->parentWidget()->close();
flChanged = true; flChanged = true;
} }
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
} }

View File

@@ -48,8 +48,6 @@ private:
ConnectorToServer* connectorToServer; ConnectorToServer* connectorToServer;
FIMtasksWidget* fimTasksWidget; FIMtasksWidget* fimTasksWidget;
SpecMsgBox* specialMessageBox;
bool flChanged; bool flChanged;
int id_task; int id_task;
QString type; QString type;

View File

@@ -22,7 +22,6 @@ FIMtasksWidget::FIMtasksWidget(ConnectorToServer* connectorToServer, TypeListTre
taskTreePreparation(nullptr), taskTreePreparation(nullptr),
waitAnimationWidget(nullptr), waitAnimationWidget(nullptr),
dlgCheckerTask(nullptr), dlgCheckerTask(nullptr),
specialMessageBox(nullptr),
userName(""), userName(""),
lastCurrentID(0) lastCurrentID(0)
{ {
@@ -103,8 +102,6 @@ FIMtasksWidget::~FIMtasksWidget()
if(dlgCheckerTask) if(dlgCheckerTask)
dlgCheckerTask->close(); dlgCheckerTask->close();
if(specialMessageBox)
specialMessageBox->close();
delete ui; delete ui;
} }
@@ -140,8 +137,6 @@ void FIMtasksWidget::closeChildDlg()
{ {
if(dlgCheckerTask) if(dlgCheckerTask)
dlgCheckerTask->close(); dlgCheckerTask->close();
if(specialMessageBox)
specialMessageBox->close();
} }
void FIMtasksWidget::changeEvent(QEvent *event) void FIMtasksWidget::changeEvent(QEvent *event)
@@ -401,17 +396,11 @@ void FIMtasksWidget::on_btnDelete_clicked()
int id = treeItemCurrent->text(ColumnsTreeFIM::clmnFIM_ID).toInt(); 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(SpecMsgBox::WarningYesNo(this, tr("The deletion will be irrevocable.\nDelete it anyway?")) == QDialog::Accepted)
if(specialMessageBox->exec() == QDialog::Accepted)
{ {
waitAnimationWidget->showWithPlay(); waitAnimationWidget->showWithPlay();
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TASK_FIM_TO_TRAINEE, id); 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() void FIMtasksWidget::on_btnAssignTask_clicked()
{ {
specialMessageBox = new SpecMsgBox(this, SpecMsgBox::TypeSpecMsgBox::warningYesNo, tr("Assign this task?")); if(SpecMsgBox::WarningYesNo(this, tr("Assign this task?")) == QDialog::Accepted)
if(specialMessageBox->exec() == QDialog::Accepted)
assignTaskFIMtoTrainee(); assignTaskFIMtoTrainee();
if(specialMessageBox)
{
delete specialMessageBox;
specialMessageBox = nullptr;
}
} }
void FIMtasksWidget::updateTaskItem(QTreeWidgetItem *itemTask) void FIMtasksWidget::updateTaskItem(QTreeWidgetItem *itemTask)

View File

@@ -92,8 +92,6 @@ private:
DialogChekerTask* dlgCheckerTask; DialogChekerTask* dlgCheckerTask;
SpecMsgBox* specialMessageBox;
QString userName; //FIM QString userName; //FIM
int lastCurrentID; int lastCurrentID;

View File

@@ -9,8 +9,7 @@ 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);
@@ -55,8 +54,6 @@ EditorTrainees::~EditorTrainees()
dlgEditGroup = nullptr; dlgEditGroup = nullptr;
} }
//SpecMsgBox::CloseAndDelete(specialMessageBox);
delete ui; delete ui;
} }
@@ -67,8 +64,6 @@ 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()
@@ -98,12 +93,12 @@ void EditorTrainees::on_btnDeleteGroup_clicked()
if(connectorToServer->getListTraineesInGroup(id_group).count() > 0) 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; return;
} }
else 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(); waitAnimationWidget->showWithPlay();
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_GROUP, id_group); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_GROUP, id_group);
@@ -154,11 +149,11 @@ void EditorTrainees::on_btnDeleteTrainee_clicked()
if(connectorToServer->isLoggedInTrainee(id_trainee)) 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; 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(); waitAnimationWidget->showWithPlay();
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TRAINEE, id_trainee); connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_DEL_TRAINEE, id_trainee);
@@ -193,7 +188,7 @@ void EditorTrainees::on_btnToOrFromArchiveTrainee_clicked()
{//Не Архивный {//Не Архивный
if(connectorToServer->isLoggedInTrainee(id_trainee)) 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; return;
} }
@@ -239,7 +234,7 @@ void EditorTrainees::on_btnEdit_clicked()
if(connectorToServer->isLoggedInTrainee(id_trainee)) 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; return;
} }
@@ -408,7 +403,7 @@ bool EditorTrainees::verifyGroup(Group group)
if(group.getName() == QStringLiteral("<group>")) if(group.getName() == QStringLiteral("<group>"))
{//Имя не корректно! {//Имя не корректно!
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; return false;
} }
@@ -418,7 +413,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())
{//Имя уже существует {//Имя уже существует
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; return false;
} }
} }
@@ -432,19 +427,19 @@ bool EditorTrainees::verifyTrainee(Trainee trainee)
if(trainee.getName() == QStringLiteral("<name>")) if(trainee.getName() == QStringLiteral("<name>"))
{//Имя не корректно! {//Имя не корректно!
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; return false;
} }
if(trainee.getLogin() == QStringLiteral("<login>")) if(trainee.getLogin() == QStringLiteral("<login>"))
{//Логин не корректен! {//Логин не корректен!
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; return false;
} }
if(trainee.getPassword() == QStringLiteral("<password>")) if(trainee.getPassword() == QStringLiteral("<password>"))
{//Пароль не корректный! {//Пароль не корректный!
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; return false;
} }
@@ -453,7 +448,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())))
{//Логин уже существует! {//Логин уже существует!
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; return 0;
} }

View File

@@ -49,7 +49,6 @@ private:
DialogEditTrainee* dlgEditTrainee; DialogEditTrainee* dlgEditTrainee;
DialogEditGroup* dlgEditGroup; DialogEditGroup* dlgEditGroup;
SpecMsgBox* specialMessageBox;
}; };
#endif // DIALOGTRAINEESGROUPS_H #endif // DIALOGTRAINEESGROUPS_H