From 1f88ace8f69a25bb34a97d8a8765099ffcf320d5 Mon Sep 17 00:00:00 2001 From: Max Waterman Date: Sat, 24 Apr 2010 03:42:15 +0300 Subject: [PATCH] Fixed: problem with invalid addresses; version 0.8 --- zouba/debian/changelog | 8 +++++++- zouba/debian/files | 2 +- zouba/src/location.cpp | 6 ++++++ zouba/src/location.h | 2 ++ zouba/src/location_p.cpp | 31 +++++++++++++++++++++---------- zouba/src/uicontroller.cpp | 36 ++++++++++++++++++++++++++++++++---- zouba/src/uicontroller.h | 4 +++- 7 files changed, 72 insertions(+), 17 deletions(-) diff --git a/zouba/debian/changelog b/zouba/debian/changelog index 7baafd5..8249ab2 100644 --- a/zouba/debian/changelog +++ b/zouba/debian/changelog @@ -1,9 +1,15 @@ +zouba (0.8) unstable; urgency=low + + * Fixed problem when changing the address of a location to something invalid. + + -- Max Waterman 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 Mon, 20 Apr 2010 06:27:00 +0200 + -- Max Waterman Tue, 20 Apr 2010 06:27:00 +0200 zouba (0.6) unstable; urgency=low diff --git a/zouba/debian/files b/zouba/debian/files index 8ea7a7a..3752086 100644 --- a/zouba/debian/files +++ b/zouba/debian/files @@ -1 +1 @@ -zouba_0.7_armel.deb user/navigation extra +zouba_0.8_armel.deb user/navigation extra diff --git a/zouba/src/location.cpp b/zouba/src/location.cpp index d7761fd..c54f65c 100644 --- a/zouba/src/location.cpp +++ b/zouba/src/location.cpp @@ -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 diff --git a/zouba/src/location.h b/zouba/src/location.h index ae501c1..dfb5d00 100644 --- a/zouba/src/location.h +++ b/zouba/src/location.h @@ -44,6 +44,8 @@ public Q_SLOTS: Q_SIGNALS: void becomeValid(); + void becomeInValid(); + void busy( bool busy ); private Q_SLOTS: void replyFinished( QNetworkReply * reply ); diff --git a/zouba/src/location_p.cpp b/zouba/src/location_p.cpp index 383622d..442977b 100644 --- a/zouba/src/location_p.cpp +++ b/zouba/src/location_p.cpp @@ -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 { diff --git a/zouba/src/uicontroller.cpp b/zouba/src/uicontroller.cpp index 503c449..962135f 100644 --- a/zouba/src/uicontroller.cpp +++ b/zouba/src/uicontroller.cpp @@ -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 ) diff --git a/zouba/src/uicontroller.h b/zouba/src/uicontroller.h index a220031..7cbbbf5 100644 --- a/zouba/src/uicontroller.h +++ b/zouba/src/uicontroller.h @@ -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 m_routeData; -- 1.7.9.5