Ejemplo n.º 1
0
void TextEditItem::updateText()
{
    if (formEditorItem()) {
        TextEditItemWidget::updateText(formEditorItem()->qmlItemNode().
            stripedTranslatableText("text"));
    }
}
void AnchorLineController::updatePosition()
{
    QRectF boundingRect = m_data->formEditorItem->qmlItemNode().instanceBoundingRect();

    QRectF topBoundingRect(boundingRect);
    QRectF leftBoundingRect(boundingRect);
    QRectF bottomBoundingRect(boundingRect);
    QRectF rightBoundingRect(boundingRect);


    if (formEditorItem()->isContainer()) {
        topBoundingRect.setBottom(boundingRect.top() + 6);
        topBoundingRect.adjust(7, -5, -7, 0);

        leftBoundingRect.setRight(boundingRect.left() + 6);
        leftBoundingRect.adjust(-5, 7, 0, -7);

        bottomBoundingRect.setTop(boundingRect.bottom() - 6);
        bottomBoundingRect.adjust(7, 0, -7, 5);

        rightBoundingRect.setLeft(boundingRect.right() - 6);
        rightBoundingRect.adjust(0, 7, 5, -7);

    } else {
        double height = qMin(boundingRect.height() / 4., 10.0);
        double width = qMin(boundingRect.width() / 4., 10.0);

        topBoundingRect.setHeight(height);
        topBoundingRect.adjust(width, -4, -width, -1);

        leftBoundingRect.setWidth(width);
        leftBoundingRect.adjust(-4, height, -1, -height);

        bottomBoundingRect.setTop(boundingRect.bottom() - height);
        bottomBoundingRect.adjust(width, 1, -width, 4);

        rightBoundingRect.setLeft(boundingRect.right() - width);
        rightBoundingRect.adjust(1, height, 4, -height);
    }

    m_data->topItem->setHandlePath(m_data->formEditorItem->mapToItem(m_data->layerItem.data(),
                                                                        rectToPath(topBoundingRect)));
    m_data->leftItem->setHandlePath(m_data->formEditorItem->mapToItem(m_data->layerItem.data(),
                                                                         rectToPath(leftBoundingRect)));
    m_data->bottomItem->setHandlePath(m_data->formEditorItem->mapToItem(m_data->layerItem.data(),
                                                                           rectToPath(bottomBoundingRect)));
    m_data->rightItem->setHandlePath(m_data->formEditorItem->mapToItem(m_data->layerItem.data(),
                                                                          rectToPath(rightBoundingRect)));
}