本文整理汇总了C++中PropertyEditorValue类的典型用法代码示例。如果您正苦于以下问题:C++ PropertyEditorValue类的具体用法?C++ PropertyEditorValue怎么用?C++ PropertyEditorValue使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PropertyEditorValue类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setValue
void PropertyEditorQmlBackend::setValue(const QmlObjectNode & qmlObjectNode, const PropertyName &name, const QVariant &value)
{
PropertyName propertyName = name;
propertyName.replace('.', '_');
PropertyEditorValue *propertyValue = qobject_cast<PropertyEditorValue*>(variantToQObject(m_backendValuesPropertyMap.value(propertyName)));
if (propertyValue) {
propertyValue->setValue(value);
if (!qmlObjectNode.hasBindingProperty(name))
propertyValue->setExpression(value.toString());
else
propertyValue->setExpression(qmlObjectNode.expression(name));
}
}
示例2: QLatin1Char
void PropertyEditor::NodeType::setValue(const QmlObjectNode & fxObjectNode, const QString &name, const QVariant &value)
{
QString propertyName = name;
propertyName.replace(QLatin1Char('.'), QLatin1Char('_'));
PropertyEditorValue *propertyValue = qobject_cast<PropertyEditorValue*>(variantToQObject(m_backendValuesPropertyMap.value(propertyName)));
if (propertyValue) {
propertyValue->setValue(value);
if (!fxObjectNode.hasBindingProperty(name))
propertyValue->setExpression(value.toString());
else
propertyValue->setExpression(fxObjectNode.expression(name));
}
}
示例3: fxObjectNode
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);
}
}
示例4: qmlObjectNode
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);
}
}
示例5: propertyName
void PropertyEditorQmlBackend::createPropertyEditorValue(const QmlObjectNode &qmlObjectNode,
const PropertyName &name,
const QVariant &value,
PropertyEditorView *propertyEditor)
{
PropertyName propertyName(name);
propertyName.replace('.', '_');
PropertyEditorValue *valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(backendValuesPropertyMap().value(propertyName)));
if (!valueObject) {
valueObject = new PropertyEditorValue(&backendValuesPropertyMap());
QObject::connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), &backendValuesPropertyMap(), SIGNAL(valueChanged(QString,QVariant)));
QObject::connect(valueObject, SIGNAL(expressionChanged(QString)), propertyEditor, SLOT(changeExpression(QString)));
backendValuesPropertyMap().insert(QString::fromUtf8(propertyName), QVariant::fromValue(valueObject));
}
valueObject->setName(name);
valueObject->setModelNode(qmlObjectNode);
if (qmlObjectNode.propertyAffectedByCurrentState(name) && !(qmlObjectNode.modelNode().property(name).isBindingProperty()))
valueObject->setValue(qmlObjectNode.modelValue(name));
else
valueObject->setValue(value);
if (propertyName != "id" &&
qmlObjectNode.currentState().isBaseState() &&
qmlObjectNode.modelNode().property(propertyName).isBindingProperty()) {
valueObject->setExpression(qmlObjectNode.modelNode().bindingProperty(propertyName).expression());
} else {
valueObject->setExpression(qmlObjectNode.instanceValue(name).toString());
}
}
示例6: createPropertyEditorValue
void createPropertyEditorValue(const QmlObjectNode &fxObjectNode, const QString &name, const QVariant &value, QDeclarativePropertyMap *propertyMap, PropertyEditor *propertyEditor)
{
QString propertyName(name);
propertyName.replace(QLatin1Char('.'), QLatin1Char('_'));
PropertyEditorValue *valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(propertyMap->value(propertyName)));
if (!valueObject) {
valueObject = new PropertyEditorValue(propertyMap);
QObject::connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), propertyMap, SIGNAL(valueChanged(QString,QVariant)));
QObject::connect(valueObject, SIGNAL(expressionChanged(QString)), propertyEditor, SLOT(changeExpression(QString)));
propertyMap->insert(propertyName, QVariant::fromValue(valueObject));
}
valueObject->setName(name);
valueObject->setModelNode(fxObjectNode);
if (fxObjectNode.propertyAffectedByCurrentState(name) && !(fxObjectNode.modelNode().property(name).isBindingProperty())) {
valueObject->setValue(fxObjectNode.modelValue(name));
} else {
valueObject->setValue(value);
}
if (propertyName != QLatin1String("id") &&
fxObjectNode.currentState().isBaseState() &&
fxObjectNode.modelNode().property(propertyName).isBindingProperty()) {
valueObject->setExpression(fxObjectNode.modelNode().bindingProperty(propertyName).expression());
} else {
valueObject->setExpression(fxObjectNode.instanceValue(name).toString());
}
}
示例7: setupPropertyEditorValue
void setupPropertyEditorValue(const PropertyName &name, QDeclarativePropertyMap *propertyMap, PropertyEditor *propertyEditor, const QString &type)
{
QmlDesigner::PropertyName propertyName(name);
propertyName.replace('.', '_');
PropertyEditorValue *valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(propertyMap->value(propertyName)));
if (!valueObject) {
valueObject = new PropertyEditorValue(propertyMap);
QObject::connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), propertyMap, SIGNAL(valueChanged(QString,QVariant)));
QObject::connect(valueObject, SIGNAL(expressionChanged(QString)), propertyEditor, SLOT(changeExpression(QString)));
propertyMap->insert(QString::fromUtf8(propertyName), QVariant::fromValue(valueObject));
}
valueObject->setName(propertyName);
if (type == "QColor")
valueObject->setValue(QVariant("#000000"));
else
valueObject->setValue(QVariant(1));
}
示例8: Q_ASSERT
void PropertyEditorNodeWrapper::setup()
{
Q_ASSERT(m_editorValue);
Q_ASSERT(m_editorValue->modelNode().isValid());
if ((m_editorValue->modelNode().isValid() && m_modelNode.isValid())) {
QmlDesigner::QmlObjectNode fxObjectNode(m_modelNode);
foreach ( const QString &propertyName, m_valuesPropertyMap.keys())
m_valuesPropertyMap.clear(propertyName);
foreach (QObject *object, m_valuesPropertyMap.children())
delete object;
foreach (const QString &propertyName, m_modelNode.metaInfo().propertyNames()) {
if (fxObjectNode.isValid()) {
PropertyEditorValue *valueObject = new PropertyEditorValue(&m_valuesPropertyMap);
valueObject->setName(propertyName);
valueObject->setValue(fxObjectNode.instanceValue(propertyName));
connect(valueObject, SIGNAL(valueChanged(QString, const QVariant&)), &m_valuesPropertyMap, SIGNAL(valueChanged(QString, const QVariant&)));
m_valuesPropertyMap.insert(propertyName, QVariant::fromValue(valueObject));
}
}
示例9: foreach
void PropertyEditor::NodeType::setup(const QmlObjectNode &fxObjectNode, const QString &stateName, const QUrl &qmlSpecificsFile, PropertyEditor *propertyEditor)
{
if (!fxObjectNode.isValid())
return;
QDeclarativeContext *ctxt = m_view->rootContext();
if (fxObjectNode.isValid()) {
foreach (const PropertyName &propertyName, fxObjectNode.modelNode().metaInfo().propertyNames())
createPropertyEditorValue(fxObjectNode, propertyName, fxObjectNode.instanceValue(propertyName), &m_backendValuesPropertyMap, propertyEditor);
// className
PropertyEditorValue *valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(m_backendValuesPropertyMap.value("className")));
if (!valueObject)
valueObject = new PropertyEditorValue(&m_backendValuesPropertyMap);
valueObject->setName("className");
valueObject->setModelNode(fxObjectNode.modelNode());
valueObject->setValue(fxObjectNode.modelNode().simplifiedTypeName());
QObject::connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), &m_backendValuesPropertyMap, SIGNAL(valueChanged(QString,QVariant)));
m_backendValuesPropertyMap.insert("className", QVariant::fromValue(valueObject));
// id
valueObject = qobject_cast<PropertyEditorValue*>(variantToQObject(m_backendValuesPropertyMap.value("id")));
if (!valueObject)
valueObject = new PropertyEditorValue(&m_backendValuesPropertyMap);
valueObject->setName("id");
valueObject->setValue(fxObjectNode.id());
QObject::connect(valueObject, SIGNAL(valueChanged(QString,QVariant)), &m_backendValuesPropertyMap, SIGNAL(valueChanged(QString,QVariant)));
m_backendValuesPropertyMap.insert("id", QVariant::fromValue(valueObject));
// anchors
m_backendAnchorBinding.setup(QmlItemNode(fxObjectNode.modelNode()));
ctxt->setContextProperty("anchorBackend", &m_backendAnchorBinding);
ctxt->setContextProperty("transaction", m_propertyEditorTransaction.data());
m_contextObject->setSpecificsUrl(qmlSpecificsFile);
m_contextObject->setStateName(stateName);
if (!fxObjectNode.isValid())
return;
ctxt->setContextProperty("propertyCount", QVariant(fxObjectNode.modelNode().properties().count()));
m_contextObject->setIsBaseState(fxObjectNode.isInBaseState());
m_contextObject->setSelectionChanged(false);
m_contextObject->setSelectionChanged(false);
NodeMetaInfo metaInfo = fxObjectNode.modelNode().metaInfo();
if (metaInfo.isValid()) {
m_contextObject->setMajorVersion(metaInfo.majorVersion());
m_contextObject->setMinorVersion(metaInfo.minorVersion());
} else {
m_contextObject->setMajorVersion(-1);
m_contextObject->setMinorVersion(-1);
}
} else {
示例10: beginRewriterTransaction
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();
}
}
示例11: tr
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();
}
}
示例12: catch
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;
}
}
//.........这里部分代码省略.........