mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
ПП отображаются в виде выпадающего списка (назн-е)
This commit is contained in:
@@ -25,11 +25,13 @@ AMMtasksWidget::AMMtasksWidget(ConnectorToServer* connectorToServer, TypeListTre
|
||||
flOnlyActive(false),
|
||||
lastCurrentID(0)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
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::currentItemChanged, this, &AMMtasksWidget::on_treeWidgetItemClicked);
|
||||
@@ -39,8 +41,8 @@ AMMtasksWidget::AMMtasksWidget(ConnectorToServer* connectorToServer, TypeListTre
|
||||
preparationTreeWidget();
|
||||
|
||||
threadPreparation = new QThread();
|
||||
taskTreePreparation = new TaskAMMFIMTreePreparation(type);
|
||||
taskTreePreparation->moveToThread(threadPreparation);
|
||||
taskTreePreparation = new TaskAMMFIMTreePreparation(type, treeWidget);
|
||||
//taskTreePreparation->moveToThread(threadPreparation);
|
||||
threadPreparation->start();
|
||||
threadPreparation->setPriority(QThread::HighestPriority);
|
||||
connect(this, &AMMtasksWidget::signal_prepareAMMListItems, taskTreePreparation, &TaskAMMFIMTreePreparation::slot_prepareAMMListItems);
|
||||
@@ -281,11 +283,14 @@ void AMMtasksWidget::loadTasksAMM(bool flRequestFirst)
|
||||
|
||||
void AMMtasksWidget::slot_AMMlistItemsReady(QList<QTreeWidgetItem *> listItems)
|
||||
{
|
||||
//Обновление дерева
|
||||
treeWidget->clear();
|
||||
if(type != TypeListTreeAMMFIM::listForTrainee)
|
||||
{
|
||||
//Обновление дерева
|
||||
treeWidget->clear();
|
||||
|
||||
for(QTreeWidgetItem * item : listItems)
|
||||
treeWidget->addTopLevelItem(item);
|
||||
for(QTreeWidgetItem * item : listItems)
|
||||
treeWidget->addTopLevelItem(item);
|
||||
}
|
||||
|
||||
/*
|
||||
QTreeWidgetItem * item = treeWidget->topLevelItem(0);
|
||||
|
||||
@@ -38,7 +38,7 @@ FIMtasksWidget::FIMtasksWidget(ConnectorToServer* connectorToServer, TypeListTre
|
||||
preparationTreeWidget();
|
||||
|
||||
threadPreparation = new QThread();
|
||||
taskTreePreparation = new TaskAMMFIMTreePreparation(type);
|
||||
taskTreePreparation = new TaskAMMFIMTreePreparation(type, treeWidget);
|
||||
taskTreePreparation->moveToThread(threadPreparation);
|
||||
threadPreparation->start();
|
||||
threadPreparation->setPriority(QThread::HighestPriority);
|
||||
|
||||
@@ -152,8 +152,8 @@ void ListSubProc::slot_UpdateSubProcForDMCode(QString dmCode)
|
||||
{
|
||||
QList<SubProc> list = connectorToServer->getListSubProcForDMCode(dmCode);
|
||||
|
||||
if(!list.count())
|
||||
on_btnAssign_clicked();
|
||||
/*if(!list.count())
|
||||
on_btnAssign_clicked();*/
|
||||
|
||||
for(SubProc subProc : list)
|
||||
{
|
||||
@@ -177,12 +177,12 @@ void ListSubProc::slot_UpdateSubProcForDMCode(QString dmCode)
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
item->setCheckState(ColumnsTreeSubProc::clmnSP_title, Qt::Unchecked);
|
||||
|
||||
item->setFlags(item->flags() ^ Qt::ItemIsEnabled);
|
||||
//item->setFlags(item->flags() ^ Qt::ItemIsEnabled);
|
||||
|
||||
#ifdef PROJECT_TYPE_DEBUG
|
||||
treeWidget->addTopLevelItem(item);
|
||||
#else
|
||||
|
||||
item->setFlags(item->flags() ^ Qt::ItemIsEnabled);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
40
InstructorsAndTrainees/tasks/subprocitemwidget.cpp
Normal file
40
InstructorsAndTrainees/tasks/subprocitemwidget.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#include "subprocitemwidget.h"
|
||||
#include "ui_subprocitemwidget.h"
|
||||
|
||||
SubProcItemWidget::SubProcItemWidget(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::SubProcItemWidget)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
SubProcItemWidget::~SubProcItemWidget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SubProcItemWidget::setListSubProc(const QList<SubProc> &list)
|
||||
{
|
||||
int totalHeight = 0;
|
||||
|
||||
for (SubProc subProc : list)
|
||||
{/*Подпроцедуры*/
|
||||
ui->listWidget->addItem(QString("* %1\n [%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 += 10;
|
||||
}
|
||||
|
||||
// Добавляем отступы фрейма (рамки)
|
||||
totalHeight += ui->listWidget->frameWidth() * 2;
|
||||
|
||||
ui->listWidget->setMaximumHeight(totalHeight);
|
||||
}
|
||||
25
InstructorsAndTrainees/tasks/subprocitemwidget.h
Normal file
25
InstructorsAndTrainees/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
InstructorsAndTrainees/tasks/subprocitemwidget.ui
Normal file
54
InstructorsAndTrainees/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>400</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>
|
||||
@@ -1,12 +1,16 @@
|
||||
#include <QThread>
|
||||
#include <QDebug>
|
||||
#include "tasktreepreparation.h"
|
||||
#include "subprocitemwidget.h"
|
||||
|
||||
#include <QLineEdit>
|
||||
|
||||
|
||||
TaskAMMFIMTreePreparation::TaskAMMFIMTreePreparation(TypeListTreeAMMFIM type, QObject *parent) :
|
||||
TaskAMMFIMTreePreparation::TaskAMMFIMTreePreparation(TypeListTreeAMMFIM type, QTreeWidget* treeWidget, QObject *parent) :
|
||||
QObject(parent),
|
||||
flagStop(false),
|
||||
type(type)
|
||||
type(type),
|
||||
treeWidget(treeWidget)
|
||||
{
|
||||
qDebug() << "TaskAMMFIMTreePreparation init thread ID " << QThread::currentThreadId();
|
||||
}
|
||||
@@ -477,6 +481,9 @@ void TaskAMMFIMTreePreparation::slot_prepareAMMListItemsForTrainee(QList<TaskAmm
|
||||
|
||||
listItemsAll.clear();
|
||||
|
||||
//Обновление дерева
|
||||
treeWidget->clear();
|
||||
|
||||
mtxAccess.lock();
|
||||
|
||||
this->listTasksAMM = listTasks;
|
||||
@@ -491,6 +498,9 @@ void TaskAMMFIMTreePreparation::slot_prepareAMMListItemsForTrainee(QList<TaskAmm
|
||||
QString status = task.status;
|
||||
|
||||
item = new QTreeWidgetItem();
|
||||
|
||||
treeWidget->addTopLevelItem(item);
|
||||
|
||||
item->setIcon(0, QIcon(":/resources/icons/procedure.png"));
|
||||
|
||||
item->setText(ColumnsTreeAMM::clmnAMM_PMorDM, text);
|
||||
@@ -520,26 +530,22 @@ void TaskAMMFIMTreePreparation::slot_prepareAMMListItemsForTrainee(QList<TaskAmm
|
||||
|
||||
item->setToolTip(0, text);
|
||||
|
||||
|
||||
if(type == TypeListTreeAMMFIM::listForTrainee)
|
||||
{
|
||||
for (int j = 0; j < task.listSubProc.count(); j++)
|
||||
{/*Подпроцедуры*/
|
||||
SubProc subProc = task.listSubProc.at(j);
|
||||
|
||||
//Подпроцедуры
|
||||
if(task.listSubProc.count())
|
||||
{
|
||||
QTreeWidgetItem* itemSubProc = new QTreeWidgetItem();
|
||||
itemSubProc->setFlags(itemSubProc->flags() ^ Qt::ItemIsSelectable);
|
||||
|
||||
itemSubProc->setText(ColumnsTreeAMM::clmnAMM_PMorDM, subProc.getTitle());
|
||||
|
||||
itemSubProc->setIcon(ColumnsTreeAMM::clmnAMM_PMorDM, QIcon(":/resources/icons/link.png"));
|
||||
itemSubProc->setToolTip(ColumnsTreeAMM::clmnAMM_PMorDM, subProc.getTitle());
|
||||
|
||||
itemSubProc->setText(ColumnsTreeAMM::clmnAMM_code, subProc.getDmCode());
|
||||
|
||||
itemSubProc->setText(ColumnsTreeAMM::clmnAMM_canplay, subProc.getModeListStr());
|
||||
SubProcItemWidget* itemWidget = new SubProcItemWidget();
|
||||
itemWidget->setListSubProc(task.listSubProc);
|
||||
//itemWidget->setAutoFillBackground(true);
|
||||
|
||||
item->addChild(itemSubProc);
|
||||
treeWidget->setItemWidget(itemSubProc, 0, itemWidget);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
listItemsAll.append(item);
|
||||
|
||||
@@ -36,7 +36,7 @@ class TaskAMMFIMTreePreparation : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit TaskAMMFIMTreePreparation(TypeListTreeAMMFIM type, QObject *parent = nullptr);
|
||||
explicit TaskAMMFIMTreePreparation(TypeListTreeAMMFIM type, QTreeWidget* treeWidget, QObject *parent = nullptr);
|
||||
~TaskAMMFIMTreePreparation();
|
||||
|
||||
public:
|
||||
@@ -83,6 +83,8 @@ private:
|
||||
QMutex mtxAccess;
|
||||
|
||||
int countItems = 0;
|
||||
|
||||
QTreeWidget* treeWidget;
|
||||
};
|
||||
|
||||
#endif // TASKTREEPREPARATION_H
|
||||
|
||||
Reference in New Issue
Block a user