~ubuntu-branches/ubuntu/vivid/qtdeclarative-opensource-src-gles/vivid

« back to all changes in this revision

Viewing changes to src/quick/items/qquicktext.cpp

  • Committer: Package Import Robot
  • Author(s): Timo Jyrinki
  • Date: 2015-03-11 16:51:45 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20150311165145-7653iqap3mau92gy
Tags: 5.4.1-0ubuntu1
Sync package with qtdeclarative-opensource-src - 5.4.1-1ubuntu3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1166
1166
}
1167
1167
 
1168
1168
/*!
 
1169
    Returns the y offset when aligning text with a non-1.0 lineHeight
 
1170
*/
 
1171
int QQuickTextPrivate::lineHeightOffset() const
 
1172
{
 
1173
    QFontMetricsF fm(font);
 
1174
    qreal fontHeight = qCeil(fm.height());  // QScriptLine and therefore QTextLine rounds up
 
1175
    return lineHeightMode() == QQuickText::FixedHeight ? fontHeight - lineHeight()
 
1176
                                                       : (1.0 - lineHeight()) * fontHeight;
 
1177
}
 
1178
 
 
1179
/*!
1169
1180
    Ensures the QQuickTextPrivate::doc variable is set to a valid text document
1170
1181
*/
1171
1182
void QQuickTextPrivate::ensureDoc()
2090
2101
 
2091
2102
    QRectF rect = d->layedOutTextRect;
2092
2103
    rect.moveLeft(QQuickTextUtil::alignedX(rect.width(), width(), effectiveHAlign()));
2093
 
    rect.moveTop(QQuickTextUtil::alignedY(rect.height(), height(), d->vAlign));
 
2104
    rect.moveTop(QQuickTextUtil::alignedY(rect.height() + d->lineHeightOffset(), height(), d->vAlign));
2094
2105
 
2095
2106
    if (d->style != Normal)
2096
2107
        rect.adjust(-1, 0, 1, 2);
2209
2220
 
2210
2221
    d->updateType = QQuickTextPrivate::UpdateNone;
2211
2222
 
2212
 
    const qreal dy = QQuickTextUtil::alignedY(d->layedOutTextRect.height(), height(), d->vAlign);
 
2223
    const qreal dy = QQuickTextUtil::alignedY(d->layedOutTextRect.height() + d->lineHeightOffset(), height(), d->vAlign);
2213
2224
 
2214
2225
    QQuickTextNode *node = 0;
2215
2226
    if (!oldNode)
2513
2524
{
2514
2525
    Q_Q(const QQuickText);
2515
2526
    QPointF translatedMousePos = mousePos;
2516
 
    translatedMousePos.ry() -= QQuickTextUtil::alignedY(layedOutTextRect.height(), q->height(), vAlign);
 
2527
    translatedMousePos.ry() -= QQuickTextUtil::alignedY(layedOutTextRect.height() + lineHeightOffset(), q->height(), vAlign);
2517
2528
    if (styledText) {
2518
2529
        QString link = anchorAt(&layout, translatedMousePos);
2519
2530
        if (link.isEmpty() && elideLayout)
2597
2608
    \qmlproperty string QtQuick::Text::hoveredLink
2598
2609
    \since 5.2
2599
2610
 
2600
 
    This property contains the link string when user hovers a link
 
2611
    This property contains the link string when the user hovers a link
2601
2612
    embedded in the text. The link must be in rich text or HTML format
2602
2613
    and the \a hoveredLink string provides access to the particular link.
2603
2614
 
2726
2737
{
2727
2738
    Q_D(QQuickText);
2728
2739
 
2729
 
    if (d->richText && d->extra->doc != 0) {
 
2740
    if (d->richText && d->extra.isAllocated() && d->extra->doc != 0) {
2730
2741
        QTextBlock block;
2731
2742
        for (block = d->extra->doc->firstBlock(); block.isValid(); block = block.next()) {
2732
2743
            if (block.layout() != 0 && block.layout()->engine() != 0)