本文整理汇总了C++中PropertyName::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyName::isNull方法的具体用法?C++ PropertyName::isNull怎么用?C++ PropertyName::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyName
的用法示例。
在下文中一共展示了PropertyName::isNull方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void LazyClassStructure::Initializer::setConstructor(PropertyName propertyName, JSObject* constructor)
{
RELEASE_ASSERT(structure);
RELEASE_ASSERT(prototype);
RELEASE_ASSERT(!this->constructor);
this->constructor = constructor;
prototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, constructor, DontEnum);
if (!propertyName.isNull())
global->putDirect(vm, propertyName, constructor, DontEnum);
classStructure.m_constructor.set(vm, global, constructor);
}
示例2: changeExpression
void PropertyEditorView::changeExpression(const QString &propertyName)
{
PropertyName name = propertyName.toUtf8();
if (name.isNull())
return;
if (m_locked)
return;
if (!m_selectedNode.isValid())
return;
RewriterTransaction transaction = beginRewriterTransaction(QByteArrayLiteral("PropertyEditorView::changeExpression"));
try {
PropertyName underscoreName(name);
underscoreName.replace('.', '_');
QmlObjectNode qmlObjectNode(m_selectedNode);
PropertyEditorValue *value = m_qmlBackEndForCurrentType->propertyValueForName(underscoreName);
if (!value) {
qWarning() << "PropertyEditor::changeExpression no value for " << underscoreName;
return;
}
if (qmlObjectNode.modelNode().metaInfo().isValid() && qmlObjectNode.modelNode().metaInfo().hasProperty(name)) {
if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "QColor") {
if (QColor(value->expression().remove('"')).isValid()) {
qmlObjectNode.setVariantProperty(name, QColor(value->expression().remove('"')));
transaction.commit(); //committing in the try block
return;
}
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "bool") {
if (value->expression().compare("false", Qt::CaseInsensitive) == 0 || value->expression().compare("true", Qt::CaseInsensitive) == 0) {
if (value->expression().compare("true", Qt::CaseInsensitive) == 0)
qmlObjectNode.setVariantProperty(name, true);
else
qmlObjectNode.setVariantProperty(name, false);
transaction.commit(); //committing in the try block
return;
}
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "int") {
bool ok;
int intValue = value->expression().toInt(&ok);
if (ok) {
qmlObjectNode.setVariantProperty(name, intValue);
transaction.commit(); //committing in the try block
return;
}
} else if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(name) == "qreal") {
bool ok;
qreal realValue = value->expression().toFloat(&ok);
if (ok) {
qmlObjectNode.setVariantProperty(name, realValue);
transaction.commit(); //committing in the try block
return;
}
}
}
if (value->expression().isEmpty())
return;
if (qmlObjectNode.expression(name) != value->expression() || !qmlObjectNode.propertyAffectedByCurrentState(name))
qmlObjectNode.setBindingProperty(name, value->expression());
transaction.commit(); //committing in the try block
}
catch (const RewritingException &e) {
e.showException();
}
}
示例3: changeValue
void PropertyEditorView::changeValue(const QString &name)
{
PropertyName propertyName = name.toUtf8();
if (propertyName.isNull())
return;
if (m_locked)
return;
if (propertyName == "type")
return;
if (!m_selectedNode.isValid())
return;
if (propertyName == "id") {
PropertyEditorValue *value = m_qmlBackEndForCurrentType->propertyValueForName(propertyName);
const QString newId = value->value().toString();
if (newId == m_selectedNode.id())
return;
if (m_selectedNode.isValidId(newId) && !hasId(newId)) {
m_selectedNode.setIdWithRefactoring(newId);
} else {
m_locked = true;
value->setValue(m_selectedNode.id());
m_locked = false;
if (!m_selectedNode.isValidId(newId))
Core::AsynchronousMessageBox::warning(tr("Invalid Id"), tr("%1 is an invalid id.").arg(newId));
else
Core::AsynchronousMessageBox::warning(tr("Invalid Id"), tr("%1 already exists.").arg(newId));
}
return;
}
PropertyName underscoreName(propertyName);
underscoreName.replace('.', '_');
PropertyEditorValue *value = m_qmlBackEndForCurrentType->propertyValueForName(underscoreName);
if (value ==0)
return;
QmlObjectNode qmlObjectNode(m_selectedNode);
QVariant castedValue;
if (qmlObjectNode.modelNode().metaInfo().isValid() && qmlObjectNode.modelNode().metaInfo().hasProperty(propertyName)) {
castedValue = qmlObjectNode.modelNode().metaInfo().propertyCastedValue(propertyName, value->value());
} else if (propertyIsAttachedLayoutProperty(propertyName)) {
castedValue = value->value();
} else {
qWarning() << "PropertyEditor:" <<propertyName << "cannot be casted (metainfo)";
return ;
}
if (value->value().isValid() && !castedValue.isValid()) {
qWarning() << "PropertyEditor:" << propertyName << "not properly casted (metainfo)";
return ;
}
if (qmlObjectNode.modelNode().metaInfo().isValid() && qmlObjectNode.modelNode().metaInfo().hasProperty(propertyName))
if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(propertyName) == "QUrl"
|| qmlObjectNode.modelNode().metaInfo().propertyTypeName(propertyName) == "url") { //turn absolute local file paths into relative paths
QString filePath = castedValue.toUrl().toString();
if (QFileInfo(filePath).exists() && QFileInfo(filePath).isAbsolute()) {
QDir fileDir(QFileInfo(model()->fileUrl().toLocalFile()).absolutePath());
castedValue = QUrl(fileDir.relativeFilePath(filePath));
}
}
if (castedValue.type() == QVariant::Color) {
QColor color = castedValue.value<QColor>();
QColor newColor = QColor(color.name());
newColor.setAlpha(color.alpha());
castedValue = QVariant(newColor);
}
try {
if (!value->value().isValid()) { //reset
qmlObjectNode.removeProperty(propertyName);
} else {
if (castedValue.isValid() && !castedValue.isNull()) {
m_locked = true;
qmlObjectNode.setVariantProperty(propertyName, castedValue);
m_locked = false;
}
}
}
catch (const RewritingException &e) {
e.showException();
}
}
示例4: changeValue
void PropertyEditorView::changeValue(const QString &name)
{
PropertyName propertyName = name.toUtf8();
if (propertyName.isNull())
return;
if (m_locked)
return;
if (propertyName == "type")
return;
if (!m_selectedNode.isValid())
return;
if (propertyName == "id") {
PropertyEditorValue *value = m_qmlBackEndForCurrentType->propertyValueForName(propertyName);
const QString newId = value->value().toString();
if (newId == m_selectedNode.id())
return;
if (m_selectedNode.isValidId(newId) && !modelNodeForId(newId).isValid() ) {
if (m_selectedNode.id().isEmpty() || newId.isEmpty()) { //no id
try {
m_selectedNode.setId(newId);
} catch (InvalidIdException &e) { //better save then sorry
m_locked = true;
value->setValue(m_selectedNode.id());
m_locked = false;
QMessageBox::warning(0, tr("Invalid Id"), e.description());
}
} else { //there is already an id, so we refactor
if (rewriterView())
rewriterView()->renameId(m_selectedNode.id(), newId);
}
} else {
m_locked = true;
value->setValue(m_selectedNode.id());
m_locked = false;
if (!m_selectedNode.isValidId(newId))
QMessageBox::warning(0, tr("Invalid Id"), tr("%1 is an invalid id.").arg(newId));
else
QMessageBox::warning(0, tr("Invalid Id"), tr("%1 already exists.").arg(newId));
}
return;
}
//.replace(QLatin1Char('.'), QLatin1Char('_'))
PropertyName underscoreName(propertyName);
underscoreName.replace('.', '_');
PropertyEditorValue *value = m_qmlBackEndForCurrentType->propertyValueForName(underscoreName);
if (value ==0)
return;
QmlObjectNode qmlObjectNode(m_selectedNode);
QVariant castedValue;
if (qmlObjectNode.modelNode().metaInfo().isValid() && qmlObjectNode.modelNode().metaInfo().hasProperty(propertyName)) {
castedValue = qmlObjectNode.modelNode().metaInfo().propertyCastedValue(propertyName, value->value());
} else {
qWarning() << "PropertyEditor:" <<propertyName << "cannot be casted (metainfo)";
return ;
}
if (value->value().isValid() && !castedValue.isValid()) {
qWarning() << "PropertyEditor:" << propertyName << "not properly casted (metainfo)";
return ;
}
if (qmlObjectNode.modelNode().metaInfo().isValid() && qmlObjectNode.modelNode().metaInfo().hasProperty(propertyName))
if (qmlObjectNode.modelNode().metaInfo().propertyTypeName(propertyName) == "QUrl"
|| qmlObjectNode.modelNode().metaInfo().propertyTypeName(propertyName) == "url") { //turn absolute local file paths into relative paths
QString filePath = castedValue.toUrl().toString();
if (QFileInfo(filePath).exists() && QFileInfo(filePath).isAbsolute()) {
QDir fileDir(QFileInfo(model()->fileUrl().toLocalFile()).absolutePath());
castedValue = QUrl(fileDir.relativeFilePath(filePath));
}
}
if (castedValue.type() == QVariant::Color) {
QColor color = castedValue.value<QColor>();
QColor newColor = QColor(color.name());
newColor.setAlpha(color.alpha());
castedValue = QVariant(newColor);
}
try {
if (!value->value().isValid()) { //reset
qmlObjectNode.removeProperty(propertyName);
} else {
if (castedValue.isValid() && !castedValue.isNull()) {
m_locked = true;
qmlObjectNode.setVariantProperty(propertyName, castedValue);
m_locked = false;
}
}
//.........这里部分代码省略.........