4 #include <QXmlStreamReader>
7 RoutePrivate::RoutePrivate( QObject *parent ) :
16 RoutePrivate::~RoutePrivate()
20 RouteData RoutePrivate::parseReply( const QByteArray &reply )
22 qDebug() << __PRETTY_FUNCTION__;
25 QXmlStreamReader xml( reply );
27 bool haveLine = false;
28 bool haveTime = false;
32 while ( !(haveLine && haveTime) && !xml.atEnd() ) {
34 if ( !haveLine && xml.isStartElement() && xml.name() == "LINE" ) {
35 QString lineCode( xml.attributes().value("code").toString() );
36 qDebug() << "lineCode" << lineCode;
38 retVal.lineCode = parseJORECode( lineCode );
43 if ( inLine && xml.name() == "STOP" ) {
46 if ( !haveTime && inLine && inStop && xml.name() == "ARRIVAL" ) {
47 QString arrivalTime( xml.attributes().value("time").toString() );
48 qDebug() << "arrivalTime" << arrivalTime;
50 retVal.arrivalTime = arrivalTime.rightJustified(4).insert(2,":");
55 if ( xml.isEndElement() && xml.name() == "STOP" ) {
58 if ( xml.isEndElement() && xml.name() == "LINE" ) {
63 if ( xml.hasError() ) {
64 qDebug() << "xml error";
70 void RoutePrivate::setFromLocation( const Location &location )
72 m_fromLocation = location;
76 const Location &RoutePrivate::fromLocation()
78 return m_fromLocation;
81 void RoutePrivate::setToLocation( const Location &toLocation )
83 m_toLocation = toLocation;
87 QString RoutePrivate::parseJORECode( const QString &joreCode ) const
89 QString areaTransportTypeCode( joreCode.mid(0,1) );
90 QString lineCode( joreCode.mid(1,3) );
91 QString letterVariant( joreCode.mid(4,1) );
92 QString letterNumberVariant( joreCode.mid(5,1) );
93 QString direction( joreCode.mid(6,1) );
95 lineCode.setNum( lineCode.toInt() );
97 return lineCode+letterVariant;
100 const Location &RoutePrivate::toLocation()
105 bool RoutePrivate::fromValid()
110 bool RoutePrivate::toValid()