mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
refact1
This commit is contained in:
588
LibInstructorsAndTrainees/tasks/ammtaskswidget.cpp
Normal file
588
LibInstructorsAndTrainees/tasks/ammtaskswidget.cpp
Normal file
@@ -0,0 +1,588 @@
|
||||
#include <QFile>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QDomDocument>
|
||||
#include <QMessageBox>
|
||||
#include <QThread>
|
||||
#include <QResizeEvent>
|
||||
#include <QScrollBar>
|
||||
#include "ammtaskswidget.h"
|
||||
#include "ui_ammtaskswidget.h"
|
||||
#include "checkertask.h"
|
||||
#include "specialmessagebox.h"
|
||||
#include "widgettools.h"
|
||||
|
||||
AMMtasksWidget::AMMtasksWidget(ConnectorToServer* connectorToServer, TypeListTreeAMMFIM type, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::AMMtasksWidget),
|
||||
connectorToServer(connectorToServer),
|
||||
treeWidget(nullptr),
|
||||
type(type),
|
||||
idTraineeSelected(0),
|
||||
threadPreparation(nullptr),
|
||||
taskTreePreparation(nullptr),
|
||||
waitAnimationWidget(nullptr),
|
||||
dlgCheckerTask(nullptr),
|
||||
dlgListSubProc(nullptr),
|
||||
flOnlyActive(false),
|
||||
lastCurrentID(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
qDebug() << "AMMtasksWidget init thread ID " << QThread::currentThreadId();
|
||||
|
||||
treeWidget = new QTreeWidget();
|
||||
if(type == TypeListTreeAMMFIM::listForTrainee)
|
||||
treeWidget->setObjectName("treeWidget_AMMforTrainee");
|
||||
ui->horizontalLayout_Tree->addWidget(treeWidget);
|
||||
|
||||
connect(treeWidget, &QTreeWidget::itemClicked, this, &AMMtasksWidget::on_treeWidgetItemClicked);
|
||||
connect(treeWidget, &QTreeWidget::itemDoubleClicked, this, &AMMtasksWidget::on_treeWidgetDoubleClicked);
|
||||
|
||||
preparationTreeWidget();
|
||||
|
||||
taskTreePreparation = new TaskAMMFIMTreePreparation(type, treeWidget);
|
||||
if(type == TypeListTreeAMMFIM::listCommon)
|
||||
{
|
||||
threadPreparation = new QThread();
|
||||
taskTreePreparation->moveToThread(threadPreparation);
|
||||
threadPreparation->start();
|
||||
threadPreparation->setPriority(QThread::HighestPriority);
|
||||
}
|
||||
|
||||
connect(this, &AMMtasksWidget::signal_prepareAMMListItems, taskTreePreparation, &TaskAMMFIMTreePreparation::slot_prepareAMMListItems);
|
||||
connect(this, &AMMtasksWidget::signal_prepareAMMListItemsForTrainee, taskTreePreparation, &TaskAMMFIMTreePreparation::slot_prepareAMMListItemsForTrainee);
|
||||
connect(taskTreePreparation, &TaskAMMFIMTreePreparation::signal_listAMMItemsReady, this, &AMMtasksWidget::slot_AMMlistItemsReady);
|
||||
connect(this, &AMMtasksWidget::signal_stopParserPreparation, taskTreePreparation, &TaskAMMFIMTreePreparation::slot_stopParserPreparation);
|
||||
|
||||
connect(this->connectorToServer, &ConnectorToServer::signal_UpdateSubProcForDMCode, this, &AMMtasksWidget::slot_UpdateSubProcForDMCode);
|
||||
|
||||
waitAnimationWidget = new WaitAnimationWidget;
|
||||
QMovie *movie = new QMovie(":/resources/icons/762.gif");
|
||||
waitAnimationWidget->setParent(this);
|
||||
waitAnimationWidget->initialize(movie,this);
|
||||
|
||||
ui->btnDelete->setObjectName("btnDelete");
|
||||
ui->btnDelete->setEnabled(false);
|
||||
ui->btnCheck->setObjectName("btnCheck");
|
||||
ui->btnCheck->setEnabled(false);
|
||||
ui->btnOnlyActive->setObjectName("btnOnlyActive");
|
||||
ui->btnOnlyActive->setEnabled(false);
|
||||
ui->btnAssignTask->setObjectName("btnAssignTask");
|
||||
ui->btnAssignTask->setEnabled(false);
|
||||
ui->btnDocsUpdating->setObjectName("btnDocsUpdating");
|
||||
ui->btnDocsUpdating->setEnabled(false);
|
||||
|
||||
if(type == TypeListTreeAMMFIM::listCommon)
|
||||
{
|
||||
ui->btnDelete->setVisible(false);
|
||||
ui->btnCheck->setVisible(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->btnOnlyActive->setVisible(false);
|
||||
ui->btnAssignTask->setVisible(false);
|
||||
|
||||
ui->label_DocsActualed->setVisible(false);
|
||||
ui->label_Actual->setVisible(false);
|
||||
ui->btnDocsUpdating->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
AMMtasksWidget::~AMMtasksWidget()
|
||||
{
|
||||
waitAnimationWidget->hideWithStop();
|
||||
emit signal_stopParserPreparation();
|
||||
|
||||
|
||||
if(type == TypeListTreeAMMFIM::listCommon)
|
||||
{
|
||||
threadPreparation->quit();
|
||||
threadPreparation->wait();
|
||||
|
||||
delete threadPreparation;
|
||||
}
|
||||
|
||||
delete taskTreePreparation;
|
||||
delete waitAnimationWidget;
|
||||
delete treeWidget;
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void AMMtasksWidget::deactivate()
|
||||
{
|
||||
ui->btnAssignTask->setEnabled(false);
|
||||
ui->btnOnlyActive->setEnabled(false);
|
||||
treeWidget->clear();
|
||||
idTraineeSelected = 0;
|
||||
}
|
||||
|
||||
void AMMtasksWidget::waitAnimationWidgetShowWithPlay()
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
}
|
||||
|
||||
void AMMtasksWidget::setDocsActualed(bool flActualed)
|
||||
{
|
||||
if(flActualed)
|
||||
{
|
||||
ui->label_DocsActualed->setPixmap(QPixmap(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
ui->label_Actual->setText(tr("actual"));
|
||||
ui->btnDocsUpdating->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->label_DocsActualed->setPixmap(QPixmap(QStringLiteral(":/resources/icons/warning.png")));
|
||||
ui->label_Actual->setText(tr("update required"));
|
||||
ui->btnDocsUpdating->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void AMMtasksWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
setWidthColumnsTree();
|
||||
|
||||
QSize size = event->size();
|
||||
waitAnimationWidget->resize(size);
|
||||
}
|
||||
|
||||
void AMMtasksWidget::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
closeChildDlg();
|
||||
}
|
||||
|
||||
void AMMtasksWidget::closeChildDlg()
|
||||
{
|
||||
if(dlgCheckerTask)
|
||||
dlgCheckerTask->close();
|
||||
if(dlgListSubProc)
|
||||
dlgListSubProc->close();
|
||||
}
|
||||
|
||||
void AMMtasksWidget::changeEvent(QEvent *event)
|
||||
{
|
||||
// В случае получения события изменения языка приложения
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
{// переведём окно заново
|
||||
ui->retranslateUi(this);
|
||||
|
||||
reSetHeadTreeWidget();
|
||||
|
||||
if(type == TypeListTreeAMMFIM::listCommon)
|
||||
{
|
||||
//slot_NeedUpdateUI();
|
||||
}
|
||||
else if(type == TypeListTreeAMMFIM::listForTrainee)
|
||||
if(idTraineeSelected)
|
||||
slot_UpdateTasksAMMforTrainee(idTraineeSelected);
|
||||
}
|
||||
}
|
||||
|
||||
void AMMtasksWidget::on_treeWidgetItemClicked(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
if(item == nullptr)
|
||||
{
|
||||
ui->btnDelete->setEnabled(false);
|
||||
ui->btnCheck->setEnabled(false);
|
||||
ui->btnAssignTask->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if(this->type == TypeListTreeAMMFIM::listCommon)
|
||||
{
|
||||
int id = item->text(ColumnsTreeAMM::clmnAMM_ID).toInt();
|
||||
TaskAmmFim task = taskTreePreparation->getTaskAMMbyID(id);
|
||||
|
||||
if(taskTreePreparation->getTypeModuleAMMbyID(id) == ModuleType::TYPE_PM)
|
||||
ui->btnAssignTask->setEnabled(false);
|
||||
else
|
||||
{
|
||||
ui->btnAssignTask->setEnabled(true);
|
||||
}
|
||||
|
||||
if(task.getID())
|
||||
lastCurrentID = id;
|
||||
|
||||
ui->btnDelete->setEnabled(false);
|
||||
ui->btnCheck->setEnabled(false);
|
||||
}
|
||||
else if(this->type == TypeListTreeAMMFIM::listForTrainee)
|
||||
{
|
||||
QTreeWidgetItem *treeItemParent = item->parent();
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбрана задача
|
||||
ui->btnCheck->setEnabled(true);
|
||||
ui->btnDelete->setEnabled(true);
|
||||
|
||||
int id = item->text(ColumnsTreeAMM::clmnAMM_ID).toInt();
|
||||
TaskAmmFim task = taskTreePreparation->getTaskAMMbyID(id);
|
||||
|
||||
if(task.getID())
|
||||
lastCurrentID = id;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->btnCheck->setEnabled(false);
|
||||
ui->btnDelete->setEnabled(false);
|
||||
}
|
||||
ui->btnAssignTask->setEnabled(false);
|
||||
}
|
||||
else
|
||||
lastCurrentID = 0;
|
||||
}
|
||||
|
||||
void AMMtasksWidget::slot_NeedUpdateUI()
|
||||
{
|
||||
qDebug() << "AMMtasksWidget::slot_NeedUpdateUI thread ID " << QThread::currentThreadId();
|
||||
loadTasksAMM();
|
||||
setDocsActualed(true);
|
||||
}
|
||||
|
||||
void AMMtasksWidget::slot_traineeSelected(int id_trainee)
|
||||
{
|
||||
qDebug() << "AMMtasksWidget::slot_traineeSelected thread ID " << QThread::currentThreadId();
|
||||
|
||||
idTraineeSelected = id_trainee;
|
||||
|
||||
if(type == TypeListTreeAMMFIM::listForTrainee)
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_GET_TASKS_AMM_FOR_TRAINEE, idTraineeSelected);
|
||||
}
|
||||
}
|
||||
|
||||
void AMMtasksWidget::slot_UpdateTasksAMMforTrainee(int trainee_id)
|
||||
{
|
||||
qDebug() << "slot_UpdateTasksAMMforTrainee" << QThread::currentThreadId();
|
||||
if(type == TypeListTreeAMMFIM::listForTrainee)
|
||||
{
|
||||
if(idTraineeSelected == trainee_id)
|
||||
{
|
||||
QList<TaskAmmFim> listTask = connectorToServer->getListTasksAMMforTrainee(trainee_id);
|
||||
emit signal_prepareAMMListItemsForTrainee(listTask);
|
||||
|
||||
emit signal_countTasksAMMforTraineeChanged(trainee_id, listTask.count());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AMMtasksWidget::loadTasksAMM(bool flRequestFirst)
|
||||
{
|
||||
//Обновление дерева
|
||||
treeWidget->clear();
|
||||
|
||||
waitAnimationWidget->showWithPlay();
|
||||
|
||||
QByteArray arrayAMM;
|
||||
|
||||
arrayAMM = connectorToServer->getListTaskAmmArray();
|
||||
|
||||
emit signal_prepareAMMListItems(arrayAMM, flOnlyActive, flRequestFirst);
|
||||
}
|
||||
|
||||
void AMMtasksWidget::slot_AMMlistItemsReady(QList<QTreeWidgetItem *> listItems)
|
||||
{
|
||||
if(type != TypeListTreeAMMFIM::listForTrainee)
|
||||
{
|
||||
//Обновление дерева
|
||||
treeWidget->clear();
|
||||
|
||||
for(QTreeWidgetItem * item : listItems)
|
||||
treeWidget->addTopLevelItem(item);
|
||||
}
|
||||
|
||||
/*
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(0);
|
||||
if(item != nullptr)
|
||||
treeWidget->setCurrentItem(item);
|
||||
*/
|
||||
|
||||
if(type == TypeListTreeAMMFIM::listForTrainee)
|
||||
setCurrentTask(lastCurrentID);
|
||||
|
||||
waitAnimationWidget->hideWithStop();
|
||||
|
||||
ui->btnOnlyActive->setEnabled(true);
|
||||
}
|
||||
|
||||
void AMMtasksWidget::slot_UpdateSubProcForDMCode(QString dmCode)
|
||||
{
|
||||
if(lastSelectedTask.ammProcedure.dmCode == dmCode)
|
||||
{//Его ждем
|
||||
QList<SubProc> list = connectorToServer->getListSubProcForDMCode(dmCode);
|
||||
lastSelectedTask.listSubProc = list;
|
||||
|
||||
waitAnimationWidget->hideWithStop();
|
||||
|
||||
if(lastSelectedTask.listSubProc.count())
|
||||
{
|
||||
dlgListSubProc = new DialogListSubProc(this);
|
||||
dlgListSubProc->setTask(&lastSelectedTask);
|
||||
|
||||
switch( dlgListSubProc->exec() )
|
||||
{
|
||||
case QDialog::Accepted:
|
||||
{
|
||||
//Здесь нужно забрать список отмеченных подпроцедур
|
||||
lastSelectedTask.listSubProc.clear();
|
||||
dlgListSubProc->getListCheckedSubProc(&lastSelectedTask.listSubProc);
|
||||
|
||||
if(SpecMsgBox::WarningYesNo(this, tr("Assign this task?")) == QDialog::Accepted)
|
||||
{
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_AMM_TO_TRAINEE, idTraineeSelected, &lastSelectedTask);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QDialog::Rejected:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(dlgListSubProc)
|
||||
{
|
||||
delete dlgListSubProc;
|
||||
dlgListSubProc = nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lastSelectedTask.listSubProc.clear();
|
||||
|
||||
if(SpecMsgBox::WarningYesNo(this, tr("Assign this task?")) == QDialog::Accepted)
|
||||
{
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_AMM_TO_TRAINEE, idTraineeSelected, &lastSelectedTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AMMtasksWidget::preparationTreeWidget()
|
||||
{
|
||||
treeWidget->setColumnCount(clmnAMM_count);
|
||||
|
||||
reSetHeadTreeWidget();
|
||||
|
||||
if(type == TypeListTreeAMMFIM::listCommon)
|
||||
{
|
||||
treeWidget->setColumnHidden(ColumnsTreeAMM::clmnAMM_ID, true);
|
||||
treeWidget->setColumnHidden(ColumnsTreeAMM::clmnAMM_status, true);
|
||||
|
||||
#ifdef PROJECT_TYPE_DEBUG
|
||||
treeWidget->setColumnHidden(ColumnsTreeAMM::clmnAMM_canplay, false);
|
||||
#else
|
||||
treeWidget->setColumnHidden(ColumnsTreeAMM::clmnAMM_canplay, true);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef PROJECT_TYPE_DEBUG
|
||||
treeWidget->setColumnHidden(ColumnsTreeAMM::clmnAMM_ID, false);
|
||||
#else
|
||||
treeWidget->setColumnHidden(ColumnsTreeAMM::clmnAMM_ID, true);
|
||||
#endif
|
||||
|
||||
treeWidget->setColumnHidden(ColumnsTreeAMM::clmnAMM_canplay, true);
|
||||
}
|
||||
|
||||
/*
|
||||
#ifdef PROJECT_TYPE_DEBUG
|
||||
treeWidget->setColumnHidden(ColumnsTreeAMM::clmnAMM_canplay, false);
|
||||
#else
|
||||
treeWidget->setColumnHidden(ColumnsTreeAMM::clmnAMM_canplay, true);
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
|
||||
void AMMtasksWidget::reSetHeadTreeWidget()
|
||||
{
|
||||
QStringList listHeaders;
|
||||
|
||||
if(type == TypeListTreeAMMFIM::listForTrainee)
|
||||
listHeaders = QStringList{tr("Procedure AMM"), tr("DM code"), tr("Status"), tr("Canplay"), tr("ID")};
|
||||
else
|
||||
listHeaders = QStringList{tr("Procedure AMM"), tr("DM code"), tr("Status"), tr("Canplay"), tr("ID")};
|
||||
|
||||
|
||||
treeWidget->setHeaderLabels(listHeaders);
|
||||
}
|
||||
|
||||
void AMMtasksWidget::setWidthColumnsTree()
|
||||
{
|
||||
listWidthColumn.clear();
|
||||
|
||||
treeWidget->setColumnWidth(ColumnsTreeAMM::clmnAMM_PMorDM, 100);
|
||||
listWidthColumn.append(100);
|
||||
treeWidget->setColumnWidth(ColumnsTreeAMM::clmnAMM_code, 250);
|
||||
listWidthColumn.append(250);
|
||||
treeWidget->setColumnWidth(ColumnsTreeAMM::clmnAMM_status, 150);
|
||||
listWidthColumn.append(130);
|
||||
treeWidget->setColumnWidth(ColumnsTreeAMM::clmnAMM_canplay, 80);
|
||||
listWidthColumn.append(80);
|
||||
treeWidget->setColumnWidth(ColumnsTreeAMM::clmnAMM_ID, 50);
|
||||
listWidthColumn.append(50);
|
||||
|
||||
treeWidget->setColumnWidth(ColumnsTreeAMM::clmnAMM_PMorDM, calculateWidth_0Column());
|
||||
}
|
||||
|
||||
int AMMtasksWidget::calculateWidth_0Column()
|
||||
{
|
||||
int widthHeader = treeWidget->width() - 25;
|
||||
int width0Column = 0;
|
||||
int widthSB = 0;
|
||||
if(treeWidget->verticalScrollBar()->isVisible())
|
||||
widthSB = treeWidget->verticalScrollBar()->size().width();
|
||||
int cntColumns = treeWidget->columnCount();
|
||||
int widthRightColumns = 0;
|
||||
for (int i = 1; i < cntColumns; i++)
|
||||
{
|
||||
if(! treeWidget->isColumnHidden(i))
|
||||
{//Колонка не скрыта
|
||||
int w = listWidthColumn.at(i);
|
||||
widthRightColumns += w;
|
||||
}
|
||||
}
|
||||
width0Column = widthHeader - widthRightColumns - widthSB;
|
||||
|
||||
return width0Column;
|
||||
}
|
||||
|
||||
void AMMtasksWidget::assignTaskAMMtoTrainee()
|
||||
{
|
||||
QTreeWidgetItem *current = treeWidget->currentItem();
|
||||
|
||||
if(current == nullptr)
|
||||
return;
|
||||
|
||||
int id = current->text(ColumnsTreeAMM::clmnAMM_ID).toInt();
|
||||
|
||||
TaskAmmFim taskNew = taskTreePreparation->getTaskAMMbyID(id);
|
||||
|
||||
if(taskNew.getID())
|
||||
{
|
||||
if(selectSubProcForAssignTaskAMM(taskNew, &taskNew.listSubProc))
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
bool AMMtasksWidget::selectSubProcForAssignTaskAMM(TaskAmmFim taskNew, QList<SubProc>* listSubProc)
|
||||
{
|
||||
lastSelectedTask = taskNew;
|
||||
|
||||
waitAnimationWidget->showWithPlay();
|
||||
|
||||
if(! connectorToServer->sendQueryListSubProc(lastSelectedTask.ammProcedure.dmCode))
|
||||
{
|
||||
waitAnimationWidget->hideWithStop();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AMMtasksWidget::setCurrentTask(int id)
|
||||
{
|
||||
for(int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(i);
|
||||
if(item != nullptr)
|
||||
if(item->text(ColumnsTreeAMM::clmnAMM_ID).toInt() == id)
|
||||
{
|
||||
treeWidget->setCurrentItem(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AMMtasksWidget::on_btnDelete_clicked()
|
||||
{
|
||||
QTreeWidgetItem *treeItemCurrent = treeWidget->currentItem();
|
||||
|
||||
if(treeItemCurrent != nullptr)
|
||||
{
|
||||
QTreeWidgetItem *treeItemParent = treeItemCurrent->parent();
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбрана задача
|
||||
|
||||
int id = treeItemCurrent->text(ColumnsTreeAMM::clmnAMM_ID).toInt();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AMMtasksWidget::on_btnCheck_clicked()
|
||||
{
|
||||
QTreeWidgetItem *treeItemCurrent = treeWidget->currentItem();
|
||||
|
||||
if(treeItemCurrent != nullptr)
|
||||
{//Выбрана задача
|
||||
|
||||
int id = treeItemCurrent->text(ColumnsTreeAMM::clmnAMM_ID).toInt();
|
||||
|
||||
TaskAmmFim task = taskTreePreparation->getTaskAMMbyID(id);
|
||||
|
||||
if(!task.getID())
|
||||
return;
|
||||
|
||||
dlgCheckerTask = new DialogChekerTask(connectorToServer, "amm", this);
|
||||
dlgCheckerTask->setTask(&task);
|
||||
dlgCheckerTask->exec();
|
||||
|
||||
if(dlgCheckerTask->getFlChanged())
|
||||
waitAnimationWidget->showWithPlay();
|
||||
|
||||
if(dlgCheckerTask)
|
||||
{
|
||||
delete dlgCheckerTask;
|
||||
dlgCheckerTask = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AMMtasksWidget::on_btnAssignTask_clicked()
|
||||
{
|
||||
assignTaskAMMtoTrainee();
|
||||
}
|
||||
|
||||
void AMMtasksWidget::on_btnOnlyActive_clicked()
|
||||
{
|
||||
if(ui->btnOnlyActive->isChecked())
|
||||
{
|
||||
flOnlyActive = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
flOnlyActive = false;
|
||||
}
|
||||
loadTasksAMM(false);
|
||||
}
|
||||
|
||||
void AMMtasksWidget::on_treeWidgetDoubleClicked(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
if(item == nullptr)
|
||||
return;
|
||||
|
||||
int id = item->text(ColumnsTreeAMM::clmnAMM_ID).toInt();
|
||||
|
||||
TaskAmmFim task = taskTreePreparation->getTaskAMMbyID(id);
|
||||
|
||||
if(taskTreePreparation->getTypeModuleAMMbyID(id) == ModuleType::TYPE_PM)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
assignTaskAMMtoTrainee();
|
||||
}
|
||||
}
|
||||
|
||||
void AMMtasksWidget::on_btnDocsUpdating_clicked()
|
||||
{
|
||||
ui->btnAssignTask->setEnabled(false);
|
||||
connectorToServer->sendQueryTasksXML("amm");
|
||||
}
|
||||
113
LibInstructorsAndTrainees/tasks/ammtaskswidget.h
Normal file
113
LibInstructorsAndTrainees/tasks/ammtaskswidget.h
Normal file
@@ -0,0 +1,113 @@
|
||||
#ifndef AMMTASKSWIDGET_H
|
||||
#define AMMTASKSWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTreeWidget>
|
||||
#include <QDomNode>
|
||||
#include "module.h"
|
||||
#include "connectortoserver.h"
|
||||
#include "tasktreepreparation.h"
|
||||
#include "dialogchekertask.h"
|
||||
#include "dialoglistsubproc.h"
|
||||
#include "waitanimationwidget.h"
|
||||
#include "specialmessagebox.h"
|
||||
|
||||
namespace Ui {
|
||||
class AMMtasksWidget;
|
||||
}
|
||||
|
||||
class AMMtasksWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AMMtasksWidget(ConnectorToServer* connectorToServer, TypeListTreeAMMFIM type, QWidget *parent = nullptr);
|
||||
~AMMtasksWidget();
|
||||
|
||||
public:
|
||||
void deactivate();
|
||||
void waitAnimationWidgetShowWithPlay();
|
||||
|
||||
void setDocsActualed(bool flActualed);
|
||||
|
||||
public:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
void closeChildDlg();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent * event) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_treeWidgetItemClicked(QTreeWidgetItem *item, int column);
|
||||
void on_btnDelete_clicked();
|
||||
void on_btnCheck_clicked();
|
||||
void on_btnAssignTask_clicked();
|
||||
void on_btnOnlyActive_clicked(); //AMM
|
||||
|
||||
void on_treeWidgetDoubleClicked(QTreeWidgetItem *item, int column);
|
||||
|
||||
|
||||
void on_btnDocsUpdating_clicked();
|
||||
|
||||
public Q_SLOTS:
|
||||
//Слот обработки сигнала необходимости обновления интерфейса
|
||||
void slot_NeedUpdateUI();
|
||||
//слот обработки сигнала о выборе обучаемого
|
||||
void slot_traineeSelected(int id_trainee);
|
||||
|
||||
void slot_UpdateTasksAMMforTrainee(int trainee_id);
|
||||
|
||||
private:
|
||||
void preparationTreeWidget();
|
||||
void reSetHeadTreeWidget();
|
||||
void setWidthColumnsTree();
|
||||
int calculateWidth_0Column();
|
||||
|
||||
|
||||
void loadTasksAMM(bool flRequestFirst = true);
|
||||
void assignTaskAMMtoTrainee();
|
||||
|
||||
bool selectSubProcForAssignTaskAMM(TaskAmmFim taskNew, QList<SubProc>* listSubProc);
|
||||
|
||||
void setCurrentTask(int id);
|
||||
|
||||
Q_SIGNALS:
|
||||
void signal_prepareAMMListItems(QByteArray array, bool flOnlyActive, bool flRequestFirst);
|
||||
void signal_prepareAMMListItemsForTrainee(QList<TaskAmmFim> listTask);
|
||||
|
||||
void signal_stopParserPreparation();
|
||||
|
||||
void signal_countTasksAMMforTraineeChanged(int trainee_id, int count);
|
||||
|
||||
public Q_SLOTS:
|
||||
void slot_AMMlistItemsReady(QList<QTreeWidgetItem*> listItems);
|
||||
public slots:
|
||||
void slot_UpdateSubProcForDMCode(QString dmCode);
|
||||
|
||||
private:
|
||||
Ui::AMMtasksWidget *ui;
|
||||
ConnectorToServer* connectorToServer;
|
||||
QTreeWidget* treeWidget;
|
||||
TypeListTreeAMMFIM type;
|
||||
QList<int> listWidthColumn;
|
||||
|
||||
int idTraineeSelected;
|
||||
|
||||
QThread* threadPreparation;
|
||||
TaskAMMFIMTreePreparation* taskTreePreparation;
|
||||
WaitAnimationWidget *waitAnimationWidget;
|
||||
|
||||
DialogChekerTask* dlgCheckerTask;
|
||||
|
||||
DialogListSubProc* dlgListSubProc;
|
||||
|
||||
bool flOnlyActive; //AMM
|
||||
|
||||
int lastCurrentID;
|
||||
|
||||
TaskAmmFim lastSelectedTask;
|
||||
};
|
||||
|
||||
#endif // AMMTASKSWIDGET_H
|
||||
254
LibInstructorsAndTrainees/tasks/ammtaskswidget.ui
Normal file
254
LibInstructorsAndTrainees/tasks/ammtaskswidget.ui
Normal file
@@ -0,0 +1,254 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>AMMtasksWidget</class>
|
||||
<widget class="QWidget" name="AMMtasksWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>448</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Tahoma</family>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Tree"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_Btn">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Actual">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_Actual">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_DocsActualed">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../InstructorsAndTrainees.qrc">:/resources/icons/warning.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_Actual">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnDocsUpdating">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Update</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/exchange.png</normaloff>:/resources/icons/exchange.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnCheck">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Status</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/check.png</normaloff>:/resources/icons/check.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnDelete">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/delete.png</normaloff>:/resources/icons/delete.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnOnlyActive">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Аvailable</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/filter.png</normaloff>:/resources/icons/filter.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnAssignTask">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Assign</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/assignTask.png</normaloff>:/resources/icons/assignTask.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../InstructorsAndTrainees.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
212
LibInstructorsAndTrainees/tasks/checkertask.cpp
Normal file
212
LibInstructorsAndTrainees/tasks/checkertask.cpp
Normal file
@@ -0,0 +1,212 @@
|
||||
#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),
|
||||
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;
|
||||
}
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CheckerTask::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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'");
|
||||
}
|
||||
|
||||
if(SpecMsgBox::WarningYesNo(this, msgString) == QDialog::Accepted)
|
||||
{
|
||||
connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status);
|
||||
this->parentWidget()->close();
|
||||
flChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
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'");
|
||||
}
|
||||
|
||||
if(SpecMsgBox::WarningYesNo(this, msgString) == QDialog::Accepted)
|
||||
{
|
||||
connectorToServer->sendQueryToDB(typeQuery, id_task, (void*)&status);
|
||||
this->parentWidget()->close();
|
||||
flChanged = true;
|
||||
}
|
||||
}
|
||||
56
LibInstructorsAndTrainees/tasks/checkertask.h
Normal file
56
LibInstructorsAndTrainees/tasks/checkertask.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef DIALOGCHECKTASK_H
|
||||
#define DIALOGCHECKTASK_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "tasksAmmFim.h"
|
||||
//#include "fimtaskswidget.h"
|
||||
#include "module.h"
|
||||
#include "connectortoserver.h"
|
||||
#include "specialmessagebox.h"
|
||||
|
||||
namespace Ui {
|
||||
class CheckerTask;
|
||||
}
|
||||
|
||||
class FIMtasksWidget;
|
||||
|
||||
class CheckerTask : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CheckerTask(ConnectorToServer* connectorToServer, QString type, QWidget *parent = nullptr);
|
||||
~CheckerTask();
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
public:
|
||||
void setTask(TaskAmmFim* task);
|
||||
TaskAmmFim getTask();
|
||||
bool getFlChanged(){return flChanged;}
|
||||
void setIDTask(int id){id_task = id;}
|
||||
void setModule(Module* module);
|
||||
|
||||
private slots:
|
||||
void on_btnWrong_clicked();
|
||||
void on_btnRight_clicked();
|
||||
|
||||
private:
|
||||
void outReport(FIMReport report);
|
||||
|
||||
private:
|
||||
TaskAmmFim task;
|
||||
Module module;
|
||||
|
||||
private:
|
||||
Ui::CheckerTask *ui;
|
||||
private:
|
||||
ConnectorToServer* connectorToServer;
|
||||
FIMtasksWidget* fimTasksWidget;
|
||||
|
||||
bool flChanged;
|
||||
int id_task;
|
||||
QString type;
|
||||
};
|
||||
|
||||
#endif // DIALOGCHECKTASK_H
|
||||
237
LibInstructorsAndTrainees/tasks/checkertask.ui
Normal file
237
LibInstructorsAndTrainees/tasks/checkertask.ui
Normal file
@@ -0,0 +1,237 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CheckerTask</class>
|
||||
<widget class="QWidget" name="CheckerTask">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>628</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_Task">
|
||||
<property name="text">
|
||||
<string>Task</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblStatusCurrIco">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="../InstructorsAndTrainees.qrc">:/resources/icons/rectGray.png</pixmap>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblStatusCurrText">
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="lblName">
|
||||
<property name="text">
|
||||
<string>Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lblDMcode">
|
||||
<property name="text">
|
||||
<string>DM Code</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Completion Report</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPlainTextEdit" name="plainText">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnWrong">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Failed</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/circleRed.png</normaloff>:/resources/icons/circleRed.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnRight">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Right</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../InstructorsAndTrainees.qrc">
|
||||
<normaloff>:/resources/icons/circleGreen.png</normaloff>:/resources/icons/circleGreen.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../InstructorsAndTrainees.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
48
LibInstructorsAndTrainees/tasks/dialogchekertask.cpp
Normal file
48
LibInstructorsAndTrainees/tasks/dialogchekertask.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#include <QHBoxLayout>
|
||||
#include "dialogchekertask.h"
|
||||
|
||||
DialogChekerTask::DialogChekerTask(ConnectorToServer* connectorToServer, QString type, QWidget *parent) :
|
||||
QDialog(parent,
|
||||
Qt::WindowSystemMenuHint
|
||||
| Qt::WindowMaximizeButtonHint
|
||||
| Qt::WindowMinimizeButtonHint
|
||||
| Qt::WindowCloseButtonHint),
|
||||
checkerTask(nullptr)
|
||||
{
|
||||
checkerTask = new CheckerTask(connectorToServer, type, this);
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
layout->addWidget(checkerTask);
|
||||
this->setWindowTitle(tr("Check Task"));
|
||||
|
||||
if(type == "fim")
|
||||
{
|
||||
this->setMinimumSize(1400, 700);
|
||||
this->setWindowState(Qt::WindowMaximized);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->setMinimumSize(400, 200);
|
||||
}
|
||||
this->setModal(true);
|
||||
}
|
||||
|
||||
DialogChekerTask::~DialogChekerTask()
|
||||
{
|
||||
delete checkerTask;
|
||||
}
|
||||
|
||||
void DialogChekerTask::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
checkerTask->close();
|
||||
}
|
||||
|
||||
void DialogChekerTask::setTask(TaskAmmFim *task)
|
||||
{
|
||||
checkerTask->setTask(task);
|
||||
}
|
||||
|
||||
bool DialogChekerTask::getFlChanged()
|
||||
{
|
||||
return checkerTask->getFlChanged();
|
||||
}
|
||||
25
LibInstructorsAndTrainees/tasks/dialogchekertask.h
Normal file
25
LibInstructorsAndTrainees/tasks/dialogchekertask.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef DIALOGCHEKERTASK_H
|
||||
#define DIALOGCHEKERTASK_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QObject>
|
||||
#include "checkertask.h"
|
||||
|
||||
class DialogChekerTask : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DialogChekerTask(ConnectorToServer* connectorToServer, QString type, QWidget *parent = nullptr);
|
||||
~DialogChekerTask();
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
public:
|
||||
void setTask(TaskAmmFim* task);
|
||||
bool getFlChanged();
|
||||
|
||||
private:
|
||||
CheckerTask* checkerTask;
|
||||
};
|
||||
|
||||
#endif // DIALOGCHEKERTASK_H
|
||||
46
LibInstructorsAndTrainees/tasks/dialoglistsubproc.cpp
Normal file
46
LibInstructorsAndTrainees/tasks/dialoglistsubproc.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include <QHBoxLayout>
|
||||
#include "dialoglistsubproc.h"
|
||||
|
||||
DialogListSubProc::DialogListSubProc(QWidget *parent) :
|
||||
QDialog(parent,
|
||||
Qt::WindowSystemMenuHint
|
||||
| Qt::WindowMaximizeButtonHint
|
||||
| Qt::WindowMinimizeButtonHint
|
||||
| Qt::WindowCloseButtonHint),
|
||||
listSubProcCtrl(nullptr)
|
||||
{
|
||||
listSubProcCtrl = new ListSubProc(this);
|
||||
connect(listSubProcCtrl, &ListSubProc::signal_Accepted, this, &DialogListSubProc::slot_Accepted);
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
layout->addWidget(listSubProcCtrl);
|
||||
this->setWindowTitle(tr("List subprocedures"));
|
||||
|
||||
this->setMinimumSize(1400, 700);
|
||||
this->setModal(true);
|
||||
}
|
||||
|
||||
DialogListSubProc::~DialogListSubProc()
|
||||
{
|
||||
delete listSubProcCtrl;
|
||||
}
|
||||
|
||||
void DialogListSubProc::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
listSubProcCtrl->close();
|
||||
}
|
||||
|
||||
void DialogListSubProc::slot_Accepted()
|
||||
{
|
||||
this->accept();
|
||||
}
|
||||
|
||||
void DialogListSubProc::setTask(TaskAmmFim *task)
|
||||
{
|
||||
listSubProcCtrl->setTask(task);
|
||||
}
|
||||
|
||||
bool DialogListSubProc::getListCheckedSubProc(QList<SubProc>* listSubProc)
|
||||
{
|
||||
return listSubProcCtrl->getListCheckedSubProc(listSubProc);
|
||||
}
|
||||
30
LibInstructorsAndTrainees/tasks/dialoglistsubproc.h
Normal file
30
LibInstructorsAndTrainees/tasks/dialoglistsubproc.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef DIALOGLISTSUBPROC_H
|
||||
#define DIALOGLISTSUBPROC_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDialog>
|
||||
|
||||
#include "connectortoserver.h"
|
||||
#include "listsubproc.h"
|
||||
|
||||
class DialogListSubProc : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DialogListSubProc(QWidget *parent = nullptr);
|
||||
~DialogListSubProc();
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
public slots:
|
||||
void slot_Accepted();
|
||||
|
||||
public:
|
||||
void setTask(TaskAmmFim* task);
|
||||
bool getListCheckedSubProc(QList<SubProc>* listSubProcCtrl);
|
||||
|
||||
private:
|
||||
ListSubProc* listSubProcCtrl;
|
||||
};
|
||||
|
||||
#endif // DIALOGLISTSUBPROC_H
|
||||
31
LibInstructorsAndTrainees/tasks/dialogtaskscommon.cpp
Normal file
31
LibInstructorsAndTrainees/tasks/dialogtaskscommon.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <QHBoxLayout>
|
||||
#include "dialogtaskscommon.h"
|
||||
|
||||
DialogTasksCommon::DialogTasksCommon(ConnectorToServer* connectorToServer, AMMtasksWidget* ammTasksWidget_common, FIMtasksWidget* fimTasksWidget_common,
|
||||
QWidget *parent) :
|
||||
QDialog(parent,
|
||||
Qt::WindowSystemMenuHint
|
||||
| Qt::WindowMaximizeButtonHint
|
||||
| Qt::WindowMinimizeButtonHint
|
||||
| Qt::WindowCloseButtonHint),
|
||||
viewerTasks(nullptr)
|
||||
{
|
||||
viewerTasks = new ViewerTasksCommon(connectorToServer, ammTasksWidget_common, fimTasksWidget_common, this);
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout(this);
|
||||
layout->addWidget(viewerTasks);
|
||||
this->setWindowTitle(tr("Viewer tasks common"));
|
||||
this->setMinimumSize(1400, 700);
|
||||
this->setWindowState(Qt::WindowMaximized);
|
||||
this->setModal(true);
|
||||
}
|
||||
|
||||
DialogTasksCommon::~DialogTasksCommon()
|
||||
{
|
||||
delete viewerTasks;
|
||||
}
|
||||
|
||||
void DialogTasksCommon::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
viewerTasks->close();
|
||||
}
|
||||
24
LibInstructorsAndTrainees/tasks/dialogtaskscommon.h
Normal file
24
LibInstructorsAndTrainees/tasks/dialogtaskscommon.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef DIALOGTASKSCOMMON_H
|
||||
#define DIALOGTASKSCOMMON_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QDialog>
|
||||
|
||||
#include "viewertaskscommon.h"
|
||||
|
||||
|
||||
class DialogTasksCommon : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DialogTasksCommon(ConnectorToServer* connectorToServer, AMMtasksWidget* ammTasksWidget_common, FIMtasksWidget* fimTasksWidget_common,
|
||||
QWidget *parent = nullptr);
|
||||
~DialogTasksCommon();
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private:
|
||||
ViewerTasksCommon* viewerTasks;
|
||||
};
|
||||
|
||||
#endif // DIALOGTASKSCOMMON_H
|
||||
505
LibInstructorsAndTrainees/tasks/fimtaskswidget.cpp
Normal file
505
LibInstructorsAndTrainees/tasks/fimtaskswidget.cpp
Normal file
@@ -0,0 +1,505 @@
|
||||
#include <QDomDocument>
|
||||
#include <QFile>
|
||||
#include <QMessageBox>
|
||||
#include <QTreeWidget>
|
||||
#include <QThread>
|
||||
#include <QResizeEvent>
|
||||
#include <QScrollBar>
|
||||
#include "fimtaskswidget.h"
|
||||
#include "ui_fimtaskswidget.h"
|
||||
#include "tasksAmmFim.h"
|
||||
#include "checkertask.h"
|
||||
#include "specialmessagebox.h"
|
||||
|
||||
FIMtasksWidget::FIMtasksWidget(ConnectorToServer* connectorToServer, TypeListTreeAMMFIM type, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::FIMtasksWidget),
|
||||
connectorToServer(connectorToServer),
|
||||
treeWidget(nullptr),
|
||||
type(type),
|
||||
idTraineeSelected(0),
|
||||
threadPreparation(nullptr),
|
||||
taskTreePreparation(nullptr),
|
||||
waitAnimationWidget(nullptr),
|
||||
dlgCheckerTask(nullptr),
|
||||
userName(""),
|
||||
lastCurrentID(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
qDebug() << "FIMtasksWidget init thread ID " << QThread::currentThreadId();
|
||||
|
||||
treeWidget = new QTreeWidget();
|
||||
ui->horizontalLayout_Tree->addWidget(treeWidget);
|
||||
|
||||
//connect(treeWidget, &QTreeWidget::currentItemChanged, this, &FIMtasksWidget::on_treeWidgetCurrentItemChanged);
|
||||
connect(treeWidget, &QTreeWidget::itemClicked, this, &FIMtasksWidget::on_treeWidgetItemClicked);
|
||||
|
||||
preparationTreeWidget();
|
||||
|
||||
threadPreparation = new QThread();
|
||||
taskTreePreparation = new TaskAMMFIMTreePreparation(type, treeWidget);
|
||||
taskTreePreparation->moveToThread(threadPreparation);
|
||||
threadPreparation->start();
|
||||
threadPreparation->setPriority(QThread::HighestPriority);
|
||||
connect(this, &FIMtasksWidget::signal_prepareFIMListItems, taskTreePreparation, &TaskAMMFIMTreePreparation::slot_prepareFIMListItems);
|
||||
connect(this, &FIMtasksWidget::signal_prepareFIMListItemsForTrainee, taskTreePreparation, &TaskAMMFIMTreePreparation::slot_prepareFIMListItemsForTrainee);
|
||||
connect(taskTreePreparation, &TaskAMMFIMTreePreparation::signal_listFIMItemsReady, this, &FIMtasksWidget::slot_FIMlistItemsReady);
|
||||
connect(this, &FIMtasksWidget::signal_stopParserPreparation, taskTreePreparation, &TaskAMMFIMTreePreparation::slot_stopParserPreparation);
|
||||
|
||||
waitAnimationWidget = new WaitAnimationWidget;
|
||||
QMovie *movie = new QMovie(":/resources/icons/762.gif");
|
||||
waitAnimationWidget->setParent(this);
|
||||
waitAnimationWidget->initialize(movie,this);
|
||||
|
||||
ui->btnDelete->setObjectName("btnDelete");
|
||||
ui->btnDelete->setEnabled(false);
|
||||
ui->btnCheck->setObjectName("btnCheck");
|
||||
ui->btnCheck->setEnabled(false);
|
||||
ui->btnAssignTask->setObjectName("btnAssignTask");
|
||||
ui->btnAssignTask->setEnabled(false);
|
||||
|
||||
if(type == TypeListTreeAMMFIM::listCommon)
|
||||
{
|
||||
//ui->horizontalLayout_3->addWidget(ui->btnAssignTask);
|
||||
//ui->horizontalLayout_3->addWidget(ui->btnCheck);
|
||||
//ui->horizontalLayout_3->addWidget(ui->btnDelete);
|
||||
//ui->horizontalLayout_3->setAlignment(Qt::AlignmentFlag::AlignLeft);
|
||||
|
||||
ui->btnDelete->setVisible(false);
|
||||
ui->btnCheck->setVisible(false);
|
||||
}
|
||||
else if(type == TypeListTreeAMMFIM::listOneTask)
|
||||
{
|
||||
ui->btnDelete->setVisible(false);
|
||||
ui->btnCheck->setVisible(false);
|
||||
ui->btnAssignTask->setVisible(false);
|
||||
this->treeWidget->headerItem()->setHidden(true);
|
||||
this->treeWidget->setSelectionMode(QAbstractItemView::SelectionMode::NoSelection);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->btnAssignTask->setVisible(false);
|
||||
|
||||
//ui->verticalLayout->setAlignment(Qt::AlignmentFlag::AlignBottom);
|
||||
//ui->horizontalLayout_3->setAlignment(Qt::AlignmentFlag::AlignLeft);
|
||||
}
|
||||
}
|
||||
|
||||
FIMtasksWidget::~FIMtasksWidget()
|
||||
{
|
||||
waitAnimationWidget->hideWithStop();
|
||||
emit signal_stopParserPreparation();
|
||||
|
||||
threadPreparation->quit();
|
||||
threadPreparation->wait();
|
||||
|
||||
delete threadPreparation;
|
||||
|
||||
delete taskTreePreparation;
|
||||
delete waitAnimationWidget;
|
||||
delete treeWidget;
|
||||
|
||||
if(dlgCheckerTask)
|
||||
dlgCheckerTask->close();
|
||||
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FIMtasksWidget::deactivate()
|
||||
{
|
||||
ui->btnAssignTask->setEnabled(false);
|
||||
treeWidget->clear();
|
||||
idTraineeSelected = 0;
|
||||
}
|
||||
|
||||
void FIMtasksWidget::setOneTaskFim(TaskAmmFim* task)
|
||||
{
|
||||
QList<TaskAmmFim> listTask;
|
||||
listTask.append(*task);
|
||||
emit signal_prepareFIMListItemsForTrainee(listTask);
|
||||
}
|
||||
|
||||
void FIMtasksWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
setWidthColumnsTree();
|
||||
|
||||
QSize size = event->size();
|
||||
waitAnimationWidget->resize(size);
|
||||
}
|
||||
|
||||
void FIMtasksWidget::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
closeChildDlg();
|
||||
}
|
||||
|
||||
void FIMtasksWidget::closeChildDlg()
|
||||
{
|
||||
if(dlgCheckerTask)
|
||||
dlgCheckerTask->close();
|
||||
}
|
||||
|
||||
void FIMtasksWidget::changeEvent(QEvent *event)
|
||||
{
|
||||
// В случае получения события изменения языка приложения
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
{// переведём окно заново
|
||||
ui->retranslateUi(this);
|
||||
|
||||
reSetHeadTreeWidget();
|
||||
|
||||
if(type == TypeListTreeAMMFIM::listCommon)
|
||||
{
|
||||
//slot_NeedUpdateUI();
|
||||
}
|
||||
else if(type == TypeListTreeAMMFIM::listForTrainee)
|
||||
if(idTraineeSelected)
|
||||
slot_UpdateTasksFIMforTrainee(idTraineeSelected);
|
||||
}
|
||||
}
|
||||
|
||||
void FIMtasksWidget::on_treeWidgetItemClicked(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
if(item == nullptr)
|
||||
{
|
||||
ui->btnDelete->setEnabled(false);
|
||||
ui->btnCheck->setEnabled(false);
|
||||
ui->btnAssignTask->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *treeItemParent = item->parent();
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбрана задача
|
||||
int id = item->text(ColumnsTreeFIM::clmnFIM_ID).toInt();
|
||||
|
||||
TaskAmmFim task = taskTreePreparation->getTaskFIMbyID(id);
|
||||
|
||||
if(!task.getID())
|
||||
{
|
||||
ui->btnAssignTask->setEnabled(false);
|
||||
|
||||
ui->btnDelete->setEnabled(false);
|
||||
ui->btnCheck->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
lastCurrentID = task.getID();
|
||||
}
|
||||
|
||||
ui->btnAssignTask->setEnabled(true);
|
||||
|
||||
ui->btnDelete->setEnabled(true);
|
||||
|
||||
if(task.status != "new")
|
||||
ui->btnCheck->setEnabled(true);
|
||||
else
|
||||
ui->btnCheck->setEnabled(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
setCurrentParentTask(item);
|
||||
|
||||
/*
|
||||
ui->btnAssignTask->setEnabled(false);
|
||||
|
||||
ui->btnDelete->setEnabled(false);
|
||||
ui->btnCheck->setEnabled(false);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
void FIMtasksWidget::slot_NeedUpdateUI()
|
||||
{
|
||||
qDebug() << "FIMtasksWidget::slot_NeedUpdateUI thread ID " << QThread::currentThreadId();
|
||||
loadTasksFIM();
|
||||
}
|
||||
|
||||
void FIMtasksWidget::slot_traineeSelected(int id_trainee)
|
||||
{
|
||||
qDebug() << "FIMtasksWidget::slot_traineeSelected thread ID " << QThread::currentThreadId();
|
||||
|
||||
idTraineeSelected = id_trainee;
|
||||
|
||||
if(type == TypeListTreeAMMFIM::listForTrainee)
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_GET_TASKS_FIM_FOR_TRAINEE, idTraineeSelected);
|
||||
}
|
||||
}
|
||||
|
||||
void FIMtasksWidget::slot_UpdateTasksFIMforTrainee(int trainee_id)
|
||||
{
|
||||
qDebug() << "slot_UpdateTasksFIMforTrainee" << QThread::currentThreadId();
|
||||
if(type == TypeListTreeAMMFIM::listForTrainee)
|
||||
{
|
||||
if(idTraineeSelected == trainee_id)
|
||||
{
|
||||
QList<TaskAmmFim> listTask = connectorToServer->getListTasksFIMforTrainee(trainee_id);
|
||||
emit signal_prepareFIMListItemsForTrainee(listTask);
|
||||
|
||||
emit signal_countTasksFIMforTraineeChanged(trainee_id, listTask.count());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FIMtasksWidget::waitAnimationWidgetShowWithPlay()
|
||||
{
|
||||
waitAnimationWidget->showWithPlay();
|
||||
}
|
||||
|
||||
void FIMtasksWidget::loadTasksFIM()
|
||||
{
|
||||
//Обновление дерева
|
||||
treeWidget->clear();
|
||||
|
||||
waitAnimationWidget->showWithPlay();
|
||||
|
||||
QByteArray arrayFIM = connectorToServer->getListTaskFimArray();
|
||||
|
||||
emit signal_prepareFIMListItems(arrayFIM);
|
||||
}
|
||||
|
||||
void FIMtasksWidget::slot_FIMlistItemsReady(QList<QTreeWidgetItem *> listItems)
|
||||
{
|
||||
//Обновление дерева
|
||||
treeWidget->clear();
|
||||
|
||||
for(QTreeWidgetItem * item : listItems)
|
||||
treeWidget->addTopLevelItem(item);
|
||||
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(0);
|
||||
if(item != nullptr)
|
||||
{
|
||||
//treeWidget->setCurrentItem(item);
|
||||
if(type == TypeListTreeAMMFIM::listOneTask)
|
||||
treeWidget->expandAll();
|
||||
}
|
||||
|
||||
setCurrentTask(lastCurrentID);
|
||||
|
||||
waitAnimationWidget->hideWithStop();
|
||||
}
|
||||
|
||||
void FIMtasksWidget::preparationTreeWidget()
|
||||
{
|
||||
treeWidget->setColumnCount(clmnFIM_count);
|
||||
|
||||
reSetHeadTreeWidget();
|
||||
|
||||
if(type == TypeListTreeAMMFIM::listCommon || type == TypeListTreeAMMFIM::listOneTask)
|
||||
{
|
||||
treeWidget->setColumnHidden(ColumnsTreeFIM::clmnFIM_ID, true);
|
||||
treeWidget->setColumnHidden(ColumnsTreeFIM::clmnFIM_status, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef PROJECT_TYPE_DEBUG
|
||||
treeWidget->setColumnHidden(ColumnsTreeFIM::clmnFIM_ID, false);
|
||||
#else
|
||||
treeWidget->setColumnHidden(ColumnsTreeFIM::clmnFIM_ID, true);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void FIMtasksWidget::reSetHeadTreeWidget()
|
||||
{
|
||||
QStringList listHeaders;
|
||||
|
||||
if(type == TypeListTreeAMMFIM::listForTrainee)
|
||||
listHeaders = QStringList{tr("Procedure FIM"), tr("Status"), tr("ID")};
|
||||
else
|
||||
listHeaders = QStringList{tr("Procedure FIM"), tr("Status"), tr("ID")};
|
||||
|
||||
treeWidget->setHeaderLabels(listHeaders);
|
||||
}
|
||||
|
||||
void FIMtasksWidget::setWidthColumnsTree()
|
||||
{
|
||||
listWidthColumn.clear();
|
||||
|
||||
treeWidget->setColumnWidth(ColumnsTreeFIM::clmnFIM_Title, 100);
|
||||
listWidthColumn.append(100);
|
||||
treeWidget->setColumnWidth(ColumnsTreeFIM::clmnFIM_status, 150);
|
||||
listWidthColumn.append(130);
|
||||
treeWidget->setColumnWidth(ColumnsTreeFIM::clmnFIM_ID, 50);
|
||||
listWidthColumn.append(50);
|
||||
|
||||
treeWidget->setColumnWidth(ColumnsTreeFIM::clmnFIM_Title, calculateWidth_0Column());
|
||||
}
|
||||
|
||||
int FIMtasksWidget::calculateWidth_0Column()
|
||||
{
|
||||
int widthHeader = treeWidget->width() - 25;
|
||||
int width0Column = 0;
|
||||
int widthSB = 0;
|
||||
if(treeWidget->verticalScrollBar()->isVisible())
|
||||
widthSB = treeWidget->verticalScrollBar()->size().width();
|
||||
int cntColumns = treeWidget->columnCount();
|
||||
int widthRightColumns = 0;
|
||||
for (int i = 1; i < cntColumns; i++)
|
||||
{
|
||||
if(! treeWidget->isColumnHidden(i))
|
||||
{//Колонка не скрыта
|
||||
int w = listWidthColumn.at(i);
|
||||
widthRightColumns += w;
|
||||
}
|
||||
}
|
||||
width0Column = widthHeader - widthRightColumns - widthSB;
|
||||
|
||||
return width0Column;
|
||||
}
|
||||
|
||||
void FIMtasksWidget::assignTaskFIMtoTrainee()
|
||||
{
|
||||
QTreeWidgetItem *current = treeWidget->currentItem();
|
||||
|
||||
if(current == nullptr)
|
||||
return;
|
||||
|
||||
int id = current->text(ColumnsTreeFIM::clmnFIM_ID).toInt();
|
||||
|
||||
TaskAmmFim task = taskTreePreparation->getTaskFIMbyID(id);
|
||||
|
||||
if(task.getID())
|
||||
{
|
||||
TaskAmmFim taskNew;
|
||||
taskNew.title = task.title;
|
||||
|
||||
//Назначенные неисправности
|
||||
for (int i = 0; i < current->childCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem* itemMalfunction = current->child(i);
|
||||
|
||||
if(itemMalfunction->checkState(0) == Qt::Checked)
|
||||
{
|
||||
Malfunction malfunction = task.malfunctionList.at(i);
|
||||
taskNew.malfunctionList.append(malfunction);
|
||||
}
|
||||
}
|
||||
|
||||
connectorToServer->sendQueryToDB(TypeQueryToDB::TYPE_QUERY_ASSIGN_TASK_FIM_TO_TRAINEE, idTraineeSelected, &taskNew);
|
||||
|
||||
updateTaskItem(current);
|
||||
}
|
||||
}
|
||||
|
||||
void FIMtasksWidget::on_btnDelete_clicked()
|
||||
{
|
||||
QTreeWidgetItem *treeItemCurrent = treeWidget->currentItem();
|
||||
|
||||
if(treeItemCurrent != nullptr)
|
||||
{
|
||||
QTreeWidgetItem *treeItemParent = treeItemCurrent->parent();
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбрана задача
|
||||
|
||||
int id = treeItemCurrent->text(ColumnsTreeFIM::clmnFIM_ID).toInt();
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FIMtasksWidget::on_btnCheck_clicked()
|
||||
{
|
||||
QTreeWidgetItem *treeItemCurrent = treeWidget->currentItem();
|
||||
|
||||
if(treeItemCurrent != nullptr)
|
||||
{
|
||||
QTreeWidgetItem *treeItemParent = treeItemCurrent->parent();
|
||||
if(treeItemParent == nullptr)
|
||||
{//Выбрана задача
|
||||
|
||||
int id = treeItemCurrent->text(ColumnsTreeFIM::clmnFIM_ID).toInt();
|
||||
|
||||
TaskAmmFim task = taskTreePreparation->getTaskFIMbyID(id);
|
||||
|
||||
if(!task.getID())
|
||||
return;
|
||||
|
||||
dlgCheckerTask = new DialogChekerTask(connectorToServer, "fim", this);
|
||||
dlgCheckerTask->setTask(&task);
|
||||
dlgCheckerTask->exec();
|
||||
|
||||
if(dlgCheckerTask->getFlChanged())
|
||||
waitAnimationWidget->showWithPlay();
|
||||
|
||||
if(dlgCheckerTask)
|
||||
{
|
||||
delete dlgCheckerTask;
|
||||
dlgCheckerTask = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FIMtasksWidget::on_btnAssignTask_clicked()
|
||||
{
|
||||
if(SpecMsgBox::WarningYesNo(this, tr("Assign this task?")) == QDialog::Accepted)
|
||||
assignTaskFIMtoTrainee();
|
||||
}
|
||||
|
||||
void FIMtasksWidget::updateTaskItem(QTreeWidgetItem *itemTask)
|
||||
{
|
||||
for (int i = 0; i < itemTask->childCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem* itemMalfunction = itemTask->child(i);
|
||||
itemMalfunction->setCheckState(0, Qt::Checked);
|
||||
itemMalfunction->setExpanded(false);
|
||||
}
|
||||
itemTask->setExpanded(false);
|
||||
}
|
||||
|
||||
void FIMtasksWidget::setCurrentTask(int id)
|
||||
{
|
||||
for(int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(i);
|
||||
if(item != nullptr)
|
||||
if(item->text(ColumnsTreeFIM::clmnFIM_ID).toInt() == id)
|
||||
{
|
||||
treeWidget->setCurrentItem(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FIMtasksWidget::setCurrentParentTask(QTreeWidgetItem *item)
|
||||
{
|
||||
if(item == nullptr)
|
||||
return;
|
||||
|
||||
int id = 0;
|
||||
|
||||
QTreeWidgetItem *treeItemParent = item->parent();
|
||||
if(treeItemParent == nullptr)
|
||||
{//задача
|
||||
id = item->text(ColumnsTreeFIM::clmnFIM_ID).toInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
QTreeWidgetItem *treeItemParent1 = treeItemParent->parent();
|
||||
if(treeItemParent1 == nullptr)
|
||||
{//задача
|
||||
id = treeItemParent->text(ColumnsTreeFIM::clmnFIM_ID).toInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
QTreeWidgetItem *treeItemParent2 = treeItemParent1->parent();
|
||||
if(treeItemParent2 == nullptr)
|
||||
{//задача
|
||||
id = treeItemParent1->text(ColumnsTreeFIM::clmnFIM_ID).toInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(id)
|
||||
setCurrentTask(id);
|
||||
}
|
||||
|
||||
|
||||
100
LibInstructorsAndTrainees/tasks/fimtaskswidget.h
Normal file
100
LibInstructorsAndTrainees/tasks/fimtaskswidget.h
Normal file
@@ -0,0 +1,100 @@
|
||||
#ifndef FIMTASKSWIDGET_H
|
||||
#define FIMTASKSWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTreeWidget>
|
||||
#include "tasksAmmFim.h"
|
||||
#include "connectortoserver.h"
|
||||
#include "tasktreepreparation.h"
|
||||
#include "dialogchekertask.h"
|
||||
#include "waitanimationwidget.h"
|
||||
#include "specialmessagebox.h"
|
||||
|
||||
namespace Ui {
|
||||
class FIMtasksWidget;
|
||||
}
|
||||
|
||||
class FIMtasksWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
|
||||
|
||||
public:
|
||||
explicit FIMtasksWidget(ConnectorToServer* connectorToServer, TypeListTreeAMMFIM type, QWidget *parent = nullptr);
|
||||
~FIMtasksWidget();
|
||||
|
||||
public:
|
||||
void deactivate();
|
||||
void setOneTaskFim(TaskAmmFim* task); //FIM
|
||||
void waitAnimationWidgetShowWithPlay();
|
||||
|
||||
public:
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
void closeChildDlg();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent * event) override;
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_treeWidgetItemClicked(QTreeWidgetItem *item, int column);
|
||||
void on_btnDelete_clicked();
|
||||
void on_btnCheck_clicked();
|
||||
void on_btnAssignTask_clicked();
|
||||
|
||||
public Q_SLOTS:
|
||||
//Слот обработки сигнала необходимости обновления интерфейса
|
||||
void slot_NeedUpdateUI();
|
||||
//слот обработки сигнала о выборе обучаемого
|
||||
void slot_traineeSelected(int id_trainee);
|
||||
|
||||
void slot_UpdateTasksFIMforTrainee(int trainee_id);
|
||||
|
||||
private:
|
||||
void preparationTreeWidget();
|
||||
void reSetHeadTreeWidget();
|
||||
void setWidthColumnsTree();
|
||||
int calculateWidth_0Column();
|
||||
|
||||
void loadTasksFIM();
|
||||
void assignTaskFIMtoTrainee();
|
||||
void updateTaskItem(QTreeWidgetItem *itemTask);
|
||||
|
||||
void setCurrentTask(int id);
|
||||
void setCurrentParentTask(QTreeWidgetItem *item);
|
||||
|
||||
Q_SIGNALS:
|
||||
void signal_prepareFIMListItems(QByteArray array);
|
||||
void signal_prepareFIMListItemsForTrainee(QList<TaskAmmFim> listTask);
|
||||
|
||||
void signal_stopParserPreparation();
|
||||
|
||||
void signal_countTasksFIMforTraineeChanged(int trainee_id, int count);
|
||||
|
||||
public Q_SLOTS:
|
||||
void slot_FIMlistItemsReady(QList<QTreeWidgetItem*> listItems);
|
||||
|
||||
private:
|
||||
Ui::FIMtasksWidget *ui;
|
||||
ConnectorToServer* connectorToServer;
|
||||
QTreeWidget* treeWidget;
|
||||
TypeListTreeAMMFIM type;
|
||||
QList<int> listWidthColumn;
|
||||
|
||||
int idTraineeSelected;
|
||||
|
||||
QThread* threadPreparation;
|
||||
TaskAMMFIMTreePreparation* taskTreePreparation;
|
||||
WaitAnimationWidget *waitAnimationWidget;
|
||||
|
||||
DialogChekerTask* dlgCheckerTask;
|
||||
|
||||
QString userName; //FIM
|
||||
|
||||
int lastCurrentID;
|
||||
};
|
||||
|
||||
#endif // FIMTASKSWIDGET_H
|
||||
135
LibInstructorsAndTrainees/tasks/fimtaskswidget.ui
Normal file
135
LibInstructorsAndTrainees/tasks/fimtaskswidget.ui
Normal file
@@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FIMtasksWidget</class>
|
||||
<widget class="QWidget" name="FIMtasksWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>472</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Tree"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_Btn">
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnAssignTask">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Assign</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/resources/icons/assignTask.png</normaloff>:/resources/icons/assignTask.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnCheck">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Check</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/resources/icons/check.png</normaloff>:/resources/icons/check.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnDelete">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../resources.qrc">
|
||||
<normaloff>:/resources/icons/delete.png</normaloff>:/resources/icons/delete.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
167
LibInstructorsAndTrainees/tasks/listsubproc.cpp
Normal file
167
LibInstructorsAndTrainees/tasks/listsubproc.cpp
Normal file
@@ -0,0 +1,167 @@
|
||||
#include <QScrollBar>
|
||||
#include "listsubproc.h"
|
||||
#include "ui_listsubproc.h"
|
||||
|
||||
ListSubProc::ListSubProc(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::ListSubProc),
|
||||
treeWidget(nullptr)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->btnAssign->setObjectName("btnAssign");
|
||||
|
||||
treeWidget = new QTreeWidget();
|
||||
ui->horizontalLayout_Tree->addWidget(treeWidget);
|
||||
|
||||
preparationTreeWidget();
|
||||
}
|
||||
|
||||
ListSubProc::~ListSubProc()
|
||||
{
|
||||
delete treeWidget;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ListSubProc::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ListSubProc::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
setWidthColumnsTree();
|
||||
}
|
||||
|
||||
void ListSubProc::changeEvent(QEvent *event)
|
||||
{
|
||||
// В случае получения события изменения языка приложения
|
||||
if (event->type() == QEvent::LanguageChange)
|
||||
{// переведём окно заново
|
||||
ui->retranslateUi(this);
|
||||
|
||||
reSetHeadTreeWidget();
|
||||
}
|
||||
}
|
||||
|
||||
void ListSubProc::setTask(TaskAmmFim *task)
|
||||
{
|
||||
this->task = *task;
|
||||
|
||||
ui->lbl_Title->setText(task->ammProcedure.title);
|
||||
ui->lbl_DMCode->setText(task->ammProcedure.dmCode);
|
||||
|
||||
QList<SubProc> list = task->listSubProc;
|
||||
|
||||
for(SubProc subProc : list)
|
||||
{
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem(treeWidget);
|
||||
//item->setIcon(0, QIcon(":/resources/icons/link.png"));
|
||||
item->setText(ColumnsTreeSubProc::clmnSP_title, subProc.getTitle());
|
||||
item->setText(ColumnsTreeSubProc::clmnSP_code, subProc.getDmCode());
|
||||
item->setText(ColumnsTreeSubProc::clmnSP_canplay, subProc.getModeListStr());
|
||||
item->setToolTip(ColumnsTreeSubProc::clmnSP_title, subProc.getTitle());
|
||||
|
||||
ModeList modeList = subProc.getModeList();
|
||||
if(modeList.autoM && (modeList.demo || modeList.train || modeList.exam))
|
||||
{
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
item->setCheckState(ColumnsTreeSubProc::clmnSP_title, Qt::Checked);
|
||||
|
||||
treeWidget->addTopLevelItem(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
item->setCheckState(ColumnsTreeSubProc::clmnSP_title, Qt::Unchecked);
|
||||
|
||||
//item->setFlags(item->flags() ^ Qt::ItemIsEnabled);
|
||||
|
||||
#ifdef PROJECT_TYPE_DEBUG
|
||||
treeWidget->addTopLevelItem(item);
|
||||
#else
|
||||
item->setFlags(item->flags() ^ Qt::ItemIsEnabled);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ListSubProc::getListCheckedSubProc(QList<SubProc>* listSubProc)
|
||||
{
|
||||
//Заполнение списка отмеченных ПП
|
||||
for (int i = 0; i < treeWidget->topLevelItemCount(); i++)
|
||||
{
|
||||
QTreeWidgetItem *item = treeWidget->topLevelItem(i);
|
||||
if(item->checkState(0) == Qt::Checked)
|
||||
{
|
||||
SubProc subProc;
|
||||
subProc.setDmCode(item->text(ColumnsTreeSubProc::clmnSP_code));
|
||||
subProc.setTitle(item->text(ColumnsTreeSubProc::clmnSP_title));
|
||||
subProc.setModeListStr(item->text(ColumnsTreeSubProc::clmnSP_canplay));
|
||||
listSubProc->append(subProc);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ListSubProc::preparationTreeWidget()
|
||||
{
|
||||
treeWidget->setColumnCount(ColumnsTreeSubProc::clmnSP_count);
|
||||
|
||||
reSetHeadTreeWidget();
|
||||
|
||||
#ifdef PROJECT_TYPE_DEBUG
|
||||
treeWidget->setColumnHidden(ColumnsTreeSubProc::clmnSP_canplay, false);
|
||||
#else
|
||||
treeWidget->setColumnHidden(ColumnsTreeSubProc::clmnSP_canplay, true);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ListSubProc::reSetHeadTreeWidget()
|
||||
{
|
||||
QStringList listHeaders;
|
||||
listHeaders = QStringList{tr("Subprocedure"), tr("DM code"), tr("Canplay")};
|
||||
treeWidget->setHeaderLabels(listHeaders);
|
||||
}
|
||||
|
||||
void ListSubProc::setWidthColumnsTree()
|
||||
{
|
||||
listWidthColumn.clear();
|
||||
|
||||
treeWidget->setColumnWidth(ColumnsTreeSubProc::clmnSP_title, 100);
|
||||
listWidthColumn.append(100);
|
||||
treeWidget->setColumnWidth(ColumnsTreeSubProc::clmnSP_code, 250);
|
||||
listWidthColumn.append(250);
|
||||
treeWidget->setColumnWidth(ColumnsTreeSubProc::clmnSP_canplay, 80);
|
||||
listWidthColumn.append(80);
|
||||
|
||||
treeWidget->setColumnWidth(ColumnsTreeSubProc::clmnSP_title, calculateWidth_0Column());
|
||||
}
|
||||
|
||||
int ListSubProc::calculateWidth_0Column()
|
||||
{
|
||||
int widthHeader = treeWidget->width() - 25;
|
||||
int width0Column = 0;
|
||||
int widthSB = 0;
|
||||
if(treeWidget->verticalScrollBar()->isVisible())
|
||||
widthSB = treeWidget->verticalScrollBar()->size().width();
|
||||
int cntColumns = treeWidget->columnCount();
|
||||
int widthRightColumns = 0;
|
||||
for (int i = 1; i < cntColumns; i++)
|
||||
{
|
||||
if(! treeWidget->isColumnHidden(i))
|
||||
{//Колонка не скрыта
|
||||
int w = listWidthColumn.at(i);
|
||||
widthRightColumns += w;
|
||||
}
|
||||
}
|
||||
width0Column = widthHeader - widthRightColumns - widthSB;
|
||||
|
||||
return width0Column;
|
||||
}
|
||||
|
||||
void ListSubProc::on_btnAssign_clicked()
|
||||
{
|
||||
emit signal_Accepted();
|
||||
}
|
||||
56
LibInstructorsAndTrainees/tasks/listsubproc.h
Normal file
56
LibInstructorsAndTrainees/tasks/listsubproc.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef LISTSUBPROC_H
|
||||
#define LISTSUBPROC_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QResizeEvent>
|
||||
#include <QTreeWidget>
|
||||
#include "connectortoserver.h"
|
||||
|
||||
enum ColumnsTreeSubProc{
|
||||
clmnSP_title = 0,
|
||||
clmnSP_code,
|
||||
clmnSP_canplay,
|
||||
clmnSP_count
|
||||
};
|
||||
|
||||
namespace Ui {
|
||||
class ListSubProc;
|
||||
}
|
||||
|
||||
class ListSubProc : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ListSubProc(QWidget *parent = nullptr);
|
||||
~ListSubProc();
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void changeEvent(QEvent * event) override;
|
||||
|
||||
void setTask(TaskAmmFim* task);
|
||||
bool getListCheckedSubProc(QList<SubProc>* listSubProc);
|
||||
|
||||
private:
|
||||
void preparationTreeWidget();
|
||||
void reSetHeadTreeWidget();
|
||||
void setWidthColumnsTree();
|
||||
int calculateWidth_0Column();
|
||||
|
||||
private slots:
|
||||
void on_btnAssign_clicked();
|
||||
|
||||
signals:
|
||||
void signal_Accepted();
|
||||
|
||||
private:
|
||||
Ui::ListSubProc *ui;
|
||||
|
||||
TaskAmmFim task;
|
||||
|
||||
QTreeWidget* treeWidget;
|
||||
QList<int> listWidthColumn;
|
||||
};
|
||||
|
||||
#endif // LISTSUBPROC_H
|
||||
99
LibInstructorsAndTrainees/tasks/listsubproc.ui
Normal file
99
LibInstructorsAndTrainees/tasks/listsubproc.ui
Normal file
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ListSubProc</class>
|
||||
<widget class="QWidget" name="ListSubProc">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>594</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_Main">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_Info">
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_Title">
|
||||
<property name="text">
|
||||
<string>Title</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_DMCode">
|
||||
<property name="text">
|
||||
<string>DM code</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="lineWidth">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_List">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_SubProc">
|
||||
<property name="text">
|
||||
<string>Select the sub-procedures that are allowed to be run by the trainee in automatic mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Tree"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_Btn">
|
||||
<item>
|
||||
<widget class="QToolButton" name="btnAssign">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Assign</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../ServerLMS/ServerLMS.qrc">
|
||||
<normaloff>:/resources/icons/circleGreen.png</normaloff>:/resources/icons/circleGreen.png</iconset>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>32</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="../../ServerLMS/ServerLMS.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
198
LibInstructorsAndTrainees/tasks/module.cpp
Normal file
198
LibInstructorsAndTrainees/tasks/module.cpp
Normal file
@@ -0,0 +1,198 @@
|
||||
#include "module.h"
|
||||
|
||||
int Module::lastID = 0;
|
||||
|
||||
Module::Module():
|
||||
type (ModuleType::TYPE_PM),
|
||||
parentModule(nullptr),
|
||||
ID(0),
|
||||
isActive(false)
|
||||
{
|
||||
ID = ++lastID;
|
||||
}
|
||||
|
||||
Module::~Module()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Module *Module::getModuleByID(int id)
|
||||
{
|
||||
if(getID() == id)
|
||||
return this;
|
||||
|
||||
if(this->getType() == ModuleType::TYPE_PM)
|
||||
{
|
||||
PM* PMmodul = static_cast<PM*>(this);
|
||||
|
||||
Module* ptrModule = nullptr;
|
||||
|
||||
for(Module* module: PMmodul->getListChildModules())
|
||||
{
|
||||
ptrModule = module->getModuleByID(id);
|
||||
|
||||
if(ptrModule)
|
||||
return ptrModule;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Module::setIsActiveTrue()
|
||||
{
|
||||
this->isActive = true;
|
||||
|
||||
if(parentModule)
|
||||
parentModule->setIsActiveTrue();
|
||||
}
|
||||
|
||||
bool Module::getIsActive()
|
||||
{
|
||||
return this->isActive;
|
||||
}
|
||||
|
||||
void Module::setModeList(ModeList modeList)
|
||||
{
|
||||
this->modeList = modeList;
|
||||
|
||||
if(modeList.demo || modeList.train || modeList.exam /*|| modeList.autoM*/)
|
||||
setIsActiveTrue();
|
||||
}
|
||||
|
||||
PM::PM():
|
||||
modelIdentCode (),
|
||||
pmIssuer (),
|
||||
pmNumber (),
|
||||
pmVolume ()
|
||||
{
|
||||
type = ModuleType::TYPE_PM;
|
||||
|
||||
langRus.title = "";
|
||||
langEng.title = "";
|
||||
}
|
||||
|
||||
PM::~PM()
|
||||
{
|
||||
for(Module* module: listChildModules)
|
||||
{
|
||||
if(module->getType() == ModuleType::TYPE_PM)
|
||||
delete static_cast<PM*>(module);
|
||||
else
|
||||
delete static_cast<DM*>(module);
|
||||
}
|
||||
listChildModules.clear();
|
||||
}
|
||||
|
||||
void PM::initialize(QString modelIdentCode, QString pmIssuer, QString pmNumber, QString pmVolume)
|
||||
{
|
||||
this->modelIdentCode = modelIdentCode;
|
||||
this->pmIssuer = pmIssuer;
|
||||
this->pmNumber = pmNumber;
|
||||
this->pmVolume = pmVolume;
|
||||
}
|
||||
|
||||
void PM::setLangStructRus(QString title)
|
||||
{
|
||||
langRus.title = title;
|
||||
}
|
||||
|
||||
PM::pmLangStruct PM::getLangStructRus()
|
||||
{
|
||||
return langRus;
|
||||
}
|
||||
|
||||
void PM::setLangStructEng(QString title)
|
||||
{
|
||||
langEng.title = title;
|
||||
}
|
||||
|
||||
void PM::addChildModule(Module *childModule)
|
||||
{
|
||||
listChildModules.append(childModule);
|
||||
}
|
||||
|
||||
QList<Module *> PM::getListChildModules()
|
||||
{
|
||||
return listChildModules;
|
||||
}
|
||||
|
||||
QString PM::pmCode()
|
||||
{
|
||||
return (modelIdentCode + "-" + pmIssuer + "-" + pmNumber + "-" + pmVolume).toUpper();
|
||||
}
|
||||
|
||||
|
||||
|
||||
DM::DM():
|
||||
modelIdentCode (),
|
||||
systemDiffCode (),
|
||||
systemCode (),
|
||||
subSystemCode (),
|
||||
subSubSystemCode (),
|
||||
assyCode (),
|
||||
disassyCode (),
|
||||
disassyCodeVariant (),
|
||||
infoCode (),
|
||||
infoCodeVariant (),
|
||||
itemLocationCode ()
|
||||
{
|
||||
type = ModuleType::TYPE_DM;
|
||||
|
||||
setLangStructRus("", "", "", "", "");
|
||||
setLangStructEng("", "", "", "", "");
|
||||
}
|
||||
|
||||
DM::~DM()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void DM::initialize(QString modelIdentCode, QString systemDiffCode, QString systemCode,
|
||||
QString subSystemCode, QString subSubSystemCode, QString assyCode,
|
||||
QString disassyCode, QString disassyCodeVariant, QString infoCode,
|
||||
QString infoCodeVariant, QString itemLocationCode)
|
||||
{
|
||||
this->modelIdentCode = modelIdentCode;
|
||||
this->systemDiffCode = systemDiffCode;
|
||||
this->systemCode = systemCode;
|
||||
this->subSystemCode = subSystemCode;
|
||||
this->subSubSystemCode = subSubSystemCode;
|
||||
this->assyCode = assyCode;
|
||||
this->disassyCode = disassyCode;
|
||||
this->disassyCodeVariant = disassyCodeVariant;
|
||||
this->infoCode = infoCode;
|
||||
this->infoCodeVariant = infoCodeVariant;
|
||||
this->itemLocationCode = itemLocationCode;
|
||||
}
|
||||
|
||||
void DM::setLangStructRus(QString techName, QString infoName, QString pdf, QString bookmark, QString xml)
|
||||
{
|
||||
langRus.techName = techName;
|
||||
langRus.infoName = infoName;
|
||||
langRus.pdf = pdf;
|
||||
langRus.bookmark = bookmark;
|
||||
langRus.xml = xml;
|
||||
}
|
||||
|
||||
DM::dmLangStruct DM::getLangStructRus()
|
||||
{
|
||||
return langRus;
|
||||
}
|
||||
|
||||
void DM::setLangStructEng(QString techName, QString infoName, QString pdf, QString bookmark, QString xml)
|
||||
{
|
||||
langEng.techName = techName;
|
||||
langEng.infoName = infoName;
|
||||
langEng.pdf = pdf;
|
||||
langEng.bookmark = bookmark;
|
||||
langEng.xml = xml;
|
||||
}
|
||||
|
||||
QString DM::dmCode()
|
||||
{
|
||||
return (modelIdentCode + "-" + systemDiffCode + "-" + systemCode + "-" +
|
||||
subSystemCode + subSubSystemCode + "-" + assyCode + "-" +
|
||||
disassyCode + disassyCodeVariant + "-" + infoCode +
|
||||
infoCodeVariant + "-" + itemLocationCode).toUpper();
|
||||
}
|
||||
128
LibInstructorsAndTrainees/tasks/module.h
Normal file
128
LibInstructorsAndTrainees/tasks/module.h
Normal file
@@ -0,0 +1,128 @@
|
||||
#ifndef MODULE_H
|
||||
#define MODULE_H
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include "tasksAmmFim.h"
|
||||
#include "instructorsAndTrainees_global.h"
|
||||
|
||||
enum ModuleType
|
||||
{
|
||||
TYPE_PM = 0,
|
||||
TYPE_DM = 1
|
||||
};
|
||||
|
||||
class INSTRUCTORSANDTRAINEES_EXPORT Module
|
||||
{
|
||||
public:
|
||||
Module();
|
||||
~Module();
|
||||
|
||||
int getID(){ return ID; };
|
||||
ModuleType getType(){ return type; };
|
||||
void setParentModule(Module* parentModule){ this->parentModule = parentModule; };
|
||||
Module* getModuleByID(int id);
|
||||
|
||||
bool getIsActive();
|
||||
|
||||
void setModeList(ModeList modeList);
|
||||
ModeList getModeList(){return modeList;}
|
||||
|
||||
private:
|
||||
void setIsActiveTrue();
|
||||
|
||||
protected:
|
||||
ModuleType type;
|
||||
Module* parentModule;
|
||||
int ID;
|
||||
static int lastID;
|
||||
bool isActive;
|
||||
|
||||
ModeList modeList;
|
||||
};
|
||||
|
||||
|
||||
class INSTRUCTORSANDTRAINEES_EXPORT PM : public Module
|
||||
{
|
||||
public:
|
||||
struct pmLangStruct
|
||||
{
|
||||
QString title;
|
||||
};
|
||||
|
||||
public:
|
||||
PM();
|
||||
~PM();
|
||||
|
||||
public:
|
||||
void initialize(QString modelIdentCode, QString pmIssuer, QString pmNumber, QString pmVolume);
|
||||
void setLangStructRus(QString title);
|
||||
pmLangStruct getLangStructRus();
|
||||
void setLangStructEng(QString title);
|
||||
void addChildModule(Module* childModule);
|
||||
QList<Module*> getListChildModules();
|
||||
QString pmCode();
|
||||
|
||||
private:
|
||||
QString modelIdentCode;
|
||||
QString pmIssuer;
|
||||
QString pmNumber;
|
||||
QString pmVolume;
|
||||
|
||||
pmLangStruct langRus;
|
||||
pmLangStruct langEng;
|
||||
|
||||
QList<Module*> listChildModules;
|
||||
};
|
||||
|
||||
|
||||
class INSTRUCTORSANDTRAINEES_EXPORT DM : public Module
|
||||
{
|
||||
public:
|
||||
struct dmLangStruct
|
||||
{
|
||||
QString techName;
|
||||
QString infoName;
|
||||
QString pdf;
|
||||
QString bookmark;
|
||||
QString xml;
|
||||
};
|
||||
|
||||
public:
|
||||
DM();
|
||||
~DM();
|
||||
|
||||
public:
|
||||
void initialize(QString modelIdentCode,
|
||||
QString systemDiffCode,
|
||||
QString systemCode,
|
||||
QString subSystemCode,
|
||||
QString subSubSystemCode,
|
||||
QString assyCode,
|
||||
QString disassyCode,
|
||||
QString disassyCodeVariant,
|
||||
QString infoCode,
|
||||
QString infoCodeVariant,
|
||||
QString itemLocationCode);
|
||||
void setLangStructRus(QString techName, QString infoName, QString pdf, QString bookmark, QString xml);
|
||||
dmLangStruct getLangStructRus();
|
||||
void setLangStructEng(QString techName, QString infoName, QString pdf, QString bookmark, QString xml);
|
||||
QString dmCode();
|
||||
|
||||
private:
|
||||
QString modelIdentCode;
|
||||
QString systemDiffCode;
|
||||
QString systemCode;
|
||||
QString subSystemCode;
|
||||
QString subSubSystemCode;
|
||||
QString assyCode;
|
||||
QString disassyCode;
|
||||
QString disassyCodeVariant;
|
||||
QString infoCode;
|
||||
QString infoCodeVariant;
|
||||
QString itemLocationCode;
|
||||
|
||||
dmLangStruct langRus;
|
||||
dmLangStruct langEng;
|
||||
};
|
||||
|
||||
#endif // MODULE_H
|
||||
51
LibInstructorsAndTrainees/tasks/subprocitemwidget.cpp
Normal file
51
LibInstructorsAndTrainees/tasks/subprocitemwidget.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include "subprocitemwidget.h"
|
||||
#include "ui_subprocitemwidget.h"
|
||||
|
||||
SubProcItemWidget::SubProcItemWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::SubProcItemWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->listWidget->setObjectName("subProcItemListWidget");
|
||||
|
||||
this->setFocusPolicy(Qt::NoFocus);
|
||||
ui->listWidget->setFocusPolicy(Qt::NoFocus);
|
||||
ui->label->setFocusPolicy(Qt::NoFocus);
|
||||
|
||||
int totalHeight = 0;
|
||||
totalHeight += ui->label->sizeHint().height();
|
||||
totalHeight += 4;
|
||||
ui->label->setMaximumHeight(totalHeight);
|
||||
}
|
||||
|
||||
SubProcItemWidget::~SubProcItemWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SubProcItemWidget::setListSubProc(const QList<SubProc> &list)
|
||||
{
|
||||
int totalHeight = 0;
|
||||
|
||||
for (SubProc subProc : list)
|
||||
{/*Подпроцедуры*/
|
||||
ui->listWidget->addItem(QString("- %1 [%2]").arg(subProc.getTitle(), subProc.getDmCode()));
|
||||
|
||||
//Делаем item невыделяемым
|
||||
QListWidgetItem* item = ui->listWidget->item(ui->listWidget->count() - 1);
|
||||
item->setFlags(item->flags() ^ Qt::ItemIsSelectable);
|
||||
}
|
||||
|
||||
//Определяем минимальную высоту списка
|
||||
for(int row = 0; row < ui->listWidget->count(); ++row)
|
||||
{
|
||||
totalHeight += ui->listWidget->sizeHintForRow(row); // Высота каждой строки
|
||||
totalHeight += 4;
|
||||
}
|
||||
|
||||
// Добавляем отступы фрейма (рамки)
|
||||
totalHeight += ui->listWidget->frameWidth() * 2;
|
||||
|
||||
ui->listWidget->setMaximumHeight(totalHeight);
|
||||
}
|
||||
25
LibInstructorsAndTrainees/tasks/subprocitemwidget.h
Normal file
25
LibInstructorsAndTrainees/tasks/subprocitemwidget.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef SUBPROCITEMWIDGET_H
|
||||
#define SUBPROCITEMWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "module.h"
|
||||
|
||||
namespace Ui {
|
||||
class SubProcItemWidget;
|
||||
}
|
||||
|
||||
class SubProcItemWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SubProcItemWidget(QWidget *parent = nullptr);
|
||||
~SubProcItemWidget();
|
||||
|
||||
void setListSubProc(const QList<SubProc>& list);
|
||||
|
||||
private:
|
||||
Ui::SubProcItemWidget *ui;
|
||||
};
|
||||
|
||||
#endif // SUBPROCITEMWIDGET_H
|
||||
54
LibInstructorsAndTrainees/tasks/subprocitemwidget.ui
Normal file
54
LibInstructorsAndTrainees/tasks/subprocitemwidget.ui
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SubProcItemWidget</class>
|
||||
<widget class="QWidget" name="SubProcItemWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>700</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_Main">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Subprocedures allowed to be run by the trainee in automatic mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="listWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
742
LibInstructorsAndTrainees/tasks/tasktreepreparation.cpp
Normal file
742
LibInstructorsAndTrainees/tasks/tasktreepreparation.cpp
Normal file
@@ -0,0 +1,742 @@
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include "tasktreepreparation.h"
|
||||
#include "subprocitemwidget.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
|
||||
TaskAMMFIMTreePreparation::TaskAMMFIMTreePreparation(TypeListTreeAMMFIM type, QTreeWidget* treeWidget, QObject *parent) :
|
||||
QObject(parent),
|
||||
flagStop(false),
|
||||
type(type),
|
||||
treeWidget(treeWidget)
|
||||
{
|
||||
qDebug() << "TaskAMMFIMTreePreparation init thread ID " << QThread::currentThreadId();
|
||||
}
|
||||
|
||||
TaskAMMFIMTreePreparation::~TaskAMMFIMTreePreparation()
|
||||
{
|
||||
mtxAccess.lock();
|
||||
deleteAllModulsAMM();
|
||||
mtxAccess.unlock();
|
||||
}
|
||||
|
||||
void TaskAMMFIMTreePreparation::slot_stopParserPreparation()
|
||||
{
|
||||
flagStop = true;
|
||||
}
|
||||
|
||||
TaskAmmFim TaskAMMFIMTreePreparation::getTaskFIMbyID(int id)
|
||||
{
|
||||
mtxAccess.lock();
|
||||
for(int i = 0; i < listTasksFIM.count(); i++)
|
||||
{/*Задачи*/
|
||||
TaskAmmFim task = listTasksFIM.at(i);
|
||||
if(task.id == id)
|
||||
{
|
||||
mtxAccess.unlock();
|
||||
return task;
|
||||
}
|
||||
}
|
||||
mtxAccess.unlock();
|
||||
return TaskAmmFim();
|
||||
}
|
||||
|
||||
TaskAmmFim TaskAMMFIMTreePreparation::getTaskAMMbyID(int id)
|
||||
{
|
||||
mtxAccess.lock();
|
||||
for(int i = 0; i < listTasksAMM.count(); i++)
|
||||
{/*Задачи*/
|
||||
TaskAmmFim task = listTasksAMM.at(i);
|
||||
if(task.id == id)
|
||||
{
|
||||
mtxAccess.unlock();
|
||||
return task;
|
||||
}
|
||||
}
|
||||
mtxAccess.unlock();
|
||||
return TaskAmmFim();
|
||||
}
|
||||
|
||||
ModuleType TaskAMMFIMTreePreparation::getTypeModuleAMMbyID(int id)
|
||||
{
|
||||
ModuleType type = ModuleType::TYPE_PM;
|
||||
Module* ptrModule = nullptr;
|
||||
|
||||
mtxAccess.lock();
|
||||
for(Module* module: listAllModulesAMM)
|
||||
{
|
||||
ptrModule = module->getModuleByID(id);
|
||||
if(ptrModule)
|
||||
{
|
||||
type = ptrModule->getType();
|
||||
{
|
||||
mtxAccess.unlock();
|
||||
return type;
|
||||
}
|
||||
}
|
||||
}
|
||||
mtxAccess.unlock();
|
||||
return type;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *TaskAMMFIMTreePreparation::addModuleToTreeWidgetAMM(Module *module, bool flOnlyActive, QTreeWidgetItem *parentItem)
|
||||
{
|
||||
QTreeWidgetItem* itemModule = nullptr;
|
||||
|
||||
if(flagStop)
|
||||
return itemModule;
|
||||
|
||||
if(flOnlyActive && !module->getIsActive())
|
||||
return nullptr;
|
||||
|
||||
QString text = "";
|
||||
QString ID = QString::number(module->getID());
|
||||
//QString DMcode = "---";
|
||||
//QString canplay = "*";
|
||||
QString DMcode = "";
|
||||
QString canplay = "";
|
||||
|
||||
itemModule = new QTreeWidgetItem();
|
||||
countItems++;
|
||||
|
||||
if(parentItem)
|
||||
parentItem->addChild(itemModule);
|
||||
|
||||
if(module->getType() == ModuleType::TYPE_PM)
|
||||
{
|
||||
PM* PMmodul = static_cast<PM*>(module);
|
||||
text = PMmodul->getLangStructRus().title;
|
||||
//DMcode = PMmodul->pmCode();
|
||||
|
||||
for(Module* module : PMmodul->getListChildModules())
|
||||
{
|
||||
addModuleToTreeWidgetAMM(module, flOnlyActive, itemModule);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DM* DMmodul = static_cast<DM*>(module);
|
||||
text = DMmodul->getLangStructRus().techName;
|
||||
DMcode = DMmodul->dmCode();
|
||||
canplay = SubProc::buildCanplay(DMmodul->getModeList());
|
||||
|
||||
//itemModule->setFlags(itemModule->flags() | Qt::ItemIsUserCheckable);
|
||||
//itemModule->setCheckState(0, Qt::Checked);
|
||||
itemModule->setIcon(0, QIcon(":/resources/icons/procedure.png"));
|
||||
}
|
||||
|
||||
itemModule->setText(ColumnsTreeAMM::clmnAMM_PMorDM, text);
|
||||
itemModule->setText(ColumnsTreeAMM::clmnAMM_code, DMcode);
|
||||
itemModule->setText(ColumnsTreeAMM::clmnAMM_canplay, canplay);
|
||||
itemModule->setText(ColumnsTreeAMM::clmnAMM_ID, ID);
|
||||
itemModule->setToolTip(0, text);
|
||||
|
||||
return itemModule;
|
||||
}
|
||||
|
||||
void TaskAMMFIMTreePreparation::loadAMMtasksFromXML(QByteArray array)
|
||||
{
|
||||
qDebug() << "TaskAMMFIMTreePreparation::loadAMMtasksFromXML thread ID " << QThread::currentThreadId();
|
||||
|
||||
mtxAccess.lock();
|
||||
|
||||
deleteAllModulsAMM();
|
||||
listTasksAMM.clear();
|
||||
|
||||
QDomDocument docTasksDOM;
|
||||
|
||||
docTasksDOM.setContent(array);
|
||||
|
||||
QDomElement manifestElement = docTasksDOM.firstChildElement("manifest");
|
||||
if(manifestElement.isNull())
|
||||
{
|
||||
mtxAccess.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
domElementParserAMM(manifestElement, nullptr);
|
||||
|
||||
mtxAccess.unlock();
|
||||
}
|
||||
|
||||
void TaskAMMFIMTreePreparation::loadFIMtasksFromXML(QByteArray array)
|
||||
{
|
||||
qDebug() << "TaskAMMFIMTreePreparation::loadFIMtasksFromXML thread ID " << QThread::currentThreadId();
|
||||
|
||||
mtxAccess.lock();
|
||||
|
||||
listTasksFIM.clear();
|
||||
|
||||
QDomDocument docTasksDOM;
|
||||
|
||||
docTasksDOM.setContent(array);
|
||||
|
||||
QDomElement RRJTasksElement = docTasksDOM.firstChildElement("RRJTasks");
|
||||
if(RRJTasksElement.isNull())
|
||||
{
|
||||
mtxAccess.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
QDomElement taskElement = RRJTasksElement.firstChildElement();
|
||||
if(taskElement.isNull())
|
||||
{
|
||||
mtxAccess.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
do
|
||||
{/*task*/
|
||||
|
||||
if(flagStop)
|
||||
{
|
||||
mtxAccess.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
QString name = taskElement.nodeName();
|
||||
QDomNamedNodeMap nodeMap = taskElement.attributes();
|
||||
|
||||
if(name == "task")
|
||||
{
|
||||
TaskAmmFim* task = nullptr;
|
||||
task = new TaskAmmFim();
|
||||
|
||||
task->initialize(/*nodeMap.namedItem("id").nodeValue().toInt()*/ TaskAmmFim::lastID++,
|
||||
nodeMap.namedItem("type").nodeValue(),
|
||||
nodeMap.namedItem("title").nodeValue(),
|
||||
nodeMap.namedItem("status").nodeValue(),
|
||||
nodeMap.namedItem("created").nodeValue(),
|
||||
nodeMap.namedItem("changed").nodeValue());
|
||||
|
||||
QDomElement malfunctionElement = taskElement.firstChildElement();
|
||||
if(!malfunctionElement.isNull())
|
||||
{
|
||||
do
|
||||
{/*malfunction*/
|
||||
QString name = malfunctionElement.nodeName();
|
||||
QDomNamedNodeMap nodeMap = malfunctionElement.attributes();
|
||||
|
||||
if(name == "malfunction")
|
||||
{
|
||||
Malfunction malfunction;
|
||||
|
||||
malfunction.initialize(nodeMap.namedItem("dmCode").nodeValue(),
|
||||
nodeMap.namedItem("num").nodeValue(),
|
||||
nodeMap.namedItem("description").nodeValue());
|
||||
|
||||
QDomElement signElement = malfunctionElement.firstChildElement();
|
||||
if(!signElement.isNull())
|
||||
{
|
||||
do
|
||||
{/*malfunctionSign*/
|
||||
QString name = signElement.nodeName();
|
||||
QDomNamedNodeMap nodeMap = signElement.attributes();
|
||||
|
||||
if(name == "malfunctionSign")
|
||||
{
|
||||
MalfunctionSign sign;
|
||||
|
||||
sign.initialize(nodeMap.namedItem("type").nodeValue().toInt(),
|
||||
nodeMap.namedItem("description").nodeValue());
|
||||
|
||||
malfunction.addMalfunctionSign(sign);
|
||||
}
|
||||
|
||||
}while(! (signElement = signElement.nextSiblingElement()).isNull());
|
||||
}
|
||||
task->addMalfunction(malfunction);
|
||||
}
|
||||
}while(! (malfunctionElement = malfunctionElement.nextSiblingElement()).isNull());
|
||||
}
|
||||
listTasksFIM.append(*task);
|
||||
delete task;
|
||||
}
|
||||
}while (! (taskElement = taskElement.nextSiblingElement()).isNull());
|
||||
|
||||
mtxAccess.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
void TaskAMMFIMTreePreparation::deleteAllModulsAMM()
|
||||
{
|
||||
for(Module* module: listAllModulesAMM)
|
||||
{
|
||||
if(module->getType() == ModuleType::TYPE_PM)
|
||||
delete static_cast<PM*>(module);
|
||||
else
|
||||
delete static_cast<DM*>(module);
|
||||
}
|
||||
listAllModulesAMM.clear();
|
||||
}
|
||||
|
||||
void TaskAMMFIMTreePreparation::domElementParserAMM(QDomElement element, Module* moduleParent)
|
||||
{
|
||||
QString name;
|
||||
|
||||
if(flagStop)
|
||||
return;
|
||||
|
||||
QDomElement childElement = element.firstChildElement();
|
||||
if(childElement.isNull())
|
||||
return;
|
||||
|
||||
Module* module = nullptr;
|
||||
|
||||
do
|
||||
{
|
||||
name = childElement.nodeName();
|
||||
|
||||
QDomNamedNodeMap nodeMap = childElement.attributes();
|
||||
|
||||
if(name == "doc")
|
||||
{
|
||||
module = new PM();
|
||||
}
|
||||
else if(name == "pm")
|
||||
{
|
||||
module = new PM();
|
||||
PM* PMmodul = static_cast<PM*>(module);
|
||||
|
||||
PMmodul->initialize(nodeMap.namedItem("modelIdentCode").nodeValue(),
|
||||
nodeMap.namedItem("pmIssuer").nodeValue(),
|
||||
nodeMap.namedItem("pmNumber").nodeValue(),
|
||||
nodeMap.namedItem("pmVolume").nodeValue());
|
||||
|
||||
if(moduleParent)
|
||||
{
|
||||
PMmodul->setParentModule(moduleParent);
|
||||
|
||||
PM* PMmodulParent = static_cast<PM*>(moduleParent);
|
||||
PMmodulParent->addChildModule(module);
|
||||
}
|
||||
}
|
||||
else if(name == "dm")
|
||||
{
|
||||
module = new DM();
|
||||
DM* DMmodul = static_cast<DM*>(module);
|
||||
|
||||
DMmodul->initialize(nodeMap.namedItem("modelIdentCode").nodeValue(),
|
||||
nodeMap.namedItem("systemDiffCode").nodeValue(),
|
||||
nodeMap.namedItem("systemCode").nodeValue(),
|
||||
nodeMap.namedItem("subSystemCode").nodeValue(),
|
||||
nodeMap.namedItem("subSubSystemCode").nodeValue(),
|
||||
nodeMap.namedItem("assyCode").nodeValue(),
|
||||
nodeMap.namedItem("disassyCode").nodeValue(),
|
||||
nodeMap.namedItem("disassyCodeVariant").nodeValue(),
|
||||
nodeMap.namedItem("infoCode").nodeValue(),
|
||||
nodeMap.namedItem("infoCodeVariant").nodeValue(),
|
||||
nodeMap.namedItem("itemLocationCode").nodeValue());
|
||||
|
||||
if(moduleParent)
|
||||
{
|
||||
DMmodul->setParentModule(moduleParent);
|
||||
|
||||
PM* PMmodulParent = static_cast<PM*>(moduleParent);
|
||||
PMmodulParent->addChildModule(module);
|
||||
}
|
||||
}
|
||||
else if(name == "rus" || name == "eng")
|
||||
{
|
||||
if(moduleParent)
|
||||
{
|
||||
if(moduleParent->getType() == ModuleType::TYPE_PM)
|
||||
{//PM
|
||||
PM* PMmodulParent = static_cast<PM*>(moduleParent);
|
||||
|
||||
if(name == "rus")
|
||||
PMmodulParent->setLangStructRus(nodeMap.namedItem("title").nodeValue());
|
||||
else
|
||||
PMmodulParent->setLangStructEng(nodeMap.namedItem("title").nodeValue());
|
||||
}
|
||||
else
|
||||
{//DM
|
||||
DM* DMmodulParent = static_cast<DM*>(moduleParent);
|
||||
|
||||
if(name == "rus")
|
||||
{
|
||||
DMmodulParent->setLangStructRus(nodeMap.namedItem("techName").nodeValue(),
|
||||
nodeMap.namedItem("infoName").nodeValue(),
|
||||
nodeMap.namedItem("pdf").nodeValue(),
|
||||
nodeMap.namedItem("bookmark").nodeValue(),
|
||||
nodeMap.namedItem("xml").nodeValue());
|
||||
|
||||
//Активность
|
||||
QString canplay = nodeMap.namedItem("canplay").nodeValue();
|
||||
DMmodulParent->setModeList(parseCanplay(canplay));
|
||||
//if(canplay.contains("+"))
|
||||
//DMmodulParent->setIsActiveTrue();
|
||||
}
|
||||
else
|
||||
DMmodulParent->setLangStructEng(nodeMap.namedItem("techName").nodeValue(),
|
||||
nodeMap.namedItem("infoName").nodeValue(),
|
||||
nodeMap.namedItem("pdf").nodeValue(),
|
||||
nodeMap.namedItem("bookmark").nodeValue(),
|
||||
nodeMap.namedItem("xml").nodeValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
domElementParserAMM(childElement, module);
|
||||
|
||||
if(moduleParent == nullptr)
|
||||
listAllModulesAMM.append(module);
|
||||
|
||||
if(module)
|
||||
if(module->getType() == ModuleType::TYPE_DM)
|
||||
{
|
||||
TaskAmmFim* task = nullptr;
|
||||
task = new TaskAmmFim();
|
||||
task->setID(module->getID());
|
||||
task->ammProcedure.title = static_cast<DM*>(module)->getLangStructRus().techName;
|
||||
task->ammProcedure.dmCode = static_cast<DM*>(module)->dmCode();
|
||||
|
||||
listTasksAMM.append(*task);
|
||||
delete task;
|
||||
}
|
||||
|
||||
}while (! (childElement = childElement.nextSiblingElement()).isNull());
|
||||
}
|
||||
|
||||
ModeList TaskAMMFIMTreePreparation::parseCanplay(QString canplay)
|
||||
{
|
||||
ModeList modeList;
|
||||
|
||||
if(canplay == "")
|
||||
{
|
||||
modeList.demo = false;
|
||||
modeList.train = false;
|
||||
modeList.exam = false;
|
||||
modeList.autoM = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
QStringList list = canplay.split("/");
|
||||
|
||||
if(list.at(0) == "+")
|
||||
modeList.demo = true;
|
||||
else
|
||||
modeList.demo = false;
|
||||
|
||||
if(list.at(1) == "+")
|
||||
modeList.train = true;
|
||||
else
|
||||
modeList.train = false;
|
||||
|
||||
if(list.at(2) == "+")
|
||||
modeList.exam = true;
|
||||
else
|
||||
modeList.exam = false;
|
||||
|
||||
if(list.at(3) == "+")
|
||||
modeList.autoM = true;
|
||||
else
|
||||
modeList.autoM = false;
|
||||
}
|
||||
|
||||
return modeList;
|
||||
}
|
||||
|
||||
void TaskAMMFIMTreePreparation::slot_prepareAMMListItems(QByteArray array, bool flOnlyActive, bool flRequestFirst)
|
||||
{
|
||||
qDebug() << "TaskAMMFIMTreePreparation::slot_prepareAMMListItems thread ID " << QThread::currentThreadId();
|
||||
|
||||
if(flRequestFirst)
|
||||
{
|
||||
loadAMMtasksFromXML(array);
|
||||
}
|
||||
|
||||
if(flOnlyActive)
|
||||
{
|
||||
listItemsOnlyActive.clear();
|
||||
|
||||
for(Module* module : listAllModulesAMM)
|
||||
{
|
||||
QTreeWidgetItem* item = addModuleToTreeWidgetAMM(module, true);
|
||||
listItemsOnlyActive.append(item);
|
||||
}
|
||||
|
||||
emit signal_listAMMItemsReady(listItemsOnlyActive);
|
||||
}
|
||||
else
|
||||
{
|
||||
listItemsAll.clear();
|
||||
|
||||
for(Module* module : listAllModulesAMM)
|
||||
{
|
||||
QTreeWidgetItem* item = addModuleToTreeWidgetAMM(module, false);
|
||||
listItemsAll.append(item);
|
||||
}
|
||||
|
||||
emit signal_listAMMItemsReady(listItemsAll);
|
||||
}
|
||||
}
|
||||
|
||||
void TaskAMMFIMTreePreparation::slot_prepareAMMListItemsForTrainee(QList<TaskAmmFim> listTasks)
|
||||
{
|
||||
qDebug() << "TaskAMMFIMTreePreparation::slot_prepareAMMListItemsForTrainee thread ID " << QThread::currentThreadId();
|
||||
|
||||
listItemsAll.clear();
|
||||
|
||||
//Обновление дерева
|
||||
treeWidget->clear();
|
||||
|
||||
mtxAccess.lock();
|
||||
|
||||
this->listTasksAMM = listTasks;
|
||||
|
||||
for(TaskAmmFim task : listTasks)
|
||||
{
|
||||
QTreeWidgetItem* item = nullptr;
|
||||
|
||||
QString text = task.ammProcedure.title;
|
||||
QString ID = QString::number(task.getID());
|
||||
QString code = task.ammProcedure.dmCode;
|
||||
QString status = task.status;
|
||||
|
||||
item = new QTreeWidgetItem(treeWidget);
|
||||
|
||||
treeWidget->addTopLevelItem(item);
|
||||
|
||||
item->setIcon(0, QIcon(":/resources/icons/procedure.png"));
|
||||
|
||||
item->setText(ColumnsTreeAMM::clmnAMM_PMorDM, text);
|
||||
item->setText(ColumnsTreeAMM::clmnAMM_code, code);
|
||||
item->setText(ColumnsTreeAMM::clmnAMM_ID, ID);
|
||||
|
||||
if(status == "completed")
|
||||
{
|
||||
item->setText(ColumnsTreeAMM::clmnAMM_status, tr("completed"));
|
||||
item->setIcon(ColumnsTreeAMM::clmnAMM_status, QIcon(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
}
|
||||
else if(status == "failed")
|
||||
{
|
||||
item->setText(ColumnsTreeAMM::clmnAMM_status, tr("failed"));
|
||||
item->setIcon(ColumnsTreeAMM::clmnAMM_status, QIcon(QStringLiteral(":/resources/icons/circleRed.png")));
|
||||
}
|
||||
else if(status == "checkup")
|
||||
{
|
||||
item->setText(ColumnsTreeAMM::clmnAMM_status, tr("checkup"));
|
||||
item->setIcon(ColumnsTreeAMM::clmnAMM_status, QIcon(QStringLiteral(":/resources/icons/circleYellow.png")));
|
||||
}
|
||||
else
|
||||
{
|
||||
item->setText(ColumnsTreeAMM::clmnAMM_status, tr("new"));
|
||||
item->setIcon(ColumnsTreeAMM::clmnAMM_status, QIcon(QStringLiteral(":/resources/icons/circleGray.png")));
|
||||
}
|
||||
|
||||
item->setToolTip(0, text);
|
||||
|
||||
|
||||
if(type == TypeListTreeAMMFIM::listForTrainee)
|
||||
{
|
||||
//Подпроцедуры
|
||||
if(task.listSubProc.count())
|
||||
{
|
||||
QTreeWidgetItem* itemSubProc = new QTreeWidgetItem();
|
||||
itemSubProc->setFlags(itemSubProc->flags() ^ Qt::ItemIsSelectable);
|
||||
|
||||
SubProcItemWidget* itemWidget = new SubProcItemWidget();
|
||||
itemWidget->setListSubProc(task.listSubProc);
|
||||
itemWidget->setAutoFillBackground(true);
|
||||
|
||||
item->addChild(itemSubProc);
|
||||
treeWidget->setItemWidget(itemSubProc, 0, itemWidget);
|
||||
|
||||
//Объединение всех ячеек
|
||||
itemSubProc->setFirstColumnSpanned(true);
|
||||
}
|
||||
}
|
||||
|
||||
listItemsAll.append(item);
|
||||
}
|
||||
|
||||
mtxAccess.unlock();
|
||||
|
||||
Q_EMIT signal_listAMMItemsReady(listItemsAll);
|
||||
}
|
||||
|
||||
void TaskAMMFIMTreePreparation::slot_prepareFIMListItems(QByteArray array)
|
||||
{
|
||||
qDebug() << "TaskAMMFIMTreePreparation::slot_prepareFIMListItems thread ID " << QThread::currentThreadId();
|
||||
|
||||
loadFIMtasksFromXML(array);
|
||||
|
||||
listItemsAll.clear();
|
||||
|
||||
mtxAccess.lock();
|
||||
|
||||
for(TaskAmmFim taskPtr : listTasksFIM)
|
||||
{/*Задачи*/
|
||||
TaskAmmFim task = taskPtr;
|
||||
|
||||
QTreeWidgetItem* itemTask = new QTreeWidgetItem();
|
||||
|
||||
itemTask->setText(ColumnsTreeFIM::clmnFIM_Title, task.title);
|
||||
itemTask->setText(ColumnsTreeFIM::clmnFIM_ID, QString::number(task.id));
|
||||
//itemTask->setFlags(itemTask->flags() | Qt::ItemIsUserCheckable);
|
||||
//itemTask->setCheckState(ColumnsTreeFIM::clmnFIM_Title, Qt::Checked);
|
||||
|
||||
if(task.status == "completed")
|
||||
{
|
||||
itemTask->setText(ColumnsTreeFIM::clmnFIM_status, tr("completed"));
|
||||
itemTask->setIcon(ColumnsTreeFIM::clmnFIM_status, QIcon(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
}
|
||||
else if(task.status == "failed")
|
||||
{
|
||||
itemTask->setText(ColumnsTreeFIM::clmnFIM_status, tr("failed"));
|
||||
itemTask->setIcon(ColumnsTreeFIM::clmnFIM_status, QIcon(QStringLiteral(":/resources/icons/circleRed.png")));
|
||||
}
|
||||
else if(task.status == "checkup")
|
||||
{
|
||||
itemTask->setText(ColumnsTreeFIM::clmnFIM_status, tr("checkup"));
|
||||
itemTask->setIcon(ColumnsTreeFIM::clmnFIM_status, QIcon(QStringLiteral(":/resources/icons/circleYellow.png")));
|
||||
}
|
||||
else
|
||||
{
|
||||
itemTask->setText(ColumnsTreeFIM::clmnFIM_status, tr("new"));
|
||||
itemTask->setIcon(ColumnsTreeFIM::clmnFIM_status, QIcon(QStringLiteral(":/resources/icons/circleGray.png")));
|
||||
}
|
||||
|
||||
|
||||
itemTask->setIcon(ColumnsTreeFIM::clmnFIM_Title, QIcon(":/resources/icons/procedure.png"));
|
||||
itemTask->setToolTip(ColumnsTreeFIM::clmnFIM_Title, task.title);
|
||||
|
||||
|
||||
for (int j = 0; j < task.malfunctionList.count(); j++)
|
||||
{/*Неисправности*/
|
||||
Malfunction malfunction = task.malfunctionList.at(j);
|
||||
|
||||
QTreeWidgetItem* itemMalfunction = new QTreeWidgetItem();
|
||||
itemMalfunction->setFlags(itemMalfunction->flags() ^ Qt::ItemIsSelectable);
|
||||
|
||||
itemMalfunction->setText(ColumnsTreeFIM::clmnFIM_Title, malfunction.description);
|
||||
if(type == TypeListTreeAMMFIM::listCommon)
|
||||
{
|
||||
itemMalfunction->setFlags(itemMalfunction->flags() | Qt::ItemIsUserCheckable);
|
||||
itemMalfunction->setCheckState(ColumnsTreeFIM::clmnFIM_Title, Qt::Checked);
|
||||
}
|
||||
|
||||
itemMalfunction->setIcon(ColumnsTreeFIM::clmnFIM_Title, QIcon(":/resources/icons/malfunction.png"));
|
||||
itemMalfunction->setToolTip(ColumnsTreeFIM::clmnFIM_Title, malfunction.description);
|
||||
|
||||
itemTask->addChild(itemMalfunction);
|
||||
|
||||
for (int k = 0; k < malfunction.malfunctionSigns.count(); k++)
|
||||
{/*Сигнализация*/
|
||||
MalfunctionSign sign = malfunction.malfunctionSigns.at(k);
|
||||
|
||||
QTreeWidgetItem* itemSign = new QTreeWidgetItem();
|
||||
itemSign->setFlags(itemSign->flags() ^ Qt::ItemIsSelectable);
|
||||
|
||||
itemSign->setText(ColumnsTreeFIM::clmnFIM_Title, sign.description);
|
||||
//itemSign->setFlags(itemSign->flags() | Qt::ItemIsUserCheckable);
|
||||
//itemSign->setCheckState(ColumnsTreeFIM::clmnFIM_Title, Qt::Checked);
|
||||
itemSign->setIcon(ColumnsTreeFIM::clmnFIM_Title, QIcon(":/resources/icons/sign.png"));
|
||||
itemSign->setToolTip(ColumnsTreeFIM::clmnFIM_Title, sign.description);
|
||||
|
||||
itemMalfunction->addChild(itemSign);
|
||||
}
|
||||
}
|
||||
listItemsAll.append(itemTask);
|
||||
}
|
||||
|
||||
mtxAccess.unlock();
|
||||
|
||||
Q_EMIT signal_listFIMItemsReady(listItemsAll);
|
||||
}
|
||||
|
||||
void TaskAMMFIMTreePreparation::slot_prepareFIMListItemsForTrainee(QList<TaskAmmFim> listTasks)
|
||||
{
|
||||
qDebug() << "TaskAMMFIMTreePreparation::slot_prepareFIMListItemsForTrainee thread ID " << QThread::currentThreadId();
|
||||
|
||||
listItemsAll.clear();
|
||||
|
||||
mtxAccess.lock();
|
||||
this->listTasksFIM = listTasks;
|
||||
|
||||
for(TaskAmmFim task : listTasks)
|
||||
{/*Задачи*/
|
||||
//TaskAmmFim* task = listTaskAmmFim.at(i);
|
||||
//TaskAmmFim* taskNew = nullptr;
|
||||
//taskNew = new TaskAmmFim();
|
||||
//*taskNew = task;
|
||||
//listTaskFIM.append(taskNew);
|
||||
|
||||
QTreeWidgetItem* itemTask = new QTreeWidgetItem();
|
||||
|
||||
itemTask->setText(ColumnsTreeFIM::clmnFIM_Title, task.title);
|
||||
itemTask->setText(ColumnsTreeFIM::clmnFIM_ID, QString::number(task.id));
|
||||
//itemTask->setFlags(itemTask->flags() | Qt::ItemIsUserCheckable);
|
||||
//itemTask->setCheckState(ColumnsTreeFIM::clmnFIM_Title, Qt::Checked);
|
||||
|
||||
if(task.status == "completed")
|
||||
{
|
||||
itemTask->setText(ColumnsTreeFIM::clmnFIM_status, tr("completed"));
|
||||
itemTask->setIcon(ColumnsTreeFIM::clmnFIM_status, QIcon(QStringLiteral(":/resources/icons/circleGreen.png")));
|
||||
}
|
||||
else if(task.status == "failed")
|
||||
{
|
||||
itemTask->setText(ColumnsTreeFIM::clmnFIM_status, tr("failed"));
|
||||
itemTask->setIcon(ColumnsTreeFIM::clmnFIM_status, QIcon(QStringLiteral(":/resources/icons/circleRed.png")));
|
||||
}
|
||||
else if(task.status == "checkup")
|
||||
{
|
||||
itemTask->setText(ColumnsTreeFIM::clmnFIM_status, tr("checkup"));
|
||||
itemTask->setIcon(ColumnsTreeFIM::clmnFIM_status, QIcon(QStringLiteral(":/resources/icons/circleYellow.png")));
|
||||
}
|
||||
else
|
||||
{
|
||||
itemTask->setText(ColumnsTreeFIM::clmnFIM_status, tr("new"));
|
||||
itemTask->setIcon(ColumnsTreeFIM::clmnFIM_status, QIcon(QStringLiteral(":/resources/icons/circleGray.png")));
|
||||
}
|
||||
|
||||
|
||||
itemTask->setIcon(ColumnsTreeFIM::clmnFIM_Title, QIcon(":/resources/icons/procedure.png"));
|
||||
itemTask->setToolTip(ColumnsTreeFIM::clmnFIM_Title, task.title);
|
||||
|
||||
|
||||
for (int j = 0; j < task.malfunctionList.count(); j++)
|
||||
{/*Неисправности*/
|
||||
Malfunction malfunction = task.malfunctionList.at(j);
|
||||
|
||||
QTreeWidgetItem* itemMalfunction = new QTreeWidgetItem();
|
||||
|
||||
itemMalfunction->setText(ColumnsTreeFIM::clmnFIM_Title, malfunction.description);
|
||||
if(type == TypeListTreeAMMFIM::listCommon)
|
||||
{
|
||||
itemMalfunction->setFlags(itemMalfunction->flags() | Qt::ItemIsUserCheckable);
|
||||
itemMalfunction->setCheckState(ColumnsTreeFIM::clmnFIM_Title, Qt::Checked);
|
||||
}
|
||||
|
||||
itemMalfunction->setIcon(ColumnsTreeFIM::clmnFIM_Title, QIcon(":/resources/icons/malfunction.png"));
|
||||
itemMalfunction->setToolTip(ColumnsTreeFIM::clmnFIM_Title, malfunction.description);
|
||||
|
||||
itemTask->addChild(itemMalfunction);
|
||||
|
||||
for (int k = 0; k < malfunction.malfunctionSigns.count(); k++)
|
||||
{/*Сигнализация*/
|
||||
MalfunctionSign sign = malfunction.malfunctionSigns.at(k);
|
||||
|
||||
QTreeWidgetItem* itemSign = new QTreeWidgetItem();
|
||||
|
||||
itemSign->setText(ColumnsTreeFIM::clmnFIM_Title, sign.description);
|
||||
//itemSign->setFlags(itemSign->flags() | Qt::ItemIsUserCheckable);
|
||||
//itemSign->setCheckState(ColumnsTreeFIM::clmnFIM_Title, Qt::Checked);
|
||||
itemSign->setIcon(ColumnsTreeFIM::clmnFIM_Title, QIcon(":/resources/icons/sign.png"));
|
||||
itemSign->setToolTip(ColumnsTreeFIM::clmnFIM_Title, sign.description);
|
||||
|
||||
itemMalfunction->addChild(itemSign);
|
||||
}
|
||||
}
|
||||
|
||||
listItemsAll.append(itemTask);
|
||||
}
|
||||
|
||||
mtxAccess.unlock();
|
||||
|
||||
Q_EMIT signal_listFIMItemsReady(listItemsAll);
|
||||
}
|
||||
90
LibInstructorsAndTrainees/tasks/tasktreepreparation.h
Normal file
90
LibInstructorsAndTrainees/tasks/tasktreepreparation.h
Normal file
@@ -0,0 +1,90 @@
|
||||
#ifndef TASKTREEPREPARATION_H
|
||||
#define TASKTREEPREPARATION_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QDomElement>
|
||||
#include <QMutex>
|
||||
#include "module.h"
|
||||
#include "tasksAmmFim.h"
|
||||
|
||||
enum ColumnsTreeAMM{
|
||||
clmnAMM_PMorDM = 0,
|
||||
clmnAMM_code,
|
||||
clmnAMM_status,
|
||||
clmnAMM_canplay,
|
||||
clmnAMM_ID,
|
||||
clmnAMM_count
|
||||
};
|
||||
|
||||
enum ColumnsTreeFIM{
|
||||
clmnFIM_Title = 0,
|
||||
clmnFIM_status,
|
||||
clmnFIM_ID,
|
||||
clmnFIM_count
|
||||
};
|
||||
|
||||
enum TypeListTreeAMMFIM
|
||||
{
|
||||
listCommon = 0,
|
||||
listForTrainee,
|
||||
listOneTask
|
||||
};
|
||||
|
||||
|
||||
class TaskAMMFIMTreePreparation : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TaskAMMFIMTreePreparation(TypeListTreeAMMFIM type, QTreeWidget* treeWidget, QObject *parent = nullptr);
|
||||
~TaskAMMFIMTreePreparation();
|
||||
|
||||
public:
|
||||
TaskAmmFim getTaskFIMbyID(int id);
|
||||
TaskAmmFim getTaskAMMbyID(int id);
|
||||
|
||||
ModuleType getTypeModuleAMMbyID(int id);
|
||||
|
||||
private:
|
||||
QTreeWidgetItem* addModuleToTreeWidgetAMM(Module* module, bool flOnlyActive = false, QTreeWidgetItem* parentItem = nullptr);
|
||||
|
||||
void loadAMMtasksFromXML(QByteArray array);
|
||||
void domElementParserAMM(QDomElement element, Module* moduleParent);
|
||||
void deleteAllModulsAMM();
|
||||
ModeList parseCanplay(QString canplay);
|
||||
|
||||
void loadFIMtasksFromXML(QByteArray array);
|
||||
|
||||
public Q_SLOTS:
|
||||
void slot_prepareAMMListItems(QByteArray array, bool flOnlyActive, bool flRequestFirst);
|
||||
void slot_prepareAMMListItemsForTrainee(QList<TaskAmmFim> listTasks);
|
||||
|
||||
void slot_prepareFIMListItems(QByteArray array);
|
||||
void slot_prepareFIMListItemsForTrainee(QList<TaskAmmFim> listTasks);
|
||||
|
||||
void slot_stopParserPreparation();
|
||||
|
||||
Q_SIGNALS:
|
||||
void signal_listAMMItemsReady(QList<QTreeWidgetItem*> listItemsAMM);
|
||||
void signal_listFIMItemsReady(QList<QTreeWidgetItem*> listItemsFIM);
|
||||
|
||||
private:
|
||||
QList<QTreeWidgetItem*> listItemsAll;
|
||||
QList<QTreeWidgetItem*> listItemsOnlyActive;
|
||||
|
||||
QList<Module*> listAllModulesAMM;
|
||||
|
||||
QList<TaskAmmFim> listTasksFIM;
|
||||
QList<TaskAmmFim> listTasksAMM;
|
||||
|
||||
bool flagStop;
|
||||
TypeListTreeAMMFIM type;
|
||||
|
||||
QMutex mtxAccess;
|
||||
|
||||
int countItems = 0;
|
||||
|
||||
QTreeWidget* treeWidget;
|
||||
};
|
||||
|
||||
#endif // TASKTREEPREPARATION_H
|
||||
25
LibInstructorsAndTrainees/tasks/viewertaskscommon.cpp
Normal file
25
LibInstructorsAndTrainees/tasks/viewertaskscommon.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
#include "viewertaskscommon.h"
|
||||
#include "ui_viewertaskscommon.h"
|
||||
|
||||
ViewerTasksCommon::ViewerTasksCommon(ConnectorToServer* connectorToServer, AMMtasksWidget* ammTasksWidgetIn, FIMtasksWidget* fimTasksWidgetIn, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
connectorToServer(connectorToServer),
|
||||
ammTasksWidget_common(ammTasksWidgetIn),
|
||||
fimTasksWidget_common(fimTasksWidgetIn),
|
||||
ui(new Ui::ViewerTasksCommon)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->verticalLayout_AMMcommon->addWidget(ammTasksWidget_common);
|
||||
ui->verticalLayout_FIMcommon->addWidget(fimTasksWidget_common);
|
||||
}
|
||||
|
||||
ViewerTasksCommon::~ViewerTasksCommon()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ViewerTasksCommon::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
|
||||
}
|
||||
33
LibInstructorsAndTrainees/tasks/viewertaskscommon.h
Normal file
33
LibInstructorsAndTrainees/tasks/viewertaskscommon.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef VIEWERTASKSCOMMON_H
|
||||
#define VIEWERTASKSCOMMON_H
|
||||
|
||||
#include <QWidget>
|
||||
#include"connectortoserver.h"
|
||||
#include "ammtaskswidget.h"
|
||||
#include "fimtaskswidget.h"
|
||||
|
||||
namespace Ui {
|
||||
class ViewerTasksCommon;
|
||||
}
|
||||
|
||||
class ViewerTasksCommon : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ViewerTasksCommon(ConnectorToServer* connectorToServer, AMMtasksWidget* ammTasksWidget_common, FIMtasksWidget* fimTasksWidget_common, QWidget *parent = nullptr);
|
||||
~ViewerTasksCommon();
|
||||
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private:
|
||||
ConnectorToServer* connectorToServer;
|
||||
|
||||
AMMtasksWidget* ammTasksWidget_common;
|
||||
FIMtasksWidget* fimTasksWidget_common;
|
||||
|
||||
private:
|
||||
Ui::ViewerTasksCommon *ui;
|
||||
};
|
||||
|
||||
#endif // VIEWERTASKSCOMMON_H
|
||||
52
LibInstructorsAndTrainees/tasks/viewertaskscommon.ui
Normal file
52
LibInstructorsAndTrainees/tasks/viewertaskscommon.ui
Normal file
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ViewerTasksCommon</class>
|
||||
<widget class="QWidget" name="ViewerTasksCommon">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_Main">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab_AMM">
|
||||
<attribute name="title">
|
||||
<string>AMM</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_AMMcommon"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_FIM">
|
||||
<attribute name="title">
|
||||
<string>FIM</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_FIMcommon"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user