Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/text/qtextobject.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    617617/*!
    618618    Returns an iterator pointing to the first document element inside the frame.
     619    Please see the document \l{STL-style-Iterators} for more information.
    619620
    620621    \sa end()
     
    629630
    630631/*!
    631     Returns an iterator pointing to the last document element inside the frame.
    632 
     632    Returns an iterator pointing to the position past the last document element inside the frame.
     633    Please see the document \l{STL-Style Iterators} for more information.   
    633634    \sa begin()
    634635*/
     
    11411142
    11421143/*!
     1144  \since 4.7
     1145
     1146  Returns the resolved text direction.
     1147
     1148  If the block has no explicit direction set, it will resolve the
     1149  direction from the blocks content. Returns either Qt::LeftToRight
     1150  or Qt::RightToLeft.
     1151
     1152  \sa QTextFormat::layoutDirection(), QString::isRightToLeft(), Qt::LayoutDirection
     1153*/
     1154Qt::LayoutDirection QTextBlock::textDirection() const
     1155{
     1156    Qt::LayoutDirection dir = blockFormat().layoutDirection();
     1157    if (dir != Qt::LayoutDirectionAuto)
     1158        return dir;
     1159
     1160    dir = p->defaultTextOption.textDirection();
     1161    if (dir != Qt::LayoutDirectionAuto)
     1162        return dir;
     1163
     1164    const QString buffer = p->buffer();
     1165
     1166    const int pos = position();
     1167    QTextDocumentPrivate::FragmentIterator it = p->find(pos);
     1168    QTextDocumentPrivate::FragmentIterator end = p->find(pos + length() - 1); // -1 to omit the block separator char
     1169    for (; it != end; ++it) {
     1170        const QTextFragmentData * const frag = it.value();
     1171        const QChar *p = buffer.constData() + frag->stringPosition;
     1172        const QChar * const end = p + frag->size_array[0];
     1173        while (p < end) {
     1174            switch(QChar::direction(p->unicode()))
     1175            {
     1176            case QChar::DirL:
     1177                return Qt::LeftToRight;
     1178            case QChar::DirR:
     1179            case QChar::DirAL:
     1180                return Qt::RightToLeft;
     1181            default:
     1182                break;
     1183            }
     1184            ++p;
     1185        }
     1186    }
     1187    return Qt::LeftToRight;
     1188}
     1189
     1190/*!
    11431191    Returns the block's contents as plain text.
    11441192
     
    14411489QTextBlock QTextBlock::next() const
    14421490{
    1443     if (!p)
     1491    if (!isValid())
    14441492        return QTextBlock();
    14451493
     
    14571505QTextBlock QTextBlock::previous() const
    14581506{
    1459     if (!p)
     1507    if (!isValid())
    14601508        return QTextBlock();
    14611509
Note: See TracChangeset for help on using the changeset viewer.