QTM_USE_NAMESPACE
-Location::Location( QString x, QString y ) :
- q( new LocationPrivate( x, y ) ),
+Location::Location( const QString &x, const QString &y, const QString &label ) :
+ q( new LocationPrivate( x, y, label ) ),
manager( new QNetworkAccessManager(this) )
{
- connect( manager, SIGNAL( finished(QNetworkReply*) ), this, SLOT( replyFinished(QNetworkReply*) ) );
+ qDebug() << "Location::Location(" << x << "," << y << "," << label <<")";
+ connect(
+ manager, SIGNAL( finished(QNetworkReply*) ),
+ this, SLOT( replyFinished(QNetworkReply*) )
+ );
}
-Location::Location( const QGeoPositionInfo &positionInfo ) :
- q( new LocationPrivate() ),
+Location::Location( const QGeoPositionInfo &positionInfo, const QString &label ) :
+ q( new LocationPrivate( label ) ),
manager(0)
{
qreal latitude = positionInfo.coordinate().latitude();
Location::Location( const Location &from ) :
QObject(0),
- q( new LocationPrivate() ),
+ q( new LocationPrivate( from.label() ) ),
manager(0)
{
+ q->setAddress( from.address() );
q->setX( from.x() );
q->setY( from.y() );
q->setValid( from.isValid() );
}
}
-Location::Location() :
- q( new LocationPrivate() ),
+Location::Location( const QString &label ) :
+ q( new LocationPrivate( label ) ),
manager( new QNetworkAccessManager(this) )
{
connect( manager, SIGNAL( finished(QNetworkReply*) ), this, SLOT( replyFinished(QNetworkReply*) ) );
Location &Location::operator=( const Location &from )
{
- q = new LocationPrivate();
+ q = new LocationPrivate( from.label() );
+ q->setAddress( from.address() );
q->setX( from.x() );
q->setY( from.y() );
q->setValid( from.isValid() );
return *this;
}
-void Location::resolveAddress( QString address )
+void Location::resolveAddress( const QString &address )
{
+ qDebug() << "resolving address";
+ qDebug() << address;
+
+ q->setAddress( address );
+ q->setValid( false );
+
QUrl fullUrl( Ytv::Url );
fullUrl.addEncodedQueryItem( "key", address.toAscii().toPercentEncoding() );
fullUrl.addQueryItem( "pass", Ytv::Password );
manager->get( QNetworkRequest( fullUrl ) );
+ qDebug() << "waiting for reply from Ytv";
}
void Location::replyFinished( QNetworkReply * reply )
{
+ qDebug() << "address resolved";
q->parseReply( reply->readAll() );
if ( isValid() ) {
+ qDebug() << label() << "becomeValid";
emit( becomeValid() );
}
}
return q->y();
}
+void Location::setLabel( const QString &label ) const
+{
+ q->setLabel( label );
+}
+
+QString Location::label() const
+{
+ return q->label();
+}
+
+void Location::setAddress( const QString &address ) const
+{
+ qDebug() << "setting address to" << address;
+ q->setAddress( address );
+}
+
+QString Location::address() const
+{
+ return q->address();
+}
+
bool Location::isValid() const
{
return q->isValid();
}
-
// Degrees to radians
double Location::radians(double deg)
{