You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
218 lines
4.9 KiB
218 lines
4.9 KiB
/**
|
|
* @file EnemyStatsDialog.h
|
|
* @brief 敌情统计对话框定义
|
|
* @author Qt UI Optimizer
|
|
* @date 2024-07-08
|
|
* @version 1.0
|
|
*/
|
|
|
|
#ifndef ENEMYSTATS_DIALOG_H
|
|
#define ENEMYSTATS_DIALOG_H
|
|
|
|
#include <QDialog>
|
|
#include <QVBoxLayout>
|
|
#include <QHBoxLayout>
|
|
#include <QTableWidget>
|
|
#include <QTableWidgetItem>
|
|
#include <QHeaderView>
|
|
#include <QLabel>
|
|
#include <QPushButton>
|
|
#include <QGroupBox>
|
|
#include <QTimer>
|
|
#include <QDateTime>
|
|
#include <QMessageBox>
|
|
#include <QFileDialog>
|
|
#include <QTextStream>
|
|
#include <QApplication>
|
|
#include <QDesktopWidget>
|
|
#include "core/database/EnemyDatabase.h"
|
|
|
|
/**
|
|
* @struct EnemyInfo
|
|
* @brief 敌情信息结构体
|
|
*/
|
|
struct EnemyInfo {
|
|
QString id; ///< 敌人ID/编号
|
|
double longitude; ///< 经度坐标
|
|
double latitude; ///< 纬度坐标
|
|
QString threatLevel; ///< 威胁等级
|
|
QDateTime discoveryTime; ///< 发现时间
|
|
QString enemyType; ///< 敌人类型
|
|
QString status; ///< 状态
|
|
};
|
|
|
|
/**
|
|
* @class EnemyStatsDialog
|
|
* @brief 敌情统计对话框
|
|
*
|
|
* 提供敌情数据的表格显示、统计分析和数据导出功能
|
|
*/
|
|
class EnemyStatsDialog : public QDialog
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
/**
|
|
* @brief 构造函数
|
|
* @param parent 父组件指针
|
|
*/
|
|
explicit EnemyStatsDialog(QWidget *parent = nullptr);
|
|
|
|
/**
|
|
* @brief 析构函数
|
|
*/
|
|
~EnemyStatsDialog();
|
|
|
|
/**
|
|
* @brief 添加敌情信息
|
|
* @param enemy 敌情信息结构体
|
|
*/
|
|
void addEnemyInfo(const EnemyInfo &enemy);
|
|
|
|
/**
|
|
* @brief 更新敌情信息
|
|
* @param id 敌人ID
|
|
* @param enemy 更新后的敌情信息
|
|
*/
|
|
void updateEnemyInfo(const QString &id, const EnemyInfo &enemy);
|
|
|
|
/**
|
|
* @brief 删除敌情信息
|
|
* @param id 敌人ID
|
|
*/
|
|
void removeEnemyInfo(const QString &id);
|
|
|
|
/**
|
|
* @brief 清空所有敌情信息
|
|
*/
|
|
void clearAllEnemies();
|
|
|
|
/**
|
|
* @brief 获取敌情总数
|
|
* @return 敌情总数
|
|
*/
|
|
int getEnemyCount() const;
|
|
|
|
signals:
|
|
/**
|
|
* @brief 敌情数据更新信号
|
|
* @param totalCount 敌情总数
|
|
* @param highThreatCount 高威胁敌情数量
|
|
*/
|
|
void enemyDataUpdated(int totalCount, int highThreatCount);
|
|
|
|
private slots:
|
|
/**
|
|
* @brief 刷新数据槽函数
|
|
*/
|
|
void onRefreshData();
|
|
|
|
/**
|
|
* @brief 导出数据槽函数
|
|
*/
|
|
void onExportData();
|
|
|
|
/**
|
|
* @brief 表格行选择变化槽函数
|
|
*/
|
|
void onTableSelectionChanged();
|
|
|
|
/**
|
|
* @brief 自动刷新定时器槽函数
|
|
*/
|
|
void onAutoRefresh();
|
|
|
|
private:
|
|
/**
|
|
* @brief 设置UI界面
|
|
*/
|
|
void setupUI();
|
|
|
|
/**
|
|
* @brief 设置表格
|
|
*/
|
|
void setupTable();
|
|
|
|
/**
|
|
* @brief 设置统计面板
|
|
*/
|
|
void setupStatsPanel();
|
|
|
|
/**
|
|
* @brief 应用样式表
|
|
*/
|
|
void applyStyles();
|
|
|
|
/**
|
|
* @brief 连接信号槽
|
|
*/
|
|
void connectSignals();
|
|
|
|
/**
|
|
* @brief 更新统计信息
|
|
*/
|
|
void updateStatistics();
|
|
|
|
/**
|
|
* @brief 加载数据库数据
|
|
*/
|
|
void loadDatabaseData();
|
|
|
|
/**
|
|
* @brief 加载测试数据
|
|
*/
|
|
void loadTestData();
|
|
|
|
/**
|
|
* @brief 将EnemyRecord转换为EnemyInfo
|
|
* @param record 数据库记录
|
|
* @return EnemyInfo结构体
|
|
*/
|
|
EnemyInfo recordToInfo(const EnemyRecord &record);
|
|
|
|
/**
|
|
* @brief 获取威胁等级颜色
|
|
* @param threatLevel 威胁等级
|
|
* @return 对应的颜色
|
|
*/
|
|
QColor getThreatLevelColor(const QString &threatLevel);
|
|
|
|
/**
|
|
* @brief 格式化坐标显示
|
|
* @param longitude 经度
|
|
* @param latitude 纬度
|
|
* @return 格式化后的坐标字符串
|
|
*/
|
|
QString formatCoordinates(double longitude, double latitude);
|
|
|
|
// UI组件
|
|
QVBoxLayout *m_mainLayout; ///< 主布局
|
|
QHBoxLayout *m_contentLayout; ///< 内容布局
|
|
|
|
// 表格组件
|
|
QGroupBox *m_tableGroup; ///< 表格分组框
|
|
QTableWidget *m_enemyTable; ///< 敌情表格
|
|
|
|
// 统计面板组件
|
|
QGroupBox *m_statsGroup; ///< 统计分组框
|
|
QLabel *m_totalCountLabel; ///< 总数标签
|
|
QLabel *m_highThreatLabel; ///< 高威胁数量标签
|
|
QLabel *m_mediumThreatLabel; ///< 中威胁数量标签
|
|
QLabel *m_lowThreatLabel; ///< 低威胁数量标签
|
|
QLabel *m_lastUpdateLabel; ///< 最后更新时间标签
|
|
|
|
// 操作按钮
|
|
QPushButton *m_refreshBtn; ///< 刷新按钮
|
|
QPushButton *m_exportBtn; ///< 导出按钮
|
|
QPushButton *m_closeBtn; ///< 关闭按钮
|
|
|
|
// 数据存储
|
|
QList<EnemyInfo> m_enemyList; ///< 敌情信息列表
|
|
EnemyDatabase *m_enemyDatabase; ///< 敌情数据库实例
|
|
|
|
// 定时器
|
|
QTimer *m_autoRefreshTimer; ///< 自动刷新定时器
|
|
};
|
|
|
|
#endif // ENEMYSTATS_DIALOG_H
|