Files
RRJServer/LibInstructorsAndTrainees/tasks/devicewidget.cpp
2026-01-13 13:11:23 +03:00

74 lines
1.9 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "devicewidget.h"
#include "ui_devicewidget.h"
DeviceWidget::DeviceWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::DeviceWidget)
{
ui->setupUi(this);
ui->lbl_Status->setObjectName("DeviceWidget_lbl_Status");
ui->lbl_ObjName->setObjectName("DeviceWidget_lbl_ObjName");
ui->lbl_Code->setObjectName("DeviceWidget_lbl_Code");
}
DeviceWidget::~DeviceWidget()
{
delete ui;
}
void DeviceWidget::setItem(FIMReportWarehouseItem whItem)
{
//QString str;
//WhItem ID
//str = QString("<p>WhItem ID: %1</p>").arg(QString::number(whItem.id));
// статус GameObject-а в сцене
ui->lbl_Status->setText(getStatusStr(whItem.status));
setStyleStatusLabel(whItem.status);
// имя GameObject-а в сцене
//str = QString("<p>%1</p>").arg(whItem.goName);
// человеческое название прибора
ui->lbl_ObjName->setText(whItem.objName);
// его код из документации
ui->lbl_Code->setText(whItem.code);
}
QString DeviceWidget::getStatusStr(int status)
{
switch (status)
{
//демонтировано
case 0: return tr("dismantled");
//неисправно
case 1: return tr("faulty");
//заменено на новое со склада
case 2: return tr("replaced with a new one from the warehouse");
//unknown
default: return "unknown";
}
}
void DeviceWidget::setStyleStatusLabel(int status)
{
switch (status)
{
//демонтировано
case 0: ui->lbl_Status->setStyleSheet("color: brown;");
break;
//неисправно
case 1: ui->lbl_Status->setStyleSheet("color: red;");
break;
//заменено на новое со склада
case 2: ui->lbl_Status->setStyleSheet("color: green;");
break;
//unknown
default: ui->lbl_Status->setStyleSheet("color: black;");
break;
}
}