GrabBag/App/WheelMeasure/WheelMeasureApp/widgets/MeasureResultListWidget.h

107 lines
2.8 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.

#ifndef MEASURERESULTLISTWIDGET_H
#define MEASURERESULTLISTWIDGET_H
#include <QWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QScrollArea>
#include <QMap>
#include <QLabel>
#include <QFrame>
#include "IVrWheelMeasureConfig.h"
/**
* @brief 结果卡片显示模式
*/
enum class ResultCardMode {
Wheel = 0, // 显示拱高/到地面高度/上下点位
Correction = 1, // 只显示工装长度
};
/**
* @brief 单个设备结果卡片控件
*/
class DeviceResultCard : public QFrame
{
Q_OBJECT
public:
explicit DeviceResultCard(const QString& deviceName, QWidget* parent = nullptr);
~DeviceResultCard();
void updateResult(const WheelMeasureData& data, bool isValid);
void clearResult();
void setDisplayMode(ResultCardMode mode);
QString getDeviceName() const { return m_deviceName; }
private:
void setupUI();
void applyDisplayMode();
QString m_deviceName;
ResultCardMode m_mode = ResultCardMode::Wheel;
QLabel* m_nameLabel = nullptr;
QLabel* m_heightLabel = nullptr;
QLabel* m_groundHeightLabel = nullptr; // 到地面高度
QLabel* m_archPosLabel = nullptr; // 拱点位置
QLabel* m_upPosLabel = nullptr; // 上点位置
QLabel* m_downPosLabel = nullptr; // 下点位置
QLabel* m_lengthLabel = nullptr; // 工装长度Correction 模式)
QLabel* m_timestampLabel = nullptr;
QLabel* m_statusLabel = nullptr;
};
/**
* @brief 检测结果列表控件
* 每个设备显示为一个卡片,显示最新的检测结果
*/
class MeasureResultListWidget : public QWidget
{
Q_OBJECT
public:
explicit MeasureResultListWidget(QWidget* parent = nullptr);
~MeasureResultListWidget();
/**
* @brief 设置设备列表
* @param deviceNames 设备名称列表
*/
void setDeviceList(const QStringList& deviceNames);
/**
* @brief 更新设备检测结果
* @param deviceName 设备名称
* @param data 检测数据
* @param isValid 结果是否有效
*/
void updateDeviceResult(const QString& deviceName, const WheelMeasureData& data, bool isValid);
/**
* @brief 清空所有结果
*/
void clearAllResults();
/**
* @brief 清空指定设备的结果
*/
void clearDeviceResult(const QString& deviceName);
/**
* @brief 设置所有卡片的显示模式(轮毂/工装)
*/
void setDisplayMode(ResultCardMode mode);
private:
void setupUI();
DeviceResultCard* findOrCreateCard(const QString& deviceName);
QScrollArea* m_scrollArea = nullptr;
QWidget* m_contentWidget = nullptr;
QVBoxLayout* m_contentLayout = nullptr;
QMap<QString, DeviceResultCard*> m_deviceCards;
ResultCardMode m_mode = ResultCardMode::Wheel;
};
#endif // MEASURERESULTLISTWIDGET_H