void TransformsGui::onLoadState() { MessageDialog errorDialog(guiHelper); connect(transformFactory, SIGNAL(error(QString,QString)), &errorDialog, SLOT(logError(QString))); QString fileName = QFileDialog::getOpenFileName(this,tr("Choose state file to load from"),"",tr("XML documents (*.xml);; All (*)")); if (fileName.isEmpty()) return; TransformChain talist = transformFactory->loadConfFromFile(fileName); if (talist.isEmpty()) QMessageBox::critical(this,tr("Error"),tr("The loaded chain is empty. Check the logs."),QMessageBox::Ok); else { if (errorDialog.hasMessages()) { errorDialog.setWindowTitle(tr("Error(s) while loading the state file")); if (errorDialog.exec() == QDialog::Rejected) { while (!talist.isEmpty()) delete talist.takeLast(); return; } } else { logger->logStatus(tr("File %1 loaded").arg(fileName)); } setCurrentTransformChain(talist); // not really efficient QString conf; QXmlStreamWriter writer(&conf); transformFactory->saveConfToXML(talist, &writer); emit chainChanged(conf); } }
void TransformsGui::setCurrentChainConf(const QString &conf) { if (conf.isEmpty()) return; MessageDialog errorDialog(guiHelper); connect(transformFactory, SIGNAL(error(QString,QString)), &errorDialog, SLOT(logError(QString))); QXmlStreamReader reader(conf); TransformChain talist = transformFactory->loadConfFromXML(&reader); if (talist.isEmpty()) QMessageBox::critical(this,tr("Error"),tr("The loaded chain is empty. Check the logs."),QMessageBox::Ok); else { if (errorDialog.hasMessages()) { errorDialog.setWindowTitle(tr("Error(s) while loading the configuration")); if (errorDialog.exec() == QDialog::Rejected) { while (!talist.isEmpty()) delete talist.takeLast(); return; } } setCurrentTransformChain(talist); emit chainChanged(conf); } }