get rid of deprecated dialogs and make them more uniform.

This commit is contained in:
2021-11-29 15:39:34 +01:00
parent e56c4bb450
commit 1fb60c0aae
22 changed files with 193 additions and 256 deletions

View File

@@ -96,7 +96,7 @@ bool PFuncXMLParser::parse(QIODevice *device)
if (fXml.hasError()) {
QString msg;
msg = QString("%1 Line %2, column %3").arg(fXml.errorString()).arg(fXml.lineNumber()).arg(fXml.columnNumber());
QMessageBox::critical(0, "**ERROR**", msg, QMessageBox::Ok, QMessageBox::NoButton);
QMessageBox::critical(nullptr, "ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return false;
}
@@ -140,7 +140,7 @@ bool PFuncXMLParser::startElement()
QXmlStreamAttributes qAttr = fXml.attributes();
if (qAttr.count() != 2) {
errMsg = QString("theo_map should have 2 attributes, called 'no', and 'name', found %1").arg(qAttr.count());
QMessageBox::critical(0, "ERROR", errMsg);
QMessageBox::critical(nullptr, "ERROR", errMsg);
return false;
}
PParam map;
@@ -149,7 +149,7 @@ bool PFuncXMLParser::startElement()
ival = str.toInt(&ok);
if (!ok) {
errMsg = QString("theo_map attribute 'no' is not a number (%1)").arg(str);
QMessageBox::critical(0, "ERROR", errMsg);
QMessageBox::critical(nullptr, "ERROR", errMsg);
return false;
}
map.setNumber(ival);
@@ -160,7 +160,7 @@ bool PFuncXMLParser::startElement()
// check that all necessary attributes where found
if ((map.getName() == "UnDef") || (map.getNumber() == -1)) {
errMsg = QString("found theo_map with missing attribute(s)");
QMessageBox::critical(0, "ERROR", errMsg);
QMessageBox::critical(nullptr, "ERROR", errMsg);
return false;
}
fTheoTemplate.appendMap(map);
@@ -168,7 +168,7 @@ bool PFuncXMLParser::startElement()
QXmlStreamAttributes qAttr = fXml.attributes();
if ((qAttr.count() != 4) && (qAttr.count() != 6)) {
errMsg = QString("template_param should have 4 or 6 attributes, called\n'no', 'name', 'value', 'step', ['boundLow', 'boundHigh'] found %1").arg(qAttr.count());
QMessageBox::critical(0, "ERROR", errMsg);
QMessageBox::critical(nullptr, "ERROR", errMsg);
return false;
}
PParam param;
@@ -177,7 +177,7 @@ bool PFuncXMLParser::startElement()
ival = str.toInt(&ok);
if (!ok) {
errMsg = QString("template_param attribute 'no' is not a number (%1)").arg(str);
QMessageBox::critical(0, "ERROR", errMsg);
QMessageBox::critical(nullptr, "ERROR", errMsg);
return false;
}
param.setNumber(ival);
@@ -189,7 +189,7 @@ bool PFuncXMLParser::startElement()
dval = str.toDouble(&ok);
if (!ok) {
errMsg = QString("template_param attribute 'value' is not a number (%1)").arg(str);
QMessageBox::critical(0, "ERROR", errMsg);
QMessageBox::critical(nullptr, "ERROR", errMsg);
return false;
}
param.setValue(dval);
@@ -198,7 +198,7 @@ bool PFuncXMLParser::startElement()
dval = str.toDouble(&ok);
if (!ok) {
errMsg = QString("template_param attribute 'step' is not a number (%1)").arg(str);
QMessageBox::critical(0, "ERROR", errMsg);
QMessageBox::critical(nullptr, "ERROR", errMsg);
return false;
}
param.setStep(dval);
@@ -378,7 +378,7 @@ bool PInstrumentDefXMLParser::parse(QIODevice *device)
if (fXml.hasError()) {
QString msg;
msg = QString("%1 Line %2, column %3").arg(fXml.errorString()).arg(fXml.lineNumber()).arg(fXml.columnNumber());
QMessageBox::critical(0, "**ERROR**", msg, QMessageBox::Ok, QMessageBox::NoButton);
QMessageBox::critical(nullptr, "ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return false;
}
@@ -419,12 +419,12 @@ bool PInstrumentDefXMLParser::startElement()
QXmlStreamAttributes qAttr = fXml.attributes();
if (qAttr.count() != 1) {
errMsg = QString("instrument should have 1 attribute, called 'name', found %1").arg(qAttr.count());
QMessageBox::critical(0, "ERROR", errMsg);
QMessageBox::critical(nullptr, "ERROR", errMsg);
return false;
}
if (fInstituteName == "") {
errMsg = QString("found instrument without institute set.");
QMessageBox::critical(0, "ERROR", errMsg);
QMessageBox::critical(nullptr, "ERROR", errMsg);
return false;
}
// create an instrument object
@@ -633,13 +633,13 @@ bool PInstrumentDefXMLParser::characters()
case eNoOfDetectors:
if (fSetup == 0) {
errMsg = "setup object not found.";
QMessageBox::critical(0, "ERROR", errMsg);
QMessageBox::critical(nullptr, "ERROR", errMsg);
return false;
}
ival = str.toInt(&ok);
if (!ok) {
errMsg = QString("Setup Error: No of Detectors = '%1', which is not an int.").arg(str);
QMessageBox::critical(0, "ERROR", errMsg);
QMessageBox::critical(nullptr, "ERROR", errMsg);
return false;
}
fSetup->setNoOfDetectors(ival);
@@ -664,7 +664,7 @@ bool PInstrumentDefXMLParser::characters()
strList = str.split(' ', Qt::SkipEmptyParts);
if (strList.size() != 2) {
errMsg = QString("Found wrong Asymmetry background range: '%1'").arg(str);
QMessageBox::critical(0, "ERROR", errMsg);
QMessageBox::critical(nullptr, "ERROR", errMsg);
return false;
}
start = strList[0].toInt(&ok);
@@ -692,7 +692,7 @@ bool PInstrumentDefXMLParser::characters()
bool PInstrumentDefXMLParser::endDocument()
{
if (fInstituteName == "") {
QMessageBox::critical(0, "FATAL ERROR", "Didn't find any institute name in the instrument definitions.");
QMessageBox::critical(nullptr, "FATAL ERROR", "Didn't find any institute name in the instrument definitions.");
return false;
}
@@ -765,7 +765,7 @@ bool PMusrWizDefaultXMLParser::parse(QIODevice *device)
if (fXml.hasError()) {
QString msg;
msg = QString("%1 Line %2, column %3").arg(fXml.errorString()).arg(fXml.lineNumber()).arg(fXml.columnNumber());
QMessageBox::critical(0, "**ERROR**", msg, QMessageBox::Ok, QMessageBox::NoButton);
QMessageBox::critical(nullptr, "ERROR", msg, QMessageBox::Ok, QMessageBox::NoButton);
return false;
}
@@ -876,7 +876,7 @@ PAdmin::PAdmin() : QObject()
path = std::getenv("HOME");
pathFln = path + "/.musrfit/musrWiz/musrWiz.xml";
if (loadMusrWizDefault(pathFln)) {
QMessageBox::warning(0, "WARNING", "Couldn't find musrWiz.xml file.");
QMessageBox::warning(nullptr, "WARNING", "Couldn't find musrWiz.xml file.");
}
}
@@ -889,7 +889,7 @@ PAdmin::PAdmin() : QObject()
pathFln = path + "/.musrfit/musrWiz/musrfit_funcs.xml";
if (loadMusrfitFunc(pathFln)) {
fValid = false;
QMessageBox::critical(0, "FATAL ERROR", "Couldn't find any musrfit function definitions.");
QMessageBox::critical(nullptr, "FATAL ERROR", "Couldn't find any musrfit function definitions.");
return;
}
}
@@ -918,7 +918,7 @@ PAdmin::PAdmin() : QObject()
}
if (count == 0) {
QMessageBox::critical(0, "FATAL ERROR", "Couldn't find any instrument definition.");
QMessageBox::critical(nullptr, "FATAL ERROR", "Couldn't find any instrument definition.");
fValid = false;
}
}
@@ -1215,7 +1215,7 @@ int PAdmin::loadMusrWizDefault(QString fln)
cout << "**INFO** '" << pathName.toLatin1().data() << "' did not exist, hence it is created." << endl;
} else {
QString msg = QString("Couldn't create '%1'. Please check.").arg(pathName);
QMessageBox::critical(0, "ERROR", msg);
QMessageBox::critical(nullptr, "ERROR", msg);
return 1;
}
}
@@ -1224,7 +1224,7 @@ int PAdmin::loadMusrWizDefault(QString fln)
PMusrWizDefaultXMLParser handler(fln, this);
if (!handler.isValid()) {
QString errMsg = QString("Error parsing %1 file.").arg(fln);
QMessageBox::critical(0, "ERROR", errMsg);
QMessageBox::critical(nullptr, "ERROR", errMsg);
return 1;
}
return 0;
@@ -1248,7 +1248,7 @@ int PAdmin::loadMusrfitFunc(QString fln)
cout << "**INFO** '" << pathName.toLatin1().data() << "' did not exist, hence it is created." << endl;
} else {
QString msg = QString("Couldn't create '%1'. Please check.").arg(pathName);
QMessageBox::critical(0, "ERROR", msg);
QMessageBox::critical(nullptr, "ERROR", msg);
return 1;
}
}
@@ -1257,7 +1257,7 @@ int PAdmin::loadMusrfitFunc(QString fln)
PFuncXMLParser handler(fln, this);
if (!handler.isValid()) {
QString errMsg = QString("Error parsing %1 musrfit func file.").arg(fln);
QMessageBox::critical(0, "ERROR", errMsg);
QMessageBox::critical(nullptr, "ERROR", errMsg);
return 1;
}
return 0;
@@ -1286,7 +1286,7 @@ int PAdmin::loadInstrumentDef(QString path, QString fln)
cout << "**INFO** '" << pathName.toLatin1().data() << "' did not exist, hence it is created." << endl;
} else {
QString msg = QString("Couldn't create '%1'. Please check.").arg(pathName);
QMessageBox::critical(0, "ERROR", msg);
QMessageBox::critical(nullptr, "ERROR", msg);
return 1;
}
} else {
@@ -1297,7 +1297,7 @@ int PAdmin::loadInstrumentDef(QString path, QString fln)
PInstrumentDefXMLParser handler(pathFln, this);
if (!handler.isValid()) {
QString errMsg = QString("Error parsing %1 instrument def file.").arg(pathFln);
QMessageBox::critical(0, "ERROR", errMsg);
QMessageBox::critical(nullptr, "ERROR", errMsg);
return 1;
}

View File

@@ -553,7 +553,7 @@ void PIntroPage::handleFitType(int idx)
{
if ( (idx != FIT_TYPE_SINGLE_HISTO) &&
(idx != FIT_TYPE_ASYMMETRY) ){
QMessageBox::warning(0, "WARNING", "Currently only fit type: single histo and asymmetry available.");
QMessageBox::warning(this, "WARNING", "Currently only fit type: single histo and asymmetry available.");
fFitType->setCurrentIndex(FIT_TYPE_SINGLE_HISTO);
}
}
@@ -580,7 +580,7 @@ void PIntroPage::checkSetup(int idx)
case MEASURE_LF:
setup = instru->getLFSetups();
measure = "LF";
QMessageBox::information(0, "INFO", "Not yet implemented.");
QMessageBox::information(this, "INFO", "Not yet implemented.");
break;
case MEASURE_UNDEF:
default:
@@ -589,7 +589,7 @@ void PIntroPage::checkSetup(int idx)
if (setup.size() == 0) {
QString msg = QString("Didn't find any setup for:\nInstitute: %1\nInstrument: %2").arg(fInstitute->currentText()).arg(fInstrument->currentText());
QMessageBox::critical(0, "ERROR", msg);
QMessageBox::critical(this, "ERROR", msg);
return;
} else if (setup.size() == 1) {
if (setup[0].getName() == "Default") {
@@ -907,7 +907,7 @@ void PTheoPage::checkTheory()
ok = analyzeTokens(line[i], 0);
if (!ok) {
QString str = QString("**ERROR** in line %1.\n funX takes no parameter.").arg(i+1);
QMessageBox::critical(0, "Check Theory", str);
QMessageBox::critical(this, "Check Theory", str);
// eventually it would be nice to highlight the faulty line
return;
}
@@ -915,7 +915,7 @@ void PTheoPage::checkTheory()
ok = analyzeTokens(line[i], 0);
if (!ok) {
QString str = QString("**ERROR** in line %1.\n mapX takes no parameter.").arg(i+1);
QMessageBox::critical(0, "Check Theory", str);
QMessageBox::critical(this, "Check Theory", str);
// eventually it would be nice to highlight the faulty line
return;
}
@@ -924,14 +924,14 @@ void PTheoPage::checkTheory()
func = fAdmin->getMusrfitFunc(strList[0]);
if (func.getName() == "UnDef") { // function not found
QString str = QString("**ERROR** in line %1, '%2' is not a recognized musrfit function.").arg(i+1).arg(line[i]);
QMessageBox::critical(0, "Check Theory", str);
QMessageBox::critical(this, "Check Theory", str);
// eventually it would be nice to highlight the faulty line
return;
}
ok = analyzeTokens(line[i], func.getNoOfParam());
if (!ok) {
QString str = QString("**ERROR** in line %1.\n %2 takes %3 parameter.").arg(i+1).arg(func.getName()).arg(func.getNoOfParam());
QMessageBox::critical(0, "Check Theory", str);
QMessageBox::critical(this, "Check Theory", str);
// eventually it would be nice to highlight the faulty line
return;
}
@@ -952,7 +952,7 @@ void PTheoPage::checkTheory()
QObject *obj = sender();
if (obj == fCheckTheo)
QMessageBox::information(0, "Check Theory", "Theory seems to be OK.");
QMessageBox::information(this, "Check Theory", "Theory seems to be OK.");
}
//-------------------------------------------------------------------------
@@ -1013,7 +1013,7 @@ bool PTheoPage::analyzeTokens(QString str, int noOfTokens)
dealWithMap(tok[0], stokNo, 0);
} else {
QString msg = QString("Found map of the form '%1'.\nThis is NOT a legal map!").arg(tok[0]);
QMessageBox::critical(0, "analyzeTokens", msg);
QMessageBox::critical(this, "analyzeTokens", msg);
return false;
}
} else if (tok[0].startsWith("fun")) {
@@ -1024,7 +1024,7 @@ bool PTheoPage::analyzeTokens(QString str, int noOfTokens)
dealWithFun(stokNo);
} else {
QString msg = QString("Found fun of the form '%1'.\nThis is NOT a legal function!").arg(tok[0]);
QMessageBox::critical(0, "analyzeTokens", msg);
QMessageBox::critical(this, "analyzeTokens", msg);
return false;
}
}
@@ -1043,7 +1043,7 @@ bool PTheoPage::analyzeTokens(QString str, int noOfTokens)
dealWithParam(tok[0], paramNo, i);
} else if (!tok[i].startsWith("map") && !tok[i].startsWith("fun")) {
QString msg = QString("Found parameter of the form '%1'.\nThis is NOT a legal parameter!").arg(tok[i]);
QMessageBox::critical(0, "analyzeTokens", msg);
QMessageBox::critical(this, "analyzeTokens", msg);
return false;
}
}
@@ -1060,7 +1060,7 @@ bool PTheoPage::analyzeTokens(QString str, int noOfTokens)
dealWithMap(tok[0], mapNo, i);
} else {
QString msg = QString("Found map of the form '%1'.\nThis is NOT a legal map!").arg(tok[i]);
QMessageBox::critical(0, "analyzeTokens", msg);
QMessageBox::critical(this, "analyzeTokens", msg);
return false;
}
}
@@ -1078,7 +1078,7 @@ bool PTheoPage::analyzeTokens(QString str, int noOfTokens)
dealWithFun(funNo);
} else {
QString msg = QString("Found function of the form '%1'.\nThis is NOT a legal function!").arg(tok[i]);
QMessageBox::critical(0, "analyzeTokens", msg);
QMessageBox::critical(this, "analyzeTokens", msg);
return false;
}
}
@@ -2015,7 +2015,7 @@ int PMusrWiz::writeMsrFile(int result)
// no msr-file name given, hence generate it
if (fMsrData->getMsrFileName() == QString("")) {
if (fMsrData->getRunNumber() == -1) {
QMessageBox::critical(0, "ERROR", "No run number given! Won't do anything.");
QMessageBox::critical(this, "ERROR", "No run number given! Won't do anything.");
return -2;
}
fMsrData->setMsrFileName(QString("%1").arg(fMsrData->getRunNumber()));
@@ -2062,7 +2062,7 @@ int PMusrWiz::writeMsrFileSingleHisto()
QFile fln(pathFileName);
if (!fln.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::critical(0, "ERROR", "Cannot open file for writting.");
QMessageBox::critical(this, "ERROR", "Cannot open file for writting.");
return -3;
}
@@ -2104,7 +2104,7 @@ int PMusrWiz::writeMsrFileSingleHisto()
PInstrument *instru = fAdmin->getInstrument(fMsrData->getInstitute(), fMsrData->getInstrument());
if (instru == 0) {
QString msg = QString("No setups found for %1: %2").arg(fMsrData->getInstitute(), fMsrData->getInstrument());
QMessageBox::critical(0, "ERROR", msg);
QMessageBox::critical(this, "ERROR", msg);
return -4;
}
PSetup *setup = 0;
@@ -2124,7 +2124,7 @@ int PMusrWiz::writeMsrFileSingleHisto()
}
if (setup == 0) {
QString msg = QString("No setups found for %1: %2: %3").arg(fMsrData->getInstitute(), fMsrData->getInstrument()).arg(fMsrData->getSetup());
QMessageBox::critical(0, "ERROR", msg);
QMessageBox::critical(this, "ERROR", msg);
return -5;
}
int noOfDetec = setup->getNoOfLogicalDetectors();
@@ -2295,7 +2295,7 @@ int PMusrWiz::writeMsrFileAsymmetry()
QFile fln(pathFileName);
if (!fln.open(QIODevice::WriteOnly | QIODevice::Text)) {
QMessageBox::critical(0, "ERROR", "Cannot open file for writting.");
QMessageBox::critical(this, "ERROR", "Cannot open file for writting.");
return -3;
}
@@ -2337,7 +2337,7 @@ int PMusrWiz::writeMsrFileAsymmetry()
PInstrument *instru = fAdmin->getInstrument(fMsrData->getInstitute(), fMsrData->getInstrument());
if (instru == 0) {
QString msg = QString("No setups found for %1: %2").arg(fMsrData->getInstitute(), fMsrData->getInstrument());
QMessageBox::critical(0, "ERROR", msg);
QMessageBox::critical(this, "ERROR", msg);
return -4;
}
PSetup *setup = 0;
@@ -2357,7 +2357,7 @@ int PMusrWiz::writeMsrFileAsymmetry()
}
if (setup == 0) {
QString msg = QString("No setups found for %1: %2: %3").arg(fMsrData->getInstitute(), fMsrData->getInstrument()).arg(fMsrData->getSetup());
QMessageBox::critical(0, "ERROR", msg);
QMessageBox::critical(this, "ERROR", msg);
return -5;
}
int noOfDetec = setup->getNoOfLogicalAsymDetectors();
@@ -2579,5 +2579,5 @@ QString PMusrWiz::getRunName(PInstrument *instru)
*/
void PMusrWiz::help()
{
QMessageBox::information(0, "Help", "Eventually there will be a help here.");
QMessageBox::information(this, "Help", "Eventually there will be a help here.");
}

View File

@@ -132,7 +132,7 @@ int main(int argc, char *argv[])
arguments << pathFln;
QProcess::startDetached(musrt0, arguments, "./");
} else {
QMessageBox::warning(0, "WARNING", "Couldn't find musrt0 :-(.\n Only the msr-file has been generated.");
QMessageBox::warning(nullptr, "WARNING", "Couldn't find musrt0 :-(.\n Only the msr-file has been generated.");
}
}
}