4 #include <QXmlStreamReader>
8 RoutePrivate::RoutePrivate( QObject *parent ) :
17 RoutePrivate::~RoutePrivate()
21 QList<RouteData> RoutePrivate::parseReply( const QByteArray &reply )
23 QList<RouteData> retVal;
26 QXmlStreamReader xml( reply );
28 bool haveLine = false;
29 bool haveTime = false;
33 while ( !xml.atEnd() ) {
35 if ( xml.isStartElement() && xml.name() == "LINE" ) {
36 QString lineCode( xml.attributes().value("code").toString() );
38 routeData.lineCode = parseJORECode( lineCode );
43 if ( inLine && xml.name() == "STOP" ) {
46 if ( inLine && inStop && xml.name() == "ARRIVAL" ) {
47 QString arrivalTime( xml.attributes().value("time").toString() );
49 routeData.arrivalTime = arrivalTime.rightJustified(4).insert(2,":");
54 if ( xml.isEndElement() && xml.name() == "STOP" ) {
58 if ( xml.isEndElement() && xml.name() == "LINE" ) {
63 if ( haveLine && haveTime ) {
64 retVal.append( routeData );
66 // only want first STOP per LINE
72 if ( xml.hasError() ) {
73 qDebug() << "xml error";
79 void RoutePrivate::setFromLocation( const Location &location )
81 m_fromLocation = location;
85 const Location &RoutePrivate::fromLocation()
87 return m_fromLocation;
90 void RoutePrivate::setToLocation( const Location &toLocation )
92 m_toLocation = toLocation;
96 QString RoutePrivate::parseJORECode( const QString &joreCode ) const
100 QString areaTransportTypeCode( joreCode.mid(0,1) );
101 QString lineCode( joreCode.mid(1,3) );
102 QString letterVariant( joreCode.mid(4,1) );
103 QString letterNumberVariant( joreCode.mid(5,1) );
104 QString direction( joreCode.mid(6,1) );
106 lineCode.setNum( lineCode.toInt() );
110 if ( letterVariant != " " ) {
111 retVal += letterVariant;
117 const Location &RoutePrivate::toLocation()
122 bool RoutePrivate::fromValid()
127 bool RoutePrivate::toValid()