Works now without any existing location settings, enabling a new user to start using it.
[ptas] / zouba / location_p.cpp
index 5e74595..b915be2 100644 (file)
@@ -5,14 +5,18 @@
 #include <QByteArray>
 #include <QDebug>
 
-LocationPrivate::LocationPrivate( QString x, QString y ) :
+LocationPrivate::LocationPrivate( const QString &x, const QString &y, const QString &label ) :
+  m_label(label),
+  m_address(),
   m_x(x),
   m_y(y),
   m_valid(true)
 {
 }
 
-LocationPrivate::LocationPrivate() :
+LocationPrivate::LocationPrivate( const QString &label ) :
+  m_label(label),
+  m_address(),
   m_x(0),
   m_y(0),
   m_valid(false)
@@ -25,6 +29,7 @@ LocationPrivate::~LocationPrivate()
 
 void LocationPrivate::parseReply( const QByteArray &reply )
 {
+  qDebug() << "parsing";
   QXmlStreamReader xml( reply );
 
   while ( !xml.atEnd() ) {
@@ -45,16 +50,43 @@ void LocationPrivate::parseReply( const QByteArray &reply )
     qDebug() << "xml error";
     m_valid = false;
   } else {
-    m_valid = true;
+    qDebug() << "(" << m_x << "," << m_y << ")";
+    if ( m_x.isEmpty() ||  m_y.isEmpty() ) {
+      qDebug() << "is NOT valid";
+      m_valid = false;
+    } else {
+      qDebug() << "is now valid";
+      m_valid = true;
+    }
   }
 }
 
+void LocationPrivate::setLabel( const QString &label)
+{
+  m_label = label;
+}
+
+QString LocationPrivate::label() const
+{
+  return m_label;
+}
+
+void LocationPrivate::setAddress( const QString &address)
+{
+  m_address = address;
+}
+
+QString LocationPrivate::address() const
+{
+  return m_address;
+}
+
 void LocationPrivate::setX( uint x )
 {
   m_x = QString( "%1" ).arg( x );
 }
 
-void LocationPrivate::setX( QString x )
+void LocationPrivate::setX( const QString &x )
 {
   m_x = x;
 }
@@ -69,7 +101,7 @@ void LocationPrivate::setY( uint y )
   m_y = QString( "%1" ).arg( y );
 }
 
-void LocationPrivate::setY( QString y )
+void LocationPrivate::setY( const QString &y )
 {
   m_y = y;
 }