99 lines
2.6 KiB
C++
99 lines
2.6 KiB
C++
#ifndef FACEMANAGEDIALOG_H
|
|
#define FACEMANAGEDIALOG_H
|
|
|
|
#include <QDialog>
|
|
#include <QGridLayout>
|
|
#include <QScrollArea>
|
|
#include <QLabel>
|
|
#include <QLineEdit>
|
|
#include <QPushButton>
|
|
#include <QMap>
|
|
#include <QNetworkAccessManager>
|
|
#include <QNetworkReply>
|
|
|
|
/**
|
|
* @brief 人脸照片项组件
|
|
* 显示单个人脸照片及其学号映射
|
|
*/
|
|
class FacePhotoItem : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit FacePhotoItem(const QString &faceId, bool hasPhoto = true, QWidget *parent = nullptr);
|
|
|
|
QString getFaceId() const { return m_faceId; }
|
|
QString getStudentId() const { return m_studentIdEdit->text().trimmed(); }
|
|
void setStudentId(const QString &studentId) { m_studentIdEdit->setText(studentId); }
|
|
void setPhoto(const QPixmap &pixmap);
|
|
bool hasPhoto() const { return m_hasPhoto; }
|
|
|
|
signals:
|
|
void studentIdChanged(const QString &faceId, const QString &studentId);
|
|
void deleteRequested(const QString &faceId);
|
|
|
|
private:
|
|
QString m_faceId;
|
|
bool m_hasPhoto;
|
|
QLabel *m_photoLabel;
|
|
QLabel *m_idLabel;
|
|
QLineEdit *m_studentIdEdit;
|
|
QPushButton *m_deleteButton;
|
|
};
|
|
|
|
/**
|
|
* @brief 人脸管理对话框
|
|
* 显示K210上传的人脸照片,允许配置学号映射
|
|
*/
|
|
class FaceManageDialog : public QDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit FaceManageDialog(QWidget *parent = nullptr);
|
|
~FaceManageDialog();
|
|
|
|
void setServerUrl(const QString &url) { m_serverUrl = url; }
|
|
|
|
signals:
|
|
void mappingSaved();
|
|
|
|
public slots:
|
|
void refreshPhotos();
|
|
|
|
private slots:
|
|
void onPhotoListReceived(QNetworkReply *reply);
|
|
void onPhotoReceived(QNetworkReply *reply);
|
|
void onMappingReceived(QNetworkReply *reply);
|
|
void onMappingSaved(QNetworkReply *reply);
|
|
void onAllStudentIdsReceived(QNetworkReply *reply);
|
|
void onFaceDeleted(QNetworkReply *reply);
|
|
void saveMapping();
|
|
void onDeleteRequested(const QString &studentId);
|
|
|
|
private:
|
|
void setupUI();
|
|
void fetchPhotoList();
|
|
void fetchPhoto(const QString &faceId);
|
|
void fetchMapping();
|
|
void fetchAllStudentIds();
|
|
void uploadMapping();
|
|
void deleteFace(const QString &studentId, bool deleteRecords);
|
|
void clearPhotoItems();
|
|
|
|
QString m_serverUrl;
|
|
QNetworkAccessManager *m_networkManager;
|
|
QScrollArea *m_scrollArea;
|
|
QWidget *m_contentWidget;
|
|
QGridLayout *m_gridLayout;
|
|
QPushButton *m_refreshButton;
|
|
QPushButton *m_saveButton;
|
|
QLabel *m_statusLabel;
|
|
|
|
QMap<QString, FacePhotoItem*> m_photoItems; // faceId -> item
|
|
QMap<QString, QString> m_idMapping; // faceId -> studentId
|
|
int m_pendingPhotoCount;
|
|
};
|
|
|
|
#endif // FACEMANAGEDIALOG_H
|