12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #ifndef SAFETYINSPECT_H
- #define SAFETYINSPECT_H
- #include <QDialog>
- #include <QHBoxLayout>
- #include <QHeaderView>
- #include <QJsonArray>
- #include <QJsonDocument>
- #include <QJsonObject>
- #include <QLabel>
- #include <QNetworkAccessManager>
- #include <QNetworkReply>
- #include <QPushButton>
- #include <QTableWidget>
- #include <QVBoxLayout>
- /**
- * SafetyInspect Dialog Component
- *
- * Usage example:
- *
- * // Method 1: Set data manually
- * SafetyInspect *dialog = new SafetyInspect(this);
- * dialog->setDate("2025-07-30");
- *
- * QList<SafetyInspect::InspectionRecord> records;
- * SafetyInspect::InspectionRecord record1;
- * record1.name = "张三";
- * record1.phone = "13800138000";
- * record1.checkStatus = "检查通过";
- * records.append(record1);
- *
- * dialog->setInspectionRecords(records);
- * dialog->exec();
- *
- * // Method 2: Fetch data from HTTP
- * SafetyInspect *dialog = new SafetyInspect(this);
- * dialog->fetchDataFromHttp("https://api.example.com/safety-inspection");
- * dialog->exec();
- */
- class SafetyInspectDialog : public QDialog {
- Q_OBJECT
- public:
- struct InspectionRecord {
- QString name;
- QString phone;
- QString confirmTime;
- };
- explicit SafetyInspectDialog(QWidget *parent = nullptr,
- const QMap<QString, QString> &userNameById = QMap<QString, QString>(),
- const QString &dateStr = QString());
- ~SafetyInspectDialog();
- // Set the date to display in header
- void setDate(const QString &date);
- // Set the inspection records to display in table
- void setInspectionRecords(const QList<InspectionRecord> &records);
- void onCloseButtonClicked();
- private:
- void setupUI();
- void setupTable();
- void populateTable();
- QLabel *m_dateLabel;
- QTableWidget *m_tableWidget;
- QPushButton *m_closeButton;
- QString m_currentDate;
- QMap<QString, QString> m_userNameById;
- QList<InspectionRecord> m_inspectionRecords;
- };
- #endif // SAFETYINSPECT_H
|