4 #include <QXmlStreamReader>
7 RoutePrivate::RoutePrivate( QObject *parent ) :
16 RoutePrivate::~RoutePrivate()
20 RouteData RoutePrivate::parseReply( const QByteArray &reply )
24 QXmlStreamReader xml( reply );
28 while ( !xml.atEnd() ) {
30 if ( xml.isStartElement() && xml.name() == "LINE" ) {
31 QString lineCode( xml.attributes().value("code").toString() );
33 retVal.lineCode = parseJORECode( lineCode );
37 if ( inLine && xml.name() == "STOP" ) {
40 if ( inLine && inStop && xml.name() == "ARRIVAL" ) {
41 QString arrivalTime( xml.attributes().value("time").toString() );
43 retVal.arrivalTime = arrivalTime;
47 if ( xml.isEndElement() && xml.name() == "STOP" ) {
50 if ( xml.isEndElement() && xml.name() == "LINE" ) {
55 if ( xml.hasError() ) {
56 qDebug() << "xml error";
62 void RoutePrivate::setFromLocation( const Location &location )
64 m_fromLocation = location;
68 const Location &RoutePrivate::fromLocation()
70 return m_fromLocation;
73 void RoutePrivate::setToLocation( const Location &toLocation )
75 m_toLocation = toLocation;
79 QString RoutePrivate::parseJORECode( const QString &joreCode ) const
81 QString areaTransportTypeCode( joreCode.mid(0,1) );
82 QString lineCode( joreCode.mid(1,3) );
83 QString letterVariant( joreCode.mid(4,1) );
84 QString letterNumberVariant( joreCode.mid(5,1) );
85 QString direction( joreCode.mid(6,1) );
87 lineCode.setNum( lineCode.toInt() );
89 return lineCode+letterVariant;
92 const Location &RoutePrivate::toLocation()
97 bool RoutePrivate::fromValid()
102 bool RoutePrivate::toValid()