void MapView::tileDownloaded(QNetworkReply *reply) { //recreate original request from reply and delete it from the current requests QElapsedTimer timer; timer.start(); TileRequest finishedRequest(reply); currentRequests.removeAll(finishedRequest); //check to see if any requests are left in stack if (!requestStack.isEmpty()) { //pop the last request in the stack TileRequest request = requestStack.takeLast(); //proceed to download the request networkManager->get(request); currentRequests.append(request); } QByteArray *data = new QByteArray(reply->readAll()); QByteArray *cpData = new QByteArray(*data); qDebug("curreq"+QString::number(currentRequests.size())+ " reqstck"+QString::number(requestStack.size())); //check if actual data was returned if (data->length()!=0) //todo: check if data is valid { //AddTileToDBThread* t = new AddTileToDBThread(finishedRequest.z(),finishedRequest.x(),finishedRequest.y(),cpData,finishedRequest.mapSource().url); //t->start(); //the method below also checks presence of tile in db addTileToDB(finishedRequest.z(),finishedRequest.x(),finishedRequest.y(),data,finishedRequest.mapSource().url); //qDebug(qPrintable("Tile image file size:" + QString::number(data.length()) + " bits" // "(x:"+QString::number(x)+" y:"+QString::number(y)+" z:"+QString::number(z)+")")); } else emit noNetwork(); qDebug("adding tile to db took "+QString::number(timer.elapsed())); timer.restart(); //check if zoomlevel and map source did not change while downloading if( currentZoom == finishedRequest.z() && finishedRequest.mapSource().url == MapSource.url) placeTile(data, finishedRequest.x(), finishedRequest.y(), finishedRequest.z()); qDebug("placing tile took "+QString::number(timer.elapsed())); reply->deleteLater(); //do not 'delete reply;' }
void AccessController::onStatusChanged(int status) { qDebug() << "emit " << status; if (NetworkConnectivity::Disconnected == doCheckNetworkConnectivity()) { emit noNetwork(); return; } switch (status) { case ClientStatus::Unintialized: return; case ClientStatus::Started: emit connecting(); return; case ClientStatus::Stopped: emit stopped(); break; case ClientStatus::PageReady: m_client->Connect(m_accessToken); return; case ClientStatus::Connecting: return; case ClientStatus::ConnectOk: emit connected(); break; case ClientStatus::ConnectServerFailed: emit connectFailed(AccessError::ConnectServerFailed); break; case ClientStatus::InvalidToken: emit connectFailed(AccessError::InvalidToken); break; case ClientStatus::Disconnected: emit disconnected(); break; } }