Skip to content

Commit 5e0ba12

Browse files
committed
ui
1 parent 61210c6 commit 5e0ba12

8 files changed

Lines changed: 466 additions & 0 deletions

File tree

Ui/datastructwidget.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// Author : XuBenHao
2+
// Version : 1.0.0
3+
// Mail : xbh370970843@163.com
4+
// Copyright : XuBenHao 2020 - 2030
5+
6+
#include "datastructwidget.h"
7+
#include "ui_datastructwidget.h"
8+
#include "Functions/datastructfactory.h"
9+
DataStructWidget::DataStructWidget(QWidget *parent) :
10+
QWidget(parent),
11+
ui(new Ui::DataStructWidget)
12+
{
13+
ui->setupUi(this);
14+
Initial();
15+
}
16+
17+
DataStructWidget::~DataStructWidget()
18+
{
19+
delete ui;
20+
}
21+
22+
void DataStructWidget::Initial()
23+
{
24+
QPair<QString, QString> _arrPairs[2] =
25+
{
26+
QPair<QString, QString>("数组", "Array"),
27+
QPair<QString, QString>("链表", "List"),
28+
};
29+
30+
/*QStringList theStrings;
31+
theStrings << "数组" << "链表" << "栈" << "队列";
32+
theStrings << "堆" << "优先队列" << "哈希表" << "二叉树";
33+
theStrings << "二叉搜索树" << "红黑树" << "BTree" << "BPlusTree";
34+
theStrings << "Graph";*/
35+
36+
theModel = new QStandardItemModel(this);
37+
ui->listView->setModel(theModel);
38+
ui->listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
39+
QStringList::iterator i;
40+
for (int i = 0; i < 2; i++)
41+
{
42+
QStandardItem* pItem = new QStandardItem();
43+
pItem->setData(_arrPairs[i].first, Qt::DisplayRole);
44+
pItem->setData(_arrPairs[i].second, Qt::UserRole);
45+
theModel->appendRow(pItem);
46+
}
47+
48+
// register signal-slot
49+
connect(ui->listView,
50+
SIGNAL(doubleClicked(QModelIndex)),
51+
this,
52+
SLOT(ListClicked(QModelIndex)));
53+
//connect(this,SIGNAL(DataStructShow(QWidget*)),parent(),SLOT(AddChildWidget(QWidget*)));
54+
}
55+
56+
void DataStructWidget::ListClicked(const QModelIndex& index)
57+
{
58+
// how to do
59+
// emit signal to parent's window,parameter is the name of wanted window
60+
QVariant var = theModel->data(index, Qt::UserRole);
61+
emit ShowDataStruct(var.toString());
62+
//DataStructFactory* dataFactor = DataStructFactory::Instance();
63+
//QWidget* pParent = parentWidget();
64+
//QWidget* widget = dataFactor->GetDataStructWidget(var.toString(), pParent);
65+
//MainWindow::Instance()->AddChildWidget(widget);
66+
//this->hide();
67+
//widget->show();
68+
}

Ui/datastructwidget.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Author : XuBenHao
2+
// Version : 1.0.0
3+
// Mail : xbh370970843@163.com
4+
// Copyright : XuBenHao 2020 - 2030
5+
6+
#ifndef APP_UI_DATASTRUCTWIDGET_H
7+
#define APP_UI_DATASTRUCTWIDGET_H
8+
#include "header.h"
9+
10+
namespace Ui {
11+
class DataStructWidget;
12+
}
13+
14+
class DataStructWidget : public QWidget
15+
{
16+
Q_OBJECT
17+
18+
public:
19+
explicit DataStructWidget(QWidget *parent = nullptr);
20+
~DataStructWidget();
21+
22+
Q_SIGNALS:
23+
void ShowDataStruct(const QString& strName_);
24+
25+
private:
26+
void Initial();
27+
private slots:
28+
void ListClicked(const QModelIndex& index);
29+
30+
signals:
31+
void DataStructShow(QWidget*);
32+
33+
private:
34+
QStandardItemModel* theModel;
35+
36+
private:
37+
Ui::DataStructWidget *ui;
38+
};
39+
40+
#endif // DATASTRUCTWIDGET_H

Ui/datastructwidget.ui

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>DataStructWidget</class>
4+
<widget class="QWidget" name="DataStructWidget">
5+
<property name="geometry">
6+
<rect>
7+
<x>0</x>
8+
<y>0</y>
9+
<width>400</width>
10+
<height>300</height>
11+
</rect>
12+
</property>
13+
<property name="windowTitle">
14+
<string>Form</string>
15+
</property>
16+
<layout class="QVBoxLayout" name="verticalLayout">
17+
<item>
18+
<widget class="QListView" name="listView">
19+
<property name="palette">
20+
<palette>
21+
<active>
22+
<colorrole role="Text">
23+
<brush brushstyle="SolidPattern">
24+
<color alpha="255">
25+
<red>85</red>
26+
<green>170</green>
27+
<blue>0</blue>
28+
</color>
29+
</brush>
30+
</colorrole>
31+
<colorrole role="PlaceholderText">
32+
<brush brushstyle="SolidPattern">
33+
<color alpha="128">
34+
<red>85</red>
35+
<green>170</green>
36+
<blue>0</blue>
37+
</color>
38+
</brush>
39+
</colorrole>
40+
</active>
41+
<inactive>
42+
<colorrole role="Text">
43+
<brush brushstyle="SolidPattern">
44+
<color alpha="255">
45+
<red>85</red>
46+
<green>170</green>
47+
<blue>0</blue>
48+
</color>
49+
</brush>
50+
</colorrole>
51+
<colorrole role="PlaceholderText">
52+
<brush brushstyle="SolidPattern">
53+
<color alpha="128">
54+
<red>85</red>
55+
<green>170</green>
56+
<blue>0</blue>
57+
</color>
58+
</brush>
59+
</colorrole>
60+
</inactive>
61+
<disabled>
62+
<colorrole role="Text">
63+
<brush brushstyle="SolidPattern">
64+
<color alpha="255">
65+
<red>190</red>
66+
<green>190</green>
67+
<blue>190</blue>
68+
</color>
69+
</brush>
70+
</colorrole>
71+
<colorrole role="PlaceholderText">
72+
<brush brushstyle="SolidPattern">
73+
<color alpha="128">
74+
<red>0</red>
75+
<green>0</green>
76+
<blue>0</blue>
77+
</color>
78+
</brush>
79+
</colorrole>
80+
</disabled>
81+
</palette>
82+
</property>
83+
<property name="font">
84+
<font>
85+
<family>文泉驿正黑</family>
86+
<pointsize>26</pointsize>
87+
</font>
88+
</property>
89+
</widget>
90+
</item>
91+
</layout>
92+
</widget>
93+
<resources/>
94+
<connections/>
95+
</ui>

Ui/header.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#ifndef APP_UI_HEADER_H
2+
#define APP_UI_HEADER_H
3+
#include "Global/lib.h"
4+
#include "ModelManager/lib.h"
5+
#include "NcManager/lib.h"
6+
#include "Functions/lib.h"
7+
#include "Parameter/lib.h"
8+
#include "FileGenerate/lib.h"
9+
#include "FileParse/lib.h"
10+
#include "AnimationService/lib.h"
11+
12+
struct ArrayItem
13+
{
14+
ArrayItem()
15+
{
16+
m_nId = -1;
17+
m_nCapacity = 0;
18+
}
19+
20+
int m_nId;
21+
int m_nCapacity;
22+
};
23+
Q_DECLARE_METATYPE(ArrayItem)
24+
#endif // HEADER_H

Ui/lib.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef APP_UI_LIB_H
2+
#define APP_UI_LIB_H
3+
#include "mainwindow.h"
4+
#include "datastructwidget.h"
5+
#include "Array/arraydeletewidget.h"
6+
#include "Array/arrayindexvisitwidget.h"
7+
#include "Array/arrayinsertwidget.h"
8+
#include "Array/arrayintroducewidget.h"
9+
#include "Array/arrayorganizewidget.h"
10+
#include "Array/arraysummarywidget.h"
11+
#include "Array/arrayvaluevisitwidget.h"
12+
13+
#include "DataStruct/arraywidget.h"
14+
#include "Drawing/arrayintroducedrawingwidget.h"
15+
#endif

0 commit comments

Comments
 (0)