本文整理汇总了C++中PropertyEditorValue::value方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyEditorValue::value方法的具体用法?C++ PropertyEditorValue::value怎么用?C++ PropertyEditorValue::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyEditorValue
的用法示例。
在下文中一共展示了PropertyEditorValue::value方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: changeValue
void PropertyEditorNodeWrapper::changeValue(const QString &name)
{
if (name.isNull())
return;
if (m_modelNode.isValid()) {
QmlDesigner::QmlObjectNode fxObjectNode(m_modelNode);
PropertyEditorValue *valueObject = qvariant_cast<PropertyEditorValue *>(m_valuesPropertyMap.value(name));
if (valueObject->value().isValid())
fxObjectNode.setVariantProperty(name, valueObject->value());
else
fxObjectNode.removeVariantProperty(name);
}
}
示例2: changeValue
void PropertyEditorNodeWrapper::changeValue(const QString &propertyName)
{
const QmlDesigner::PropertyName name = propertyName.toUtf8();
if (name.isNull())
return;
if (m_modelNode.isValid()) {
QmlDesigner::QmlObjectNode qmlObjectNode(m_modelNode);
PropertyEditorValue *valueObject = qvariant_cast<PropertyEditorValue *>(m_valuesPropertyMap.value(QString::fromLatin1(name)));
if (valueObject->value().isValid())
qmlObjectNode.setVariantProperty(name, valueObject->value());
else
qmlObjectNode.removeProperty(name);
}
}
示例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;
}
}
//.........这里部分代码省略.........