Fixed: problem with invalid addresses; version 0.8
authorMax Waterman <david.waterman@nokia.com>
Sat, 24 Apr 2010 00:42:15 +0000 (03:42 +0300)
committerMax Waterman <david.waterman@nokia.com>
Sat, 24 Apr 2010 00:42:15 +0000 (03:42 +0300)
zouba/debian/changelog
zouba/debian/files
zouba/src/location.cpp
zouba/src/location.h
zouba/src/location_p.cpp
zouba/src/uicontroller.cpp
zouba/src/uicontroller.h

index 7baafd5..8249ab2 100644 (file)
@@ -1,9 +1,15 @@
+zouba (0.8) unstable; urgency=low
+
+  * Fixed problem when changing the address of a location to something invalid.
+
+ -- Max Waterman <davidmaxwaterman@fastmail.co.uk>  Sat, 24 Apr 2010 03:39:00 +0200
+
 zouba (0.7) unstable; urgency=low
 
   * Changed gps controller to use labels for fake gps instead of a new Location instance.
   * Added route detail table and general associated shuffle of api.
 
- -- Max Waterman <davidmaxwaterman@fastmail.co.uk>  Mon, 20 Apr 2010 06:27:00 +0200
+ -- Max Waterman <davidmaxwaterman@fastmail.co.uk>  Tue, 20 Apr 2010 06:27:00 +0200
 
 zouba (0.6) unstable; urgency=low
 
index 8ea7a7a..3752086 100644 (file)
@@ -1 +1 @@
-zouba_0.7_armel.deb user/navigation extra
+zouba_0.8_armel.deb user/navigation extra
index d7761fd..c54f65c 100644 (file)
@@ -124,6 +124,7 @@ void Location::resolveAddress( const QString &address )
 
   manager->get( QNetworkRequest( fullUrl ) );
   qDebug() << "waiting for reply from Ytv";
+  emit( busy( true ) );
 }
 
 void Location::replyFinished( QNetworkReply * reply )
@@ -134,7 +135,12 @@ void Location::replyFinished( QNetworkReply * reply )
   if ( isValid() ) {
     qDebug() << label() << "becomeValid";
     emit( becomeValid() );
+  } else {
+    qDebug() << label() << "not valid";
+    emit( becomeInValid() );
   }
+
+  emit( busy( false ) );
 }
 
 QString Location::x() const
index ae501c1..dfb5d00 100644 (file)
@@ -44,6 +44,8 @@ public Q_SLOTS:
 
 Q_SIGNALS:
   void becomeValid();
+  void becomeInValid();
+  void busy( bool busy );
 
 private Q_SLOTS:
   void replyFinished( QNetworkReply * reply );
index 383622d..442977b 100644 (file)
@@ -36,22 +36,33 @@ void LocationPrivate::parseReply( const QByteArray &reply )
 {
   qDebug() << "parsing";
   QXmlStreamReader xml( reply );
+  bool responseHasError = false;
 
   while ( !xml.atEnd() ) {
     xml.readNext();
-    if ( xml.isStartElement() && xml.name() == "LOC" ) {
-      QXmlStreamAttributes attributes( xml.attributes() );
-      QStringRef xAttribute( attributes.value("x") );
-      QStringRef yAttribute( attributes.value("y") );
-      QString newX( xAttribute.toString() );
-      QString newY( yAttribute.toString() );
-
-      m_x = newX;
-      m_y = newY;
+
+    if ( xml.isStartElement() ) {
+      QString xmlName( xml.name().toString() );
+
+      if ( xmlName == "LOC" ) {
+        QXmlStreamAttributes attributes( xml.attributes() );
+        QStringRef xAttribute( attributes.value("x") );
+        QStringRef yAttribute( attributes.value("y") );
+        QString newX( xAttribute.toString() );
+        QString newY( yAttribute.toString() );
+
+        m_x = newX;
+        m_y = newY;
+      }
+
+      if ( xmlName == "ERROR" ) {
+        responseHasError = true;
+      }
+
     }
   }
 
-  if ( xml.hasError() ) {
+  if ( xml.hasError() || responseHasError ) {
     qDebug() << "xml error";
     m_valid = false;
   } else {
index 503c449..962135f 100644 (file)
@@ -43,18 +43,34 @@ UiController::UiController( Ui *ui ) :
       this, SLOT( setHomeButtonValid() )
   );
   connect(
+      homeLocation, SIGNAL( becomeInValid() ),
+      this, SLOT( setHomeButtonInValid() )
+  );
+  connect(
       homeLocation, SIGNAL( becomeValid() ),
       locations, SLOT( saveLocation() )
       );
+  connect(
+      homeLocation, SIGNAL( busy( bool ) ),
+      ui, SLOT( setBusy( bool ) )
+      );
 
   connect(
       workLocation, SIGNAL( becomeValid() ),
       this, SLOT( setWorkButtonValid() )
   );
   connect(
+      workLocation, SIGNAL( becomeInValid() ),
+      this, SLOT( setWorkButtonInValid() )
+  );
+  connect(
       workLocation, SIGNAL( becomeValid() ),
       locations, SLOT( saveLocation() )
       );
+  connect(
+      workLocation, SIGNAL( busy( bool ) ),
+      ui, SLOT( setBusy( bool ) )
+      );
 
   m_destination.append( homeLocation );
   m_destination.append( workLocation );
@@ -74,21 +90,33 @@ UiController::~UiController()
 {
 }
 
+void UiController::setHomeButtonInValid()
+{
+  qDebug() << "setting home button invalid";
+  setButtonValid( Ui::HomeButtonId, false );
+}
+
 void UiController::setHomeButtonValid()
 {
   qDebug() << "setting home button valid";
-  setButtonValid( Ui::HomeButtonId );
+  setButtonValid( Ui::HomeButtonId, true );
+}
+
+void UiController::setWorkButtonInValid()
+{
+  qDebug() << "setting work button invalid";
+  setButtonValid( Ui::WorkButtonId, false );
 }
 
 void UiController::setWorkButtonValid()
 {
   qDebug() << "setting work button valid";
-  setButtonValid( Ui::WorkButtonId );
+  setButtonValid( Ui::WorkButtonId, true );
 }
 
-void UiController::setButtonValid( int id )
+void UiController::setButtonValid( int id, bool isValid )
 {
-  m_ui->m_destinationButtons->button( id )->setEnabled(true);
+  m_ui->m_destinationButtons->button( id )->setEnabled( isValid );
 }
 
 void UiController::changeDestination( int id )
index a220031..7cbbbf5 100644 (file)
@@ -28,10 +28,12 @@ private Q_SLOTS:
   void changeRoute( int id );
   void setHomeButtonValid();
   void setWorkButtonValid();
+  void setHomeButtonInValid();
+  void setWorkButtonInValid();
   void displayRouteDetail( int id );
 
 private:
-  void setButtonValid( int id );
+  void setButtonValid( int id, bool isValid );
 
 private:
   QList<RouteData> m_routeData;