创建请求相关动作完成

This commit is contained in:
jackfiled 2022-06-26 17:21:24 +08:00
parent 54c4521fb2
commit 04d6ab09ee
7 changed files with 50 additions and 8 deletions

View File

@ -9,6 +9,8 @@
#include "QLabel" #include "QLabel"
#include "QHBoxLayout" #include "QHBoxLayout"
#include "define.h"
class QueryListItem : public QWidget class QueryListItem : public QWidget
{ {
Q_OBJECT Q_OBJECT

View File

@ -35,12 +35,21 @@ void CentralWidget::SetControlConnection()
// 处理轨道重新设置事件 // 处理轨道重新设置事件
QObject::connect(controller, &BusControllerModel::RailsCreated, QObject::connect(controller, &BusControllerModel::RailsCreated,
this, &CentralWidget::SetRailsScene); this, &CentralWidget::SetRailsScene);
// 处理添加请求事件
QObject::connect(this, &CentralWidget::AppendQuerySignal,
controller, &BusControllerModel::AddQuerySlot);
} }
void CentralWidget::SetWidgetConnection() void CentralWidget::SetWidgetConnection()
{ {
// 处理点击创建请求按钮事件
QObject::connect(ui->create_query_button, &QPushButton::clicked, QObject::connect(ui->create_query_button, &QPushButton::clicked,
this, &CentralWidget::AddQueryButtonClicked); this, &CentralWidget::AddQueryButtonClicked);
// 处理添加请求事件
QObject::connect(this, &CentralWidget::AppendQuerySignal,
this, &CentralWidget::AppendQueryItemSlot);
} }
void CentralWidget::SetupQueryList() void CentralWidget::SetupQueryList()
@ -66,7 +75,7 @@ void CentralWidget::DeleteQueryList()
query_items.clear(); query_items.clear();
} }
void CentralWidget::AppendQueryItem(int query_type, int node_id) void CentralWidget::AppendQueryItemSlot(int query_type, int node_id)
{ {
QueryListItem *item = new QueryListItem(query_type, node_id); QueryListItem *item = new QueryListItem(query_type, node_id);
@ -78,7 +87,7 @@ void CentralWidget::AppendQueryItem(int query_type, int node_id)
ui->query_list->setItemWidget(widget_item, item); ui->query_list->setItemWidget(widget_item, item);
} }
void CentralWidget::DeleteQueryItem(int query_id) void CentralWidget::DeleteQueryItemSlot(int query_id)
{ {
// 由于表头的存在且请求的编号从1开始请求的编号恰好就是请求在列表中的位置 // 由于表头的存在且请求的编号从1开始请求的编号恰好就是请求在列表中的位置
QListWidgetItem *deleted_widget = ui->query_list->takeItem(query_id); QListWidgetItem *deleted_widget = ui->query_list->takeItem(query_id);
@ -97,7 +106,17 @@ void CentralWidget::DeleteQueryItem(int query_id)
void CentralWidget::AddQueryButtonClicked() void CentralWidget::AddQueryButtonClicked()
{ {
int query_type = ui->query_type_combo->currentIndex();
int node_id = ui->query_node_combo->currentIndex() + 1;
if(node_id == 0)
{
//此时还没有读取配置文件
QMessageBox::warning(this, "警告", "请先读取配置文件");
return;
}
emit AppendQuerySignal(query_type, node_id);
} }
void CentralWidget::SetRailsScene(int node_num) void CentralWidget::SetRailsScene(int node_num)

View File

@ -23,7 +23,7 @@
</size> </size>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>MainWindow</string> <string>Auto Bus(GUI)</string>
</property> </property>
<widget class="QMenuBar" name="menuBar"> <widget class="QMenuBar" name="menuBar">
<property name="geometry"> <property name="geometry">

View File

@ -9,6 +9,7 @@
#include "QListWidgetItem" #include "QListWidgetItem"
#include "string" #include "string"
#include "list" #include "list"
#include "QMessageBox"
#include "mainScene.h" #include "mainScene.h"
#include "queryListItem.h" #include "queryListItem.h"
@ -30,19 +31,25 @@ public:
~CentralWidget() override; ~CentralWidget() override;
signals:
/**
*
*/
void AppendQuerySignal(int type, int node);
public slots: public slots:
/** /**
* *
* @param query_type * @param query_type
* @param node_id id * @param node_id id
*/ */
void AppendQueryItem(int query_type, int node_id); void AppendQueryItemSlot(int query_type, int node_id);
/** /**
* *
* @param query_id * @param query_id
*/ */
void DeleteQueryItem(int query_id); void DeleteQueryItemSlot(int query_id);
/** /**
* *

View File

@ -8,6 +8,7 @@
#include <QMainWindow> #include <QMainWindow>
#include "QFileDialog" #include "QFileDialog"
#include "QThread" #include "QThread"
#include "QMessageBox"
#include "centralwidget.h" #include "centralwidget.h"
#include "busModel.h" #include "busModel.h"

View File

@ -72,11 +72,11 @@ void MainWindow::ReadConfigFileButtonClicked()
if(file_name.isEmpty()) if(file_name.isEmpty())
{ {
qDebug() << "文件名为空"; QMessageBox::warning(this, "警告", "文件名错误");
return;
} }
else else
{ {
qDebug() << file_name;
emit OpenConfigFileSignal(file_name); emit OpenConfigFileSignal(file_name);
} }
} }

View File

@ -16,7 +16,20 @@ QueryListItem::QueryListItem(const int &type, const int &node_id) : QWidget()
this->setFixedHeight(20); this->setFixedHeight(20);
// 设置文本 // 设置文本
type_text.setText(QString::number(type)); switch (type)
{
case BUS_CLOCK_WISE:
type_text.setText(QString("顺时针上车"));
break;
case BUS_COUNTER_CLOCK_WISE:
type_text.setText(QString("逆时针上车"));
break;
case BUS_TARGET:
type_text.setText(QString("下车"));
break;
default:
break;
}
target_pos_text.setText(QString::number(node_id)); target_pos_text.setText(QString::number(node_id));
type_text.setFont(font); type_text.setFont(font);
target_pos_text.setFont(font); target_pos_text.setFont(font);