void FilesystemWidget::ExtractDirectory(const DiscIO::Partition& partition, const QString& path, const QString& out) { const DiscIO::FileSystem* filesystem = m_volume->GetFileSystem(partition); if (!filesystem) return; std::unique_ptr<DiscIO::FileInfo> info = filesystem->FindFileInfo(path.toStdString()); u32 size = info->GetTotalChildren(); QProgressDialog* dialog = new QProgressDialog(this); dialog->setMinimum(0); dialog->setMaximum(size); dialog->show(); bool all = path.isEmpty(); DiscIO::ExportDirectory( *m_volume, partition, *info, true, path.toStdString(), out.toStdString(), [all, dialog](const std::string& current) { dialog->setLabelText( (all ? QObject::tr("Extracting All Files...") : QObject::tr("Extracting Directory...")) .append(QStringLiteral(" %1").arg(QString::fromStdString(current)))); dialog->setValue(dialog->value() + 1); QCoreApplication::processEvents(); return dialog->wasCanceled(); }); dialog->close(); }
void FilesystemWidget::CheckIntegrity(const DiscIO::Partition& partition) { QProgressDialog* dialog = new QProgressDialog(this); std::future<bool> is_valid = std::async( std::launch::async, [this, partition] { return m_volume->CheckIntegrity(partition); }); dialog->setLabelText(tr("Verifying integrity of partition...")); dialog->setWindowFlags(dialog->windowFlags() & ~Qt::WindowContextHelpButtonHint); dialog->setWindowTitle(tr("Verifying partition")); dialog->setMinimum(0); dialog->setMaximum(0); dialog->show(); while (is_valid.wait_for(std::chrono::milliseconds(50)) != std::future_status::ready) QCoreApplication::processEvents(); dialog->close(); if (is_valid.get()) QMessageBox::information(nullptr, tr("Success"), tr("Integrity check completed. No errors have been found.")); else QMessageBox::critical(nullptr, tr("Error"), tr("Integrity check for partition failed. The disc image is most " "likely corrupted or has been patched incorrectly.")); }
void Main_Window::on_sweep_clicked() { QProgressDialog *dlg = new QProgressDialog(this); dlg->setWindowModality(Qt::WindowModal); dlg->setLabelText("Frequency Sweep"); dlg->setCancelButtonText("Cancel"); dlg->setMaximum(100); dlg->show(); double start = ui.sweep_start->value(); double stop = ui.sweep_stop->value(); double step = ui.sweep_step->value(); for (double f = start; f <= stop && !dlg->wasCanceled(); f += step) { dlg->setValue((int)((f - start) * 100.0 / (stop - start))); QCoreApplication::processEvents(); ui.freq->setValue(f); on_idle_clicked(); update_freq(); send_freq(); on_cal_clicked(); on_tx_clicked(); usleep(100 * 1000); } delete dlg; }
void MainWindow::on_actionVista_Previa_triggered() { QProgressDialog* pDlg = new QProgressDialog(this); pDlg->setMaximum(0); pDlg->setValue(0); pDlg->show(); QPrinter * printer = new QPrinter(); QPrintDialog dlg(printer,this); // bool error; QDomDocument doc = paper.preview(); render = new ReportRenderer(); render->setPrinter(printer); render->setDocIn(doc); QMap<QString,QString> c; c["Empresa.cab_fac"] = "id = 1"; c["Empresa.lin_fac"] = "id_cab = 1"; render->setQueryClausules(c); QtConcurrent::run(render, &ReportRenderer::PreRender); connect(render,SIGNAL(end()),pDlg,SLOT(deleteLater())); connect(render,SIGNAL(end()),this,SLOT(previewReady())); }
void MainWindow::OnImportNANDBackup() { auto response = QMessageBox::question( this, tr("Question"), tr("Merging a new NAND over your currently selected NAND will overwrite any channels " "and savegames that already exist. This process is not reversible, so it is " "recommended that you keep backups of both NANDs. Are you sure you want to " "continue?")); if (response == QMessageBox::No) return; QString file = QFileDialog::getOpenFileName(this, tr("Select the save file"), QDir::currentPath(), tr("BootMii NAND backup file (*.bin);;" "All Files (*)")); if (file.isEmpty()) return; QProgressDialog* dialog = new QProgressDialog(this); dialog->setMinimum(0); dialog->setMaximum(0); dialog->setLabelText(tr("Importing NAND backup")); dialog->setCancelButton(nullptr); auto beginning = QDateTime::currentDateTime().toMSecsSinceEpoch(); auto result = std::async(std::launch::async, [&] { DiscIO::NANDImporter().ImportNANDBin( file.toStdString(), [&dialog, beginning] { QueueOnObject(dialog, [&dialog, beginning] { dialog->setLabelText( tr("Importing NAND backup\n Time elapsed: %1s") .arg((QDateTime::currentDateTime().toMSecsSinceEpoch() - beginning) / 1000)); }); }, [this] { return RunOnObject(this, [this] { return QFileDialog::getOpenFileName(this, tr("Select the keys file (OTP/SEEPROM dump)"), QDir::currentPath(), tr("BootMii keys file (*.bin);;" "All Files (*)")) .toStdString(); }); }); QueueOnObject(dialog, &QProgressDialog::close); }); dialog->exec(); result.wait(); m_menu_bar->UpdateToolsMenu(Core::IsRunning()); }
void updateItemSiteLeadTimes::sUpdate() { ParameterList params; _warehouse->appendValue(params); _classCode->appendValue(params); XSqlQuery updateUpdate; QProgressDialog progress; progress.setWindowModality(Qt::ApplicationModal); MetaSQLQuery mql = mqlLoad("updateItemsiteLeadTimes", "load"); updateUpdate = mql.toQuery(params); if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Loading Item Site Lead Times"), updateUpdate, __FILE__, __LINE__)) { return; } int count=0; progress.setMaximum(updateUpdate.size()); XSqlQuery update; while (updateUpdate.next()) { progress.setLabelText(tr("Site: %1\n" "Item: %2 - %3") .arg(updateUpdate.value("warehous_code").toString()) .arg(updateUpdate.value("item_number").toString()) .arg(updateUpdate.value("item_descrip1").toString())); ParameterList rparams = params; rparams.append("itemsite_id", updateUpdate.value("itemsite_id")); rparams.append("leadTimePad", _leadTimePad->value()); MetaSQLQuery mql2 = mqlLoad("updateItemsiteLeadTimes", "update"); update = mql2.toQuery(rparams); if (ErrorReporter::error(QtCriticalMsg, this, tr("Error Updating Item Site Lead Times"), update, __FILE__, __LINE__)) { return; } if (progress.wasCanceled()) break; count++; progress.setValue(count); } accept(); }
bool MainWindow::parseDirectory(QString dirName, parseType type,bool convert,bool create,QProgressDialog &progress) { QFileInfoList list; QStringList filter; QDir dir(dirName); /* create filter list for files */ filter.append(QString("*.h")); filter.append(QString("*.c")); filter.append(QString("*.cpp")); filter.append(QString("*.cxx")); /* parse files in current directory */ list = dir.entryInfoList(filter,QDir::Files); progress.setMaximum(progress.maximum()+list.size()); for(int i = 0;i<list.size();i++) { /* increase progress bar */ progress.setValue(progress.value()+1); if(convert) { if(!parser.converteFile(list.at(i).absoluteFilePath())) return false; } else { if(!parser.parseFile(list.at(i).absoluteFilePath())) return false; } progress.setLabelText(list.at(i).absoluteFilePath()); } /* go recursive through all the subdiectories */ list = dir.entryInfoList(QDir::Dirs|QDir::NoDotAndDotDot); for(int i = 0;i<list.size();i++) { if(!parseDirectory(list.at(i).absoluteFilePath(),type,convert,create,progress)) return false; } return true; }
void createPlannedOrdersByPlannerCode::sCreate(ParameterList params) { XSqlQuery createCreate; QProgressDialog progress; progress.setWindowModality(Qt::ApplicationModal); MetaSQLQuery mql = mqlLoad("schedule", "load"); createCreate = mql.toQuery(params); if (createCreate.lastError().type() != QSqlError::NoError) { systemError(this, createCreate.lastError().databaseText(), __FILE__, __LINE__); return; } int count=0; progress.setMaximum(createCreate.size()); XSqlQuery create; while (createCreate.next()) { progress.setLabelText(tr("Site: %1\n" "Item: %2 - %3") .arg(createCreate.value("warehous_code").toString()) .arg(createCreate.value("item_number").toString()) .arg(createCreate.value("item_descrip1").toString())); ParameterList rparams = params; rparams.append("itemsite_id", createCreate.value("itemsite_id")); MetaSQLQuery mql2 = mqlLoad("schedule", "create"); create = mql2.toQuery(rparams); if (create.lastError().type() != QSqlError::NoError) { systemError(this, create.lastError().databaseText(), __FILE__, __LINE__); return; } if (progress.wasCanceled()) break; count++; progress.setValue(count); } accept(); }
void Polar::setPolarName(QString fname) { isCsv=true; loaded=false; clearPolar(); if(this->mainWindow->getSelectedBoat() && this->mainWindow->getSelectedBoat()->get_boatType()==BOAT_REAL) coeffPolar=Settings::getSetting("polarEfficiency",100).toInt()/100.0; else coeffPolar=1.0; //qWarning() << "Opening polar" << fname<<"with coeff"<<coeffPolar; name=fname; QString nameF = appFolder.value("polar")+fname+".csv"; QFile file(nameF); if (fname.endsWith(".csv",Qt::CaseInsensitive) || fname.endsWith(".pol",Qt::CaseInsensitive)) { nameF=appFolder.value("polar")+fname; file.setFileName(nameF); if (!file.open(QIODevice::ReadOnly | QIODevice::Text )) { QMessageBox::warning(0,QObject::tr("Lecture de polaire"), QString(QObject::tr("Impossible d'ouvrir le fichier %1")).arg(name)); return; } isCsv=fname.endsWith("csv",Qt::CaseInsensitive); } else { if (!file.open(QIODevice::ReadOnly | QIODevice::Text )) { isCsv=false; nameF = appFolder.value("polar")+fname+".pol"; file.setFileName(nameF); if (!file.open(QIODevice::ReadOnly | QIODevice::Text )) { QMessageBox::warning(0,QObject::tr("Lecture de polaire"), QString(QObject::tr("Impossible d'ouvrir le fichier %1 (ni en .csv ni en .pol)")).arg(name)); return; } } } QTextStream stream(&file); QString line; QStringList list; /* read first line to see line length */ line=stream.readLine(); line.remove("\""); if(line.isNull()) { QMessageBox::warning(0,QObject::tr("Lecture de polaire"), QString(QObject::tr("Fichier %1 vide")).arg(fname)); file.close(); return; } if(isCsv) list = line.split(';'); else list = line.split('\t'); if(list[0].toUpper() != "TWA\\TWS" && list[0].toUpper() != "TWA/TWS" && list[0].toUpper() != "TWA") { QMessageBox::warning(0,QObject::tr("Lecture de polaire"), QString(QObject::tr("Fichier %1 invalide (doit commencer par TWA\\TWS et non '%2')")) .arg(fname) .arg(list[0])); file.close(); return; } int i; for(i=1;i<list.count();++i) { if(!tws.isEmpty() && list[i].toDouble()<=tws.last()) break; tws.append(list[i].toDouble()); } bool missingTws0=false; if(tws.first()!=0.0) { missingTws0=true; } bool firstTWA=true; while(true) { line=stream.readLine(); if(line.isNull()) break; line.remove("\""); if (isCsv) list = line.split(";"); else list = line.split("\t"); if(firstTWA) { firstTWA=false; if(list.first().toDouble()!=0.0) { for(int t=0;t<tws.count();++t) { polar_data.append(0); } if(missingTws0) polar_data.append(0); twa.append(0.0); } } twa.append(list[0].toDouble()); if(missingTws0) polar_data.append(0); for(i=1;i<list.count();++i) { if(i>tws.count()) break; polar_data.append(list[i].toDouble()*this->coeffPolar); } while(i<=tws.count()) polar_data.append(0); } if(missingTws0) tws.prepend(0.0); #if 0 qWarning()<<"polar data for"<<nameF; QString debug="xxx.x "; foreach(double dd,tws) debug+=QString().sprintf("%04.1f ",dd); qWarning()<<debug; QListIterator<double> i1(polar_data); QListIterator<double> i2(twa); while(i2.hasNext()) { debug=QString().sprintf("%05.1f ",i2.next()); for(int nn=0;nn<tws.count();++nn) debug+=QString().sprintf("%04.1f ",i1.next()); qWarning()<<debug; } #endif mid_twa=qRound(twa.count()/2.0); mid_tws=qRound(tws.count()/2.0); /* polaire chargee */ /* pre-calculate B-VMG for every tws at 0.1 precision with a twa step of 1 and then .1 */ double ws=0.0; double wa=0.0; double bvmg,bvmg_d,bvmg_u,wa_u,wa_d,wa_limit; maxSpeed=0.0; do { wa_u=0.0; wa_d=180.0; bvmg_u=bvmg_d=0; double speed; do { speed=myGetSpeed(ws,wa,true); if(speed>maxSpeed) maxSpeed=speed; bvmg=speed*cos(degToRad(wa)); if(bvmg_u<bvmg) //bvmg is positive here { bvmg_u=bvmg; wa_u=wa; } if(bvmg_d>bvmg) //bvmg is negative here { bvmg_d=bvmg; wa_d=wa; } wa=qRound(wa+1); } while(wa<181.00); wa=wa_u-1; wa_limit=wa_u+1; if(wa<0) wa=0.0; if(wa_limit<1) wa_limit=1.0; if(wa_limit>180) wa_limit=180.0; bvmg_u=0.0; do { speed=myGetSpeed(ws,wa,true); if(speed>maxSpeed) maxSpeed=speed; bvmg=speed*cos(degToRad(wa)); if(bvmg_u<bvmg) { bvmg_u=bvmg; wa_u=wa; } wa=wa+0.1; } while(wa<(wa_limit+0.1000)); wa=wa_d-1; wa_limit=wa_d+1; if(wa<0) wa=0.0; if(wa_limit<1) wa_limit=1.0; if(wa_limit>180) wa_limit=180.0; bvmg_d=0.0; do { speed=myGetSpeed(ws,wa,true); if(speed>maxSpeed) maxSpeed=speed; bvmg=speed*cos(degToRad(wa)); if(bvmg_d>bvmg) { bvmg_d=bvmg; wa_d=wa; } wa=wa+0.1; }while(wa<wa_limit+0.1); best_vmg_up.append(wa_u); best_vmg_down.append(wa_d); wa=0.0; ws=ws+.1; }while(ws<60.1); loaded=true; QFileInfo fi(file.fileName()); QString nameFVmg = appFolder.value("polar")+fi.baseName()+".vmg"; fileVMG.setFileName(nameFVmg); if (fileVMG.open(QIODevice::ReadOnly | QIODevice::Text )) { if(fileVMG.size()<4329500 || fileVMG.size()>4329700) fileVMG.remove(); else { QFileInfo info1(fileVMG); QFileInfo info2(file); if(this->mainWindow->isStartingUp && info1.lastModified()<info2.lastModified()) fileVMG.remove(); else { file.close(); return; } } } file.close(); //precalculate regular VMGs //qWarning() << "Start computing vmg"; fileVMG.open(QIODevice::WriteOnly | QIODevice::Text ); double vmg=0; QTextStream sVmg(&fileVMG); QString ssVmg; QProgressDialog * progress; progress=new QProgressDialog((QWidget*)mainWindow); progress->setWindowModality(Qt::ApplicationModal); progress->setLabelText(tr("Pre-calcul des valeurs de VMG pour ")+fname); progress->setMaximum(600); progress->setMinimum(0); progress->setCancelButton(NULL); progress->setMaximumHeight(100); progress->show(); for (int tws=0;tws<601;tws++) { progress->setValue(tws); for (int twa=0;twa<1801;twa++) { bvmgWind((double) twa/10.0,(double) tws/10.0,&vmg); ssVmg.sprintf("%.4d",qRound(A360(vmg)*10.0)); sVmg<<ssVmg; } } fileVMG.close(); if(!fileVMG.open(QIODevice::ReadOnly | QIODevice::Text )) qWarning()<<"fileVMG could not be re-opened!"; progress->close(); delete progress; }
void MainWindow::launchInstance(InstancePtr instance, AuthSessionPtr session, BaseProfilerFactory *profiler) { Q_ASSERT_X(instance != NULL, "launchInstance", "instance is NULL"); Q_ASSERT_X(session.get() != nullptr, "launchInstance", "session is NULL"); QString launchScript; if(!instance->prepareForLaunch(session, launchScript)) return; MinecraftProcess *proc = new MinecraftProcess(instance); proc->setLaunchScript(launchScript); proc->setWorkdir(instance->minecraftRoot()); this->hide(); console = new ConsoleWindow(proc); connect(console, SIGNAL(isClosing()), this, SLOT(instanceEnded())); proc->setLogin(session); proc->arm(); if (profiler) { QString error; if (!profiler->check(&error)) { QMessageBox::critical(this, tr("Error"), tr("Couldn't start profiler: %1").arg(error)); proc->abort(); return; } BaseProfiler *profilerInstance = profiler->createProfiler(instance, this); QProgressDialog dialog; dialog.setMinimum(0); dialog.setMaximum(0); dialog.setValue(0); dialog.setLabelText(tr("Waiting for profiler...")); connect(&dialog, &QProgressDialog::canceled, profilerInstance, &BaseProfiler::abortProfiling); dialog.show(); connect(profilerInstance, &BaseProfiler::readyToLaunch, [&dialog, this, proc](const QString &message) { dialog.accept(); QMessageBox msg; msg.setText(tr("The launch of Minecraft itself is delayed until you press the " "button. This is the right time to setup the profiler, as the " "profiler server is running now.\n\n%1").arg(message)); msg.setWindowTitle(tr("Waiting")); msg.setIcon(QMessageBox::Information); msg.addButton(tr("Launch"), QMessageBox::AcceptRole); msg.exec(); proc->launch(); }); connect(profilerInstance, &BaseProfiler::abortLaunch, [&dialog, this, proc](const QString &message) { dialog.accept(); QMessageBox msg; msg.setText(tr("Couldn't start the profiler: %1").arg(message)); msg.setWindowTitle(tr("Error")); msg.setIcon(QMessageBox::Critical); msg.addButton(QMessageBox::Ok); msg.exec(); proc->abort(); }); profilerInstance->beginProfiling(proc); dialog.exec(); } else { proc->launch(); } }
bool QgsShapeFile::scanGeometries() { QProgressDialog *sg = new QProgressDialog(); sg->setMinimum( 0 ); sg->setMaximum( 0 ); QString label = tr( "Scanning " ); label += fileName; sg->setLabel( new QLabel( label ) ); sg->show(); qApp->processEvents(); OGRFeatureH feat; OGRwkbGeometryType currentType = wkbUnknown; bool multi = false; while (( feat = OGR_L_GetNextFeature( ogrLayer ) ) ) { qApp->processEvents(); // feat->DumpReadable(NULL); OGRGeometryH geom = OGR_F_GetGeometryRef( feat ); if ( geom ) { QString gml = OGR_G_ExportToGML( geom ); // QgsDebugMsg(gml); if ( gml.indexOf( "gml:Multi" ) > -1 ) { // QgsDebugMsg("MULTI Part Feature detected"); multi = true; } OGRFeatureDefnH fDef = OGR_F_GetDefnRef( feat ); OGRwkbGeometryType gType = OGR_FD_GetGeomType( fDef ); // QgsDebugMsg(gType); if ( gType > currentType ) { currentType = gType; } if ( gType < currentType ) { QgsDebugMsg( QString( "Encountered inconsistent geometry type %1" ).arg( gType ) ); } } } // a hack to support 2.5D geometries (their wkb is equivalent to 2D variants // except that the highest bit is set also). For now we will ignore 3rd coordinate. hasMoreDimensions = false; if ( currentType & wkb25DBit ) { QgsDebugMsg( "Got a shapefile with 2.5D geometry." ); currentType = wkbFlatten( currentType ); hasMoreDimensions = true; } OGR_L_ResetReading( ogrLayer ); geom_type = geometries[currentType]; if ( multi && ( geom_type.indexOf( "MULTI" ) == -1 ) ) { geom_type = "MULTI" + geom_type; } delete sg; // QgsDebugMsg(QString("Geometry type is %1 (%2)").arg(currentType).arg(geometries[currentType])); return multi; }
void createFakeData() { QStringList names; names << "Eabha Biddell" << "Prentice Hutchison" << "Rameesha Davidge" << "Digby Roson" << "Nettah Newarch" << "Lewisha Middleton" << "Ahmed Hanmer" << "Jordyn-Leigh Lamant" << "Lindsay Bigham" << "Kaylay Weir" << "Sofia Weir" << "Coel Spurlock" << "Youcef Culpan" << "Lucy-Jasmine Blanchard" << "Ally Hodgkin" << "Ara Collinge" << "Luka Dempster" << "Samanta Winster" << "Keri Palin" << "Ruiridh Bisset" << "Norman Epworth" << "Kezia Raw" << "Kaylan-Thomas Swynford" << "Kashaf Benning" << "Norma Yair" << "Edan Bassett" << "Akshat Mcglasson" << "Philippa Upton" << "Tylor Rockliff" << "Aqdas Buckman" << "Briana Dowell" << "Querida North" << "Chelsay Botts" << "Kishanth Calloway" << "Jan Covington" << "Teighan Monson" << "Claudia Mendel" << "Kerra Doe" << "Kara Depp" << "Harlie Soole" << "Viggo Streeter" << "Ava Cofel" << "Catherine Balderston" << "Brendan Gosnay" << "Zhaoyun Haygarth" << "Deri Pepler" << "Vicki Hopwood" << "Amitra Bindless" << "Cerhys Hayton" << "Gwendoline Westall"; QProgressDialog progress; progress.setWindowModality(Qt::WindowModal); progress.setWindowTitle(QObject::tr("Staff Manager")); progress.setLabelText(QObject::tr("Creating database...")); progress.setMinimum(0); progress.setMaximum(names.count() + 6); progress.setValue(1); qApp->processEvents(); QSqlQuery query; query.exec("DROP TABLE department"); query.exec("DROP TABLE employee"); query.exec("DROP TABLE location"); progress.setValue(2); qApp->processEvents(); query.exec("CREATE TABLE location (" "id INTEGER PRIMARY KEY AUTOINCREMENT, " "name VARCHAR(40) NOT NULL)"); progress.setValue(3); qApp->processEvents(); query.exec("CREATE TABLE department (" "id INTEGER PRIMARY KEY AUTOINCREMENT, " "name VARCHAR(40) NOT NULL, " "locationid INTEGER NOT NULL, " "FOREIGN KEY (locationid) REFERENCES location)"); progress.setValue(4); qApp->processEvents(); query.exec("CREATE TABLE employee (" "id INTEGER PRIMARY KEY AUTOINCREMENT, " "name VARCHAR(40) NOT NULL, " "departmentid INTEGER NOT NULL, " "extension INTEGER NOT NULL, " "email VARCHAR(40) NOT NULL, " "startdate DATE NOT NULL, " "FOREIGN KEY (departmentid) REFERENCES department)"); progress.setValue(5); qApp->processEvents(); query.exec("INSERT INTO location (name) VALUES (" "'Floor 18, 1129 Evanston Heights, New York, NY')"); query.exec("INSERT INTO location (name) VALUES (" "'The Shed, Elmtree Drive, Boston, MA')"); query.exec("INSERT INTO location (name) VALUES (" "'14 Valentine Buildings, Amor Street, Cambridge, MA')"); query.exec("INSERT INTO location (name) VALUES (" "'Bunker Building, Silo Avenue, Los Angeles, CA')"); query.exec("INSERT INTO department (name, locationid) VALUES (" "'Sales', 1)"); query.exec("INSERT INTO department (name, locationid) VALUES (" "'Marketing', 2)"); query.exec("INSERT INTO department (name, locationid) VALUES (" "'Processing', 1)"); query.exec("INSERT INTO department (name, locationid) VALUES (" "'Support', 4)"); query.exec("INSERT INTO department (name, locationid) VALUES (" "'Research', 3)"); progress.setValue(6); qApp->processEvents(); int count = 0; query.prepare("INSERT INTO employee (name, departmentid, " "extension, email, startdate) " "VALUES (:name, :departmentid, :extension, " ":email, :startdate)"); foreach (QString name, names) { query.bindValue(":name", name); query.bindValue(":departmentid", 1 + (std::rand() % 5)); query.bindValue(":extension", 400 + (std::rand() % 100)); query.bindValue(":email", name.toLower().replace(" ", ".") + "@company.com"); query.bindValue(":startdate", QDate::currentDate().addDays(-(std::rand() % 3600))); query.exec(); ++count; progress.setValue(count + 6); }
void Uploading::uploadingProcess(const QString &actionId) { { QProgressDialog progressDialog; progressDialog.setWindowModality(Qt::WindowModal); progressDialog.setWindowTitle(tr("Выгрузка базы данных")); progressDialog.setLabelText(tr("Процесс выгрузки базы данных")); progressDialog.setCancelButton(0); progressDialog.setMinimumDuration(0); progressDialog.setMaximum(6); progressDialog.setValue(0); QSqlDatabase db = QSqlDatabase::database(UPLOADING); createDBScheme(); progressDialog.setValue(1); QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); QSqlQuery selectDataQuery(QSqlDatabase::database(mConnection)); QSqlQuery insertDataQuery(db); if(selectDataQuery.exec("SELECT id, title, performer FROM Actions WHERE id = " + actionId)) { insertDataQuery.prepare("INSERT INTO Actions VALUES(:id, :title, :performer);"); while(selectDataQuery.next()) { insertDataQuery.bindValue(":id", selectDataQuery.value(0)); insertDataQuery.bindValue(":title", selectDataQuery.value(1)); insertDataQuery.bindValue(":performer", selectDataQuery.value(2)); insertDataQuery.exec(); } } progressDialog.setValue(2); QList<int> placeSchemeIds; QList<int> clientIds; if(selectDataQuery.exec("SELECT id, id_action, id_placeScheme, id_client, identifier FROM Tickets WHERE id_action = " + actionId)) { insertDataQuery.prepare("INSERT INTO Tickets VALUES(NULL, :id_action, :id_placeScheme, :id_client, :identifier, :passedFlag);"); while(selectDataQuery.next()) { insertDataQuery.bindValue(":id_action", selectDataQuery.value(1)); insertDataQuery.bindValue(":id_placeScheme", selectDataQuery.value(2)); insertDataQuery.bindValue(":id_client", selectDataQuery.value(3)); insertDataQuery.bindValue(":identifier", selectDataQuery.value(4)); insertDataQuery.bindValue(":passedFlag", "false"); insertDataQuery.exec(); if(selectDataQuery.isNull(2) == false) placeSchemeIds.append(selectDataQuery.value(2).toInt()); if(selectDataQuery.isNull(3) == false) clientIds.append(selectDataQuery.value(4).toInt()); } } progressDialog.setValue(3); if(placeSchemeIds.isEmpty() == false) { if(selectDataQuery.exec("SELECT id, seatNumber, row FROM PlaceSchemes")) { insertDataQuery.prepare("INSERT INTO PlaceSchemes VALUES(:id, :seatNumber, :row)"); while(selectDataQuery.next()) { if(placeSchemeIds.contains( selectDataQuery.value(0).toInt()) ) { insertDataQuery.bindValue(":id", selectDataQuery.value(0)); insertDataQuery.bindValue(":seatNumber", selectDataQuery.value(1)); insertDataQuery.bindValue(":row", selectDataQuery.value(2)); insertDataQuery.exec(); } } } } progressDialog.setValue(4); if(clientIds.isEmpty() == false) { if(selectDataQuery.exec("SELECT id, name, login FROM Clients")) { insertDataQuery.prepare("INSERT INTO Clients VALUES(:id, :name, :login)"); while(selectDataQuery.next()) { if(clientIds.contains( selectDataQuery.value(0).toInt() )) { insertDataQuery.bindValue(":id", selectDataQuery.value(0)); insertDataQuery.bindValue(":name", selectDataQuery.value(1)); insertDataQuery.bindValue(":login", selectDataQuery.value(2)); insertDataQuery.exec(); } } } } progressDialog.setValue(5); if(selectDataQuery.exec("SELECT id, id_client, identifier FROM ReturnedTickets WHERE id_action = " + actionId)) { insertDataQuery.prepare("INSERT INTO ReturnedTickets VALUES(NULL, :id_client, :identifier);"); while(selectDataQuery.next()) { insertDataQuery.bindValue(":id_client", selectDataQuery.value(1)); insertDataQuery.bindValue(":identifier", selectDataQuery.value(2)); insertDataQuery.exec(); } } progressDialog.setValue(6); progressDialog.close(); db.close(); } QSqlDatabase::removeDatabase(UPLOADING); }
void MainWindow::on_computeButton_clicked() { //disabling actions that could make the application crash ui->openButton->setEnabled(false); ui->computeButton->setEnabled(false); QPrincipalAxisGenerator generator; if( computedMeshes ){ //cleaning previous calculation for( int i=1;i<nViewers; i++ ){ leftWidgets[i]->deleteMeshes(); rightWidgets[i]->deleteMeshes(); } } vector<Method> methods2compute; //add them in the order of the tabs methods2compute.push_back( JUST_PCA ); methods2compute.push_back( ROBUS_DETERMINATION ); int progressIt=0; QProgressDialog progress; progress.setWindowTitle("Loading"); progress.setLabelText("Computing meshes..."); progress.setCancelButton(NULL); progress.setMinimum(0); progress.setMaximum(100); progress.show(); for( int i=0; i< leftWidgets[0]->getNumberOfMeshes(); i++ ){ generator.setMesh( leftWidgets[0]->getMesh(i) ); for( int j=0; j<methods2compute.size(); j++ ){ generator.setMethod( methods2compute.at(j) );//selecting method to generate axis generator.start();//computing on other thread not to freeze the main window while(generator.isRunning()){ //forcing window refresh events so the window not freezes during the wait qApp->processEvents(); update(); repaint(); ui->centralWidget->repaint(); } //tab position, 0 is the original tab leftWidgets[j+1]->insert_mesh( leftWidgets[0]->getMesh(i),generator.getAxis() ); rightWidgets[j+1]->insert_mesh( rightWidgets[0]->getMesh(i),generator.getAxis() ); leftWidgets[j+1]->setMeshVisiblility( i,leftWidgets[0]->isMeshVisible(i) ); rightWidgets[j+1]->setMeshVisiblility( i,leftWidgets[0]->isMeshVisible(i) ); progressIt++; progress.setValue( progressIt*100/(leftWidgets[0]->getNumberOfMeshes()*2) ); progress.update(); } /* //stating way, just for debuging generator.setMethod( JUST_PCA );//selecting method to generate axis generator.start();//computing on other thread not to freeze the main window while(generator.isRunning()){ //forcing window refresh events so the window not freezes during the wait qApp->processEvents(); update(); repaint(); ui->centralWidget->repaint(); } leftWidgets[1]->insert_mesh( leftWidgets[0]->getMesh(i),generator.getAxis() ); rightWidgets[1]->insert_mesh( rightWidgets[0]->getMesh(i),generator.getAxis() ); leftWidgets[1]->setMeshVisiblility( i,leftWidgets[0]->isMeshVisible(i) ); rightWidgets[1]->setMeshVisiblility( i,leftWidgets[0]->isMeshVisible(i) ); progressIt++; progress.setValue( progressIt*100/(leftWidgets[0]->getNumberOfMeshes()*2) ); progress.update(); //sleep(2); generator.setMethod( ROBUS_DETERMINATION ); generator.start(); while(generator.isRunning()){ //forcing window refresh events so the window not freezes during the wait qApp->processEvents(); update(); repaint(); ui->centralWidget->repaint(); } leftWidgets[2]->insert_mesh( leftWidgets[0]->getMesh(i),generator.getAxis() ); rightWidgets[2]->insert_mesh( rightWidgets[0]->getMesh(i),generator.getAxis() ); leftWidgets[2]->setMeshVisiblility( i,leftWidgets[0]->isMeshVisible(i) ); rightWidgets[2]->setMeshVisiblility( i,leftWidgets[0]->isMeshVisible(i) ); progressIt++; progress.setValue( progressIt*100/(leftWidgets[0]->getNumberOfMeshes()*2) ); progress.update(); */ //sleep(2); } progress.setValue(100); progress.close(); //apply translation and rotation cout <<"Computing axis completed"<<endl; computedMeshes=true; ui->openButton->setEnabled(true); ui->computeButton->setEnabled(true); ui->alignButton->setEnabled(true); }