/
operatorandlist.cpp
89 lines (76 loc) · 2.33 KB
/
operatorandlist.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "operatorandlist.h"
#include <QStandardItemModel>
#include <QBoxLayout>
#include <QFileDialog>
#include <QDebug>
#include <QStringListModel>
#include <QProgressBar>
#include <QHeaderView>
#include <QProcessEnvironment>
#include <QBuffer>
#include <QMessageBox>
#include <QVBoxLayout>
#include <thread>
OperatorAndList::OperatorAndList(QWidget *parent,View* view)
: QWidget(parent),m_view(view)
{
QVBoxLayout* vbox = new QVBoxLayout(this);
QGridLayout* gbox = new QGridLayout();
tableList = new QTableWidget(0,1);
QStringList header;
header<<"index";
tableList->setHorizontalHeaderLabels(header);
tableList->setEditTriggers(QAbstractItemView::NoEditTriggers);
tableList->horizontalHeader()->setStretchLastSection(true);
connect(tableList,&QTableWidget::pressed,this,[this](const QModelIndex &index){
m_view->dataFileChang(index,testPointsList[index.row()],4096);
});
clearButton = new QPushButton("clear");
connect(clearButton,SIGNAL(clicked(bool)),this,SLOT(clearButtonclicked(bool)));
vbox->setMargin(2);
vbox->addWidget(tableList);
vbox->addLayout(gbox);
gbox->addWidget(clearButton,0,0);
connect(this,SIGNAL(signaldataFileCount(int)),m_view,SLOT(dataFileCount(int)));
connect(this,SIGNAL(signaldataStatusClear()),m_view,SLOT(slotsdataStatusClear()));
QStringList filetmp;
QVector<QPointF> tmp;
for(int i = 0;i<13;i++)
{
filetmp << "No."+QString::number(i);
tmp.clear();
for(int j = 0;j<4096;j++)
{
tmp.append(QPointF(j,qrand()%((i+1)*100)));
}
testPointsList.append(tmp);
}
slotDataFileList(filetmp);
slotDataLoadFinish();
}
void OperatorAndList::clearButtonclicked(bool checked)
{
emit signaldataStatusClear();
}
void OperatorAndList::slotDataFileList(QStringList list)
{
for(const auto& fileitem : list)
{
int row = tableList->rowCount();
tableList->insertRow(row);
QTableWidgetItem *itemname = new QTableWidgetItem(fileitem);
tableList->setItem(row, 0, itemname);
}
if(list.count() > 0)
{
tableList->selectRow(0);
emit signaldataFileCount(list.count());
}
}
void OperatorAndList::slotDataLoadFinish()
{
if(tableList->rowCount() > 0)
{
emit tableList->pressed(tableList->currentIndex());
}
}