本文整理汇总了C++中QmlItemNode类的典型用法代码示例。如果您正苦于以下问题:C++ QmlItemNode类的具体用法?C++ QmlItemNode怎么用?C++ QmlItemNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QmlItemNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createParentAnchorPoint
static QPointF createParentAnchorPoint(const QmlItemNode &parentQmlItemNode, AnchorLine::Type anchorLineType, const QmlItemNode &childQmlItemNode)
{
QRectF parentBoundingRect = parentQmlItemNode.instanceSceneTransform().mapRect(parentQmlItemNode.instanceBoundingRect().adjusted(0., 0., 1., 1.));
QRectF childBoundingRect = childQmlItemNode.instanceSceneTransform().mapRect(childQmlItemNode.instanceBoundingRect().adjusted(0., 0., 1., 1.));
QPointF anchorPoint;
switch (anchorLineType) {
case AnchorLine::Top:
anchorPoint = QPointF(childBoundingRect.center().x(), parentBoundingRect.top());
break;
case AnchorLine::Bottom:
anchorPoint = QPointF(childBoundingRect.center().x(), parentBoundingRect.bottom());
break;
case AnchorLine::Left:
anchorPoint = QPointF(parentBoundingRect.left(), childBoundingRect.center().y());
break;
case AnchorLine::Right:
anchorPoint = QPointF(parentBoundingRect.right(), childBoundingRect.center().y());
break;
default:
break;
}
return anchorPoint;
}
示例2: createAnchorPoint
static QPointF createAnchorPoint(const QmlItemNode &qmlItemNode, AnchorLine::Type anchorLineType)
{
QRectF boundingRect = qmlItemNode.instanceBoundingRect().adjusted(0., 0., 1., 1.);
QPointF anchorPoint;
switch (anchorLineType) {
case AnchorLine::Top:
anchorPoint = QPointF(boundingRect.center().x(), boundingRect.top());
break;
case AnchorLine::Bottom:
anchorPoint = QPointF(boundingRect.center().x(), boundingRect.bottom());
break;
case AnchorLine::Left:
anchorPoint = QPointF(boundingRect.left(), boundingRect.center().y());
break;
case AnchorLine::Right:
anchorPoint = QPointF(boundingRect.right(), boundingRect.center().y());
break;
default:
break;
}
return qmlItemNode.instanceSceneTransform().map(anchorPoint);
}
示例3: clear
void BindingIndicator::setItems(const QList<FormEditorItem *> &itemList)
{
clear();
if (itemList.count() == 1) {
m_formEditorItem = itemList.first();
QmlItemNode qmlItemNode = m_formEditorItem->qmlItemNode();
if (qmlItemNode.hasBindingProperty("x")) {
m_indicatorTopShape = new BindingIndicatorGraphicsItem(m_layerItem.data());
m_indicatorTopShape->updateBindingIndicator(leftLine(qmlItemNode));
}
if (qmlItemNode.hasBindingProperty("y")) {
m_indicatorLeftShape = new BindingIndicatorGraphicsItem(m_layerItem.data());
m_indicatorLeftShape->updateBindingIndicator(topLine(qmlItemNode));
}
if (qmlItemNode.hasBindingProperty("width")) {
m_indicatorRightShape = new BindingIndicatorGraphicsItem(m_layerItem.data());
m_indicatorRightShape->updateBindingIndicator(rightLine(qmlItemNode));
}
if (qmlItemNode.hasBindingProperty("height")) {
m_indicatorBottomShape = new BindingIndicatorGraphicsItem(m_layerItem.data());
m_indicatorBottomShape->updateBindingIndicator(bottomLine(qmlItemNode));
}
}
}
示例4: boundingBox
QRectF QmlAnchorBindingProxy::boundingBox(const QmlItemNode &node)
{
if (node.isValid())
return node.instanceTransformWithContentTransform().mapRect(node.instanceBoundingRect());
return QRect();
}
示例5: QmlItemNode
QmlItemNode QmlItemNode::createQmlItemNode(AbstractView *view, const ItemLibraryEntry &itemLibraryEntry, const QPointF &position, QmlItemNode parentQmlItemNode)
{
if (!parentQmlItemNode.isValid())
parentQmlItemNode = QmlItemNode(view->rootModelNode());
Q_ASSERT(parentQmlItemNode.isValid());
NodeAbstractProperty parentProperty = parentQmlItemNode.defaultNodeAbstractProperty();
return QmlItemNode::createQmlItemNode(view, itemLibraryEntry, position, parentProperty);
}
示例6: allQmlItemsRecursive
static QList<QmlItemNode> allQmlItemsRecursive(const QmlItemNode &qmlItemNode)
{
QList<QmlItemNode> qmlItemNodeList;
if (qmlItemNode.isValid()) {
qmlItemNodeList.append(qmlItemNode);
foreach (const ModelNode &modelNode, qmlItemNode.modelNode().directSubModelNodes()) {
if (QmlItemNode::isValidQmlItemNode(modelNode))
qmlItemNodeList.append(allQmlItemsRecursive(modelNode));
}
}
示例7: rootQmlItemNode
QmlItemNode QmlModelView::createQmlItemNode(const ItemLibraryEntry &itemLibraryEntry, const QPointF &position, QmlItemNode parentNode)
{
if (!parentNode.isValid())
parentNode = rootQmlItemNode();
Q_ASSERT(parentNode.isValid());
QmlItemNode newNode;
RewriterTransaction transaction = beginRewriterTransaction();
{
QList<QPair<QString, QVariant> > propertyPairList;
propertyPairList.append(qMakePair(QString("x"), QVariant(round(position.x(), 4))));
propertyPairList.append(qMakePair(QString("y"), QVariant(round(position.y(), 4))));
foreach (const PropertyContainer &property, itemLibraryEntry.properties())
propertyPairList.append(qMakePair(property.name(), property.value()));
newNode = createQmlItemNode(itemLibraryEntry.typeName(), itemLibraryEntry.majorVersion(), itemLibraryEntry.minorVersion(), propertyPairList);
parentNode.nodeAbstractProperty("data").reparentHere(newNode);
Q_ASSERT(newNode.isValid());
QString id;
int i = 1;
QString name(itemLibraryEntry.name().toLower());
//remove forbidden characters
name.replace(QRegExp(QLatin1String("[^a-zA-Z0-9_]")), QLatin1String("_"));
do {
id = name + QString::number(i);
i++;
} while (hasId(id)); //If the name already exists count upwards
try {
newNode.setId(id);
} catch (InvalidIdException &e) {
// should never happen
QMessageBox::warning(0, tr("Invalid Id"), e.description());
}
if (!currentState().isBaseState()) {
newNode.modelNode().variantProperty("opacity") = 0;
newNode.setVariantProperty("opacity", 1);
}
Q_ASSERT(newNode.isValid());
}
Q_ASSERT(newNode.isValid());
return newNode;
}
示例8: removeNodeFromScene
void FormEditorView::removeNodeFromScene(const QmlItemNode &qmlItemNode)
{
if (qmlItemNode.isValid()) {
QList<QmlItemNode> nodeList;
nodeList.append(qmlItemNode.allSubModelNodes());
nodeList.append(qmlItemNode);
QList<FormEditorItem*> removedItemList;
removedItemList.append(scene()->itemsForQmlItemNodes(nodeList));
m_currentTool->itemsAboutToRemoved(removedItemList);
qDeleteAll(removedItemList);
}
}
示例9: allFxItemsRecursive
static QList<QmlItemNode> allFxItemsRecursive(const QmlItemNode &fxNode)
{
QList<QmlItemNode> returnList;
if (fxNode.isValid()) {
returnList.append(fxNode);
QList<QmlItemNode> allChildNodes;
foreach (const ModelNode &node, fxNode.modelNode().allDirectSubModelNodes()) {
if (QmlItemNode(node).isValid())
allChildNodes.append(node);
}
foreach (const QmlItemNode &node, allChildNodes) {
returnList.append(allFxItemsRecursive(node));
}
示例10: getUpperLeftPosition
static inline QPointF getUpperLeftPosition(const QList<ModelNode> &modelNodeList)
{
QPointF postion(std::numeric_limits<qreal>::max(), std::numeric_limits<qreal>::max());
foreach (const ModelNode &modelNode, modelNodeList) {
if (QmlItemNode::isValidQmlItemNode(modelNode)) {
QmlItemNode qmlIitemNode = QmlItemNode(modelNode);
if (qmlIitemNode.instancePosition().x() < postion.x())
postion.setX(qmlIitemNode.instancePosition().x());
if (qmlIitemNode.instancePosition().y() < postion.y())
postion.setY(qmlIitemNode.instancePosition().y());
}
}
return postion;
}
示例11: updateContext
virtual void updateContext()
{
defaultAction()->setSelectionContext(selectionContext());
if (selectionContext().isValid()) {
defaultAction()->setEnabled(isEnabled(selectionContext()));
defaultAction()->setVisible(isVisible(selectionContext()));
defaultAction()->setCheckable(true);
QmlItemNode itemNode = QmlItemNode(selectionContext().currentSingleSelectedNode());
if (itemNode.isValid())
defaultAction()->setChecked(itemNode.instanceValue("visible").toBool());
else
defaultAction()->setEnabled(false);
}
}
示例12: idForNode
QString QmlAnchorBindingProxy::idForNode(const QmlItemNode &qmlItemNode) const
{
if (m_qmlItemNode.instanceParent().modelNode() == qmlItemNode)
return QStringLiteral("parent");
return qmlItemNode.id();
}
示例13: hideNodeFromScene
void FormEditorView::hideNodeFromScene(const QmlItemNode &qmlItemNode)
{
if (qmlItemNode.isValid()) {
FormEditorItem *item = m_scene->itemForQmlItemNode(qmlItemNode);
QList<QmlItemNode> nodeList;
nodeList.append(qmlItemNode.allSubModelNodes());
nodeList.append(qmlItemNode);
QList<FormEditorItem*> removedItemList;
removedItemList.append(scene()->itemsForQmlItemNodes(nodeList));
m_currentTool->itemsAboutToRemoved(removedItemList);
item->setFormEditorVisible(false);
}
}
示例14: foreach
//This method does the setup of the initial FormEditorItem tree in the scene
void FormEditorView::setupFormEditorItemTree(const QmlItemNode &qmlItemNode)
{
m_scene->addFormEditorItem(qmlItemNode);
foreach (const QmlItemNode &nextNode, qmlItemNode.children()) //TODO instance children
setupFormEditorItemTree(nextNode);
}
示例15: foreach
foreach (FormEditorItem *formEditorItem, itemList) {
if (formEditorItem == m_formEditorItem) {
QmlItemNode sourceQmlItemNode = m_formEditorItem->qmlItemNode();
if (!sourceQmlItemNode.modelNode().isRootNode()) {
QmlAnchors qmlAnchors = formEditorItem->qmlItemNode().anchors();
if (qmlAnchors.modelHasAnchor(AnchorLine::Top)) {
if (m_indicatorTopShape.isNull())
m_indicatorTopShape = new AnchorIndicatorGraphicsItem(m_layerItem.data());
m_indicatorTopShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Top),
qmlAnchors.modelAnchor(AnchorLine::Top));
} else {
delete m_indicatorTopShape;
}
if (qmlAnchors.modelHasAnchor(AnchorLine::Bottom)) {
if (m_indicatorBottomShape.isNull())
m_indicatorBottomShape = new AnchorIndicatorGraphicsItem(m_layerItem.data());
m_indicatorBottomShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Bottom),
qmlAnchors.modelAnchor(AnchorLine::Bottom));
} else {
delete m_indicatorBottomShape;
}
if (qmlAnchors.modelHasAnchor(AnchorLine::Left)) {
if (m_indicatorLeftShape.isNull())
m_indicatorLeftShape = new AnchorIndicatorGraphicsItem(m_layerItem.data());
m_indicatorLeftShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Left),
qmlAnchors.modelAnchor(AnchorLine::Left));
} else {
delete m_indicatorLeftShape;
}
if (qmlAnchors.modelHasAnchor(AnchorLine::Right)) {
if (m_indicatorRightShape.isNull())
m_indicatorRightShape = new AnchorIndicatorGraphicsItem(m_layerItem.data());
m_indicatorRightShape->updateAnchorIndicator(AnchorLine(sourceQmlItemNode, AnchorLine::Right),
qmlAnchors.modelAnchor(AnchorLine::Right));
} else {
delete m_indicatorRightShape;
}
}
return;
}
}