Skip to content

Commit 61210c6

Browse files
committed
pratical
1 parent 3afdc67 commit 61210c6

6 files changed

Lines changed: 926 additions & 0 deletions

File tree

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// Author : XuBenHao
2+
// Version : 1.0.0
3+
// Mail : xbh370970843@163.com
4+
// Copyright : XuBenHao 2020 - 2030
5+
6+
#include "praticalarraylistwidget.h"
7+
#include "ui_praticalarraylistwidget.h"
8+
#include "Ui/Dialog/Array/createarraydialog.h"
9+
PraticalArrayListWidget::PraticalArrayListWidget(QWidget *parent) :
10+
QWidget(parent),
11+
ui(new Ui::PraticalArrayListWidget)
12+
{
13+
ui->setupUi(this);
14+
Initialize();
15+
}
16+
17+
PraticalArrayListWidget::~PraticalArrayListWidget()
18+
{
19+
delete ui;
20+
}
21+
22+
void PraticalArrayListWidget::Initialize()
23+
{
24+
connect(ui->pre, SIGNAL(clicked(bool)), this, SLOT(Pre(bool)));
25+
connect(ui->deleteArray, SIGNAL(clicked(bool)), this, SLOT(DeleteArray(bool)));
26+
connect(ui->createArray, SIGNAL(clicked(bool)), this, SLOT(CreateArray(bool)));
27+
28+
theModel = new QStandardItemModel(this);
29+
ui->listView->setModel(theModel);
30+
ui->listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
31+
/*QStringList::iterator i;
32+
for (int i = 0; i < 2; i++)
33+
{
34+
QStandardItem* pItem = new QStandardItem();
35+
pItem->setData(_arrPairs[i].first, Qt::DisplayRole);
36+
pItem->setData(_arrPairs[i].second, Qt::UserRole);
37+
theModel->appendRow(pItem);
38+
}*/
39+
40+
// register signal-slot
41+
connect(ui->listView,
42+
SIGNAL(doubleClicked(QModelIndex)),
43+
this,
44+
SLOT(ListClicked(QModelIndex)));
45+
}
46+
47+
void PraticalArrayListWidget::Pre(bool checked_)
48+
{
49+
Q_UNUSED(checked_);
50+
emit ShowDataStruct(QString("Array"), QVariant());
51+
}
52+
53+
void PraticalArrayListWidget::DeleteArray(bool checked_)
54+
{
55+
Q_UNUSED(checked_);
56+
QModelIndex _nIndex = ui->listView->currentIndex();
57+
QStandardItem* _pItem = theModel->itemFromIndex(_nIndex);
58+
int _nId = _nIndex.row();
59+
if(_nId < 0 || _nId >= theModel->rowCount())
60+
{
61+
return;
62+
}
63+
64+
QVariant _nVar = _pItem->data(Qt::UserRole);
65+
int _nCapacity = _nVar.toInt();
66+
QString _strFile = NModelManager::ModelManager::GetPraticalArrayModelFilePath(_nId, _nCapacity);
67+
QFile::remove(_strFile);
68+
theModel->removeRow(_nId);
69+
}
70+
71+
void PraticalArrayListWidget::CreateArray(bool checked_)
72+
{
73+
Q_UNUSED(checked_);
74+
CreateArrayDialog *_pCreateArrDia = new CreateArrayDialog(this);
75+
int _nRet = _pCreateArrDia->exec();
76+
if(_nRet == QDialog::Accepted)
77+
{
78+
int _nCapacity = _pCreateArrDia->GetCapacity();
79+
QStandardItem* pItem = new QStandardItem();
80+
pItem->setData(_nCapacity, Qt::DisplayRole);
81+
pItem->setData(_nCapacity, Qt::UserRole);
82+
theModel->appendRow(pItem);
83+
}
84+
85+
delete _pCreateArrDia;
86+
}
87+
88+
void PraticalArrayListWidget::ListClicked(const QModelIndex& index)
89+
{
90+
Q_UNUSED(index);
91+
QVariant var = theModel->data(index, Qt::UserRole);
92+
int _nCapacity = var.toInt();
93+
ArrayItem _nItem;
94+
_nItem.m_nCapacity = _nCapacity;
95+
_nItem.m_nId = index.row();
96+
97+
emit ShowDataStruct(
98+
QString("PraticalArray"),
99+
QVariant::fromValue(_nItem));
100+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Author : XuBenHao
2+
// Version : 1.0.0
3+
// Mail : xbh370970843@163.com
4+
// Copyright : XuBenHao 2020 - 2030
5+
6+
#ifndef APP_UI_PRATICALARRAYLISTWIDGET_H
7+
#define APP_UI_PRATICALARRAYLISTWIDGET_H
8+
#include "../header.h"
9+
10+
namespace Ui {
11+
class PraticalArrayListWidget;
12+
}
13+
14+
15+
16+
class PraticalArrayListWidget : public QWidget
17+
{
18+
Q_OBJECT
19+
20+
public:
21+
explicit PraticalArrayListWidget(QWidget *parent = nullptr);
22+
~PraticalArrayListWidget();
23+
24+
Q_SIGNALS:
25+
void ShowDataStruct(
26+
const QString& strName_,
27+
const QVariant& nVar_);
28+
29+
private slots:
30+
void Pre(bool checked_);
31+
void DeleteArray(bool checked_);
32+
void CreateArray(bool checked_);
33+
void ListClicked(const QModelIndex& index);
34+
35+
private:
36+
void Initialize();
37+
private:
38+
QStandardItemModel* theModel;
39+
40+
private:
41+
Ui::PraticalArrayListWidget *ui;
42+
};
43+
44+
#endif // PRATICALARRAYLISTWIDGET_H
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ui version="4.0">
3+
<class>PraticalArrayListWidget</class>
4+
<widget class="QWidget" name="PraticalArrayListWidget">
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+
<layout class="QHBoxLayout" name="horizontalLayout_2">
19+
<item>
20+
<widget class="QPushButton" name="pre">
21+
<property name="font">
22+
<font>
23+
<family>文泉驿正黑</family>
24+
<pointsize>12</pointsize>
25+
</font>
26+
</property>
27+
<property name="text">
28+
<string>返回上级</string>
29+
</property>
30+
</widget>
31+
</item>
32+
<item>
33+
<spacer name="horizontalSpacer">
34+
<property name="orientation">
35+
<enum>Qt::Horizontal</enum>
36+
</property>
37+
<property name="sizeHint" stdset="0">
38+
<size>
39+
<width>40</width>
40+
<height>20</height>
41+
</size>
42+
</property>
43+
</spacer>
44+
</item>
45+
</layout>
46+
</item>
47+
<item>
48+
<widget class="QListView" name="listView">
49+
<property name="palette">
50+
<palette>
51+
<active>
52+
<colorrole role="Text">
53+
<brush brushstyle="SolidPattern">
54+
<color alpha="255">
55+
<red>85</red>
56+
<green>170</green>
57+
<blue>0</blue>
58+
</color>
59+
</brush>
60+
</colorrole>
61+
<colorrole role="PlaceholderText">
62+
<brush brushstyle="SolidPattern">
63+
<color alpha="128">
64+
<red>85</red>
65+
<green>170</green>
66+
<blue>0</blue>
67+
</color>
68+
</brush>
69+
</colorrole>
70+
</active>
71+
<inactive>
72+
<colorrole role="Text">
73+
<brush brushstyle="SolidPattern">
74+
<color alpha="255">
75+
<red>85</red>
76+
<green>170</green>
77+
<blue>0</blue>
78+
</color>
79+
</brush>
80+
</colorrole>
81+
<colorrole role="PlaceholderText">
82+
<brush brushstyle="SolidPattern">
83+
<color alpha="128">
84+
<red>85</red>
85+
<green>170</green>
86+
<blue>0</blue>
87+
</color>
88+
</brush>
89+
</colorrole>
90+
</inactive>
91+
<disabled>
92+
<colorrole role="Text">
93+
<brush brushstyle="SolidPattern">
94+
<color alpha="255">
95+
<red>190</red>
96+
<green>190</green>
97+
<blue>190</blue>
98+
</color>
99+
</brush>
100+
</colorrole>
101+
<colorrole role="PlaceholderText">
102+
<brush brushstyle="SolidPattern">
103+
<color alpha="128">
104+
<red>0</red>
105+
<green>0</green>
106+
<blue>0</blue>
107+
</color>
108+
</brush>
109+
</colorrole>
110+
</disabled>
111+
</palette>
112+
</property>
113+
<property name="font">
114+
<font>
115+
<family>文泉驿正黑</family>
116+
<pointsize>26</pointsize>
117+
</font>
118+
</property>
119+
</widget>
120+
</item>
121+
<item>
122+
<layout class="QHBoxLayout" name="horizontalLayout">
123+
<item>
124+
<widget class="QPushButton" name="createArray">
125+
<property name="font">
126+
<font>
127+
<family>文泉驿正黑</family>
128+
<pointsize>12</pointsize>
129+
</font>
130+
</property>
131+
<property name="text">
132+
<string>创建</string>
133+
</property>
134+
</widget>
135+
</item>
136+
<item>
137+
<widget class="QPushButton" name="deleteArray">
138+
<property name="font">
139+
<font>
140+
<family>文泉驿正黑</family>
141+
<pointsize>12</pointsize>
142+
</font>
143+
</property>
144+
<property name="text">
145+
<string>删除</string>
146+
</property>
147+
</widget>
148+
</item>
149+
</layout>
150+
</item>
151+
</layout>
152+
</widget>
153+
<resources/>
154+
<connections/>
155+
</ui>

0 commit comments

Comments
 (0)