void tst_QGeoAddress::countyTest()
{
    QGeoAddress testObj;
    QVERIFY2(testObj.county() == QString(), "Wrong default value");
    testObj.setCounty("testText");
    QVERIFY2(testObj.county() == "testText", "Wrong value returned");
}
Exemple #2
0
bool QLandmarkFileHandlerLmx::writeAddressInfo(const QLandmark &landmark)
{
    QGeoAddress address = landmark.address();

    if (address.street().isEmpty()
            && address.city().isEmpty()
            && address.state().isEmpty()
            && address.country().isEmpty()
            && address.postcode().isEmpty()
            && landmark.phoneNumber().isEmpty())
        return true;

    m_writer->writeStartElement(m_ns, "addressInfo");

    if (!address.country().isEmpty())
        m_writer->writeTextElement(m_ns, "country", address.country());

    if (!address.state().isEmpty())
        m_writer->writeTextElement(m_ns, "state", address.state());

    if (!address.county().isEmpty())
        m_writer->writeTextElement(m_ns, "county", address.county());

    if (!address.city().isEmpty())
        m_writer->writeTextElement(m_ns, "city", address.city());

    if (!address.district().isEmpty())
        m_writer->writeTextElement(m_ns, "district", address.district());

    if (!address.postcode().isEmpty())
        m_writer->writeTextElement(m_ns, "postalCode", address.postcode());

    QString street;

    if (!address.street().isEmpty())
        street.append(address.street());

    if (!street.isEmpty())
        m_writer->writeTextElement(m_ns, "street", street);

    if (!landmark.phoneNumber().isEmpty())
        m_writer->writeTextElement(m_ns, "phoneNumber", landmark.phoneNumber());

    m_writer->writeEndElement();

    return true;
}
Exemple #3
0
/*!
    Returns true if this address is equal to \a other,
    otherwise returns false.
    \since 1.1
*/
bool QGeoAddress::operator==(const QGeoAddress &other) const
{
#ifdef QGEOADDRESS_DEBUG
    qDebug() << "country" << (d->sCountry == other.country());
    qDebug() << "countryCode" << (d->sCountryCode == other.countryCode());
    qDebug() << "state:" <<  (d->sState == other.state());
    qDebug() << "county:" << (d->sCounty == other.county());
    qDebug() << "city:" << (d->sCity == other.city());
    qDebug() << "district:" << (d->sDistrict == other.district());
    qDebug() << "street:" << (d->sStreet == other.street());
    qDebug() << "postcode:" << (d->sPostCode == other.postcode());
#endif

    return d->sCountry == other.country() &&
           d->sCountryCode == other.countryCode() &&
           d->sState == other.state() &&
           d->sCounty == other.county() &&
           d->sCity == other.city() &&
           d->sDistrict == other.district() &&
           d->sStreet == other.street() &&
           d->sPostCode == other.postcode();
}
Exemple #4
0
void MarkerDialog::setAddressLabel(QGeoAddress address)
{
    QString addressFormat = tr("$street\n$city, $state $postcode\n$country");
    addressFormat.replace("$street", address.street());
    addressFormat.replace("$city", address.city());
    addressFormat.replace("$county", address.county());
    addressFormat.replace("$state", address.state());
    addressFormat.replace("$postcode", address.postcode());
    addressFormat.replace("$district", address.district());
    addressFormat.replace("$country", address.country());

    addressLabel->setText(addressFormat);
}
void QDeclarativeGeoAddress::setAddress(const QGeoAddress& address)
{
    // Elaborate but takes care of emiting needed signals
    setCountry(address.country());
    setCountryCode(address.countryCode());
    setState(address.state());
    setCounty(address.county());
    setCity(address.city());
    setDistrict(address.district());
    setStreet(address.street());
    setPostcode(address.postcode());
    m_address = address;
}
Exemple #6
0
void GeoHelper::searchFinishedSlot(QGeoSearchReply *reply)
{
    if (reply->error() == QGeoSearchReply::NoError)
    {
        QScriptEngine scriptEngine;
        QScriptValue replyObject = scriptEngine.newArray();

        QList<QGeoPlace> places = reply->places();
        for (int i = 0; i < places.count(); i++)
        {
            QScriptValue placeObject = scriptEngine.newObject();

            QScriptValue coordinateObject = scriptEngine.newObject();
            QGeoCoordinate coordinate = places[i].coordinate();
            coordinateObject.setProperty("latitude", QScriptValue(coordinate.latitude()));
            coordinateObject.setProperty("longitude", QScriptValue(coordinate.longitude()));
            placeObject.setProperty("coordinate", coordinateObject);

            QScriptValue addressObject = scriptEngine.newObject();
            QGeoAddress address = places[i].address();

            if (!address.isEmpty())
            {
                addressObject.setProperty("country", address.country());
                addressObject.setProperty("countryCode", address.countryCode());
                addressObject.setProperty("state", address.state());
                addressObject.setProperty("county", address.county());
                addressObject.setProperty("city", address.city());
                addressObject.setProperty("district", address.district());
                addressObject.setProperty("street", address.street());
                addressObject.setProperty("postcode", address.postcode());

            }

            placeObject.setProperty("address", addressObject);
            replyObject.setProperty(i, placeObject);
        }


        QScriptValue fun = scriptEngine.evaluate("(function(a) { return JSON.stringify(a); })");
        QScriptValueList args;
        args << replyObject;
        QScriptValue result = fun.call(QScriptValue(), args);

        emit searchReply(result.toString());
    }


}