-
Notifications
You must be signed in to change notification settings - Fork 0
/
widget.cpp
73 lines (56 loc) · 2.22 KB
/
widget.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
#include "widget.h"
#include <QFile>
#include <QDebug>
Widget::Widget(QWidget *parent) : QWidget(parent)
{
v_layout = new QVBoxLayout(this);
f_layout = new QFormLayout;
pn_line_edit = new QLineEdit("XC7A200T-2FBG484I");
in_line_edit = new QLineEdit("flight_time.csv");
out_line_edit = new QLineEdit("PinPkgDelays.txt");
go_button = new QPushButton("GO!");
text_edit = new QTextEdit;
f_layout->addRow("Part Number:", pn_line_edit);
f_layout->addRow("CSV file:", in_line_edit);
f_layout->addRow("Output:", out_line_edit);
v_layout->addLayout(f_layout);
v_layout->addWidget(go_button);
go_button->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
v_layout->addWidget(text_edit);
this->setLayout(v_layout);
this->setGeometry(500,500,700,500);
this->setWindowTitle("Vivado-to-CES package delay converter");
connect(go_button,SIGNAL(clicked()),this,SLOT(process()));
}
void Widget::process(){
QFile in_file(in_line_edit->text());
QFile out_file(out_line_edit->text());
if (!in_file.open(QIODevice::ReadOnly | QIODevice::Text)){
//сообщение об ошибке чтения файла
text_edit->append("Ошибка чтения входного файла!");
}
else if (!out_file.open(QIODevice::WriteOnly | QIODevice::Text)){
//сообщение об ошибке записи файла
text_edit->append("Ошибка записи PinPkgDelays.txt!");
}
else {
text_edit->append("Создание файла...");
out_file.write("UNITS ps\n\n");
out_file.write("PART_NUMBER " + pn_line_edit->text().toUtf8() + "\n");
text_edit->append("...");
QString line = "";
QStringList items;
while(!in_file.atEnd()) {
line = in_file.readLine().trimmed();
items = line.split(',');
if (items.size()>4){
out_file.write(items.at(1).toUtf8() + " " + items.at(4).toUtf8() + "\n");
}
}
in_file.close();
out_file.close();
text_edit->append("Готово.");
}
}
Widget::~Widget(){
}