-
Notifications
You must be signed in to change notification settings - Fork 11
/
indirect.cpp
66 lines (60 loc) · 1.66 KB
/
indirect.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
#include "indirect.h"
#include "ui_indirect.h"
#include<iostream>
#include<cstdio>
#include<cstring>
#include<fstream>
#include<QFile>
#include<QTextStream>
#include<QDebug>
#include<QDate>
#include<QDateTimeEdit>
#include<QMessageBox>
#include<QIODevice>
//it will open the window for showing indirect trains
indirect::indirect(QWidget *parent) :
QDialog(parent),
ui(new Ui::indirect)
{
ui->setupUi(this);
show_train();
this->setWindowTitle("SORRY!!!");
}
indirect::~indirect()
{
delete ui;
}
void indirect::show_train()
{
QString filename="D:\\qt\\irctc3\\extra.txt";
QFile file(filename);
if(!file.exists()){
qDebug() << "NO exist "<<filename;
}else{
qDebug() << filename<<" exits...";
}
QString line;
if (file.open(QIODevice::ReadOnly | QIODevice::Text)){
QTextStream stream(&file);
int i=0;
ui->label->setText(ui->label->text()+"source\t\tdest\t\ttrain_no\t\ttrain_name\t\tfare\n\n");
while (!stream.atEnd()){
line = stream.readLine();
QString s=line.split(" ").at(0);
if(s.compare("12345")==0)
{
ui->label->setText(ui->label->text()+QString :: number(i+1)+"\n\n");
i++;
}
else
{
ui->label->setText(ui->label->text()+line.split(" ").at(0) +"\t\t");
ui->label->setText(ui->label->text()+line.split(" ").at(1)+ "\t\t");
ui->label->setText(ui->label->text()+line.split(" ").at(2)+"\t\t");
ui->label->setText(ui->label->text()+line.split(" ").at(3)+"\t\t");
ui->label->setText(ui->label->text()+line.split(" ").at(4)+"\n\n");
}
}
}
file.close();
}