任务决策页面调整 #24

Merged
pg9nrcf7t merged 1 commits from lcf_branch into main 2 months ago

@ -32,19 +32,33 @@ TaskDecisionPage::TaskDecisionPage(QWidget* parent)
connect(targetManager_, &TargetManager::targetStatusChanged, this, &TaskDecisionPage::updateTargetTable);
connect(targetManager_, &TargetManager::targetPriorityChanged, this, &TaskDecisionPage::updateTargetTable);
connect(targetManager_, &TargetManager::targetStrikeMethodChanged, this, &TaskDecisionPage::updateTargetTable);
taskData_ = new TaskDataObject();
// Remove: QMessageBox and initTaskData
}
void TaskDecisionPage::setupUI() {
auto* mainLayout = new QHBoxLayout(this);
auto* mainLayout = new QVBoxLayout(this); // Change to VBox for stacking
mainLayout->setContentsMargins(10, 10, 10, 10);
stack_ = new QStackedWidget();
mainLayout->addWidget(stack_);
// Page 0: Welcome page with new task button
stack_->addWidget(createWelcomeWidget());
// Page 1: Main decision UI
QWidget* decisionWidget = new QWidget();
auto* decisionLayout = new QHBoxLayout(decisionWidget);
// Add existing UI to decisionLayout
// 左侧步骤导航
stepList_ = new QListWidget();
stepList_->setFixedWidth(200);
stepList_->addItems({"1. 目标位置确认", "2. 路径规划", "3. 区域搜索策略", "4. 打击目标清单", "5. 任务预览与生成"});
connect(stepList_, &QListWidget::currentRowChanged, this, &TaskDecisionPage::onStepChanged);
mainLayout->addWidget(stepList_);
decisionLayout->addWidget(stepList_);
// 中间内容区
auto* contentLayout = new QVBoxLayout();
contentStack_ = new QStackedWidget();
@ -54,7 +68,7 @@ void TaskDecisionPage::setupUI() {
contentStack_->addWidget(createStep4Widget());
contentStack_->addWidget(createStep5Widget());
contentLayout->addWidget(contentStack_, 1);
// 底部导航
auto* bottomLayout = new QHBoxLayout();
prevBtn_ = new QPushButton("上一步");
@ -69,10 +83,12 @@ void TaskDecisionPage::setupUI() {
bottomLayout->addStretch(1);
bottomLayout->addWidget(generateBtn_);
contentLayout->addLayout(bottomLayout);
mainLayout->addLayout(contentLayout, 1);
decisionLayout->addLayout(contentLayout, 1);
stack_->addWidget(decisionWidget);
// 初始化
stack_->setCurrentIndex(0); // Start with welcome page
onStepChanged(0);
}
@ -277,6 +293,7 @@ void TaskDecisionPage::onStepChanged(int step) {
prevBtn_->setEnabled(step > 0);
nextBtn_->setEnabled(step < 4);
generateBtn_->setEnabled(step == 4);
generateBtn_->setVisible(step == 4); // Show only in last step
// 调试信息
qDebug() << "Step changed to:" << step << "Stack index:" << contentStack_->currentIndex();
@ -518,6 +535,12 @@ void TaskDecisionPage::onAddTargetType() {
}
void TaskDecisionPage::onGenerateTask() {
// Validation
if (pathData_.isEmpty() && searchData_.isEmpty() && targetTable_->rowCount() == 0) {
QMessageBox::warning(this, "警告", "所有数据为空,无法生成任务包。请完成至少一个步骤。");
return;
}
// 汇总数据生成预览(模拟)
QString preview = "任务摘要:\n";
preview += QString("目标明确: %1\n").arg(isTargetClear_ ? "" : "");
@ -544,7 +567,8 @@ void TaskDecisionPage::onGenerateTask() {
file.close();
}
}
QMessageBox::information(this, "生成", "任务数据包已生成!路径保存到 data_paths/task_path.json");
saveTaskData();
QMessageBox::information(this, "生成", "任务数据包已生成!路径保存到 Src/data_paths/task_path.json");
}
void TaskDecisionPage::onNextStep() {
@ -1024,3 +1048,62 @@ void TaskDecisionPage::showBatchUpdateDialog() {
dialog.exec();
}
void TaskDecisionPage::initTaskData(bool isNew) {
if (isNew) {
taskData_->pathData = "";
taskData_->searchData = "";
taskData_->strikeList = QJsonArray();
} else {
// Optionally load from file, but for now, assume new
initTaskData(true);
}
}
void TaskDecisionPage::saveTaskData() {
// Update strikeList from table
taskData_->strikeList = QJsonArray();
for (int i = 0; i < targetTable_->rowCount(); ++i) {
QJsonObject item;
item["type"] = qobject_cast<QComboBox*>(targetTable_->cellWidget(i, 0))->currentText();
item["priority"] = qobject_cast<QSpinBox*>(targetTable_->cellWidget(i, 1))->value();
item["method"] = qobject_cast<QComboBox*>(targetTable_->cellWidget(i, 2))->currentText();
taskData_->strikeList.append(item);
}
// Save to file
QJsonDocument doc(taskData_->toJson());
QFile file("task_data.json");
if (file.open(QIODevice::WriteOnly)) {
file.write(doc.toJson());
file.close();
}
}
void TaskDecisionPage::viewTaskData() {
QJsonDocument doc(taskData_->toJson());
QMessageBox::information(this, "任务数据", doc.toJson(QJsonDocument::Indented));
}
void TaskDecisionPage::onNewTaskClicked() {
QMessageBox::StandardButton reply = QMessageBox::question(this, "新建任务", "是否新建一个任务?", QMessageBox::Yes | QMessageBox::No);
if (reply == QMessageBox::Yes) {
initTaskData(true);
stack_->setCurrentIndex(1); // Switch to main decision page
onStepChanged(0); // Proceed to step 1
}
}
QWidget* TaskDecisionPage::createWelcomeWidget() {
QWidget* welcome = new QWidget();
auto* layout = new QVBoxLayout(welcome);
layout->setAlignment(Qt::AlignCenter);
QLabel* label = new QLabel("欢迎进入任务决策页面");
layout->addWidget(label);
newTaskBtn_ = new QPushButton("新建任务");
connect(newTaskBtn_, &QPushButton::clicked, this, &TaskDecisionPage::onNewTaskClicked);
layout->addWidget(newTaskBtn_);
return welcome;
}

@ -23,6 +23,29 @@
#include <QInputDialog>
#include <QMessageBox>
#include "../models/targetdata.h"
#include <QJsonObject>
#include <QJsonArray>
class TaskDataObject {
public:
QString pathData;
QString searchData;
QJsonArray strikeList; // Array of objects: {type, priority, method}
QJsonObject toJson() const {
QJsonObject obj;
obj["pathData"] = pathData;
obj["searchData"] = searchData;
obj["strikeList"] = strikeList;
return obj;
}
void fromJson(const QJsonObject& obj) {
pathData = obj["pathData"].toString();
searchData = obj["searchData"].toString();
strikeList = obj["strikeList"].toArray();
}
};
class TaskDecisionPage : public QWidget {
Q_OBJECT
@ -53,8 +76,10 @@ private slots:
void onBatchUpdatePriority();
void onBatchUpdateStrikeMethod();
void onClearAllTargets();
void onNewTaskClicked(); // New slot for new task confirmation
private:
QWidget* createWelcomeWidget();
void setupUI();
QWidget* createStep1Widget(); // 目标位置确认
QWidget* createStep2Widget(); // 路径规划
@ -74,6 +99,9 @@ private:
void showTargetEditDialog(TargetData* target = nullptr);
void showBatchUpdateDialog();
void updateSearchTableFromCoverageData(const QString& coveragePathData);
void initTaskData(bool isNew);
void saveTaskData();
void viewTaskData();
// 成员变量
QStackedWidget* contentStack_;
@ -83,6 +111,8 @@ private:
QPushButton* generateBtn_;
QPushButton* previewBtn_;
QListWidget* historyList_; // 新增:历史路径列表
QPushButton* newTaskBtn_; // New button for new task
QStackedWidget* stack_; // To switch between welcome and main page
// 步骤1
QRadioButton* clearYes_;
@ -125,6 +155,7 @@ private:
// 目标管理
TargetManager* targetManager_;
QMap<QString, int> targetRowMap_; // 目标ID到表格行的映射
TaskDataObject* taskData_; // New member
};

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
struct qt_meta_stringdata_TaskDecisionPage_t {
QByteArrayData data[25];
char stringdata0[408];
QByteArrayData data[26];
char stringdata0[425];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
@ -56,7 +56,8 @@ QT_MOC_LITERAL(20, 290, 27), // "onTargetStrikeMethodChanged"
QT_MOC_LITERAL(21, 318, 23), // "onSortTargetsByPriority"
QT_MOC_LITERAL(22, 342, 21), // "onBatchUpdatePriority"
QT_MOC_LITERAL(23, 364, 25), // "onBatchUpdateStrikeMethod"
QT_MOC_LITERAL(24, 390, 17) // "onClearAllTargets"
QT_MOC_LITERAL(24, 390, 17), // "onClearAllTargets"
QT_MOC_LITERAL(25, 408, 16) // "onNewTaskClicked"
},
"TaskDecisionPage\0onStepChanged\0\0step\0"
@ -70,7 +71,8 @@ QT_MOC_LITERAL(24, 390, 17) // "onClearAllTargets"
"onTargetPriorityChanged\0"
"onTargetStrikeMethodChanged\0"
"onSortTargetsByPriority\0onBatchUpdatePriority\0"
"onBatchUpdateStrikeMethod\0onClearAllTargets"
"onBatchUpdateStrikeMethod\0onClearAllTargets\0"
"onNewTaskClicked"
};
#undef QT_MOC_LITERAL
@ -80,7 +82,7 @@ static const uint qt_meta_data_TaskDecisionPage[] = {
8, // revision
0, // classname
0, 0, // classinfo
20, 14, // methods
21, 14, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
@ -88,26 +90,27 @@ static const uint qt_meta_data_TaskDecisionPage[] = {
0, // signalCount
// slots: name, argc, parameters, tag, flags
1, 1, 114, 2, 0x08 /* Private */,
4, 1, 117, 2, 0x08 /* Private */,
6, 0, 120, 2, 0x08 /* Private */,
7, 0, 121, 2, 0x08 /* Private */,
8, 0, 122, 2, 0x08 /* Private */,
9, 0, 123, 2, 0x08 /* Private */,
10, 0, 124, 2, 0x08 /* Private */,
11, 0, 125, 2, 0x08 /* Private */,
12, 0, 126, 2, 0x08 /* Private */,
13, 0, 127, 2, 0x08 /* Private */,
14, 0, 128, 2, 0x08 /* Private */,
15, 0, 129, 2, 0x08 /* Private */,
16, 1, 130, 2, 0x08 /* Private */,
18, 0, 133, 2, 0x08 /* Private */,
19, 0, 134, 2, 0x08 /* Private */,
20, 0, 135, 2, 0x08 /* Private */,
21, 0, 136, 2, 0x08 /* Private */,
22, 0, 137, 2, 0x08 /* Private */,
23, 0, 138, 2, 0x08 /* Private */,
24, 0, 139, 2, 0x08 /* Private */,
1, 1, 119, 2, 0x08 /* Private */,
4, 1, 122, 2, 0x08 /* Private */,
6, 0, 125, 2, 0x08 /* Private */,
7, 0, 126, 2, 0x08 /* Private */,
8, 0, 127, 2, 0x08 /* Private */,
9, 0, 128, 2, 0x08 /* Private */,
10, 0, 129, 2, 0x08 /* Private */,
11, 0, 130, 2, 0x08 /* Private */,
12, 0, 131, 2, 0x08 /* Private */,
13, 0, 132, 2, 0x08 /* Private */,
14, 0, 133, 2, 0x08 /* Private */,
15, 0, 134, 2, 0x08 /* Private */,
16, 1, 135, 2, 0x08 /* Private */,
18, 0, 138, 2, 0x08 /* Private */,
19, 0, 139, 2, 0x08 /* Private */,
20, 0, 140, 2, 0x08 /* Private */,
21, 0, 141, 2, 0x08 /* Private */,
22, 0, 142, 2, 0x08 /* Private */,
23, 0, 143, 2, 0x08 /* Private */,
24, 0, 144, 2, 0x08 /* Private */,
25, 0, 145, 2, 0x08 /* Private */,
// slots: parameters
QMetaType::Void, QMetaType::Int, 3,
@ -129,6 +132,7 @@ static const uint qt_meta_data_TaskDecisionPage[] = {
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
QMetaType::Void,
0 // eod
@ -160,6 +164,7 @@ void TaskDecisionPage::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int
case 17: _t->onBatchUpdatePriority(); break;
case 18: _t->onBatchUpdateStrikeMethod(); break;
case 19: _t->onClearAllTargets(); break;
case 20: _t->onNewTaskClicked(); break;
default: ;
}
}
@ -194,13 +199,13 @@ int TaskDecisionPage::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
if (_id < 20)
if (_id < 21)
qt_static_metacall(this, _c, _id, _a);
_id -= 20;
_id -= 21;
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
if (_id < 20)
if (_id < 21)
*reinterpret_cast<int*>(_a[0]) = -1;
_id -= 20;
_id -= 21;
}
return _id;
}

Binary file not shown.

Binary file not shown.

@ -0,0 +1,6 @@
{
"pathData": "",
"searchData": "",
"strikeList": [
]
}
Loading…
Cancel
Save