-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlistform.cpp
111 lines (92 loc) · 3.28 KB
/
listform.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
#include "listform.h"
#include "listelem.h"
#include "utils.h"
#include "tableworker.h"
#include <QString>
#include <QDebug>
#include <QAxObject>
#include <string.h>
ListForm::ListForm(Criterions crt, QWidget * parent)
: QWidget(parent),
ui(new Ui::ResElemForm),
crt(crt)
{
ui->setupUi(this);
//ui->CmdsList->setLayout(main_layout);
//ui->CmdsList->setAlignment(Qt::AlignTop);
ui->ParamName->setText(crtiterionsToString(crt));
scroll_w = new QWidget(ui->CmdsList);
main_layout = new QVBoxLayout(scroll_w);
main_layout->setAlignment(Qt::AlignTop);
scroll_w->setLayout(main_layout);
ui->CmdsList->setWidget(scroll_w);
}
ListForm::~ListForm() {
delete ui;
}
void ListForm::setDataPth(QString path) {
this->path = path;
}
Criterions ListForm::getCriterion() const {
return crt;
}
QVBoxLayout * ListForm::getMainLayout() const {
return main_layout;
}
void ListForm::changeStateLable(ProccesThreadState ptc) {
ui->ProccesState->setText(stringProcessState(ptc));
}
void ListForm::addElem(listElemetData led) {
ListElem * le = new ListElem(led, scroll_w);
//connect(le, SIGNAL(rightMBClicked(QString, QString, QString)), this, SLOT(elementPressed(QString, QString, QString)));
connect(le, SIGNAL(leftMBDClicked(listElemetData)), this, SLOT(openXlsx(listElemetData)));
int i = 0;
while (i < main_layout->count()) {
ListElem * cle = (ListElem *)main_layout->itemAt(i)->widget();
if ((cle->getPercent() == led.percent && QString::compare(cle->getCmdName(), led.command, Qt::CaseInsensitive) > 0)
|| (cle->getPercent() < led.percent))
break;
i++;
}
main_layout->insertWidget(i, le);
}
void ListForm::delElem(int index) {
QLayoutItem * witem = main_layout->takeAt(index);
main_layout->removeWidget(witem->widget());
delete witem->widget();
}
void ListForm::showCurrentSet(int percent) {
int i = 0;
while (i < main_layout->count()) {
ListElem * cle = (ListElem *)main_layout->itemAt(i)->widget();
if (cle->getPercent() < percent)
cle->setVisible(false);
else
cle->setVisible(true);
i++;
}
main_layout->update();
}
void ListForm::showCurrentSet(QString value) {
int i = 0;
while (i < main_layout->count()) {
ListElem * cle = (ListElem *)main_layout->itemAt(i)->widget();
if (!strncmp(cle->getCmdName().toStdString().c_str(), value.toStdString().c_str(), value.size()))
cle->setVisible(true);
else
cle->setVisible(false);
i++;
}
main_layout->update();
}
void ListForm::openXlsx(listElemetData led) {
qDebug() << led.country << " " << led.league << " " << led.command;
QString xlsx_path = path + "/" + led.country + "/" + led.league;
QAxObject * excel = new QAxObject("Excel.Application", 0);
excel->dynamicCall("SetVisible(bool)", true);
QAxObject * workbooks = excel->querySubObject("Workbooks");
QAxObject * workbook = workbooks->querySubObject("Open(const QString&)", xlsx_path);
QAxObject * worksheet = workbook->querySubObject("Worksheets(int)", led.id + 1);
worksheet->dynamicCall("Select()");
delete excel;
}