Changeset 846 for trunk/src/gui/text/qtextobject.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/text/qtextobject.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 617 617 /*! 618 618 Returns an iterator pointing to the first document element inside the frame. 619 Please see the document \l{STL-style-Iterators} for more information. 619 620 620 621 \sa end() … … 629 630 630 631 /*! 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. 633 634 \sa begin() 634 635 */ … … 1141 1142 1142 1143 /*! 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 */ 1154 Qt::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 /*! 1143 1191 Returns the block's contents as plain text. 1144 1192 … … 1441 1489 QTextBlock QTextBlock::next() const 1442 1490 { 1443 if (! p)1491 if (!isValid()) 1444 1492 return QTextBlock(); 1445 1493 … … 1457 1505 QTextBlock QTextBlock::previous() const 1458 1506 { 1459 if (! p)1507 if (!isValid()) 1460 1508 return QTextBlock(); 1461 1509
Note:
See TracChangeset
for help on using the changeset viewer.