mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
232 lines
6.2 KiB
C++
232 lines
6.2 KiB
C++
#include "checkertask.h"
|
|
#include "specialmessagebox.h"
|
|
#include "ui_checkertask.h"
|
|
#include "fimtaskswidget.h"
|
|
|
|
CheckerTask::CheckerTask(ConnectorToServer* connectorToServer, QString type, QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::CheckerTask),
|
|
connectorToServer(connectorToServer),
|
|
fimTasksWidget(nullptr),
|
|
specialMessageBox(nullptr),
|
|
flChanged(false),
|
|
id_task(0),
|
|
type("fim")
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
this->type = type;
|
|
|
|
if(type == "fim")
|
|
{
|
|
fimTasksWidget = new FIMtasksWidget(nullptr, TypeListTreeAMMFIM::listOneTask, this);
|
|
|
|
ui->verticalLayout_3->addWidget(fimTasksWidget);
|
|
ui->lblName->setVisible(false);
|
|
ui->lblDMcode->setVisible(false);
|
|
|
|
ui->plainText->setReadOnly(true);
|
|
ui->plainText->setObjectName("plainText");
|
|
}
|
|
else
|
|
{
|
|
ui->plainText->setVisible(false);
|
|
ui->label->setVisible(false);
|
|
//ui->label_Task->setVisible(false);
|
|
ui->btnRight->setText(tr("Completed"));
|
|
ui->btnWrong->setText(tr("New"));
|
|
ui->btnWrong->setIcon(QIcon(QStringLiteral(":/resources/icons/circleGray.png")));
|
|
|
|
ui->btnRight->setEnabled(false);
|
|
ui->btnWrong->setEnabled(false);
|
|
}
|
|
}
|
|
|
|
CheckerTask::~CheckerTask()
|
|
{
|
|
if(fimTasksWidget)
|
|
{
|
|
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)
|
|
{
|
|
this->task = *task;
|
|
id_task = task->getID();
|
|
|
|
if(type == "fim")
|
|
{
|
|
//Задача
|
|
fimTasksWidget->setOneTaskFim(&this->task);
|
|
|
|
//Репорт
|
|
outReport(this->task.report);
|
|
}
|
|
else if(type == "amm")
|
|
{
|
|
if(this->task.status == "new")
|
|
ui->btnRight->setEnabled(true);
|
|
else
|
|
ui->btnWrong->setEnabled(true);
|
|
|
|
ui->lblName->setText(task->ammProcedure.title);
|
|
ui->lblDMcode->setText(task->ammProcedure.dmCode);
|
|
}
|
|
|
|
//Статус
|
|
if(this->task.status == "completed")
|
|
{
|
|
ui->lblStatusCurrText->setText(tr("completed"));
|
|
ui->lblStatusCurrIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
|
}
|
|
else if(this->task.status == "failed")
|
|
{
|
|
ui->lblStatusCurrText->setText(tr("failed"));
|
|
ui->lblStatusCurrIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleRed.png")));
|
|
}
|
|
else if(this->task.status == "checkup")
|
|
{
|
|
ui->lblStatusCurrText->setText(tr("checkup"));
|
|
ui->lblStatusCurrIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleYellow.png")));
|
|
}
|
|
else
|
|
{
|
|
ui->lblStatusCurrText->setText(tr("new"));
|
|
ui->lblStatusCurrIco->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGray.png")));
|
|
}
|
|
}
|
|
|
|
TaskAmmFim CheckerTask::getTask()
|
|
{
|
|
return this->task;
|
|
}
|
|
|
|
void CheckerTask::setModule(Module *module)
|
|
{
|
|
this->module = *module;
|
|
id_task = this->module.getID();
|
|
}
|
|
|
|
void CheckerTask::outReport(FIMReport report)
|
|
{
|
|
QString str;
|
|
/*
|
|
str = QString("<b>Report ID: %1</b>").arg(QString::number(report.id));
|
|
ui->plainText->appendHtml(str);
|
|
ui->plainText->appendHtml("<br>");
|
|
*/
|
|
|
|
for(FIMReportItem item : report.itemList)
|
|
{
|
|
/*
|
|
//Item ID
|
|
str = QString("<p>Item ID: %1</p>").arg(QString::number(item.id));
|
|
ui->plainText->appendHtml(str);
|
|
*/
|
|
|
|
//Title
|
|
str = QString("<b>%1</b>").arg(item.procedure.title);
|
|
ui->plainText->appendHtml(str);
|
|
|
|
//DMcode
|
|
str = QString("<p>%1</p>").arg(item.procedure.dmCode);
|
|
ui->plainText->appendHtml(str);
|
|
|
|
//Result
|
|
str = item.procedure.result;
|
|
if(str == "viewed")
|
|
str = tr("viewed");
|
|
else if(str == "completed")
|
|
str = tr("completed");
|
|
str = QString("<p>%1</p>").arg(str);
|
|
ui->plainText->appendHtml(str);
|
|
|
|
//Text
|
|
str = QString("<p style=\"color:green;\">%1</p>").arg(item.text);
|
|
ui->plainText->appendHtml(str);
|
|
|
|
ui->plainText->appendHtml("<br>");
|
|
}
|
|
}
|
|
|
|
void CheckerTask::on_btnWrong_clicked()
|
|
{
|
|
TypeQueryToDB typeQuery;
|
|
QString status;
|
|
QString msgString;
|
|
|
|
if(type == "fim")
|
|
{
|
|
typeQuery = TypeQueryToDB::TYPE_QUERY_CHANGE_STATUS_REPORT_TASK_FIM_TO_TRAINEE;
|
|
status = "failed";
|
|
msgString = tr("Change task status?\nThe status will be set:\n'failed'");
|
|
}
|
|
else
|
|
{
|
|
typeQuery = TypeQueryToDB::TYPE_QUERY_CHANGE_STATUS_REPORT_TASK_AMM_TO_TRAINEE;
|
|
status = "new";
|
|
msgString = tr("Change task status?\nThe status will be set:\n'new'");
|
|
}
|
|
|
|
specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, msgString);
|
|
if(specialMessageBox->exec() == 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()
|
|
{
|
|
TypeQueryToDB typeQuery;
|
|
QString status;
|
|
QString msgString;
|
|
|
|
if(type == "fim")
|
|
{
|
|
typeQuery = TypeQueryToDB::TYPE_QUERY_CHANGE_STATUS_REPORT_TASK_FIM_TO_TRAINEE;
|
|
status = "completed";
|
|
msgString = tr("Change task status?\nThe status will be set:\n'completed'");
|
|
}
|
|
else
|
|
{
|
|
typeQuery = TypeQueryToDB::TYPE_QUERY_CHANGE_STATUS_REPORT_TASK_AMM_TO_TRAINEE;
|
|
status = "completed";
|
|
msgString = tr("Change task status?\nThe status will be set:\n'completed'");
|
|
}
|
|
|
|
specialMessageBox = new SpecialMessageBox(this, SpecialMessageBox::TypeSpecMsgBox::warningYesNo, msgString);
|
|
if(specialMessageBox->exec() == QDialog::Accepted)
|
|
{
|
|
connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status);
|
|
this->parentWidget()->close();
|
|
flChanged = true;
|
|
}
|
|
if(specialMessageBox)
|
|
{
|
|
delete specialMessageBox;
|
|
specialMessageBox = nullptr;
|
|
}
|
|
}
|