--- emuopt.cpp 2017-02-12 13:23:51.059819191 +0100 +++ emuopt.cpp 2017-03-07 01:57:07.400869534 +0100 @@ -53,6 +53,13 @@ QStringList optionChoices; QString optionPart; QString optionRelativeTo; +// String literals for QString::compare() +static const QString s_true = QStringLiteral("true"); +static const QString s_false = QStringLiteral("false"); +static const QString s_combo = QStringLiteral("combo"); +static const QString s_choice = QStringLiteral("choice"); +static const QString s_file = QStringLiteral("file"); +static const QString s_emulatorWorkingDirectory = QStringLiteral("emulatorWorkingDirectory"); #if defined(_MIN) #undef _MIN @@ -514,7 +521,7 @@ optionType = subItem->text(1); } if ( optionType == "bool" ) - defaultValue = defaultValue == tr("true") ? "true" : "false"; + defaultValue = defaultValue == tr("true") ? s_true : s_false; if ( qmc2Config->group() == settingsGroup ) { qmc2Config->endGroup(); if ( qmc2Config->contains(QMC2_EMULATOR_PREFIX + "Configuration/Global/" + optionName) ) @@ -543,9 +550,9 @@ case QMC2_EMUOPT_TYPE_BOOL: { QCheckBox *checkBoxEditor = static_cast(editor); if ( checkBoxEditor->isChecked() ) - currentValue = "true"; + currentValue = s_true; else - currentValue = "false"; + currentValue = s_false; break; } case QMC2_EMUOPT_TYPE_INT: { @@ -1201,7 +1208,7 @@ if ( xmlReader->isStartElement() ) { QString elementType(xmlReader->name().toString()); if ( choiceEntity.compare(elementType) == 0 ) { - if ( xmlReader->attributes().value("ignore").compare("true") != 0 && xmlReader->attributes().value(ignoreOS).compare("true") != 0 ) + if ( xmlReader->attributes().value("ignore").compare(s_true) != 0 && xmlReader->attributes().value(ignoreOS).compare(s_true) != 0 ) validChoices.append(xmlReader->attributes().value("name").toString()); } else readNext = false; @@ -1257,9 +1264,9 @@ if ( sectionEntity.compare(elementType) == 0 ) { bool ignore = false; if ( xmlReader.attributes().hasAttribute("ignore") ) - ignore = xmlReader.attributes().value("ignore").compare("true") == 0; + ignore = xmlReader.attributes().value("ignore").compare(s_true) == 0; if ( xmlReader.attributes().hasAttribute(ignoreOS) ) - ignore |= xmlReader.attributes().value(ignoreOS).compare("true") == 0; + ignore |= xmlReader.attributes().value(ignoreOS).compare(s_true) == 0; if ( !ignore ) { sectionTitle = readDescription(&xmlReader, lang, &readNext); templateMap[sectionTitle].clear(); @@ -1272,14 +1279,14 @@ bool wip = false; int decimals = QMC2_EMUOPT_DFLT_DECIMALS; if ( xmlReader.attributes().hasAttribute("ignore") ) - ignore = xmlReader.attributes().value("ignore").compare("true") == 0; + ignore = xmlReader.attributes().value("ignore").compare(s_true) == 0; if ( xmlReader.attributes().hasAttribute(ignoreOS) ) - ignore |= xmlReader.attributes().value(ignoreOS).compare("true") == 0; + ignore |= xmlReader.attributes().value(ignoreOS).compare(s_true) == 0; if ( xmlReader.attributes().hasAttribute("wip") ) - wip = xmlReader.attributes().value("wip").compare("true") == 0; + wip = xmlReader.attributes().value("wip").compare(s_true) == 0; if ( !ignore ) { if ( xmlReader.attributes().hasAttribute("visible") ) - visible = xmlReader.attributes().value("visible").compare("true") == 0; + visible = xmlReader.attributes().value("visible").compare(s_true) == 0; if ( xmlReader.attributes().hasAttribute("decimals") ) decimals = xmlReader.attributes().value("decimals").toString().toInt(); QString type(xmlReader.attributes().value("type").toString()); @@ -1290,17 +1297,17 @@ defaultValue = xmlReader.attributes().value("default").toString(); QString optionDescription(readDescription(&xmlReader, lang, &readNext)); optionChoices.clear(); - if ( type.compare("combo") == 0 && xmlReader.name().compare("choice") == 0 ) + if ( type.compare(s_combo) == 0 && xmlReader.name().compare(s_choice) == 0 ) optionChoices = readChoices(&xmlReader); optionPart.clear(); optionRelativeTo.clear(); - if ( type.compare("file") == 0 ) { + if ( type.compare(s_file) == 0 ) { if ( xmlReader.attributes().hasAttribute("part") ) optionPart = xmlReader.attributes().value("part").toString(); if ( xmlReader.attributes().hasAttribute("relativeTo") ) optionRelativeTo = xmlReader.attributes().value("relativeTo").toString(); if ( !optionRelativeTo.isEmpty() ) { - if ( optionRelativeTo.compare("emulatorWorkingDirectory") == 0 ) + if ( optionRelativeTo.compare(s_emulatorWorkingDirectory) == 0 ) optionDescription.append(" (" + tr("relative to the emulator's working directory") + ")"); else optionDescription.append(" (" + tr("relative to the path specified in '%1'").arg(optionRelativeTo) + ")"); @@ -1507,7 +1514,7 @@ break; case QMC2_EMUOPT_TYPE_BOOL: { assumedType = "bool"; - QString emuOpt(emuOptions[option.name] == "0" ? "false" : (emuOptions[option.name] == "1" ? "true" : emuOptions[option.name])); + QString emuOpt(emuOptions[option.name] == "0" ? s_false : (emuOptions[option.name] == "1" ? s_true : emuOptions[option.name])); if ( option.dvalue != emuOpt ) { diffCount++; if ( qmc2TemplateCheck ) {