完善了请求列表的相关槽函数
This commit is contained in:
parent
7cbdf5963e
commit
a044ff1044
|
@ -15,10 +15,66 @@ CentralWidget::CentralWidget(QWidget *parent) : QWidget(parent), ui(new Ui::Cent
|
|||
scene_manager = new SceneManager(20);
|
||||
|
||||
ui->main_canva->setScene(scene_manager->scene);
|
||||
|
||||
SetupQueryList();
|
||||
}
|
||||
|
||||
CentralWidget::~CentralWidget()
|
||||
{
|
||||
DeleteQueryList();
|
||||
|
||||
delete scene_manager;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void CentralWidget::SetupQueryList()
|
||||
{
|
||||
// 设置请求列表的表头
|
||||
QueryListItem *column_name = new QueryListItem(1,1);
|
||||
column_name->SetColumnName();
|
||||
|
||||
query_items.push_back(column_name);
|
||||
|
||||
// 在列表中显示
|
||||
QListWidgetItem *widget_item = new QListWidgetItem;
|
||||
ui->query_list->addItem(widget_item);
|
||||
ui->query_list->setItemWidget(widget_item, column_name);
|
||||
}
|
||||
|
||||
void CentralWidget::DeleteQueryList()
|
||||
{
|
||||
for(auto itor = query_items.begin(); itor != query_items.end(); ++itor)
|
||||
{
|
||||
delete *itor;
|
||||
}
|
||||
query_items.clear();
|
||||
}
|
||||
|
||||
void CentralWidget::AppendQueryItem(int query_type, int node_id)
|
||||
{
|
||||
QueryListItem *item = new QueryListItem(query_type, node_id);
|
||||
|
||||
query_items.push_back(item);
|
||||
|
||||
// 在列表中显示
|
||||
QListWidgetItem *widget_item = new QListWidgetItem;
|
||||
ui->query_list->addItem(widget_item);
|
||||
ui->query_list->setItemWidget(widget_item, item);
|
||||
}
|
||||
|
||||
void CentralWidget::DeleteQueryItem(int query_id)
|
||||
{
|
||||
// 由于表头的存在,且请求的编号从1开始,请求的编号恰好就是请求在列表中的位置
|
||||
QListWidgetItem *deleted_widget = ui->query_list->takeItem(query_id);
|
||||
|
||||
auto itor = query_items.begin();
|
||||
|
||||
for(int i = 0; i < query_id; i++)
|
||||
{
|
||||
++itor;
|
||||
}
|
||||
|
||||
delete deleted_widget;
|
||||
delete *itor;
|
||||
query_items.erase(itor);
|
||||
}
|
|
@ -29,32 +29,6 @@
|
|||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>659</x>
|
||||
<y>-1</y>
|
||||
<width>201</width>
|
||||
<height>411</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="test_button">
|
||||
<property name="text">
|
||||
<string>测试输出</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>控制面板</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="text_output">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
|
@ -78,6 +52,105 @@
|
|||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>770</x>
|
||||
<y>160</y>
|
||||
<width>121</width>
|
||||
<height>231</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>添加请求</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>请求类型</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="query_type_combo">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>顺时针上车</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>逆时针上车</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>下车</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>目标站点</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="query_node_combo"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="create_query_button">
|
||||
<property name="text">
|
||||
<string>创建请求</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>600</x>
|
||||
<y>170</y>
|
||||
<width>161</width>
|
||||
<height>221</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>请求列表</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QListWidget" name="query_list"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
@ -41,7 +41,16 @@
|
|||
<addaction name="actionRead_ConfigFile"/>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuRun">
|
||||
<property name="title">
|
||||
<string>Run</string>
|
||||
</property>
|
||||
<addaction name="actionRun_Bus"/>
|
||||
<addaction name="actionPause_Bus"/>
|
||||
<addaction name="actionStop_Bus"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuRun"/>
|
||||
</widget>
|
||||
<action name="actionRead_ConfigFile">
|
||||
<property name="text">
|
||||
|
@ -53,6 +62,21 @@
|
|||
<string>Exit</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRun_Bus">
|
||||
<property name="text">
|
||||
<string>Run Bus</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPause_Bus">
|
||||
<property name="text">
|
||||
<string>Pause Bus</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionStop_Bus">
|
||||
<property name="text">
|
||||
<string>Stop Bus</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
@ -6,8 +6,12 @@
|
|||
#define AUTO_BUS_GUI_CENTRAL_WIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "QListWidgetItem"
|
||||
#include "string"
|
||||
#include "list"
|
||||
|
||||
#include "mainScene.h"
|
||||
#include "queryListItem.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace Ui
|
||||
|
@ -26,11 +30,41 @@ public:
|
|||
~CentralWidget() override;
|
||||
|
||||
public slots:
|
||||
/**
|
||||
* 处理添加一个请求的槽函数
|
||||
* @param query_type 请求的类型
|
||||
* @param node_id 请求指向的站点id
|
||||
*/
|
||||
void AppendQueryItem(int query_type, int node_id);
|
||||
|
||||
void DeleteQueryItem(int query_id);
|
||||
|
||||
private:
|
||||
/**
|
||||
* UI控件
|
||||
*/
|
||||
Ui::CentralWidget *ui;
|
||||
|
||||
/**
|
||||
* 画图的场景管理器
|
||||
*/
|
||||
SceneManager *scene_manager;
|
||||
|
||||
/**
|
||||
* 请求列表中的对象
|
||||
*/
|
||||
std::list<QueryListItem *> query_items;
|
||||
|
||||
/**
|
||||
* 初始化请求展示列表
|
||||
* 展示表头的说明文字
|
||||
*/
|
||||
void SetupQueryList();
|
||||
|
||||
/**
|
||||
* 清除展示对象占用的内存空间
|
||||
*/
|
||||
void DeleteQueryList();
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user