159 lines
3.8 KiB
C++
159 lines
3.8 KiB
C++
#ifndef PROCEDUREPLAYERWIDGET_H
|
||
#define PROCEDUREPLAYERWIDGET_H
|
||
|
||
#include <QWidget>
|
||
#include <QVBoxLayout>
|
||
#include <QHBoxLayout>
|
||
#include <QSplitter>
|
||
#include <QScrollArea>
|
||
#include <QLabel>
|
||
#include <QPushButton>
|
||
#include <QTreeWidget>
|
||
#include <QStackedWidget>
|
||
#include <QTableWidget>
|
||
#include <QCheckBox>
|
||
#include "../procedure/proceduredata.h"
|
||
#include "tableoverlaywidget.h"
|
||
|
||
class ProcedureManager;
|
||
|
||
/**
|
||
* @class StepItemWidget
|
||
* @brief 步骤项组件
|
||
*
|
||
* 显示单个步骤的内容,包括:
|
||
* - 步骤类型标记(自动/手动)
|
||
* - 步骤内容
|
||
* - 执行状态
|
||
* - 确认复选框(手动步骤)
|
||
*/
|
||
class StepItemWidget : public QWidget
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
explicit StepItemWidget(const StepData &step, QWidget *parent = nullptr);
|
||
|
||
QString stepId() const { return m_step.id; }
|
||
void setHighlighted(bool highlighted);
|
||
void updateStatus(StepStatus status);
|
||
|
||
signals:
|
||
void confirmRequested(const QString &stepId);
|
||
void confirmCancelled(const QString &stepId, const QString &reason);
|
||
void tableExpandRequested(const QString &tableId);
|
||
void stepTypeChanged(const QString &stepId, StepType newType);
|
||
|
||
private slots:
|
||
void onCheckboxToggled(bool checked);
|
||
void onTypeBtnClicked();
|
||
|
||
private:
|
||
void setupUI();
|
||
void updateStatusDisplay();
|
||
void updateTypeButton();
|
||
|
||
StepData m_step;
|
||
QPushButton *m_typeBtn;
|
||
QLabel *m_contentLabel;
|
||
QLabel *m_statusLabel;
|
||
QCheckBox *m_confirmCheckbox;
|
||
QPushButton *m_tableBtn;
|
||
QWidget *m_container;
|
||
};
|
||
|
||
/**
|
||
* @class TableViewWidget
|
||
* @brief 表格展示组件
|
||
*
|
||
* 内联展示相关表格,可展开/收起
|
||
*/
|
||
class TableViewWidget : public QWidget
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
explicit TableViewWidget(const TableData &table, QWidget *parent = nullptr);
|
||
|
||
void setHighlightedFields(const QStringList &fields);
|
||
void toggleExpanded();
|
||
bool isExpanded() const { return m_expanded; }
|
||
|
||
private:
|
||
void setupUI();
|
||
void updateTable();
|
||
|
||
TableData m_table;
|
||
QTableWidget *m_tableWidget;
|
||
QLabel *m_headerLabel;
|
||
QPushButton *m_toggleBtn;
|
||
QWidget *m_tableContainer;
|
||
QStringList m_highlightedFields;
|
||
bool m_expanded;
|
||
};
|
||
|
||
/**
|
||
* @class ProcedurePlayerWidget
|
||
* @brief 规程执行页面
|
||
*
|
||
* 主执行界面,包括:
|
||
* - 顶部信息栏(规程ID、名称、返回按钮)
|
||
* - 左侧步骤导航
|
||
* - 中间步骤内容区
|
||
* - 内联表格展示
|
||
*/
|
||
class ProcedurePlayerWidget : public QWidget
|
||
{
|
||
Q_OBJECT
|
||
|
||
public:
|
||
explicit ProcedurePlayerWidget(ProcedureManager *manager, QWidget *parent = nullptr);
|
||
~ProcedurePlayerWidget();
|
||
|
||
void loadProcedure(const QString &procedureId);
|
||
|
||
signals:
|
||
void backToListRequested();
|
||
|
||
private slots:
|
||
void onBackClicked();
|
||
void onNavigationItemClicked(QTreeWidgetItem *item, int column);
|
||
void onStepConfirmRequested(const QString &stepId);
|
||
void onStepConfirmCancelled(const QString &stepId, const QString &reason);
|
||
void onTableExpandRequested(const QString &tableId);
|
||
void onStepStatusChanged(const QString &stepId, StepStatus status);
|
||
|
||
private:
|
||
void setupUI();
|
||
void populateNavigation();
|
||
void populateStepContent();
|
||
void showStep(const QString &stepId);
|
||
void showGroupSteps(const QString &groupId);
|
||
void updateNavigationStatus();
|
||
|
||
ProcedureManager *m_manager;
|
||
ProcedureData m_currentProcedure;
|
||
QString m_currentStepId;
|
||
QString m_currentGroupId;
|
||
|
||
// UI 组件
|
||
QLabel *m_procedureIdLabel;
|
||
QLabel *m_procedureNameLabel;
|
||
QPushButton *m_backBtn;
|
||
QTreeWidget *m_navigationTree;
|
||
QScrollArea *m_contentArea;
|
||
QWidget *m_contentWidget;
|
||
QVBoxLayout *m_contentLayout;
|
||
QLabel *m_stepTitleLabel; // 当前步骤标题
|
||
|
||
QMap<QString, StepItemWidget *> m_stepWidgets;
|
||
QMap<QString, TableViewWidget *> m_tableWidgets;
|
||
QMap<QString, QTreeWidgetItem *> m_navItems;
|
||
QMap<QString, StepData> m_allSteps; // 存储所有步骤数据
|
||
|
||
// 表格浮层
|
||
TableOverlayWidget *m_tableOverlay;
|
||
};
|
||
|
||
#endif // PROCEDUREPLAYERWIDGET_H
|