-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStation.cpp
More file actions
32 lines (27 loc) · 704 Bytes
/
Station.cpp
File metadata and controls
32 lines (27 loc) · 704 Bytes
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
#include "Station.h"
#include <QDebug>
#include <QString>
#include <QFile>
bool Station::operator==(const Station& other) const
{
if (name == other.name)
return true;
else
return false;
}
QList<Station> readStation(QString fileName) {
QFile file(fileName);
QList<Station> stations;
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
qDebug() << file.errorString();
return stations;
}
QTextStream in(&file);
while (!in.atEnd()) {
QString line = in.readLine();
QStringList fields = line.split(",");
stations.append(Station(fields[0]+fields[1], fields[2]));
}
file.close();
return stations;
}