创建请求相关动作完成
This commit is contained in:
parent
54c4521fb2
commit
04d6ab09ee
|
@ -9,6 +9,8 @@
|
|||
#include "QLabel"
|
||||
#include "QHBoxLayout"
|
||||
|
||||
#include "define.h"
|
||||
|
||||
class QueryListItem : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
@ -35,12 +35,21 @@ void CentralWidget::SetControlConnection()
|
|||
// 处理轨道重新设置事件
|
||||
QObject::connect(controller, &BusControllerModel::RailsCreated,
|
||||
this, &CentralWidget::SetRailsScene);
|
||||
|
||||
// 处理添加请求事件
|
||||
QObject::connect(this, &CentralWidget::AppendQuerySignal,
|
||||
controller, &BusControllerModel::AddQuerySlot);
|
||||
}
|
||||
|
||||
void CentralWidget::SetWidgetConnection()
|
||||
{
|
||||
// 处理点击创建请求按钮事件
|
||||
QObject::connect(ui->create_query_button, &QPushButton::clicked,
|
||||
this, &CentralWidget::AddQueryButtonClicked);
|
||||
|
||||
// 处理添加请求事件
|
||||
QObject::connect(this, &CentralWidget::AppendQuerySignal,
|
||||
this, &CentralWidget::AppendQueryItemSlot);
|
||||
}
|
||||
|
||||
void CentralWidget::SetupQueryList()
|
||||
|
@ -66,7 +75,7 @@ void CentralWidget::DeleteQueryList()
|
|||
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);
|
||||
|
||||
|
@ -78,7 +87,7 @@ void CentralWidget::AppendQueryItem(int query_type, int node_id)
|
|||
ui->query_list->setItemWidget(widget_item, item);
|
||||
}
|
||||
|
||||
void CentralWidget::DeleteQueryItem(int query_id)
|
||||
void CentralWidget::DeleteQueryItemSlot(int query_id)
|
||||
{
|
||||
// 由于表头的存在,且请求的编号从1开始,请求的编号恰好就是请求在列表中的位置
|
||||
QListWidgetItem *deleted_widget = ui->query_list->takeItem(query_id);
|
||||
|
@ -97,7 +106,17 @@ void CentralWidget::DeleteQueryItem(int query_id)
|
|||
|
||||
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)
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
<string>Auto Bus(GUI)</string>
|
||||
</property>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "QListWidgetItem"
|
||||
#include "string"
|
||||
#include "list"
|
||||
#include "QMessageBox"
|
||||
|
||||
#include "mainScene.h"
|
||||
#include "queryListItem.h"
|
||||
|
@ -30,19 +31,25 @@ public:
|
|||
|
||||
~CentralWidget() override;
|
||||
|
||||
signals:
|
||||
/**
|
||||
* 添加一个请求的信号
|
||||
*/
|
||||
void AppendQuerySignal(int type, int node);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* 处理添加一个请求的槽函数
|
||||
* @param query_type 请求的类型
|
||||
* @param node_id 请求指向的站点id
|
||||
*/
|
||||
void AppendQueryItem(int query_type, int node_id);
|
||||
void AppendQueryItemSlot(int query_type, int node_id);
|
||||
|
||||
/**
|
||||
* 处理删除一个请求的槽函数
|
||||
* @param query_id 请求的编号
|
||||
*/
|
||||
void DeleteQueryItem(int query_id);
|
||||
void DeleteQueryItemSlot(int query_id);
|
||||
|
||||
/**
|
||||
* 处理点击添加请求按钮的槽函数
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <QMainWindow>
|
||||
#include "QFileDialog"
|
||||
#include "QThread"
|
||||
#include "QMessageBox"
|
||||
|
||||
#include "centralwidget.h"
|
||||
#include "busModel.h"
|
||||
|
|
|
@ -72,11 +72,11 @@ void MainWindow::ReadConfigFileButtonClicked()
|
|||
|
||||
if(file_name.isEmpty())
|
||||
{
|
||||
qDebug() << "文件名为空";
|
||||
QMessageBox::warning(this, "警告", "文件名错误");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << file_name;
|
||||
emit OpenConfigFileSignal(file_name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,20 @@ QueryListItem::QueryListItem(const int &type, const int &node_id) : QWidget()
|
|||
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));
|
||||
type_text.setFont(font);
|
||||
target_pos_text.setFont(font);
|
||||
|
|
Loading…
Reference in New Issue
Block a user