Example #1
0
void FLUtil::createProgressDialog(const QString &l, int tS, const QString &id)
{
  QProgressDialog *pd = dictProgressD_.find(id);
  if (!pd) {
    pd = new QProgressDialog(l, 0, tS, 0, 0, true);
    dictProgressD_.insert(id, pd);
    pd->setCaption("AbanQ");
  }
}
Example #2
0
void ProgressDialog::updateProgress(float progress, const QString &stepString) {
  progressDialog->setValue(int(progress * 100));
  QString message(stepString);
  if (message.length() > 33)
    message = message.left(17) + "..." + message.right(12);
  progressDialog->setLabelText(message);
  progressDialog->update();
  qApp->processEvents();
}
Example #3
0
void MainWindow::LoadFile()
{

    if (FileFormatPluginList.size()) {


        QString FileName = QFileDialog::getOpenFileName(this, tr("Open File"),
                                                     "",
                                                     FileFormatPluginList[0]->getFormatDescription());

        //test();
        // Create a progress dialog.
            QProgressDialog dialog;

            dialog.setLabelText(QString("Загрузка данных из файла"));

            // Create a QFutureWatcher and connect signals and slots.
            QFutureWatcher<void> futureWatcher;
            QTimer timer;
            connect(&timer, SIGNAL(timeout()), this, SLOT(updateProgress()));
            timer.start(1000);
            QObject::connect(&futureWatcher, SIGNAL(finished()), &dialog, SLOT(reset()));
            QObject::connect(&dialog, SIGNAL(canceled()), SLOT(cancelOperation()));
            QObject::connect(&dialog, SIGNAL(canceled()), &futureWatcher, SLOT(cancel()));
            QObject::connect(this, SIGNAL(progressValueChanged(int)), &dialog, SLOT(setValue(int)));

            //extern void FileFormatPluginList[0]->getDataFromChannel(channel,(qint8*)data);


            QFuture<void> future = QtConcurrent::run(FileFormatPluginList[0], &FileReadInterface::LoadFile, FileName);

            // Start the computation.
            futureWatcher.setFuture(future);

            // Display the dialog and start the event loop.
            dialog.exec();

            futureWatcher.waitForFinished();
            dialog.setValue(100);
            dialog.hide();


            timer.stop();



        cube= FileFormatPluginList[0]->getCube();


        QList<double> list = cube->GetListOfChannels();




        foreach(double l , list) {
            ui->ChannelListWidget->addItem(QString("%1").arg(l));
        }
Example #4
0
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();
}
Example #5
0
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."));
}
Example #6
0
/*=========================================================================
  doFileSearch 
=========================================================================*/
void MainWindow::doFileSearch (const QString &path, const QString &text, 
    KFileList *fileList)
  {
  QProgressDialog progress (tr("Searching..."), tr("Stop"), 
      0, 100, this);
  progress.setWindowModality (Qt::WindowModal);
  progress.setMinimumDuration (0);
  progress.show();

  _doFileSearch (path, "", text, fileList, progress);

  progress.setValue (100);
  }
Example #7
0
void MainWindow::openFile() {
		QString newFile = QFileDialog::getOpenFileName(this, tr("Open SQL File"),
				QDir::currentPath(), tr("SQL file (*.sql);;All Files (*)"));
		if (newFile.isNull())
			return;



		QFile f(newFile);
		if (!f.open(QIODevice::ReadOnly | QIODevice::Text))
		{
			QMessageBox::warning(this, tr("Open SQL Script"), tr("Cannot open file %1").arg(newFile));
			return;
		}

		int prgTmp = 0;
		QProgressDialog * progress = new QProgressDialog(tr("Opening: %1").arg(newFile), tr("Abort"), 0, f.size(), this);
		connect(progress, SIGNAL(canceled()), this, SLOT(cancel()));
		progress->setWindowModality(Qt::WindowModal);
		progress->setMinimumDuration(1000);
		SqlViewWidget *newSqlview = new SqlViewWidget();
		QFileInfo pathInfo(newFile);
		sqlViewWidget->addTab(newSqlview,pathInfo.fileName());
		sqlViewWidget->setCurrentWidget(newSqlview);


		newSqlview->sqlInput->clear();
		QTextStream in(&f);
		QString line;
		QStringList strList;
		while (!in.atEnd())
		{
			line = in.readLine();
			strList.append(line);
			prgTmp += line.length();

		}

		f.close();


		progress->setLabelText(tr("Formatting the text. Please wait."));
		newSqlview->sqlInput->append(strList.join("\n"));
		newSqlview->sqlInput->setModified(false);

		delete progress;
		progress = 0;



}
Example #8
0
bool downloadTracksFromOSM(QWidget* Main, const QString& aWeb, const QString& aUser, const QString& aPassword, const CoordBox& aBox , Document* theDocument)
{
    Downloader theDownloader(aUser, aPassword);
    QList<TrackLayer*> theTracklayers;
    //TrackMapLayer* trackLayer = new TrackMapLayer(QApplication::translate("Downloader","Downloaded tracks"));
    //theDocument->add(trackLayer);

    IProgressWindow* aProgressWindow = dynamic_cast<IProgressWindow*>(Main);
    if (!aProgressWindow)
        return false;

    QProgressDialog* dlg = aProgressWindow->getProgressDialog();
    dlg->setWindowTitle(QApplication::translate("Downloader","Parsing..."));

    QProgressBar* Bar = aProgressWindow->getProgressBar();
    Bar->setTextVisible(false);
    Bar->setMaximum(11);

    QLabel* Lbl = aProgressWindow->getProgressLabel();
    Lbl->setText(QApplication::translate("Downloader","Parsing XML"));

    if (dlg)
        dlg->show();

    theDownloader.setAnimator(dlg,Lbl,Bar,true);
    for (int Page=0; ;++Page)
    {
        Lbl->setText(QApplication::translate("Downloader","Downloading trackpoints %1-%2").arg(Page*5000+1).arg(Page*5000+5000));
        QString URL = theDownloader.getURLToTrackPoints();
        URL = URL.arg(aBox.bottomLeft().x()).
                arg(aBox.bottomLeft().y()).
                arg(aBox.topRight().x()).
                arg(aBox.topRight().y()).
                arg(Page);
        QUrl theUrl(aWeb+URL);
        if (!theDownloader.go(theUrl))
            return false;
        if (theDownloader.resultCode() != 200)
            return false;
        int Before = theTracklayers.size();
        QByteArray Ar(theDownloader.content());
        bool OK = importGPX(Main, Ar, theDocument, theTracklayers, true);
        if (!OK)
            return false;
        if (Before == theTracklayers.size())
            break;
        theTracklayers[theTracklayers.size()-1]->setName(QApplication::translate("Downloader", "Downloaded track - nodes %1-%2").arg(Page*5000+1).arg(Page*5000+5000));
    }
    return true;
}
Example #9
0
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 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);
}
Example #11
0
/**
 * 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;
}
Example #12
0
void SearchDialog::newSearch() {
  QString phrase = QInputDialog::getText(pgView, "Search in notebook",
                                         "Search phrase:",
                                         QLineEdit::Normal,
                                         lastPhrase);
  lastPhrase = phrase;

  if (phrase.isEmpty())
    return;

  QProgressDialog *progress = new QProgressDialog(pgView);
  progress->setLabelText("Searching...");
  progress->setCancelButton(0);
  progress->setMinimumDuration(500);
  progress->setValue(0);
  Search *search = new Search(pgView->notebook());
  QList<SearchResult> res = search->immediatelyFindPhrase(phrase);

  if (res.isEmpty()) {
    delete progress;
    QMessageBox::information(pgView, "Search - eln",
                             QString::fromUtf8("Search phrase “%1” not found")
                             .arg(phrase));
    return;
  }
  
  SearchResultScene *scene
    = new SearchResultScene(phrase,
			    QString::fromUtf8("Search results for “%1”")
			    .arg(phrase),
			    res,
			    pgView->notebook()->bookData());
  scene->populate();
  connect(scene,
	  SIGNAL(pageNumberClicked(int, Qt::KeyboardModifiers,
				   QString, QString)),
	  this,
	  SLOT(gotoPage(int, Qt::KeyboardModifiers, QString, QString)));
  SearchView *view = new SearchView(scene);
  view->setAttribute(Qt::WA_DeleteOnClose, true);
  connect(parent(), SIGNAL(destroyed()), view, SLOT(close()));
  delete progress;
  
  view->resize(pgView->size()*.9);
  QString ttl = pgView->notebook()->bookData()->title();
  view->setWindowTitle("Search in: "
		       + ttl.replace(QRegExp("\\s\\s*"), " ") + " - eln");
  view->show();
}
bool NXMAccessManager::loggedIn() const
{
  if (m_LoginState == LOGIN_CHECKING) {
    QProgressDialog progress;
    progress.setLabelText(tr("Verifying Nexus login"));
    progress.show();
    while (m_LoginState == LOGIN_CHECKING) {
      QCoreApplication::processEvents();
      QThread::msleep(100);
    }
    progress.hide();
  }

  return m_LoginState == LOGIN_VALID;
}
int CPL_STDCALL QgsImageWarper::updateWarpProgress( double dfComplete, const char *pszMessage, void *pProgressArg )
{
  QProgressDialog *progress = static_cast<QProgressDialog*>( pProgressArg );
  progress->setValue( qMin( 100u, ( uint )( dfComplete*100.0 ) ) );
  qApp->processEvents();
  // TODO: call QEventLoop manually to make "cancel" button more responsive
  if ( progress->wasCanceled() )
  {
    mWarpCanceled = true;
    return false;
  }

  mWarpCanceled = false;
  return true;
}
void DatabaseWidget::readCsvBase(QString openFilename)
{
//    QString currTime=QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss.zzz");
//    qDebug().noquote() << "readCsvBase BEGIN"
//             << currTime
//             << this->thread()->currentThreadId();

    emit toDebug(objectName(),
                 QString("Открывается файл '%1'.").arg(openFilename));

    QString name = QFileInfo(openFilename).fileName();
    if(!QFileInfo(openFilename).exists())
    {
        emit toDebug(objectName(),
                     QString("Файл '%1' не найден").arg(openFilename));
        return;
    }


    QProgressDialog *dialog = new QProgressDialog;
    dialog->setWindowTitle(trUtf8("Обработка базы (1/3)"));
    dialog->setLabelText(trUtf8("Открывается файл \"%1\". \nОжидайте ...")
                         .arg(name));
    dialog->setCancelButtonText(trUtf8("Отмена"));
    QObject::connect(dialog, SIGNAL(canceled()),
                     &_futureWatcher, SLOT(cancel()));
    QObject::connect(&_futureWatcher, SIGNAL(progressRangeChanged(int,int)),
                     dialog, SLOT(setRange(int,int)));
    QObject::connect(&_futureWatcher, SIGNAL(progressValueChanged(int)),
                     dialog, SLOT(setValue(int)));
    QObject::connect(&_futureWatcher, SIGNAL(finished()),
                     dialog, SLOT(deleteLater()));
    QObject::connect(&_futureWatcher, SIGNAL(finished()),
                     dialog, SLOT(hide()));

    QFuture<ListAddress> f1 = QtConcurrent::run(
                                         readFile,
                                         openFilename,
                                         MAX_OPEN_ROWS);
    // Start the computation.
    _futureWatcher.setFuture(f1);
    dialog->exec();

//    currTime=QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss.zzz");
//    qDebug().noquote() << "readCsvBase END"
//             << currTime
//             << this->thread()->currentThreadId();
}
Example #16
0
void
ConfigDialog::devpairClicked()
{
    DeviceConfiguration add;

    // get values from the gui elements
    add.name = devicePage->deviceName->displayText();
    add.type = devicePage->typeSelector->itemData(devicePage->typeSelector->currentIndex()).toInt();
    add.portSpec = devicePage->deviceSpecifier->displayText();
    add.deviceProfile = devicePage->deviceProfile->displayText();

    QProgressDialog *progress = new QProgressDialog("Looking for Devices...", "Abort Scan", 0, 200, this);
    progress->setWindowModality(Qt::WindowModal);

    devicePage->pairClicked(&add, progress);
}
Example #17
0
void BatchTranslationDialog::startTranslation()
{
    int translatedcount = 0;
    QCursor oldCursor = cursor();
    setCursor(Qt::BusyCursor);
    int messageCount = m_dataModel->messageCount();

    QProgressDialog *dlgProgress;
    dlgProgress = new QProgressDialog(tr("Searching, please wait..."), tr("&Cancel"), 0, messageCount, this);
    dlgProgress->show();

    int msgidx = 0;
    const bool translateTranslated = m_ui.ckTranslateTranslated->isChecked();
    const bool translateFinished = m_ui.ckTranslateFinished->isChecked();
    for (MultiDataModelIterator it(m_dataModel, m_modelIndex); it.isValid(); ++it) {
        if (MessageItem *m = it.current()) {
            if (!m->isObsolete()
                && (translateTranslated || m->translation().isEmpty())
                && (translateFinished || !m->isFinished())) {

                // Go through them in the order the user specified in the phrasebookList
                for (int b = 0; b < m_model.rowCount(); ++b) {
                    QModelIndex idx(m_model.index(b, 0));
                    QVariant checkState = m_model.data(idx, Qt::CheckStateRole);
                    if (checkState == Qt::Checked) {
                        PhraseBook *pb = m_phrasebooks[m_model.data(idx, Qt::UserRole).toInt()];
                        foreach (const Phrase *ph, pb->phrases()) {
                            if (ph->source() == m->text()) {
                                m_dataModel->setTranslation(it, ph->target());
                                m_dataModel->setFinished(it, m_ui.ckMarkFinished->isChecked());
                                ++translatedcount;
                                goto done; // break 2;
                            }
                        }
                    }
                }
            }
        }
      done:
        ++msgidx;
        if (!(msgidx & 15))
            dlgProgress->setValue(msgidx);
        qApp->processEvents();
        if (dlgProgress->wasCanceled())
            break;
    }
Example #18
0
int QgsRasterFileWriter::pyramidsProgress( double dfComplete, const char *pszMessage, void* pData )
{
  Q_UNUSED( pszMessage );
  GDALTermProgress( dfComplete, 0, 0 );
  QProgressDialog* progressDialog = static_cast<QProgressDialog*>( pData );
  if ( pData && progressDialog->wasCanceled() )
  {
    return 0;
  }

  if ( pData )
  {
    progressDialog->setRange( 0, 100 );
    progressDialog->setValue( dfComplete * 100 );
  }
  return 1;
}
Example #19
0
void Thread::Execute(bool WaitTilDone) { //starts the thread, waits til complete;
	clock_t startTime, finishTime;
	startTime = clock();

	QProgressDialog progress;
	progress.setModal(true);
	if (pCancelFlag) *pCancelFlag = false; //haven't canceled before we started!

	start(); 

	if (WantProgress) progress.show();

	if (WantProgress || WantTimed || WaitTilDone){ //if we want to stick around until the thread is finished...
		while (isRunning()){
			if (WantProgress){
				progress.setLabelText(QString((*pCurMessage).c_str()));
				progress.setRange(0, *pCurMaxTick);
				progress.setValue(*pCurTick);
				QApplication::processEvents();
				if (progress.wasCanceled()){
					*pCancelFlag = true;
					wait();
					return; //returns
				}
			}
			msleep(50);
		}
	}

	finishTime = clock();
	double duration = (double)(finishTime - startTime) / CLOCKS_PER_SEC;
	std::ostringstream os;
	os << "Elapsed time: " << duration << " Sec";
	if (WantTimed) QMessageBox::warning(NULL, "Warning", (os.str()).c_str());
}
void DatabaseWidget::onProcessOfOpenFinished()
{
    if(_futureWatcher.isFinished()
            && !_futureWatcher.isCanceled())
    {
        _paddr.reset(new ListAddress(_futureWatcher.future().result()));
        emit toDebug(objectName(),
                     QString("Открытие файла успешно завершено. Прочитано строк = %1")
                     .arg(_paddr.data()->size()));
        if(!_paddr.data()->isEmpty())
        {
//                QString currTime=QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss.zzz");
//                qDebug().noquote() << "onProcessOfOpenFinished BEGIN"
//                         << currTime
//                         << this->thread()->currentThreadId();

            emit toDebug(objectName(),
                         QString("Начало обработки прочитанной базы."));

            QProgressDialog *dialog = new QProgressDialog;
            dialog->setWindowTitle(trUtf8("Обработка базы (2/3)"));
            dialog->setLabelText(trUtf8("Обрабатывается файл. Строк: \"%1\". \nОжидайте ...")
                                 .arg(_paddr.data()->size()));
            dialog->setCancelButtonText(trUtf8("Отмена"));
            QObject::connect(dialog, SIGNAL(canceled()),
                             &_futureWatcherParser, SLOT(cancel()));
            QObject::connect(&_futureWatcherParser, SIGNAL(progressRangeChanged(int,int)),
                             dialog, SLOT(setRange(int,int)));
            QObject::connect(&_futureWatcherParser, SIGNAL(progressValueChanged(int)),
                             dialog, SLOT(setValue(int)));
            QObject::connect(&_futureWatcherParser, SIGNAL(finished()),
                             dialog, SLOT(deleteLater()));

            QFuture<void> f1 = QtConcurrent::map(*_paddr,
                                                 parsingAddress
                                                 );
            // Start the computation.
            _futureWatcherParser.setFuture(f1);
            dialog->exec();

//            currTime=QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss.zzz");
//            qDebug().noquote() << "onProcessOfOpenFinished END"
//                               << currTime
//                               << this->thread()->currentThreadId();
        }
Example #21
0
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);
}
Example #22
0
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;
}
Example #23
0
void LibraryView::deleteSongs(){
  QSet<library_song_id_t> selectedIds =
    Utils::getSelectedIds<library_song_id_t>(
      this,
      libraryModel,
      DataStore::getLibIdColName(),
      proxyModel);

  QProgressDialog *deletingProgress =
    new QProgressDialog(tr("Deleting Songs..."), tr("Cancel"), 0, selectedIds.size()*2, this);
  deletingProgress->setWindowModality(Qt::WindowModal);
  deletingProgress->setMinimumDuration(250);

  dataStore->removeSongsFromLibrary(selectedIds, deletingProgress);
  if(!deletingProgress->wasCanceled()){
    emit libNeedsSync();
  }
  deletingProgress->close();
}
Example #24
0
void MetaWindow::addMediaSources(const QList<Phonon::MediaSource>& musicToAdd){
  if(musicToAdd.isEmpty()){
    QMessageBox::information(
        this, 
        "No Music Found", 
        "Sorry, but we couldn't find any new music that we know how to play.");
    return;
  }

  int numNewFiles = musicToAdd.size();
  QProgressDialog *addingProgress = new QProgressDialog(
    "Loading Library...", "Cancel", 0, numNewFiles, this);
  addingProgress->setWindowModality(Qt::WindowModal);
  addingProgress->setMinimumDuration(250);
  dataStore->addMusicToLibrary(musicToAdd, addingProgress);
  if(!addingProgress->wasCanceled()){
    syncLibrary();
  }
  addingProgress->close();
}
void MVCrossCorrelogramsWidget::updateWidget()
{
	if (d->m_path.isEmpty()) return;

	int k0=d->m_base_unit_num;

	DiskReadMda X;
	X.setPath(d->m_path);

	QProgressDialog dlg;
	dlg.show();
	dlg.setLabelText("Loading cross correlograms...");
	dlg.repaint(); qApp->processEvents();
	QList<FloatList> data0=get_cross_correlogram_datas_2(X,k0);

	int K=data0.count()-1;
	int num_rows=(int)sqrt(K); if (num_rows<1) num_rows=1;
	int num_cols=(K+num_rows-1)/num_rows;
	d->m_num_columns=num_cols;

	QWidget *W=this;
	W->setAttribute(Qt::WA_DeleteOnClose);
	QGridLayout *GL=new QGridLayout;
	GL->setHorizontalSpacing(20); GL->setVerticalSpacing(0);
	GL->setMargin(0);
	W->setLayout(GL);

	for (int k1=1; k1<=K; k1++) {
		HistogramView *HV=new HistogramView;
		HV->setData(data0[k1]);
		HV->autoSetBins(50);
		int k2=k1; if (k0>=1) k2=k0;
		QString title0=QString("%1/%2").arg(k1).arg(k2);
		HV->setTitle(title0);
		GL->addWidget(HV,(k1-1)/num_cols,(k1-1)%num_cols);
		HV->setProperty("unit_number",k1);
		connect(HV,SIGNAL(clicked()),this,SLOT(slot_histogram_view_clicked()));
		connect(HV,SIGNAL(activated()),this,SLOT(slot_histogram_view_activated()));
		d->m_histogram_views << HV;
	}
}
Example #26
0
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());
}
Example #27
0
bool KDReports::ReportPrivate::doPrint( QPrinter* printer, QWidget* parent )
{
    // caller has to ensure that we have been layouted for this printer already
    const int pageCount = m_layout->numberOfPages();
    QProgressDialog* dialog = 0;
    if ( QThread::currentThread() == qApp->thread() ) {
        dialog = new QProgressDialog( QObject::tr( "Printing" ), QObject::tr( "Cancel" ), 0, pageCount, parent );
        dialog->setWindowModality( Qt::ApplicationModal );
    }
    QPainter painter( printer );

    int fromPage = 0;
    int toPage = pageCount;
    if ( printer->printRange() == QPrinter::PageRange ) {
        fromPage = printer->fromPage() - 1; // it starts at 1
        toPage = printer->toPage(); // -1 because it starts at 1, and +1 because of '<'
        if ( toPage == 0 )
            toPage = pageCount;
    }

    bool firstPage = true;
    for ( int pageIndex = fromPage; pageIndex < toPage; ++pageIndex ) {
        if ( dialog ) {
            dialog->setValue( pageIndex );
            if ( dialog->wasCanceled() )
                break;
        }

        if ( !firstPage )
            printer->newPage();

        paintPage( pageIndex, painter );
        firstPage = false;
    }

    delete dialog;
    return true;
}
Example #28
0
void MainWindow::on_actionFind_all_text_string_16_bit_triggered()
{
    HexEditorWidget* v = dynamic_cast<HexEditorWidget*>(ui->twHex->currentWidget());
    if (v==NULL)return;
    QByteArray br = v->data();
    QByteArray akk;
    int lastAdr=0;

    QProgressDialog * progress = new QProgressDialog(tr("Search..."), tr("Cancel"), 0, br.size(), this);
    progress->setWindowModality(Qt::WindowModal);
    progress->show();

    for(int i=0;i<=br.count()-1;i=i+2)
    {
        if (i % 1000 == 0 )
        {
            progress->setValue(i);
            QCoreApplication::processEvents ();
            if (progress->wasCanceled()) break;
        }

        unsigned char c = br[i];
        unsigned char d = br[i+1];

        bool mached = false;

        if( d >= 0x20 && d <= 0x7E && c == 0x00)
        {
            if(akk.count()==0)lastAdr=i;
            akk.append(d);
            mached = true;

        }

        if( d >= 0x20 && d <= 0x7E && c >= 0x20 && c <= 0x7E)
        {
            if(akk.count()==0)lastAdr=i;
            akk.append(d);
            akk.append(c);
            mached = true;

        }

        if(!mached)
        {
            if (akk.length()>3)
            {
                QString s;
                s.setNum(lastAdr,16);
                ui->consoleView->appendPlainText(s.toUpper() + " : \""+akk+"\"");
            }
            akk.clear();
        }
    }

    progress->close();
    delete progress;
}
    foreach(const QString &uid, uids) {
        // Progress cosmetics
        dlg.setLabelText(tr("Setting patient uuid %1 as current patient").arg(uid));
        Utils::centerWidget(&dlg, this);
        qApp->processEvents(QEventLoop::ExcludeUserInputEvents);

        // Define current patient for extraction
        job.setPatientUid(uid);
        patient()->setCurrentPatientUid(uid);

        // Define output path
        QString fullname = patient()->data(Core::IPatient::FullName).toString();
        QString dob = patient()->data(Core::IPatient::DateOfBirth).toString();
        QString path = QString("%1/%2 %3")
               .arg(d->ui->pathChooser->path())
               .arg(fullname)
               .arg(dob);
        if (!QDir().mkpath(path))
            LOG_ERROR("Unable to create path: " + path);
        job.setOutputAbsolutePath(path);

        // Run extractors
        result << extractAll(extractors, job);
        Utils::Log::logTimeElapsed(chr, objectName(), QString("Extracted patient uid: %1").arg(uid));

        // According to params -> recreate one big HTML file
        QString out, outCss;
        foreach(Core::PatientDataExtraction *exp, result) {
            // Append all secondary files into the master
            QString master;
            master = Utils::readTextFile(exp->masterAbsoluteFilePath(), Utils::DontWarnUser);
            QFile(exp->masterAbsoluteFilePath()).remove();
            if (master.isEmpty())
                continue;
            QString masterCss;
            masterCss = Utils::htmlTakeAllCssContent(master);
            master = Utils::htmlBodyContent(master);
            foreach(const QString &sec, exp->secondaryFiles()) {
                QString second = Utils::readTextFile(sec, Utils::DontWarnUser);
                QFile(sec).remove();
                if (second.isEmpty())
                    continue;
                QString secCss;
                secCss = Utils::htmlTakeAllCssContent(second);
                master += Utils::htmlBodyContent(second);
                masterCss += secCss;
            }
            out += master;
            outCss += masterCss;
        }
// ///////////////////////SET Doors/////////////////////////////////
void LvlScene::setDoors(QProgressDialog &progress)
{
    int i=0;

    for(i=0; i<LvlData->doors.size(); i++)
    {
        //add Doors points to scene
        placeDoor(LvlData->doors[i]);

        if(progress.wasCanceled())
            //progress.setValue(progress.value()+1);
        /*else*/ return;
    }
}