void VInfoRequest::ensureAddress(DataType type) { QString method; QString field; NameMapper *mapper; switch (type) { case Country: method = QLatin1String("places.getCountries"); field = QLatin1String("country"); mapper = countries(); break; case City: method = QLatin1String("places.getCities"); field = QLatin1String("city"); mapper = cities(); break; default: return; } int id = m_data.value(field, -1).toInt(); if (id == -1) return; if (QString *obj = mapper->object(id)) { m_data.insert(field, *obj); } else { QVariantMap data; data.insert(QLatin1String("country"), QString::number(id)); FuncPointerHelper *helper = new FuncPointerHelper; helper->mapper = mapper; Vreen::Reply *reply = m_client->request(method, data); reply->setProperty("field", field); reply->setProperty("mapper", reinterpret_cast<qptrdiff>(helper)); connect(this, SIGNAL(canceled()), reply, SLOT(deleteLater())); connect(reply, SIGNAL(resultReady(QVariant)), this, SLOT(onAddressEnsured())); m_unknownCount++; } }