bool PropertyList::property2Vector(const QString &aPropertyName, Vector *aPosition, bool useDefault) const { QString myValue = getPropertyNoDefault(aPropertyName).trimmed(); if (myValue.isEmpty() && useDefault == false) return false; Vector myVector; bool isOK = myVector.fromString(myValue); if (isOK) { *aPosition = myVector; return true; } myValue = getDefaultProperty(aPropertyName).trimmed(); if (myValue.isEmpty()) return false; isOK = myVector.fromString(myValue); if (isOK) { *aPosition = myVector; return true; } return false; }
CString DLrtfhtml::beginChange(CString rtfPath) { openfile(rtfPath); readfontgroup(); readcolor(); getDefaultProperty(); return toHtmlTag(); }
bool PropertyList::property2String(const QString &aPropertyName, QString *aString, bool useDefault) const { QString myValue = getPropertyNoDefault(aPropertyName); if (myValue.isEmpty()) { if (useDefault == false) return false; myValue = getDefaultProperty(aPropertyName); if (myValue.isEmpty()) return false; } *aString = myValue; return true; }
bool PropertyList::property2Bool(const QString &aPropertyName, bool *aBool, bool useDefault) const { bool myResult; // we run two passes here: // 1) use getPropertyNoDefault // 2) use getDefaultProperty // 3) a third pass indicates trouble and we return false int myPass = 1; QString myValue = getPropertyNoDefault(aPropertyName).toLower().trimmed(); while (myPass < 3) { if (myValue.isEmpty() && useDefault == false) return false; // if myValue is empty, none of these will ever trigger // if myValue is nonempty and we parse, we're happy if (myValue == "true") { myResult = true; break; } if (myValue == "yes") { myResult = true; break; } if (myValue == "false") { myResult = false; break; } if (myValue == "no") { myResult = false; break; } // ok, myValue was empty or unparsed. let's get the // default and go again... myValue = getDefaultProperty(aPropertyName).toLower(); myPass++; } if (myPass >= 3) return false; *aBool = myResult; return true; }
bool PropertyList::property2Float(const QString &aPropertyName, float *aFloat, bool useDefault) const { QString myValue = getPropertyNoDefault(aPropertyName); if (myValue.isEmpty() && useDefault == false) return false; bool isOK = false; float myFloat = myValue.toFloat(&isOK); if (isOK == false) { myFloat = getDefaultProperty(aPropertyName).toFloat(&isOK); if (isOK == false) return false; } *aFloat = myFloat; return true; }