4 #include <QXmlStreamReader>
7 RoutePrivate::RoutePrivate( QObject *parent ) :
14 RoutePrivate::~RoutePrivate()
18 RouteData RoutePrivate::parseReply( const QByteArray &reply )
22 QXmlStreamReader xml( reply );
26 while ( !xml.atEnd() ) {
28 if ( xml.isStartElement() && xml.name() == "LINE" ) {
29 QString lineCode( xml.attributes().value("code").toString() );
31 retVal.lineCode = parseJORECode( lineCode );
35 if ( inLine && xml.name() == "STOP" ) {
38 if ( inLine && inStop && xml.name() == "ARRIVAL" ) {
39 QString arrivalTime( xml.attributes().value("time").toString() );
41 retVal.arrivalTime = arrivalTime;
45 if ( xml.isEndElement() && xml.name() == "STOP" ) {
48 if ( xml.isEndElement() && xml.name() == "LINE" ) {
53 if ( xml.hasError() ) {
54 qDebug() << "xml error";
60 void RoutePrivate::setFromLocation( Location fromLocation )
62 m_fromLocation = fromLocation;
65 Location RoutePrivate::fromLocation()
67 return m_fromLocation;
70 void RoutePrivate::setToLocation( Location toLocation )
72 m_toLocation = toLocation;
75 QString RoutePrivate::parseJORECode( const QString &joreCode ) const
77 QString areaTransportTypeCode( joreCode.mid(0,1) );
78 QString lineCode( joreCode.mid(1,3) );
79 QString letterVariant( joreCode.mid(4,1) );
80 QString letterNumberVariant( joreCode.mid(5,1) );
81 QString direction( joreCode.mid(6,1) );
83 lineCode.setNum( lineCode.toInt() );
85 return lineCode+letterVariant;
88 Location RoutePrivate::toLocation()