void BoffinRqlRequest::issueRequest(lastfm::NetworkAccessManager* wam, PlaydarApi& api, const QString& rql, const QString& session) { QNetworkReply *reply = wam->get(QNetworkRequest(api.boffinTracks(session, qid(), rql))); if (reply) { connect(reply, SIGNAL(finished()), this, SLOT(onFinished())); emit requestMade( qid()); } else { fail("couldn't issue boffin rql request"); } }
void BoffinRqlRequest::onFinished() { sender()->deleteLater(); QNetworkReply *reply = (QNetworkReply*) sender(); if (reply->error() == QNetworkReply::NoError) { QString queryId; if (getQueryId(reply->readAll(), queryId)) { if (queryId == qid()) { // all is good return; } fail("qid mismatch"); // we can't handle this } fail("bad response"); } fail(""); }
void PreFlightCheckListPage::slotEditCell( int row, int column ) { if( column == 0 ) { // Cell of column 0 can only change the icon. return; } QTableWidgetItem *item = m_list->item( row, column ); if( item == 0 ) { return; } m_editButton->setEnabled( false ); QString title = tr("Edit Checkpoint"); QString label = tr("Text:"); QInputDialog qid( this ); qid.setWindowTitle( title ); qid.setLabelText( label ); qid.setInputMode( QInputDialog::TextInput ); #ifndef MAEMO5 qid.setInputMethodHints( Qt::ImhNoPredictiveText ); #endif qid.setTextValue( item->text() ); qid.show(); qid.setMinimumWidth( width() ); int result = qid.exec(); if( result == QDialog::Accepted ) { item->setText( qid.textValue() ); m_ok->show(); } m_editButton->setEnabled( true ); }
void FtpApp::downloadFile() { QInputDialog qid(this); qid.setLabelText("Enter file name:"); qid.exec(); QString fileName = qid.textValue(); if(fileName!=0){ QHash<QString, qint64>::const_iterator i = fileSize.find(fileName); if(i==fileSize.end()) QMessageBox::information(this,"File Not Found","No such file is present on server"); else { QString file=QFileDialog::getSaveFileName(this,tr("Save Downloaded File"),"/home/gaurav/Downloads/"+fileName); if(file!=0){ url.setUrl("ftp://ftp.ftpjigs.comze.com/public_html/"+fileName); url.setPort(21); url.setUserName("a1996228"); url.setPassword("11107jigs"); QNetworkRequest download(url); statusLabel->setText("Downloading file...wait!"); JIGSProgressDialog *progressDialog=new JIGSProgressDialog(); progressDialog->show(); progressDialog->setTotal(fileSize[fileName]); progressDialog->setFixedWidth(300); JIGSNetworkReply *qreply=new JIGSNetworkReply(manager->get(download)); JIGSNetworkReply *reply=qreply->getJIGSNetworkReply(); reply->setFileName(file); connect(reply->reply,SIGNAL(downloadProgress(qint64,qint64)),progressDialog,SLOT(setProgress(qint64))); connect(reply->reply,SIGNAL(finished()),progressDialog,SLOT(setProgress())); connect(reply,SIGNAL(downloadedData(QByteArray,QString)),this,SLOT(writeDownloadedFile(QByteArray,QString))); connect(reply->reply,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(checkError(QNetworkReply::NetworkError))); } } } }
int Ffmt(Fmt *f) { IxpFcall *fcall; fcall = va_arg(f->args, IxpFcall*); fmtprint(f, "% 2d %s\t", fcall->hdr.tag, fcnames[fcall->hdr.type - TVersion]); switch(fcall->hdr.type) { case TVersion: case RVersion: fmtprint(f, " msize: %uld version: \"%s\"", (ulong)fcall->version.msize, fcall->version.version); break; case TAuth: fmtprint(f, " afid: %uld uname: \"%s\" aname: \"%s\"", (ulong)fcall->tauth.afid, fcall->tauth.uname, fcall->tauth.aname); break; case RAuth: fmtprint(f, " aqid: "); qid(f, &fcall->rauth.aqid); break; case RAttach: fmtprint(f, " qid: "); qid(f, &fcall->rattach.qid); break; case TAttach: fmtprint(f, " fid: %uld afid: %uld uname: \"%s\" aname: \"%s\"", (ulong)fcall->hdr.fid, (ulong)fcall->tattach.afid, fcall->tattach.uname, fcall->tattach.aname); break; case RError: fmtprint(f, " \"%s\"", fcall->error.ename); break; case TFlush: fmtprint(f, " oldtag: %uld", (ulong)fcall->tflush.oldtag); break; case TWalk: fmtprint(f, " newfid: %uld wname: {", (ulong)fcall->twalk.newfid); for(int i=0; i<fcall->twalk.nwname; i++) { if(i > 0) fmtprint(f, ", "); fmtprint(f, "\"%s\"", fcall->twalk.wname[i]); } fmtprint(f, "}"); break; case RWalk: fmtprint(f, " wqid: {"); for(int i=0; i<fcall->rwalk.nwqid; i++) { if(i > 0) fmtprint(f, ", "); qid(f, &fcall->rwalk.wqid[i]); } fmtprint(f, "}"); break; case TOpen: fmtprint(f, " fid: %uld mode: %ulo", (ulong)fcall->hdr.fid, (ulong)fcall->topen.mode); break; case ROpen: case RCreate: fmtprint(f, " qid: "); qid(f, &fcall->ropen.qid); fmtprint(f, " %uld", (ulong)fcall->ropen.iounit); break; case TCreate: fmtprint(f, " fid: %uld name: \"%s\" perm: %ulo mode: %ulo", (ulong)fcall->hdr.fid, fcall->tcreate.name, (ulong)fcall->tcreate.perm, (ulong)fcall->tcreate.mode); break; case TRead: fmtprint(f, " fid: %uld offset: %ulld count: %uld", (ulong)fcall->hdr.fid, fcall->tread.offset, (ulong)fcall->tread.count); break; case RRead: fmtprint(f, " data: {data: %uld}", fcall->rread.count); break; case TWrite: fmtprint(f, " fid: %uld offset: %ulld data: {data: %uld}", (ulong)fcall->hdr.fid, fcall->twrite.offset, fcall->twrite.count); break; case RWrite: fmtprint(f, " count: %uld", (ulong)fcall->rwrite.count); break; case TClunk: case TRemove: case TStat: fmtprint(f, " fid: %uld", (ulong)fcall->hdr.fid); break; case RStat: fmtprint(f, " stat: {data: %uld}", fcall->rstat.nstat); break; } return 0; }
HandleGetMapRequestResult RasterImg( const WebMapService::GetMapRequest& gmr, const BBox& osmBBox, const OGRSpatialReference* requestSRS, Image& img) { const int Width = img.width; const int Height = img.height; const double DistanceDomain = 10.0; const double cellSize = (gmr.bbox.maxX - gmr.bbox.minX) / Width; const double ScaledDistanceDomain = cellSize * DistanceDomain; QueryIntermediateData qid(GetTransform(OSM_SpatRef, requestSRS)); if (!LoadDataSets(osmBBox, Width, Height, qid)) { return HGMRR_InternalError; } atomic_int yProgress(0); for (int y = 0; y < Height; y++) { int invertedY = (Height - y - 1); u8* sdf = &img.rawData[invertedY * Width]; for (int x = 0; x < Width; x++) { *sdf = 0; BoundingBox<double> bb( gmr.bbox.minX + x * cellSize - ScaledDistanceDomain, gmr.bbox.minY + y * cellSize - ScaledDistanceDomain, cellSize + ScaledDistanceDomain * 2.0, cellSize + ScaledDistanceDomain * 2.0); double minSqrDistance = numeric_limits<double>::max(); double px = bb.left + bb.width * 0.5; double py = bb.top + bb.height * 0.5; LooseGeoQuadtree::Query query = qid.waterPolyQuadtree.QueryIntersectsRegion(bb); while (!query.EndOfQuery()) { Polygon* poly = query.GetCurrent(); // TODO: support perfect precision mode: // reproject polygon into azimuthal equidistant projection // around requested pixel location before computing the distance const double aabbDistanceSqr = poly->ComputeSqrDistanceToBoundingBox(px, py); if (aabbDistanceSqr < minSqrDistance) // test distance to AABB first before doing the expensive polygon distance test { double sqrDistance = poly->ComputeSignedSquareDistance(px, py); minSqrDistance = Min(minSqrDistance, sqrDistance); } if (minSqrDistance < 0.0) { // TODO: merge polygon with surrounding polygons if their id matches // do distance check again to get correct distance break; } query.Next(); } while (!query.EndOfQuery()) // we have to finish a query to release it from the quadtree { query.Next(); } if (minSqrDistance == numeric_limits<double>::max()) { (*sdf) = 255; } else { double minDistance = Sign(minSqrDistance) * Sqrt(Abs(minSqrDistance)); u8 sdfValue = (u8)Clamp(255.0 * (minDistance * 0.5 / ScaledDistanceDomain + 0.5), 0.0, 255.0); (*sdf) = sdfValue; } sdf++; } yProgress++; cout << "rasterized: " << (int)(100.0f * yProgress / (float)Height) << "%s\r"; } return HGMRR_OK; }