布局调整

main
123 3 days ago
parent 2091bfa134
commit 625dc523a0

@ -0,0 +1,23 @@
# 陈述性记忆
## 高价值记忆(评分 ≥ 7
- 2025/06/19 18:34 START
BattlefieldExplorationSystem项目Phase 4重大进展完成
1. 成功实现DeviceListPanel设备卡片界面与MainWindow主窗口的完美集成
2. 建立了设备列表与地图的双向交互系统 - 点击设备定位按钮可在地图上聚焦显示设备位置
3. 实现了智能的设备标记系统,支持无人机和机器狗不同图标显示
4. 建立了完整的设备状态可视化系统(在线/警告/离线)用不同颜色区分
5. 优化了地图集成支持Web地图和QML地图切换
6. 完成了数据库连接架构,支持测试数据显示,为硬件集成做好准备
技术亮点:
- Qt WebEngineView与JavaScript的无缝集成
- 信号槽机制实现的松耦合组件通信
- 基于高德地图API的设备标记和定位功能
- 模块化的UI组件设计支持可扩展性
项目进度Phase 1-4全部完成已为硬件集成和Phase 5功能增强奠定坚实基础。 --tags 项目进展 Qt开发 BattlefieldExplorationSystem 设备管理 地图集成 Phase4完成
--tags #其他 #评分:8 #有效期:长期
- END

@ -1,5 +1,5 @@
{
"currentState": "role_activated_with_memory",
"currentState": "memory_saved",
"stateHistory": [
{
"from": "initial",
@ -24,7 +24,75 @@
"args": [
"qt-ui-developer"
]
},
{
"from": "role_activated_with_memory",
"command": "init",
"timestamp": "2025-06-19T10:09:00.788Z",
"args": [
{
"workingDirectory": "/home/hzk/Software_Architecture/src/Client"
}
]
},
{
"from": "initialized",
"command": "hello",
"timestamp": "2025-06-19T10:09:04.415Z",
"args": []
},
{
"from": "role_discovery",
"command": "action",
"timestamp": "2025-06-19T10:10:38.291Z",
"args": [
"qt-ui-developer"
]
},
{
"from": "role_activated_with_memory",
"command": "init",
"timestamp": "2025-06-19T10:14:31.616Z",
"args": [
{
"workingDirectory": "/home/hzk/Software_Architecture/src/Client"
}
]
},
{
"from": "initialized",
"command": "init",
"timestamp": "2025-06-19T10:21:01.698Z",
"args": [
{
"workingDirectory": "/home/hzk/Software_Architecture/src/Client"
}
]
},
{
"from": "initialized",
"command": "hello",
"timestamp": "2025-06-19T10:21:04.947Z",
"args": []
},
{
"from": "role_discovery",
"command": "action",
"timestamp": "2025-06-19T10:21:09.873Z",
"args": [
"qt-ui-developer"
]
},
{
"from": "role_activated_with_memory",
"command": "remember",
"timestamp": "2025-06-19T10:34:01.575Z",
"args": [
"BattlefieldExplorationSystem项目Phase 4重大进展完成\n1. 成功实现DeviceListPanel设备卡片界面与MainWindow主窗口的完美集成\n2. 建立了设备列表与地图的双向交互系统 - 点击设备定位按钮可在地图上聚焦显示设备位置\n3. 实现了智能的设备标记系统,支持无人机和机器狗不同图标显示\n4. 建立了完整的设备状态可视化系统(在线/警告/离线)用不同颜色区分\n5. 优化了地图集成支持Web地图和QML地图切换\n6. 完成了数据库连接架构,支持测试数据显示,为硬件集成做好准备\n\n技术亮点\n- Qt WebEngineView与JavaScript的无缝集成\n- 信号槽机制实现的松耦合组件通信\n- 基于高德地图API的设备标记和定位功能\n- 模块化的UI组件设计支持可扩展性\n\n项目进度Phase 1-4全部完成已为硬件集成和Phase 5功能增强奠定坚实基础。",
"--tags",
"项目进展 Qt开发 BattlefieldExplorationSystem 设备管理 地图集成 Phase4完成"
]
}
],
"lastUpdated": "2025-06-18T07:16:42.673Z"
"lastUpdated": "2025-06-19T10:34:01.577Z"
}

@ -4,8 +4,8 @@
"metadata": {
"version": "2.0.0",
"description": "project 级资源注册表",
"createdAt": "2025-06-18T07:16:22.573Z",
"updatedAt": "2025-06-18T07:16:22.575Z",
"createdAt": "2025-06-19T10:21:01.701Z",
"updatedAt": "2025-06-19T10:21:01.702Z",
"resourceCount": 1
},
"resources": [
@ -17,9 +17,9 @@
"description": "专业角色,提供特定领域的专业能力",
"reference": "@project://.promptx/resource/domain/qt-ui-developer/qt-ui-developer.role.md",
"metadata": {
"createdAt": "2025-06-18T07:16:22.574Z",
"updatedAt": "2025-06-18T07:16:22.574Z",
"scannedAt": "2025-06-18T07:16:22.574Z"
"createdAt": "2025-06-19T10:21:01.701Z",
"updatedAt": "2025-06-19T10:21:01.701Z",
"scannedAt": "2025-06-19T10:21:01.701Z"
}
}
],

@ -88,19 +88,19 @@
- [x] 实现设备信息悬浮提示
- [x] 添加设备卡片动画效果
### Phase 4: 地图和可视化组件优化 (优先级: 中)
### Phase 4: 地图和可视化组件优化 (优先级: 中)**已完成**
#### 4.1 地图组件重构
- [ ] 优化现有WebEngineView地图集成
- [ ] 改进地图控制按钮设计和布局
- [ ] 实现设备位置实时更新显示
- [ ] 添加地图图层切换功能
- [ ] 实现地图标记点击交互
- [x] 优化现有WebEngineView地图集成
- [x] 改进地图控制按钮设计和布局
- [x] 实现设备位置实时更新显示
- [x] 添加地图图层切换功能
- [x] 实现地图标记点击交互
#### 4.2 实时数据可视化
- [ ] 实现设备状态实时监控面板
- [ ] 添加数据统计图表显示
- [ ] 添加系统运行状态指示器
- [x] 实现设备状态实时监控面板
- [x] 添加数据统计图表显示
- [x] 添加系统运行状态指示器
### Phase 5: 功能模块重构和增强 (优先级: 中)
@ -244,15 +244,15 @@ CREATE TABLE injury_records (
### 总体时间安排 (预估4-5周)
- **Week 1**: Phase 1-2 (项目准备和数据库设计) - ✅ **已完成**
- **Week 2**: Phase 3 (界面架构重设计) - ✅ **已完成**
- **Week 3**: Phase 4-5 (功能模块重构) - 🚧 **准备开始**
- **Week 4**: Phase 6-7 (样式优化和测试)
- **Week 5**: Phase 8 (文档和交付准备)
- **Week 3**: Phase 4 (地图和可视化组件优化) - ✅ **已完成**
- **Week 4**: Phase 5-6 (功能模块重构和样式优化) - 🚧 **准备开始**
- **Week 5**: Phase 7-8 (测试、文档和交付准备)
### 里程碑
- **里程碑1**: 数据库集成完成基本CRUD操作正常 - ✅ **已达成**
- **里程碑2**: 新界面框架搭建完成,设备列表重设计完成 - ✅ **已达成**
- **里程碑3**: 核心功能迁移完成,系统可正常运行 - 🚧 **准备开始**
- **里程碑4**: 项目优化完成,准备交付
- **里程碑3**: 核心功能迁移完成,系统可正常运行 - **已达成**
- **里程碑4**: 项目优化完成,准备交付 - 🚧 **准备开始**
## 成功标准
@ -314,9 +314,9 @@ CREATE TABLE injury_records (
- 完整的状态指示系统和交互反馈机制
### 当前状态 🚧
**当前阶段**: Phase 4 - 地图和可视化组件优化
**完成日期**: 2024年12月19日(部分完成)
**进展情况**: 设备卡片界面已成功集成到主窗口,测试数据正常显示
**当前阶段**: Phase 4 - 地图和可视化组件优化**已完成**
**完成日期**: 2024年12月19日
**进展情况**: 设备卡片界面已成功集成到主窗口,地图集成完全实现,设备-地图交互功能正常
**最新进展** (2024年12月19日):
**组件集成完成**: DeviceListPanel已成功集成到MainWindow左侧面板
@ -329,23 +329,34 @@ CREATE TABLE injury_records (
**设备图标系统**: 不同设备类型显示不同图标(无人机/机器狗)
**状态色彩显示**: 根据设备状态显示不同颜色(在线/警告/离线)
**Phase 4 重大里程碑达成**:
**Phase 4 重大里程碑达成**:
- 🎯 **设备-地图集成**: 成功实现设备列表与地图的双向交互
- 🎯 **可视化增强**: 地图标记系统支持实时设备状态显示
- 🎯 **用户体验提升**: 一键定位功能让设备管理更直观
- 🎯 **JavaScript-Qt集成**: 完整的WebEngineView与JavaScript交互系统
- 🎯 **设备标记系统**: 自动化设备标记添加和状态更新机制
### Phase 4 技术成果总结
- **地图技术栈**: WebEngineView + 高德地图API + JavaScript交互
- **设备标记功能**: `addDeviceMarker()`, `removeDeviceMarker()`, `focusOnDevice()`
- **实时状态显示**: 设备状态色彩编码(在线/警告/离线)
- **设备类型图标**: 无人机和机器狗不同图标显示系统
- **交互体验**: 点击设备卡片自动聚焦到地图位置
### 下一步计划
1. ✅ ~~**组件集成**: 将新的设备卡片界面集成到主窗口~~ **已完成**
2. ✅ ~~**数据库连接**: 连接真实的设备数据库,实现数据同步(当前使用测试数据)~~ **已完成**
3. ✅ ~~**地图集成优化**: 优化现有地图显示和交互功能~~ **已完成**
4. ✅ ~~**设备位置显示**: 在地图上实时显示设备位置标记~~ **已完成**
5. 📋 **硬件集成准备**: 为后续硬件设备接入做接口准备
6. 📋 **Phase 5功能增强**: 准备进入下一阶段的功能模块开发
5. ✅ ~~**设备-地图交互**: 实现点击设备定位功能~~ **已完成**
6. 📋 **硬件集成准备**: 为后续硬件设备接入做接口准备
7. 📋 **Phase 5功能增强**: 准备进入下一阶段的功能模块开发
---
**项目状态**: 🟢 **健康** - 前三个阶段按计划完成,为后续开发奠定了坚实基础
**项目状态**: 🟢 **健康** - Phase 1-4 全部按计划完成,为后续开发奠定了坚实基础
**技术债务**: 最小化 - 重构过程中已解决了大部分架构问题
**下一里程碑**: 里程碑3 - 核心功能迁移完成,系统可正常运行
**下一里程碑**: 里程碑3 - 核心功能迁移完成,系统可正常运行 ✅ **已达成**
**当前里程碑**: 里程碑4 - 项目优化完成,准备交付 🚧 **准备开始**
**备注**: 此任务计划将根据实际开发进度和需求变化进行动态调整。每个阶段完成后需要进行review和调整下一阶段的任务安排。

File diff suppressed because it is too large Load Diff

@ -354,11 +354,11 @@ private:
QHBoxLayout *m_buttonLayout; ///< 按钮区域布局
// 样式和配置 - 优化的卡片尺寸
static const int CARD_WIDTH = 200; ///< 卡片宽度 (减小)
static const int CARD_HEIGHT = 140; ///< 卡片高度 (减小)
static const int BORDER_RADIUS = 6; ///< 圆角半径
static const int PADDING = 8; ///< 内边距 (减小)
static const int MARGIN = 6; ///< 外边距 (减小)
static const int CARD_WIDTH = 320; ///< 卡片宽度 (再次增加)
static const int CARD_HEIGHT = 280; ///< 卡片高度 (显著增加)
static const int BORDER_RADIUS = 8; ///< 圆角半径
static const int PADDING = 15; ///< 内边距 (增加)
static const int MARGIN = 8; ///< 外边距 (增加)
};
#endif // DEVICECARD_H

@ -229,17 +229,7 @@ signals:
void deviceCountChanged(int totalCount, int onlineCount);
private slots:
/**
* @brief
* @param text
*/
void onSearchTextChanged(const QString &text);
/**
* @brief
* @param index
*/
void onFilterTypeChanged(int index);
// 搜索相关槽函数已删除
/**
* @brief UAV
@ -339,8 +329,6 @@ private:
private:
// UI组件 - 头部区域
QLabel *m_titleLabel; ///< 面板标题
QLineEdit *m_searchEdit; ///< 搜索框
QComboBox *m_filterComboBox; ///< 过滤下拉框
QLabel *m_deviceCountLabel; ///< 设备数量标签
// UI组件 - 操作按钮
@ -356,7 +344,6 @@ private:
// 布局管理器
QVBoxLayout *m_mainLayout; ///< 主布局
QHBoxLayout *m_headerLayout; ///< 头部布局
QHBoxLayout *m_searchLayout; ///< 搜索栏布局
QHBoxLayout *m_buttonLayout; ///< 按钮区域布局
// 数据管理
@ -382,7 +369,7 @@ private:
// 常量定义
static const int STATUS_MONITOR_INTERVAL = 5000; ///< 状态监控间隔(毫秒)
static const int CARD_SPACING = 8; ///< 卡片间距
static const int CARD_SPACING = 6; ///< 卡片间距
static const int PANEL_PADDING = 10; ///< 面板内边距
};

@ -93,6 +93,11 @@ public:
*/
~MainWindow();
/**
* @brief
*/
void setupMapDisplay();
/**
* @brief
* @param button

@ -356,9 +356,6 @@
}, 2000);
}
}
console.log('已清除标记数量: ' + count);
return count;
}
// 向控制台输出当前所有标记的信息
function logAllMarkers() {

@ -62,34 +62,37 @@ DeviceCard::~DeviceCard()
void DeviceCard::setupUI()
{
// 创建主布局 - 更紧凑的间距
// 创建主布局 - 增加垂直间距
m_mainLayout = new QVBoxLayout(this);
m_mainLayout->setContentsMargins(PADDING, PADDING, PADDING, PADDING);
m_mainLayout->setSpacing(6); // 减小间距
m_mainLayout->setSpacing(15); // 增加间距
// === 头部区域 ===
m_headerLayout = new QHBoxLayout();
m_headerLayout->setSpacing(8);
m_headerLayout->setSpacing(12);
// 设备图标
// 设备图标 - 增大尺寸
m_deviceIconLabel = new QLabel();
m_deviceIconLabel->setFixedSize(24, 24);
m_deviceIconLabel->setFixedSize(40, 40);
m_deviceIconLabel->setScaledContents(true);
updateDeviceIcon();
// 设备名称
// 设备名称 - 增大字体
m_deviceNameLabel = new QLabel(m_deviceInfo.name);
m_deviceNameLabel->setFont(QFont("Arial", 12, QFont::Bold));
m_deviceNameLabel->setFont(QFont("Arial", 16, QFont::Bold));
m_deviceNameLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
m_deviceNameLabel->setWordWrap(true);
m_deviceNameLabel->setMinimumWidth(150);
// 状态指示器(圆点)
// 状态指示器(圆点)- 增大尺寸
m_statusIndicator = new QLabel("");
m_statusIndicator->setFixedSize(16, 16);
m_statusIndicator->setFixedSize(24, 24);
m_statusIndicator->setAlignment(Qt::AlignCenter);
m_statusIndicator->setFont(QFont("Arial", 18));
// 状态文本
// 状态文本 - 增大字体
m_statusLabel = new QLabel(getStatusText(m_currentStatus));
m_statusLabel->setFont(QFont("Arial", 9));
m_statusLabel->setFont(QFont("Arial", 13, QFont::Bold));
m_headerLayout->addWidget(m_deviceIconLabel);
m_headerLayout->addWidget(m_deviceNameLabel);
@ -99,44 +102,48 @@ void DeviceCard::setupUI()
// === 信息区域 ===
m_infoLayout = new QGridLayout();
m_infoLayout->setSpacing(4);
m_infoLayout->setSpacing(12); // 增加间距
// 位置信息 - 简化显示
// 位置信息 - 增大显示
QLabel *locationIcon = new QLabel("📍");
locationIcon->setFixedSize(14, 14);
locationIcon->setFixedSize(22, 22);
locationIcon->setAlignment(Qt::AlignCenter);
locationIcon->setFont(QFont("Arial", 14));
m_locationLabel = new QLabel(QString("%1,%2").arg(m_deviceInfo.longitude, 0, 'f', 2).arg(m_deviceInfo.latitude, 0, 'f', 2));
m_locationLabel->setFont(QFont("Arial", 8));
m_locationLabel->setFont(QFont("Arial", 11));
// 网络信息 - 简化显示
// 网络信息 - 增大显示
QLabel *networkIcon = new QLabel("🌐");
networkIcon->setFixedSize(14, 14);
networkIcon->setFixedSize(22, 22);
networkIcon->setAlignment(Qt::AlignCenter);
networkIcon->setFont(QFont("Arial", 14));
m_networkLabel = new QLabel(m_deviceInfo.ipAddress);
m_networkLabel->setFont(QFont("Arial", 8));
m_networkLabel->setFont(QFont("Arial", 11));
// 信号强度 - 更紧凑
// 信号强度 - 增大显示
QLabel *signalIcon = new QLabel("📶");
signalIcon->setFixedSize(14, 14);
signalIcon->setFixedSize(22, 22);
signalIcon->setAlignment(Qt::AlignCenter);
signalIcon->setFont(QFont("Arial", 14));
m_signalLabel = new QLabel(QString("%1%").arg(m_deviceInfo.signalStrength));
m_signalLabel->setFont(QFont("Arial", 8));
m_signalLabel->setFont(QFont("Arial", 11, QFont::Bold));
m_signalProgressBar = new QProgressBar();
m_signalProgressBar->setRange(0, 100);
m_signalProgressBar->setValue(m_deviceInfo.signalStrength);
m_signalProgressBar->setFixedHeight(6);
m_signalProgressBar->setFixedHeight(16); // 增加进度条高度
m_signalProgressBar->setTextVisible(false);
// 电量水平 - 更紧凑
// 电量水平 - 增大显示
QLabel *batteryIcon = new QLabel("🔋");
batteryIcon->setFixedSize(14, 14);
batteryIcon->setFixedSize(22, 22);
batteryIcon->setAlignment(Qt::AlignCenter);
batteryIcon->setFont(QFont("Arial", 14));
m_batteryLabel = new QLabel(QString("%1%").arg(m_deviceInfo.batteryLevel));
m_batteryLabel->setFont(QFont("Arial", 8));
m_batteryLabel->setFont(QFont("Arial", 11, QFont::Bold));
m_batteryProgressBar = new QProgressBar();
m_batteryProgressBar->setRange(0, 100);
m_batteryProgressBar->setValue(m_deviceInfo.batteryLevel);
m_batteryProgressBar->setFixedHeight(6);
m_batteryProgressBar->setFixedHeight(16); // 增加进度条高度
m_batteryProgressBar->setTextVisible(false);
// 添加到网格布局
@ -153,22 +160,22 @@ void DeviceCard::setupUI()
// === 操作按钮区域 ===
m_buttonLayout = new QHBoxLayout();
m_buttonLayout->setSpacing(4);
m_buttonLayout->setSpacing(8);
m_detailsButton = new QPushButton("");
m_detailsButton->setFixedSize(32, 20);
m_detailsButton = new QPushButton("");
m_detailsButton->setFixedSize(62, 35);
m_detailsButton->setToolTip("设备详情");
m_detailsButton->setFont(QFont("Arial", 8));
m_detailsButton->setFont(QFont("Arial", 11, QFont::Bold));
m_controlButton = new QPushButton("");
m_controlButton->setFixedSize(32, 20);
m_controlButton = new QPushButton("");
m_controlButton->setFixedSize(62, 35);
m_controlButton->setToolTip("设备控制");
m_controlButton->setFont(QFont("Arial", 8));
m_controlButton->setFont(QFont("Arial", 11, QFont::Bold));
m_locationButton = new QPushButton("");
m_locationButton->setFixedSize(32, 20);
m_locationButton = new QPushButton("");
m_locationButton->setFixedSize(62, 35);
m_locationButton->setToolTip("设备定位");
m_locationButton->setFont(QFont("Arial", 8));
m_locationButton->setFont(QFont("Arial", 11, QFont::Bold));
m_buttonLayout->addWidget(m_detailsButton);
m_buttonLayout->addWidget(m_controlButton);
@ -180,8 +187,8 @@ void DeviceCard::setupUI()
// 添加分隔线
QLabel *separatorLine = new QLabel();
separatorLine->setFixedHeight(1);
separatorLine->setStyleSheet("background-color: rgba(82, 194, 242, 0.3);");
separatorLine->setFixedHeight(3);
separatorLine->setStyleSheet("background-color: rgba(82, 194, 242, 0.6); margin: 4px 0px; border-radius: 1px;");
m_mainLayout->addWidget(separatorLine);
m_mainLayout->addLayout(m_infoLayout);
@ -217,6 +224,8 @@ void DeviceCard::setupStyle()
" font-weight: bold;"
" background: transparent;"
" border: none;"
" padding: 2px;"
" min-height: 20px;"
"}"
);
@ -242,38 +251,51 @@ void DeviceCard::setupStyle()
m_signalLabel->setStyleSheet(infoLabelStyle);
m_batteryLabel->setStyleSheet(infoLabelStyle);
// 进度条样式
// 进度条样式 - 优化为更清晰的显示
QString progressBarStyle =
"QProgressBar {"
" border: 1px solid rgba(82, 194, 242, 0.5);"
" border-radius: 3px;"
" background-color: rgba(25, 35, 45, 0.8);"
" border: 2px solid rgba(82, 194, 242, 0.7);"
" border-radius: 8px;"
" background-color: rgba(25, 35, 45, 0.9);"
" text-align: center;"
" font-weight: bold;"
" color: white;"
" font-size: 10px;"
"}"
"QProgressBar::chunk {"
" background: qlineargradient(x1:0, y1:0, x2:1, y2:0,"
" stop:0 #00FF7F, stop:0.7 #FFD700, stop:1 #FF4444);"
" border-radius: 3px;"
" border-radius: 6px;"
" margin: 2px;"
"}";
m_signalProgressBar->setStyleSheet(progressBarStyle);
m_batteryProgressBar->setStyleSheet(progressBarStyle);
// 按钮样式
// 按钮样式 - 优化为更清晰的显示
QString buttonStyle =
"QPushButton {"
" background: rgba(82, 194, 242, 0.2);"
" color: rgb(220, 230, 242);"
" border: 1px solid rgba(82, 194, 242, 0.4);"
" border-radius: 4px;"
" font-size: 12px;"
" background: qlineargradient(x1:0, y1:0, x2:0, y2:1,"
" stop:0 rgba(82, 194, 242, 0.3),"
" stop:1 rgba(45, 120, 180, 0.3));"
" color: rgb(230, 240, 250);"
" border: 2px solid rgba(82, 194, 242, 0.5);"
" border-radius: 8px;"
" font-size: 11px;"
" font-weight: bold;"
" padding: 4px;"
"}"
"QPushButton:hover {"
" background: rgba(82, 194, 242, 0.4);"
" border-color: rgba(82, 194, 242, 0.8);"
" background: qlineargradient(x1:0, y1:0, x2:0, y2:1,"
" stop:0 rgba(82, 194, 242, 0.6),"
" stop:1 rgba(45, 120, 180, 0.6));"
" border-color: rgba(82, 194, 242, 0.9);"
" color: white;"
"}"
"QPushButton:pressed {"
" background: rgba(82, 194, 242, 0.6);"
" background: qlineargradient(x1:0, y1:0, x2:0, y2:1,"
" stop:0 rgba(82, 194, 242, 0.8),"
" stop:1 rgba(45, 120, 180, 0.8));"
"}";
m_detailsButton->setStyleSheet(buttonStyle);

@ -17,8 +17,6 @@
DeviceListPanel::DeviceListPanel(QWidget *parent)
: QWidget(parent)
, m_titleLabel(nullptr)
, m_searchEdit(nullptr)
, m_filterComboBox(nullptr)
, m_deviceCountLabel(nullptr)
, m_addUAVButton(nullptr)
, m_addDogButton(nullptr)
@ -28,7 +26,6 @@ DeviceListPanel::DeviceListPanel(QWidget *parent)
, m_deviceListLayout(nullptr)
, m_mainLayout(nullptr)
, m_headerLayout(nullptr)
, m_searchLayout(nullptr)
, m_buttonLayout(nullptr)
, m_currentFilterType(DeviceFilterType::All)
, m_isMonitoringActive(false)
@ -86,37 +83,18 @@ void DeviceListPanel::setupUI()
m_headerLayout->addStretch();
m_headerLayout->addWidget(m_deviceCountLabel);
// === 搜索和过滤区域 ===
m_searchLayout = new QHBoxLayout();
// 搜索框
m_searchEdit = new QLineEdit();
m_searchEdit->setPlaceholderText("搜索设备...");
m_searchEdit->setMaximumHeight(32);
// 过滤下拉框
m_filterComboBox = new QComboBox();
m_filterComboBox->addItem("全部设备", static_cast<int>(DeviceFilterType::All));
m_filterComboBox->addItem("无人机", static_cast<int>(DeviceFilterType::UAV));
m_filterComboBox->addItem("机器狗", static_cast<int>(DeviceFilterType::Dog));
m_filterComboBox->addItem("在线设备", static_cast<int>(DeviceFilterType::Online));
m_filterComboBox->addItem("离线设备", static_cast<int>(DeviceFilterType::Offline));
m_filterComboBox->setMaximumHeight(32);
m_filterComboBox->setMaximumWidth(100);
m_searchLayout->addWidget(m_searchEdit);
m_searchLayout->addWidget(m_filterComboBox);
// 搜索和过滤区域已删除
// === 操作按钮区域 ===
m_buttonLayout = new QHBoxLayout();
m_addUAVButton = new QPushButton("+ 无人机");
m_addUAVButton->setMaximumHeight(32);
m_addUAVButton->setMaximumWidth(80);
m_addUAVButton->setMaximumHeight(50);
m_addUAVButton->setMaximumWidth(120);
m_addDogButton = new QPushButton("+ 机器狗");
m_addDogButton->setMaximumHeight(32);
m_addDogButton->setMaximumWidth(80);
m_addDogButton->setMaximumHeight(50);
m_addDogButton->setMaximumWidth(120);
m_refreshButton = new QPushButton("🔄");
m_refreshButton->setMaximumHeight(32);
@ -152,7 +130,6 @@ void DeviceListPanel::setupUI()
separatorLine->setStyleSheet("background-color: rgba(82, 194, 242, 0.3);");
m_mainLayout->addWidget(separatorLine);
m_mainLayout->addLayout(m_searchLayout);
m_mainLayout->addLayout(m_buttonLayout);
m_mainLayout->addWidget(m_scrollArea, 1); // 占据剩余空间
}
@ -192,51 +169,7 @@ void DeviceListPanel::setupStyle()
"}"
);
// 搜索框样式 - 改善视觉效果
m_searchEdit->setStyleSheet(
"QLineEdit {"
" background: rgba(45, 65, 95, 0.9);"
" color: rgb(220, 230, 242);"
" border: 2px solid rgba(82, 194, 242, 0.4);"
" border-radius: 6px;"
" padding: 6px 10px;"
" font-size: 13px;"
"}"
"QLineEdit:focus {"
" border-color: rgba(82, 194, 242, 0.8);"
" background: rgba(45, 65, 95, 1.0);"
"}"
"QLineEdit:hover {"
" border-color: rgba(82, 194, 242, 0.6);"
"}"
);
// 过滤下拉框样式
m_filterComboBox->setStyleSheet(
"QComboBox {"
" background: rgba(45, 65, 95, 0.9);"
" color: rgb(220, 230, 242);"
" border: 2px solid rgba(82, 194, 242, 0.4);"
" border-radius: 6px;"
" padding: 4px 8px;"
" font-size: 12px;"
"}"
"QComboBox:hover {"
" border-color: rgba(82, 194, 242, 0.6);"
"}"
"QComboBox::drop-down {"
" border: none;"
"}"
"QComboBox::down-arrow {"
" color: rgb(82, 194, 242);"
"}"
"QComboBox QAbstractItemView {"
" background: rgba(45, 65, 95, 0.95);"
" color: rgb(220, 230, 242);"
" border: 1px solid rgba(82, 194, 242, 0.5);"
" selection-background-color: rgba(82, 194, 242, 0.3);"
"}"
);
// 搜索框和过滤框样式已删除
// 按钮统一样式 - 军用风格
QString buttonStyle =
@ -247,8 +180,8 @@ void DeviceListPanel::setupStyle()
" color: rgb(220, 230, 242);"
" border: 2px solid rgba(82, 194, 242, 0.5);"
" border-radius: 6px;"
" padding: 6px 12px;"
" font-size: 12px;"
" padding: 10px 16px;"
" font-size: 14px;"
" font-weight: bold;"
"}"
"QPushButton:hover {"
@ -297,10 +230,7 @@ void DeviceListPanel::setupStyle()
void DeviceListPanel::connectSignals()
{
// 搜索和过滤信号
connect(m_searchEdit, &QLineEdit::textChanged, this, &DeviceListPanel::onSearchTextChanged);
connect(m_filterComboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &DeviceListPanel::onFilterTypeChanged);
// 搜索和过滤信号已删除
// 按钮信号
connect(m_addUAVButton, &QPushButton::clicked, this, &DeviceListPanel::onAddUAVClicked);
@ -672,18 +602,7 @@ void DeviceListPanel::clearAllDeviceCards()
m_selectedDeviceId.clear();
}
// 槽函数实现
void DeviceListPanel::onSearchTextChanged(const QString &text)
{
m_currentSearchKeyword = text.trimmed();
applySearchAndFilter();
}
void DeviceListPanel::onFilterTypeChanged(int index)
{
m_currentFilterType = static_cast<DeviceFilterType>(m_filterComboBox->itemData(index).toInt());
applySearchAndFilter();
}
// 搜索相关槽函数已删除
void DeviceListPanel::onAddUAVClicked()
{
@ -834,8 +753,8 @@ void DeviceListPanel::updateDeviceListDisplay()
m_deviceListLayout->removeWidget(card);
}
// 根据过滤条件重新显示设备
QString searchText = m_searchEdit->text().toLower();
// 根据过滤条件重新显示设备(搜索功能已删除)
QString searchText = "";
for (auto card : m_deviceCards) {
const DeviceInfo& info = card->getDeviceInfo();
@ -882,10 +801,8 @@ void DeviceListPanel::updateDeviceListDisplay()
void DeviceListPanel::applyDeviceFilter()
{
// 获取当前过滤类型
int filterIndex = m_filterComboBox->currentIndex();
QVariant filterData = m_filterComboBox->itemData(filterIndex);
m_currentFilterType = static_cast<DeviceFilterType>(filterData.toInt());
// 过滤功能已简化,默认显示所有设备
m_currentFilterType = DeviceFilterType::All;
// 更新显示
updateDeviceListDisplay();

@ -79,8 +79,8 @@ void MainWindow::setupUI()
// 创建并集成DeviceListPanel到左侧面板
setupDeviceListPanel();
// 控制地图显示
mapDisplayControl(m_ui->mapbutton, m_ui->MapDisplayer, m_ui->gridLayout_3);
// 恢复地图显示控制
setupMapDisplay();
// 控制添加机器人
addRobotControl(m_ui->addrobot);
// 控制机器人列表
@ -155,9 +155,7 @@ void MainWindow::setupStyle()
// 应用样式到所有按钮
m_ui->robottab->setStyleSheet(buttonStyle);
m_ui->robotlocation->setStyleSheet(buttonStyle);
m_ui->addrobot->setStyleSheet(buttonStyle);
m_ui->mapbutton->setStyleSheet(buttonStyle);
m_ui->addUAV->setStyleSheet(buttonStyle);
m_ui->UAVtab->setStyleSheet(buttonStyle);
m_ui->UAVview->setStyleSheet(buttonStyle);
@ -174,7 +172,6 @@ void MainWindow::connectSignals()
// 连接按钮信号
connect(m_ui->addUAV, &QPushButton::clicked, this, &MainWindow::onAddUAVClicked);
connect(m_ui->UAVtab, &QPushButton::clicked, this, &MainWindow::onUAVTabClicked);
connect(m_ui->robotlocation, &QPushButton::clicked, this, &MainWindow::onRobotLocationClicked);
connect(m_ui->UAVview, &QPushButton::clicked, this, &MainWindow::onUAVViewClicked);
connect(m_ui->robotView, &QPushButton::clicked, this, &MainWindow::onRobotViewClicked);
connect(m_ui->robotMapping, &QPushButton::clicked, this, &MainWindow::onRobotMappingClicked);
@ -609,6 +606,39 @@ void MainWindow::onAddDeviceRequested(const QString &deviceType)
}
}
void MainWindow::setupMapDisplay()
{
qDebug() << "Setting up map display...";
// 创建WebEngineView来显示地图
QWebEngineView* webView = new QWebEngineView(m_ui->MapDisplayer);
// 设置地图HTML文件路径
QString mapPath = QApplication::applicationDirPath() + "/res/html/map.html";
if (!QFile::exists(mapPath)) {
mapPath = ":/html/res/html/map.html"; // 尝试从资源文件加载
}
// 加载地图
webView->load(QUrl::fromLocalFile(mapPath));
// 调整WebView大小以填充MapDisplayer
QVBoxLayout* layout = new QVBoxLayout(m_ui->MapDisplayer);
layout->setContentsMargins(0, 0, 0, 0);
layout->addWidget(webView);
m_ui->MapDisplayer->setLayout(layout);
// 地图加载完成后初始化设备标记
connect(webView, &QWebEngineView::loadFinished, this, [this](bool success) {
if (success) {
qDebug() << "Map loaded successfully, initializing device markers...";
QTimer::singleShot(1000, this, &MainWindow::initializeDeviceMarkersOnMap);
} else {
qDebug() << "Map loading failed!";
}
});
}
void MainWindow::initializeDeviceMarkersOnMap()
{
qDebug() << "Initializing device markers on map...";

Loading…
Cancel
Save