Esempio n. 1
0
void tst_QGeoAddress::textTest()
{
    QGeoAddress address;
    QVERIFY(address.text().isEmpty());
    address.setText(QLatin1String("123 Fake Street\nSpringfield"));
    QCOMPARE(address.text(), QLatin1String("123 Fake Street\nSpringfield"));
}
void QDeclarativeGeoAddress::setAddress(const QGeoAddress &address)
{
    // Elaborate but takes care of emiting needed signals
    setText(address.text());
    setCountry(address.country());
    setCountryCode(address.countryCode());
    setState(address.state());
    setCounty(address.county());
    setCity(address.city());
    setDistrict(address.district());
    setStreet(address.street());
    setPostalCode(address.postalCode());
    m_address = address;
}
Esempio n. 3
0
/*!
    Returns true if this address is equal to \a other,
    otherwise returns false.
*/
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() << "postalCode:" << (d->sPostalCode == other.postalCode());
    qDebug() << "text:" << (text() == other.text());
#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->sPostalCode == other.postalCode() &&
           this->text() == other.text();
}
Esempio n. 4
0
void tst_QGeoAddress::generatedText()
{
    QFETCH(QString, countryCode);
    QFETCH(QString, expectedPostalCodeOnly);
    QFETCH(QString, expectedFullAddress);

    QGeoAddress streetOnly;
    streetOnly.setStreet("street");
    streetOnly.setCountryCode(countryCode);

    QCOMPARE(streetOnly.text(), QLatin1String("street"));

    QGeoAddress cityOnly;
    cityOnly.setCity("city");
    cityOnly.setCountryCode(countryCode);
    if (countryCode == QLatin1String("CYM") || countryCode == QLatin1String("IRL"))
        QCOMPARE(cityOnly.text(), QString());
    else
        QCOMPARE(cityOnly.text(), QLatin1String("city"));

    QGeoAddress postalCodeOnly;
    postalCodeOnly.setPostalCode("postcode");
    postalCodeOnly.setCountryCode(countryCode);
    QCOMPARE(postalCodeOnly.text(), expectedPostalCodeOnly);

    QGeoAddress fullAddress;
    fullAddress.setStreet("street");
    fullAddress.setDistrict("district");
    fullAddress.setPostalCode("postcode");
    fullAddress.setCity("city");
    fullAddress.setState("state");
    fullAddress.setCountry("country");
    fullAddress.setCountryCode(countryCode);

    QCOMPARE(fullAddress.text(), expectedFullAddress);
}