From 21b67294d56b5001ae146f37fee1377f91833043 Mon Sep 17 00:00:00 2001 From: Max Waterman Date: Mon, 1 Mar 2010 23:41:24 +0200 Subject: [PATCH] Fixed encoding issue so can now enter addresses in the UI. --- zouba/location.cpp | 4 ++-- zouba/location_p.cpp | 1 + zouba/ytv.h | 8 +++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/zouba/location.cpp b/zouba/location.cpp index b41360c..2ffa63f 100644 --- a/zouba/location.cpp +++ b/zouba/location.cpp @@ -63,7 +63,7 @@ void Location::resolveAddress( QString address ) { QUrl fullUrl( ytv ); - fullUrl.addEncodedQueryItem( "key", address.toUtf8() ); + fullUrl.addEncodedQueryItem( "key", address.toAscii().toPercentEncoding() ); fullUrl.addQueryItem( "user", username ); fullUrl.addQueryItem( "pass", password ); @@ -74,7 +74,7 @@ void Location::replyFinished( QNetworkReply * reply ) { q->parseReply( reply->readAll() ); - if ( q->isValid() ) { + if ( isValid() ) { emit( becomeValid() ); } } diff --git a/zouba/location_p.cpp b/zouba/location_p.cpp index 318630d..8eac5e0 100644 --- a/zouba/location_p.cpp +++ b/zouba/location_p.cpp @@ -38,6 +38,7 @@ void LocationPrivate::parseReply( const QByteArray &reply ) if ( xml.hasError() ) { qDebug() << "xml error"; + m_valid = false; } else { m_valid = true; } diff --git a/zouba/ytv.h b/zouba/ytv.h index 2bcc02b..16915f0 100644 --- a/zouba/ytv.h +++ b/zouba/ytv.h @@ -3,13 +3,11 @@ #include namespace { - const QUrl ytv( "http://api.reittiopas.fi/public-ytv/fi/api/" ); + const QString ytv( "http://api.reittiopas.fi/public-ytv/fi/api/" ); const QString username( "zouba" ); const QString password( "caf9r3ee" ); - //const QString home( "Taivaanvuohentie 7, Helsinki" ); - //const QString work( "Itämerenkatu 11, Helsinki" ); - const QString home( "Taivaanvuohentie%207%2CHelsinki" ); - const QString work( "It%E4merenkatu%2011%2CHelsinki" ); + const QString home( QByteArray::fromPercentEncoding( "Taivaanvuohentie%207%2CHelsinki" ) ); + const QString work( QByteArray::fromPercentEncoding( "It%E4merenkatu%2011%2CHelsinki" ) ); } -- 1.7.9.5