/*! Returns the text fragment the iterator currently points to. */ QTextFragment QTextBlock::iterator::fragment() const { int ne = n; int formatIndex = p->fragmentMap().fragment(n)->format; do { ne = p->fragmentMap().next(ne); } while (ne != e && p->fragmentMap().fragment(ne)->format == formatIndex); return QTextFragment(p, n, ne); }
QTextFragment ChatView::getFragmentUnderMouse(const QPoint &pos) const { QTextCursor cursor(cursorForPosition(pos)); QTextBlock block(cursor.block()); QTextBlock::iterator it; for (it = block.begin(); !(it.atEnd()); ++it) { QTextFragment frag = it.fragment(); if (frag.contains(cursor.position())) return frag; } return QTextFragment(); }