-
Notifications
You must be signed in to change notification settings - Fork 0
/
resultswindow.cpp
138 lines (112 loc) · 3.75 KB
/
resultswindow.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#include "resultswindow.h"
#include "ui_resultswindow.h"
#include "threadanalizeprocess.h"
#include "listelem.h"
#include <QDebug>
ResultsWindow::ResultsWindow(ConfigWorker * cfg, QWidget *parent) :
QWidget(parent),
ui(new Ui::ResultsWindow),
cfg(cfg)
{
ui->setupUi(this);
tp = nullptr;
scroll_widget = nullptr;
main_layout = nullptr;
connect(ui->percentSpin, SIGNAL(valueChanged(int)), this, SLOT(showCurrentSet(int)));
connect(ui->SearchLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(showSearchResults(const QString)));
connect(ui->SaveResultsBtn, SIGNAL(clicked()), this, SLOT(safeResults()));
}
ResultsWindow::~ResultsWindow() {
delete ui;
if (tp != nullptr)
delete tp;
}
void ResultsWindow::runAnalize(QVector<Criterions> vcrt) {
if (tp != nullptr)
delete tp;
tp = new QThreadPool(this);
if (scroll_widget != nullptr) {
delete scroll_widget;
scroll_widget = nullptr;
}
scroll_widget = new QWidget(ui->scrollArea);
main_layout = new QHBoxLayout(scroll_widget);
main_layout->setAlignment(Qt::AlignLeft);
scroll_widget->setLayout(main_layout);
ui->scrollArea->setWidget(scroll_widget);
for (int i = 0; i < vcrt.size(); ++i) {
//qDebug() << "cicle - " << vcrt[i];
ListForm * lf = new ListForm(vcrt[i], scroll_widget);
lf->setDataPth(cfg->getXlsxPath());
lf->changeStateLable(STARTING);
main_layout->addWidget(lf);
qDebug() << "-1 " << i;
ThreadAnalizeProcess tap(lf, cfg, vcrt[i]);
qDebug() << "-1.1 " << i;
/*
while (1) {
qDebug() << "-2 " << i;
if (tp->tryStart(&tap)) {
break;
}
qDebug() << "-3 " << i;
lf->changeStateLable(WAITING);
qDebug() << "-4 " << i;
QThread::sleep(2);
}
*/
tap.run();
//delete tap;
}
}
void ResultsWindow::startAnalize(QVector<Criterions> vcrt) {
this->show();
qDebug() << "start analize";
m_vcrt = vcrt;
runAnalize(vcrt);
}
void ResultsWindow::showCurrentSet(int value) {
int i = 0;
while (i < main_layout->count()) {
ListForm * clf = (ListForm *)main_layout->itemAt(i)->widget();
clf->showCurrentSet(value);
i++;
}
}
void ResultsWindow::showSearchResults(const QString str) {
}
void ResultsWindow::safeResults() {
QList<ResAnalize> lresa;
for (int i = 0; i < main_layout->count(); ++i) {
ListForm * clf = (ListForm *)main_layout->itemAt(i)->widget();
ResAnalize resa;
resa.crt = clf->getCriterion();
QVBoxLayout * l = clf->getMainLayout();
for (int j = 0; j < l->count(); ++j) {
ListElem * le = (ListElem *)l->itemAt(j)->widget();
resa.lled.push_back(le->getData());
}
lresa.push_back(resa);
}
cfg->saveAnalizeResults(lresa);
}
void ResultsWindow::sshowSavedResults(QList<ResAnalize> lra) {
if (scroll_widget != nullptr) {
delete scroll_widget;
scroll_widget = nullptr;
}
scroll_widget = new QWidget(ui->scrollArea);
main_layout = new QHBoxLayout(scroll_widget);
main_layout->setAlignment(Qt::AlignLeft);
scroll_widget->setLayout(main_layout);
ui->scrollArea->setWidget(scroll_widget);
this->show();
for (int i = 0; i < lra.size(); ++i) {
ListForm * lf = new ListForm(lra[i].crt, scroll_widget);
lf->changeStateLable(FINISH);
main_layout->addWidget(lf);
for (int j = 0; j < lra[i].lled.size(); ++j) {
lf->addElem(lra[i].lled[j]);
}
}
}