2 #include "location_p.h"
4 #include <QXmlStreamReader>
7 #include <QMaemo5InformationBox>
9 LocationPrivate::LocationPrivate( const QString &x, const QString &y, const QString &label ) :
18 LocationPrivate::LocationPrivate( const QString &label ) :
27 LocationPrivate::~LocationPrivate()
36 void LocationPrivate::parseReply( const QByteArray &reply )
38 qDebug() << "parsing";
39 QXmlStreamReader xml( reply );
40 bool responseHasError = false;
42 while ( !xml.atEnd() ) {
45 if ( xml.isStartElement() ) {
46 QString xmlName( xml.name().toString() );
48 if ( xmlName == "LOC" ) {
49 QXmlStreamAttributes attributes( xml.attributes() );
50 QStringRef xAttribute( attributes.value("x") );
51 QStringRef yAttribute( attributes.value("y") );
52 QString newX( xAttribute.toString() );
53 QString newY( yAttribute.toString() );
59 if ( xmlName == "ERROR" ) {
60 responseHasError = true;
66 if ( xml.hasError() || responseHasError ) {
67 QMaemo5InformationBox::information( 0, "address resolution error - please check address" );
68 qDebug() << "xml error";
71 qDebug() << "(" << m_x << "," << m_y << ")";
72 if ( m_x.isEmpty() || m_y.isEmpty() ) {
73 qDebug() << "is NOT valid";
76 qDebug() << "is now valid";
82 void LocationPrivate::setLabel( const QString &label)
87 QString LocationPrivate::label() const
92 void LocationPrivate::setAddress( const QString &address)
97 QString LocationPrivate::address() const
102 void LocationPrivate::setX( uint x )
104 m_x = QString( "%1" ).arg( x );
107 void LocationPrivate::setX( const QString &x )
112 QString LocationPrivate::x() const
117 void LocationPrivate::setY( uint y )
119 m_y = QString( "%1" ).arg( y );
122 void LocationPrivate::setY( const QString &y )
127 QString LocationPrivate::y() const
132 void LocationPrivate::setValid( bool valid )
137 bool LocationPrivate::isValid() const