Prefer to use BaseClass's isDerivedFrom<T> over non template or Base::Type's
Regex based changes, manually verified
This commit is contained in:
@@ -1093,11 +1093,11 @@ std::string Cell::getFormattedQuantity()
|
||||
App::CellAddress thisCell = getAddress();
|
||||
Property* prop = owner->sheet()->getPropertyByName(thisCell.toString().c_str());
|
||||
|
||||
if (prop->isDerivedFrom(App::PropertyString::getClassTypeId())) {
|
||||
if (prop->isDerivedFrom<App::PropertyString>()) {
|
||||
const App::PropertyString* stringProp = static_cast<const App::PropertyString*>(prop);
|
||||
qFormatted = QString::fromUtf8(stringProp->getValue());
|
||||
}
|
||||
else if (prop->isDerivedFrom(App::PropertyQuantity::getClassTypeId())) {
|
||||
else if (prop->isDerivedFrom<App::PropertyQuantity>()) {
|
||||
double rawVal = static_cast<App::PropertyQuantity*>(prop)->getValue();
|
||||
const App::PropertyQuantity* floatProp = static_cast<const App::PropertyQuantity*>(prop);
|
||||
DisplayUnit du;
|
||||
@@ -1113,7 +1113,7 @@ std::string Cell::getFormattedQuantity()
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (prop->isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
|
||||
else if (prop->isDerivedFrom<App::PropertyFloat>()) {
|
||||
double rawVal = static_cast<const App::PropertyFloat*>(prop)->getValue();
|
||||
DisplayUnit du;
|
||||
bool hasDisplayUnit = getDisplayUnit(du);
|
||||
@@ -1125,7 +1125,7 @@ std::string Cell::getFormattedQuantity()
|
||||
qFormatted = number + QString::fromStdString(" " + displayUnit.stringRep);
|
||||
}
|
||||
}
|
||||
else if (prop->isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
|
||||
else if (prop->isDerivedFrom<App::PropertyInteger>()) {
|
||||
double rawVal = static_cast<const App::PropertyInteger*>(prop)->getValue();
|
||||
DisplayUnit du;
|
||||
bool hasDisplayUnit = getDisplayUnit(du);
|
||||
|
||||
@@ -1387,7 +1387,7 @@ void PropertySheet::addDependencies(CellAddress key)
|
||||
cellToPropertyNameMap[key].insert(propName);
|
||||
|
||||
// Also an alias?
|
||||
if (!name.empty() && docObj->isDerivedFrom(Sheet::getClassTypeId())) {
|
||||
if (!name.empty() && docObj->isDerivedFrom<Sheet>()) {
|
||||
auto other = static_cast<Sheet*>(docObj);
|
||||
auto j = other->cells.revAliasProp.find(name);
|
||||
|
||||
@@ -2063,7 +2063,7 @@ PropertySheet::BindingType PropertySheet::getBinding(const Range& range,
|
||||
path << ObjectIdentifier::SimpleComponent(range.from().toString().c_str());
|
||||
path << ObjectIdentifier::SimpleComponent(range.to().toString().c_str());
|
||||
auto res = owner->getExpression(path);
|
||||
if (res.expression && res.expression->isDerivedFrom(FunctionExpression::getClassTypeId())) {
|
||||
if (res.expression && res.expression->isDerivedFrom<FunctionExpression>()) {
|
||||
auto expr = static_cast<FunctionExpression*>(res.expression.get());
|
||||
if (href) {
|
||||
if ((expr->getFunction() != FunctionExpression::HIDDENREF
|
||||
|
||||
@@ -72,14 +72,14 @@ DlgBindSheet::DlgBindSheet(Sheet* sheet, const std::vector<Range>& ranges, QWidg
|
||||
ui->lineEditFromEnd->setReadOnly(true);
|
||||
ui->checkBoxHREF->setChecked(type == PropertySheet::BindingHiddenRef);
|
||||
assert(pStart && pEnd);
|
||||
if (!pStart->hasComponent() && pStart->isDerivedFrom(StringExpression::getClassTypeId())) {
|
||||
if (!pStart->hasComponent() && pStart->isDerivedFrom<StringExpression>()) {
|
||||
toStart = static_cast<StringExpression*>(pStart.get())->getText();
|
||||
}
|
||||
else {
|
||||
toStart = "=";
|
||||
toStart += pStart->toString();
|
||||
}
|
||||
if (!pEnd->hasComponent() && pEnd->isDerivedFrom(StringExpression::getClassTypeId())) {
|
||||
if (!pEnd->hasComponent() && pEnd->isDerivedFrom<StringExpression>()) {
|
||||
toEnd = static_cast<StringExpression*>(pEnd.get())->getText();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -130,7 +130,7 @@ App::Property* DlgSheetConf::prepare(CellAddress& from,
|
||||
auto prop = path.getProperty(&pseudoType);
|
||||
if (pseudoType
|
||||
|| (prop
|
||||
&& (!prop->isDerivedFrom(App::PropertyEnumeration::getClassTypeId())
|
||||
&& (!prop->isDerivedFrom<App::PropertyEnumeration>()
|
||||
|| !prop->testStatus(App::Property::PropDynamic)))) {
|
||||
FC_THROWM(Base::RuntimeError, "Invalid property referenced in: " << expr->toString());
|
||||
}
|
||||
@@ -140,7 +140,7 @@ App::Property* DlgSheetConf::prepare(CellAddress& from,
|
||||
Cell* cell = sheet->getCell(from);
|
||||
if (cell && cell->getExpression()) {
|
||||
auto expr = cell->getExpression();
|
||||
if (expr->isDerivedFrom(FunctionExpression::getClassTypeId())) {
|
||||
if (expr->isDerivedFrom<FunctionExpression>()) {
|
||||
auto fexpr = Base::freecad_dynamic_cast<FunctionExpression>(cell->getExpression());
|
||||
if (fexpr
|
||||
&& (fexpr->getFunction() == FunctionExpression::HREF
|
||||
@@ -184,7 +184,7 @@ void DlgSheetConf::accept()
|
||||
auto cell = sheet->getCell(*r);
|
||||
if (cell && cell->getExpression()) {
|
||||
ExpressionPtr expr(cell->getExpression()->eval());
|
||||
if (expr->isDerivedFrom(StringExpression::getClassTypeId())) {
|
||||
if (expr->isDerivedFrom<StringExpression>()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const
|
||||
return {};
|
||||
}
|
||||
}
|
||||
else if (prop->isDerivedFrom(App::PropertyString::getClassTypeId())) {
|
||||
else if (prop->isDerivedFrom<App::PropertyString>()) {
|
||||
/* String */
|
||||
const App::PropertyString* stringProp = static_cast<const App::PropertyString*>(prop);
|
||||
|
||||
@@ -321,7 +321,7 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const
|
||||
return {};
|
||||
}
|
||||
}
|
||||
else if (prop->isDerivedFrom(App::PropertyQuantity::getClassTypeId())) {
|
||||
else if (prop->isDerivedFrom<App::PropertyQuantity>()) {
|
||||
/* Number */
|
||||
const App::PropertyQuantity* floatProp = static_cast<const App::PropertyQuantity*>(prop);
|
||||
|
||||
@@ -386,13 +386,13 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const
|
||||
return {};
|
||||
}
|
||||
}
|
||||
else if (prop->isDerivedFrom(App::PropertyFloat::getClassTypeId())
|
||||
|| prop->isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
|
||||
else if (prop->isDerivedFrom<App::PropertyFloat>()
|
||||
|| prop->isDerivedFrom<App::PropertyInteger>()) {
|
||||
/* Number */
|
||||
double d {};
|
||||
long l {};
|
||||
bool isInteger = false;
|
||||
if (prop->isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
|
||||
if (prop->isDerivedFrom<App::PropertyFloat>()) {
|
||||
d = static_cast<const App::PropertyFloat*>(prop)->getValue();
|
||||
}
|
||||
else {
|
||||
@@ -454,7 +454,7 @@ QVariant SheetModel::data(const QModelIndex& index, int role) const
|
||||
return {};
|
||||
}
|
||||
}
|
||||
else if (prop->isDerivedFrom(App::PropertyPythonObject::getClassTypeId())) {
|
||||
else if (prop->isDerivedFrom<App::PropertyPythonObject>()) {
|
||||
auto pyProp = static_cast<const App::PropertyPythonObject*>(prop);
|
||||
|
||||
switch (role) {
|
||||
|
||||
Reference in New Issue
Block a user