/** * Saves the selected pictures. * First pops up a dialog box asking for the target dir. Then pops up * a progress dialog for feedback. */ void MainWindow::saveSelected() { /* Select target */ selectWorkDir(); /* Create a progress dialog */ QProgressDialog* progress = new QProgressDialog( i18n("Downloading ..."), i18n("Cancel"), 100, this, "progress", TRUE); progress->setCaption("Download"); connect(GPMessenger::instance(),SIGNAL(progressChanged(int)), progress,SLOT(setProgress(int))); progress->setAutoReset(false); progress->setAutoClose(false); progress->setProgress(0); KApplication::kApplication()->processEvents(); /* Download all pictures */ for (QIconViewItem *i = iconView->firstItem(); i && !progress->wasCancelled(); i = i->nextItem() ) { if (i->isSelected()) { /* Update progress dialog */ progress->setLabelText(i18n("Downloading ") + i->text() + "..."); /* Download picture */ GPInterface::downloadPicture(i->text(),"/"); } } progress->setProgress(100); delete progress; }
void QueryFinishWizardPage::initializePage() { m_result->clear(); ui.progressBar->setValue(0); Framework* fw = framework(); setCurrentAction(tr("Collecting information...")); quint32 storeId = field("store").value<quint32>(); const QString queryStr = field("query").toString(); setCurrentAction(tr("Looking for store...")); const DataStore* dataStore = fw->dataStoreById(storeId); if(dataStore == NULL) return; setCurrentAction(tr("Store found...")); setCurrentAction(tr("Parsing query...")); CGSQL_NS::RootNode *root = CGSQL_NS::QueryParser::parse(queryStr.toStdString()); if (root == NULL) { setCurrentAction("Error while parting query."); return; } pgn::GameCollection loadedGames; setCurrentAction(tr("Retrieving games from %1...").arg(dataStore->name().toLower())); bool loadResult = dataStore->load(root, loadedGames); if(!loadResult) { setCurrentAction(tr("Can not load games from %1...").arg(dataStore->name().toLower())); return; } setCurrentAction(tr("Loaded %1 games. Looking for concepts in its...").arg(loadedGames.size())); QProgressDialog* progressDialog = new QProgressDialog("Searching for concepts", "Cancel", 0, loadedGames.size()); progressDialog->setWindowModality(Qt::WindowModal); progressDialog->setValue(0); int progress = 0; for(pgn::GameCollection::iterator it = loadedGames.begin(); it != loadedGames.end(); ++it) { progressDialog->show(); m_result->data().addGame(&(*it)); if(root->body()->accept(&(m_result->data()))) m_result->games().insert(*it); progressDialog->setValue(progress); ++progress; } progressDialog->setValue(100); progressDialog->setAutoClose(true); progressDialog->reset(); progressDialog->show(); progressDialog->deleteLater(); ui.progressBar->setValue(100); }
void TomahawkApp::onShutdownDelayed() { QProgressDialog* d = new QProgressDialog( tr( "Tomahawk is updating the database. Please wait, this may take a minute!" ), QString(), 0, 0, 0, Qt::Tool | Qt::WindowTitleHint | Qt::CustomizeWindowHint ); d->setModal( true ); d->setAutoClose( false ); d->setAutoReset( false ); d->setWindowTitle( tr( "Tomahawk" ) ); #ifdef Q_OS_MAC d->setAttribute( Qt::WA_MacAlwaysShowToolWindow ); #endif d->show(); }
void MainWindow::syncStarted(int count) { ui->actionSync->setEnabled(false); if (loaded) return; QProgressDialog* progress = new QProgressDialog("Syncing Notes...", "Abort Sync", 0, count, this); progress->setAutoReset(false); progress->setAutoClose(false); connect( EdamProtocol::GetInstance(), SIGNAL(syncProgress(int)), progress, SLOT(setValue(int))); connect(progress, SIGNAL(canceled()), EdamProtocol::GetInstance(), SLOT(cancelSync())); connect(progress, SIGNAL(canceled()), progress, SLOT(deleteLater())); connect(EdamProtocol::GetInstance(), SIGNAL(syncFinished()), progress, SLOT(close())); connect(EdamProtocol::GetInstance(), SIGNAL(syncRangeChange(int)), progress, SLOT(setMaximum(int))); progress->show(); ui->statusbar->showMessage("Sync Started!", 5000); }
int QgsImageWarper::warpFile( const QString& input, const QString& output, const QgsGeorefTransform &georefTransform, ResamplingMethod resampling, bool useZeroAsTrans, const QString& compression, const QString &projection, double destResX, double destResY ) { if ( !georefTransform.parametersInitialized() ) return false; CPLErr eErr; GDALDatasetH hSrcDS, hDstDS; GDALWarpOptions *psWarpOptions; if ( !openSrcDSAndGetWarpOpt( input, resampling, georefTransform.GDALTransformer(), hSrcDS, psWarpOptions ) ) { // TODO: be verbose about failures return false; } double adfGeoTransform[6]; int destPixels, destLines; eErr = GDALSuggestedWarpOutput( hSrcDS, georefTransform.GDALTransformer(), georefTransform.GDALTransformerArgs(), adfGeoTransform, &destPixels, &destLines ); if ( eErr != CE_None ) { GDALClose( hSrcDS ); GDALDestroyWarpOptions( psWarpOptions ); return false; } // If specified, override the suggested resolution with user values if ( destResX != 0.0 || destResY != 0.0 ) { // If only one scale has been specified, fill in the other from the GDAL suggestion if ( destResX == 0.0 ) destResX = adfGeoTransform[1]; if ( destResY == 0.0 ) destResY = adfGeoTransform[5]; // Make sure user-specified coordinate system has canonical orientation if ( destResX < 0.0 ) destResX = -destResX; if ( destResY > 0.0 ) destResY = -destResY; // Assert that the north-up convention is fullfiled by GDALSuggestedWarpOutput (should always be the case) assert( adfGeoTransform[0] > 0.0 ); assert( adfGeoTransform[5] < 0.0 ); // Find suggested output image extent (in georeferenced units) double minX = adfGeoTransform[0]; double maxX = adfGeoTransform[0] + adfGeoTransform[1] * destPixels; double maxY = adfGeoTransform[3]; double minY = adfGeoTransform[3] + adfGeoTransform[5] * destLines; // Update line and pixel count to match extent at user-specified resolution destPixels = ( int )((( maxX - minX ) / destResX ) + 0.5 ); destLines = ( int )((( minY - maxY ) / destResY ) + 0.5 ); adfGeoTransform[0] = minX; adfGeoTransform[3] = maxY; adfGeoTransform[1] = destResX; adfGeoTransform[5] = destResY; } if ( !createDestinationDataset( output, hSrcDS, hDstDS, destPixels, destLines, adfGeoTransform, useZeroAsTrans, compression, projection ) ) { GDALClose( hSrcDS ); GDALDestroyWarpOptions( psWarpOptions ); return false; } // Create a QT progress dialog QProgressDialog *progressDialog = new QProgressDialog( mParent ); progressDialog->setWindowTitle( tr( "Progress indication" ) ); progressDialog->setRange( 0, 100 ); progressDialog->setAutoClose( true ); progressDialog->setModal( true ); progressDialog->setMinimumDuration( 0 ); // Set GDAL callbacks for the progress dialog psWarpOptions->pProgressArg = createWarpProgressArg( progressDialog ); psWarpOptions->pfnProgress = updateWarpProgress; psWarpOptions->hSrcDS = hSrcDS; psWarpOptions->hDstDS = hDstDS; // Create a transformer which transforms from source to destination pixels (and vice versa) psWarpOptions->pfnTransformer = GeoToPixelTransform; psWarpOptions->pTransformerArg = addGeoToPixelTransform( georefTransform.GDALTransformer(), georefTransform.GDALTransformerArgs(), adfGeoTransform ); // Initialize and execute the warp operation. GDALWarpOperation oOperation; oOperation.Initialize( psWarpOptions ); progressDialog->show(); progressDialog->raise(); progressDialog->activateWindow(); eErr = oOperation.ChunkAndWarpImage( 0, 0, destPixels, destLines ); // eErr = oOperation.ChunkAndWarpMulti(0, 0, destPixels, destLines); destroyGeoToPixelTransform( psWarpOptions->pTransformerArg ); GDALDestroyWarpOptions( psWarpOptions ); delete progressDialog; GDALClose( hSrcDS ); GDALClose( hDstDS ); return mWarpCanceled ? -1 : eErr == CE_None ? 1 : 0; }
void SongsQueryWideget::export_excel_clicked() { ///建立临时表映射 /// setCursor(Qt::WaitCursor); QSqlQueryModel *sqlquery = new QSqlQueryModel(this); QSqlQuery _query; MediaPagingQuery argu; getQueryCondition(argu); if(!_sql->queryMedia_All(argu, _query)) return; sqlquery->setQuery(_query); int rows = sqlquery->rowCount(); int columns = sqlquery->columnCount(); setCursor(Qt::ArrowCursor); QString desktopPath = QProcessEnvironment::systemEnvironment().value("USERPROFILE")+"\\Desktop"; QString fileName = QFileDialog::getSaveFileName(tableView_songsQuery, "保存", //QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation), desktopPath, "Excel 文件(*.xls *.xlsx)"); QProgressDialog *progress = new QProgressDialog(this); progress->setLabelText("正在导出表格数据……"); progress->setRange(0, rows); progress->setModal(true); progress->setCancelButtonText("取消"); // progress->setMinimumSize(300, 50); progress->setMinimumWidth(400); progress->setAutoClose(true); if (fileName!="") { QAxObject *excel = new QAxObject; if (excel->setControl("Excel.Application")) //连接Excel控件 { excel->dynamicCall("SetVisible (bool Visible)","false");//不显示窗体 excel->setProperty("DisplayAlerts", false);//不显示任何警告信息。如果为true那么在关闭是会出现类似“文件已修改,是否保存”的提示 QAxObject *workbooks = excel->querySubObject("WorkBooks");//获取工作簿集合 workbooks->dynamicCall("Add");//新建一个工作簿 QAxObject *workbook = excel->querySubObject("ActiveWorkBook");//获取当前工作簿 QAxObject *worksheet = workbook->querySubObject("Worksheets(int)", 1); // //数据区 for(int i=0; i<rows; i++) { for (int j=0;j<columns; j++) { QModelIndex index = sqlquery->index(i, j); QString text = index.data().toString(); // table->item(i,j)?table->item(i,j)->text():"" worksheet->querySubObject("Cells(int,int)", i+1, j+1)->dynamicCall("SetValue(const QString&)", text); } QString label_text = QString("正在导出%1行……").arg(i+1); progress->setLabelText(label_text); progress->setValue(i+1); if(progress->wasCanceled()) { break; } } workbook->dynamicCall("SaveAs(const QString&)",QDir::toNativeSeparators(fileName));//保存至fileName workbook->dynamicCall("Close()");//关闭工作簿 //关闭excel excel->dynamicCall("Quit (void)"); delete excel; excel=NULL; QMessageBox box(QMessageBox::Question, "完成", "文件已经导出,是否现在打开?"); box.setStandardButtons(QMessageBox::Yes|QMessageBox::No); box.setButtonText(QMessageBox::Yes, "确定(&Q)"); box.setButtonText(QMessageBox::No, "取消(&C)"); if(box.exec() == QMessageBox::Yes) // if (QMessageBox::question(NULL,"完成","文件已经导出,是否现在打开?",QMessageBox::Yes|QMessageBox::No)==QMessageBox::Yes) { QString local_path = QString("file:///") + fileName; QDesktopServices::openUrl(QUrl(local_path, QUrl::TolerantMode)); //QDir::toNativeSeparators(fileName))); } } else { QMessageBox::warning(NULL,"错误","未能创建 Excel 对象,请安装 Microsoft Excel。",QMessageBox::Apply); } } // progress->close(); }