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);
}
Exemple #2
0
void FLUtil::destroyProgressDialog(const QString &id)
{
  QProgressDialog *pd = dictProgressD_.take(id);
  if (pd)
    pd->deleteLater();
}
void AQWebApplication::handleWebEvent(const QString &msgEvent)
{
  QStringList args(QStringList::split(AQ_MSG_SEP, msgEvent, true));
  AQ::EventType evT = webEventTypeToAQEventType(args[0]);
  QWidget *w;
  AQWidgetInfo *wInfo;

  if (evT != AQ::XProgressDialog) {
    w = AQ_WIDGET(args[1].toULongLong(0, 36));
    wInfo = createdWidgets_.find(w);
    if (!wInfo)
      return;
  }

  switch (evT) {
    case AQ::MouseButtonPress: {
      QWidget *popup = activePopupWidget();
      if (popup && popup != w->topLevelWidget())
        popup->close();

      w->raise();
      w->setActiveWindow();

      QPoint local(args[2].toInt(), args[3].toInt());
      QPoint global(w->mapToGlobal(local));
      QCursor::setPos(global);
      QMouseEvent mev(QEvent::MouseButtonPress, local, global, toQtButton(args[4]), toQtButtonState(args[5]));
      qt_sendSpontaneousEvent(w, &mev);
      break;
    }

    case AQ::MouseButtonRelease: {
      QPoint local(args[2].toInt(), args[3].toInt());
      QPoint global(w->mapToGlobal(local));
      QCursor::setPos(global);
      QMouseEvent mev(QEvent::MouseButtonRelease, local, global, toQtButton(args[4]), toQtButtonState(args[5]));
      qt_sendSpontaneousEvent(w, &mev);
      break;
    }

    case AQ::MouseButtonDblClick: {
      QPoint local(args[2].toInt(), args[3].toInt());
      QPoint global(w->mapToGlobal(local));
      QCursor::setPos(global);
      QMouseEvent mev(QEvent::MouseButtonDblClick, local, global, toQtButton(args[4]), toQtButtonState(args[5]));
      qt_sendSpontaneousEvent(w, &mev);
      break;
    }

    case AQ::MouseMove: {
      QPoint local(args[2].toInt(), args[3].toInt());
      QPoint global(w->mapToGlobal(local));
      QCursor::setPos(global);
      QMouseEvent mev(QEvent::MouseMove, local, global, toQtButton(args[4]), toQtButtonState(args[5]));
      qt_sendSpontaneousEvent(w, &mev);
      break;
    }

    case AQ::KeyPress:
    case AQ::KeyRelease: {
      int keyCode = args[2].toInt();
      QWidget *keywidget = QWidget::keyboardGrabber();
      bool grabbed = false;

      if (keywidget) {
        grabbed = true;
      } else {
        keywidget = focusWidget();
        if (!keywidget) {
          keywidget = activePopupWidget();
          if (!keywidget) {
            keywidget = activeWindow();
            if (!keywidget)
              keywidget = w->topLevelWidget();
          }
        }
      }

      if (keyCode < 0) {
        QKeyEvent kev((QEvent::Type) evT, 0, keyCode, toQtButtonState(args[3]), QChar(-keyCode));
        qt_sendSpontaneousEvent(keywidget, &kev);
      } else {
        if (evT == AQ::KeyPress && !grabbed) {
          QKeyEvent a((QEvent::Type) evT, toQtKey(keyCode), keyCode, toQtButtonState(args[3]));
          if (qt_tryAccelEvent(keywidget, &a))
            return;
        }
        QKeyEvent kev((QEvent::Type) evT, toQtKey(keyCode), keyCode, toQtButtonState(args[3]));
        qt_sendSpontaneousEvent(keywidget, &kev);
      }
      break;
    }

    case AQ::Move:
      if (w != desktop_) {
        ignoreEvents_ = true;
        w->move(args[2].toInt(), args[3].toInt());
        ignoreEvents_ = false;
      }
      break;

    case AQ::Resize:
      if (w != desktop_) {
        //ignoreEvents_ = true;
        w->resize(args[2].toInt(), args[3].toInt());
        //ignoreEvents_ = false;
      } else {
        int wt = args[2].toInt();
        int ht = args[3].toInt();
        desktopGeometry_.setRect(0, 0, wt, ht);
        desktop()->resize(wt, ht);
        postAQEvent(new AQEvent(w, new QResizeEvent(QSize(wt, ht), QSize())));
        emit desktop()->resized(0);
        if (!initDone_)
          QTimer::singleShot(0, this, SLOT(init()));
      }
      break;

    case AQ::XUpload: {
      QFileDialog *fd = ::qt_cast<QFileDialog *>(w);
      if (fd)
        fd->rereadDir();
      break;
    }

    case AQ::XProgressDialog: {
      uint pid = args[1].toUInt();
      if (args.size() == 2) {
        QProgressDialog *pd = progressDialogs_.take(pid);
        if (pd) {
          pd->close();
          pd->deleteLater();
        }
      } else {
        QProgressDialog *pd = progressDialogs_.find(pid);
        if (!pd) {
          pd = new QProgressDialog(args[2], QString(), args[3].section(';', 1, 1).toInt());
          progressDialogs_.insert(pid, pd);
        }
        pd->setProgress(args[3].section(';', 0, 0).toInt());
      }
      break;
    }

    case AQ::WindowStateChange: {
      w->setWindowState(args[2].toInt());
      break;
    }

    default: {
      QEvent ev((QEvent::Type) evT);
      qt_sendSpontaneousEvent(w, &ev);
    }
  }
}
void AM1DCalibrationABEditor::onApplyToOtherScansChosen()
{
	disconnect(chooseScanDialog_, SIGNAL(accepted()), this, SLOT(onApplyToOtherScansChosen()));

	QList<QUrl> scans = chooseScanDialog_->getSelectedScans();
	chooseScanDialog_->clearSelection();
	if(scans.isEmpty()) {
		chooseScanDialog_->close();
		return;
	}

	QProgressDialog* progressDialog = new QProgressDialog(QString("Applying analysis parameters to %1 scans...").arg(scans.count()), "Stop", 0, scans.count(), chooseScanDialog_);
	progressDialog->setMinimumDuration(0);

	int scansModified = 0;

	for(int s=0; s<scans.count(); ++s) {
		progressDialog->setValue(s);
		QUrl scanUrl = scans.at(s);
		bool isScanning;
		QString scanName;
		AMScan* scan = AMScan::createFromDatabaseUrl(scanUrl, false, &isScanning, &scanName);
		if(isScanning) {
			AMErrorMon::alert(this, -333, QString("Batch calibrating: Cannot apply calibration parameters to scan '%1' because it's still acquiring data.").arg(scanName));
			continue;
		}

		if(!scan) {
			AMErrorMon::alert(this, -334, QString("Batch calibrating: Could not open the scan at '%1'. This looks like a problem in the database; please report this problem to the REIXS Acquaman developers.").arg(scanUrl.toString()));
			continue;
		}

		bool calibrationABFound = false;
		for(int i=0, cc=scan->analyzedDataSourceCount(); i<cc; ++i) {
			AM1DCalibrationAB* CalibrationAB = qobject_cast<AM1DCalibrationAB*>(scan->analyzedDataSources()->at(i));
			if(CalibrationAB) {
				calibrationABFound = true;
					CalibrationAB->setEnergyCalibrationOffset(analysisBlock_->energyCalibrationOffset());
					CalibrationAB->setEnergyCalibrationReference(analysisBlock_->energyCalibrationReference());
					CalibrationAB->setEnergyCalibrationScaling(analysisBlock_->energyCalibrationScaling());
					CalibrationAB->setToEdgeJump(analysisBlock_->toEdgeJump());
					CalibrationAB->setPreEdgePoint(analysisBlock_->preEdgePoint());
					CalibrationAB->setPostEdgePoint(analysisBlock_->postEdgePoint());
			}
		}

		if(!calibrationABFound) {
			AMErrorMon::alert(this, -335, QString("Batch calibrating: Could not find a calibration tool in the scan '%1'").arg(scan->fullName()));
		}
		else {
			scansModified++;
			scan->storeToDb(scan->database());
		}

		scan->deleteLater();	// delete scan.
	}

	progressDialog->setValue(scans.count());
	progressDialog->deleteLater();

	AMErrorMon::information(this, 0, QString("Batch Calibrating: set the calibration parameters successfully for %1 XAS scans.").arg(scansModified));
	chooseScanDialog_->close();
}