Qt 4.8
qtextobject.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qtextobject.h"
43 #include "qtextobject_p.h"
44 #include "qtextdocument.h"
45 #include "qtextformat_p.h"
46 #include "qtextdocument_p.h"
47 #include "qtextcursor.h"
48 #include "qtextlist.h"
50 #include "qtextengine_p.h"
51 #include "qdebug.h"
52 
54 
55 // ### DOC: We ought to explain the CONCEPT of objectIndexes if
56 // relevant to the public API
94  : QObject(*new QTextObjectPrivate(doc), doc)
95 {
96 }
97 
104  : QObject(p, doc)
105 {
106 }
107 
115 {
116 }
117 
124 {
125  Q_D(const QTextObject);
126  return d->pieceTable->formatCollection()->objectFormat(d->objectIndex);
127 }
128 
136 {
137  Q_D(const QTextObject);
138  return d->pieceTable->formatCollection()->objectFormatIndex(d->objectIndex);
139 }
140 
141 
148 {
149  Q_D(QTextObject);
150  int idx = d->pieceTable->formatCollection()->indexForFormat(format);
151  d->pieceTable->changeObjectFormat(this, idx);
152 }
153 
159 {
160  Q_D(const QTextObject);
161  return d->objectIndex;
162 }
163 
170 {
171  return static_cast<QTextDocument *>(parent());
172 }
173 
178 {
179  return static_cast<const QTextDocument *>(parent())->docHandle();
180 }
181 
214 {
215  for (int i = 0; i < blocks.count(); ++i) {
216  const QTextBlock &block = blocks.at(i);
217  pieceTable->documentChange(block.position(), block.length());
218  }
219 }
220 
230  : QTextObject(*new QTextBlockGroupPrivate(doc), doc)
231 {
232 }
233 
238  : QTextObject(p, doc)
239 {
240 }
241 
247 {
248 }
249 
250 // ### DOC: Shouldn't this be insertBlock()?
258 {
260  QTextBlockGroupPrivate::BlockList::Iterator it = qLowerBound(d->blocks.begin(), d->blocks.end(), block);
261  d->blocks.insert(it, block);
262  d->markBlocksDirty();
263 }
264 
265 // ### DOC: Shouldn't this be removeBlock()?
271 {
273  d->blocks.removeAll(block);
274  d->markBlocksDirty();
275  if (d->blocks.isEmpty()) {
276  document()->docHandle()->deleteObject(this);
277  return;
278  }
279 }
280 
288 {
289 }
290 
296 {
297  Q_D(const QTextBlockGroup);
298  return d->blocks;
299 }
300 
301 
302 
304 {
305 }
306 
307 
443  : QTextObject(*new QTextFramePrivate(doc), doc)
444 {
445 }
446 
447 // ### DOC: What does this do to child frames?
452 {
453  Q_D(QTextFrame);
454  delete d->layoutData;
455 }
456 
461  : QTextObject(p, doc)
462 {
463 }
464 
471 {
472  Q_D(const QTextFrame);
473  return d->childFrames;
474 }
475 
483 {
484  Q_D(const QTextFrame);
485  return d->parentFrame;
486 }
487 
488 
495 {
496  Q_D(const QTextFrame);
497  return QTextCursor(d->pieceTable, firstPosition());
498 }
499 
506 {
507  Q_D(const QTextFrame);
508  return QTextCursor(d->pieceTable, lastPosition());
509 }
510 
517 {
518  Q_D(const QTextFrame);
519  if (!d->fragment_start)
520  return 0;
521  return d->pieceTable->fragmentMap().position(d->fragment_start) + 1;
522 }
523 
530 {
531  Q_D(const QTextFrame);
532  if (!d->fragment_end)
533  return d->pieceTable->length() - 1;
534  return d->pieceTable->fragmentMap().position(d->fragment_end);
535 }
536 
541 {
542  Q_D(const QTextFrame);
543  return d->layoutData;
544 }
545 
550 {
551  Q_D(QTextFrame);
552  delete d->layoutData;
553  d->layoutData = data;
554 }
555 
556 
557 
559 {
560  if (type == QTextBeginningOfFrame) {
561  Q_ASSERT(!fragment_start);
562  fragment_start = fragment;
563  } else if (type == QTextEndOfFrame) {
564  Q_ASSERT(!fragment_end);
565  fragment_end = fragment;
566  } else if (type == QChar::ObjectReplacementCharacter) {
567  Q_ASSERT(!fragment_start);
568  Q_ASSERT(!fragment_end);
569  fragment_start = fragment;
570  fragment_end = fragment;
571  } else {
572  Q_ASSERT(false);
573  }
574 }
575 
577 {
578  Q_UNUSED(fragment); // --release warning
579  if (type == QTextBeginningOfFrame) {
580  Q_ASSERT(fragment_start == fragment);
581  fragment_start = 0;
582  } else if (type == QTextEndOfFrame) {
583  Q_ASSERT(fragment_end == fragment);
584  fragment_end = 0;
585  } else if (type == QChar::ObjectReplacementCharacter) {
586  Q_ASSERT(fragment_start == fragment);
587  Q_ASSERT(fragment_end == fragment);
588  fragment_start = 0;
589  fragment_end = 0;
590  } else {
591  Q_ASSERT(false);
592  }
593  remove_me();
594 }
595 
596 
598 {
599  Q_Q(QTextFrame);
600  if (fragment_start == 0 && fragment_end == 0
601  && !parentFrame) {
602  q->document()->docHandle()->deleteObject(q);
603  return;
604  }
605 
606  if (!parentFrame)
607  return;
608 
609  int index = parentFrame->d_func()->childFrames.indexOf(q);
610 
611  // iterator over all children and move them to the parent
612  for (int i = 0; i < childFrames.size(); ++i) {
613  QTextFrame *c = childFrames.at(i);
614  parentFrame->d_func()->childFrames.insert(index, c);
615  c->d_func()->parentFrame = parentFrame;
616  ++index;
617  }
618  Q_ASSERT(parentFrame->d_func()->childFrames.at(index) == q);
619  parentFrame->d_func()->childFrames.removeAt(index);
620 
621  childFrames.clear();
622  parentFrame = 0;
623 }
624 
660 {
662  int b = priv->blockMap().findNode(firstPosition());
663  int e = priv->blockMap().findNode(lastPosition()+1);
664  return iterator(const_cast<QTextFrame *>(this), b, b, e);
665 }
666 
673 {
675  int b = priv->blockMap().findNode(firstPosition());
676  int e = priv->blockMap().findNode(lastPosition()+1);
677  return iterator(const_cast<QTextFrame *>(this), e, b, e);
678 }
679 
684 {
685  f = 0;
686  b = 0;
687  e = 0;
688  cf = 0;
689  cb = 0;
690 }
691 
696 {
697  f = frame;
698  b = begin;
699  e = end;
700  cf = 0;
701  cb = block;
702 }
703 
708 {
709  f = other.f;
710  b = other.b;
711  e = other.e;
712  cf = other.cf;
713  cb = other.cb;
714 }
715 
721 {
722  f = other.f;
723  b = other.b;
724  e = other.e;
725  cf = other.cf;
726  cb = other.cb;
727  return *this;
728 }
729 
737 {
738  return cf;
739 }
740 
748 {
749  if (!f)
750  return QTextBlock();
751  return QTextBlock(f->docHandle(), cb);
752 }
753 
760 {
761  const QTextDocumentPrivate *priv = f->docHandle();
763  if (cf) {
764  int end = cf->lastPosition() + 1;
765  cb = map.findNode(end);
766  cf = 0;
767  } else if (cb) {
768  cb = map.next(cb);
769  if (cb == e)
770  return *this;
771 
772  if (!f->d_func()->childFrames.isEmpty()) {
773  int pos = map.position(cb);
774  // check if we entered a frame
775  QTextDocumentPrivate::FragmentIterator frag = priv->find(pos-1);
776  if (priv->buffer().at(frag->stringPosition) != QChar::ParagraphSeparator) {
777  QTextFrame *nf = qobject_cast<QTextFrame *>(priv->objectForFormat(frag->format));
778  if (nf) {
779  if (priv->buffer().at(frag->stringPosition) == QTextBeginningOfFrame && nf != f) {
780  cf = nf;
781  cb = 0;
782  } else {
783  Q_ASSERT(priv->buffer().at(frag->stringPosition) != QTextEndOfFrame);
784  }
785  }
786  }
787  }
788  }
789  return *this;
790 }
791 
798 {
799  const QTextDocumentPrivate *priv = f->docHandle();
801  if (cf) {
802  int start = cf->firstPosition() - 1;
803  cb = map.findNode(start);
804  cf = 0;
805  } else {
806  if (cb == b)
807  goto end;
808  if (cb != e) {
809  int pos = map.position(cb);
810  // check if we have to enter a frame
811  QTextDocumentPrivate::FragmentIterator frag = priv->find(pos-1);
812  if (priv->buffer().at(frag->stringPosition) != QChar::ParagraphSeparator) {
813  QTextFrame *pf = qobject_cast<QTextFrame *>(priv->objectForFormat(frag->format));
814  if (pf) {
815  if (priv->buffer().at(frag->stringPosition) == QTextBeginningOfFrame) {
816  Q_ASSERT(pf == f);
817  } else if (priv->buffer().at(frag->stringPosition) == QTextEndOfFrame) {
818  Q_ASSERT(pf != f);
819  cf = pf;
820  cb = 0;
821  goto end;
822  }
823  }
824  }
825  }
826  cb = map.previous(cb);
827  }
828  end:
829  return *this;
830 }
831 
862 {
863 }
864 
1099 {
1100  if (!p || !n)
1101  return 0;
1102 
1103  return p->blockMap().position(n);
1104 }
1105 
1115 {
1116  if (!p || !n)
1117  return 0;
1118 
1119  return p->blockMap().size(n);
1120 }
1121 
1127 {
1128  if (!p || !n)
1129  return false;
1130 
1131  int pos = p->blockMap().position(n);
1132  int len = p->blockMap().size(n);
1133  return position >= pos && position < pos + len;
1134 }
1135 
1147 {
1148  if (!p || !n)
1149  return 0;
1150 
1151  const QTextBlockData *b = p->blockMap().fragment(n);
1152  if (!b->layout)
1153  b->layout = new QTextLayout(*this);
1154  return b->layout;
1155 }
1156 
1168 {
1169  if (!p || !n)
1170  return;
1171 
1172  const QTextBlockData *b = p->blockMap().fragment(n);
1173  if (b->layout)
1174  b->layout->clearLayout();
1175 }
1176 
1183 {
1184  if (!p || !n)
1185  return QTextFormat().toBlockFormat();
1186 
1187  return p->formatCollection()->blockFormat(p->blockMap().fragment(n)->format);
1188 }
1189 
1197 {
1198  if (!p || !n)
1199  return -1;
1200 
1201  return p->blockMap().fragment(n)->format;
1202 }
1203 
1212 {
1213  if (!p || !n)
1214  return QTextFormat().toCharFormat();
1215 
1216  return p->formatCollection()->charFormat(charFormatIndex());
1217 }
1218 
1226 {
1227  if (!p || !n)
1228  return -1;
1229 
1230  return p->blockCharFormatIndex(n);
1231 }
1232 
1248 {
1249  Qt::LayoutDirection dir = blockFormat().layoutDirection();
1250  if (dir != Qt::LayoutDirectionAuto)
1251  return dir;
1252 
1253  dir = p->defaultTextOption.textDirection();
1254  if (dir != Qt::LayoutDirectionAuto)
1255  return dir;
1256 
1257  const QString buffer = p->buffer();
1258 
1259  const int pos = position();
1261  QTextDocumentPrivate::FragmentIterator end = p->find(pos + length() - 1); // -1 to omit the block separator char
1262  for (; it != end; ++it) {
1263  const QTextFragmentData * const frag = it.value();
1264  const QChar *p = buffer.constData() + frag->stringPosition;
1265  const QChar * const end = p + frag->size_array[0];
1266  while (p < end) {
1267  switch(QChar::direction(p->unicode()))
1268  {
1269  case QChar::DirL:
1270  return Qt::LeftToRight;
1271  case QChar::DirR:
1272  case QChar::DirAL:
1273  return Qt::RightToLeft;
1274  default:
1275  break;
1276  }
1277  ++p;
1278  }
1279  }
1280  return Qt::LeftToRight;
1281 }
1282 
1289 {
1290  if (!p || !n)
1291  return QString();
1292 
1293  const QString buffer = p->buffer();
1294  QString text;
1295  text.reserve(length());
1296 
1297  const int pos = position();
1299  QTextDocumentPrivate::FragmentIterator end = p->find(pos + length() - 1); // -1 to omit the block separator char
1300  for (; it != end; ++it) {
1301  const QTextFragmentData * const frag = it.value();
1302  text += QString::fromRawData(buffer.constData() + frag->stringPosition, frag->size_array[0]);
1303  }
1304 
1305  return text;
1306 }
1307 
1308 
1314 {
1315  return p ? p->document() : 0;
1316 }
1317 
1323 {
1324  if (!isValid())
1325  return 0;
1326 
1327  const QTextBlockFormat fmt = blockFormat();
1328  QTextObject *obj = p->document()->objectForFormat(fmt);
1329  return qobject_cast<QTextList *>(obj);
1330 }
1331 
1342 {
1343  if (!p || !n)
1344  return 0;
1345 
1346  const QTextBlockData *b = p->blockMap().fragment(n);
1347  return b->userData;
1348 }
1349 
1379 {
1380  if (!p || !n)
1381  return;
1382 
1383  const QTextBlockData *b = p->blockMap().fragment(n);
1384  if (data != b->userData)
1385  delete b->userData;
1386  b->userData = data;
1387 }
1388 
1398 {
1399  if (!p || !n)
1400  return -1;
1401 
1402  const QTextBlockData *b = p->blockMap().fragment(n);
1403  return b->userState;
1404 }
1405 
1416 {
1417  if (!p || !n)
1418  return;
1419 
1420  const QTextBlockData *b = p->blockMap().fragment(n);
1421  b->userState = state;
1422 }
1423 
1435 {
1436  if (!p || !n)
1437  return -1;
1438 
1439  const QTextBlockData *b = p->blockMap().fragment(n);
1440  return b->revision;
1441 }
1442 
1454 {
1455  if (!p || !n)
1456  return;
1457 
1458  const QTextBlockData *b = p->blockMap().fragment(n);
1459  b->revision = rev;
1460 }
1461 
1473 {
1474  if (!p || !n)
1475  return true;
1476 
1477  const QTextBlockData *b = p->blockMap().fragment(n);
1478  return !b->hidden;
1479 }
1480 
1491 void QTextBlock::setVisible(bool visible)
1492 {
1493  if (!p || !n)
1494  return;
1495 
1496  const QTextBlockData *b = p->blockMap().fragment(n);
1497  b->hidden = !visible;
1498 }
1499 
1500 
1513 {
1514  if (!p || !n)
1515  return -1;
1516  return p->blockMap().position(n, 1);
1517 }
1518 
1532 {
1533  if (!p || !n)
1534  return -1;
1535  return p->blockMap().position(n, 2);
1536 }
1537 
1538 
1547 {
1548  if (!p || !n)
1549  return;
1550  p->blockMap().setSize(n, count, 2);
1551 }
1560 {
1561  if (!p || !n)
1562  return -1;
1563  return p->blockMap().size(n, 2);
1564 }
1565 
1566 
1574 {
1575  if (!p || !n)
1576  return iterator();
1577 
1578  int pos = position();
1579  int len = length() - 1; // exclude the fragment that holds the paragraph separator
1580  int b = p->fragmentMap().findNode(pos);
1581  int e = p->fragmentMap().findNode(pos+len);
1582  return iterator(p, b, e, b);
1583 }
1584 
1592 {
1593  if (!p || !n)
1594  return iterator();
1595 
1596  int pos = position();
1597  int len = length() - 1; // exclude the fragment that holds the paragraph separator
1598  int b = p->fragmentMap().findNode(pos);
1599  int e = p->fragmentMap().findNode(pos+len);
1600  return iterator(p, b, e, e);
1601 }
1602 
1603 
1613 {
1614  if (!isValid() || !p->blockMap().isValid(n))
1615  return QTextBlock();
1616 
1617  return QTextBlock(p, p->blockMap().next(n));
1618 }
1619 
1629 {
1630  if (!p)
1631  return QTextBlock();
1632 
1633  return QTextBlock(p, p->blockMap().previous(n));
1634 }
1635 
1636 
1641 {
1642  int ne = n;
1643  int formatIndex = p->fragmentMap().fragment(n)->format;
1644  do {
1645  ne = p->fragmentMap().next(ne);
1646  } while (ne != e && p->fragmentMap().fragment(ne)->format == formatIndex);
1647  return QTextFragment(p, n, ne);
1648 }
1649 
1657 {
1658  int ne = n;
1659  int formatIndex = p->fragmentMap().fragment(n)->format;
1660  do {
1661  ne = p->fragmentMap().next(ne);
1662  } while (ne != e && p->fragmentMap().fragment(ne)->format == formatIndex);
1663  n = ne;
1664  return *this;
1665 }
1666 
1673 {
1674  n = p->fragmentMap().previous(n);
1675 
1676  if (n == b)
1677  return *this;
1678 
1679  int formatIndex = p->fragmentMap().fragment(n)->format;
1680  int last = n;
1681 
1682  while (n != b && p->fragmentMap().fragment(n)->format != formatIndex) {
1683  last = n;
1684  n = p->fragmentMap().previous(n);
1685  }
1686 
1687  n = last;
1688  return *this;
1689 }
1690 
1691 
1811 #if !defined(QT_NO_RAWFONT)
1813 {
1814  if (!p || !n)
1815  return QList<QGlyphRun>();
1816 
1817  int pos = position();
1818  int len = length();
1819  if (len == 0)
1820  return QList<QGlyphRun>();
1821 
1822  int blockNode = p->blockMap().findNode(pos);
1823 
1824  const QTextBlockData *blockData = p->blockMap().fragment(blockNode);
1825  QTextLayout *layout = blockData->layout;
1826 
1827  QList<QGlyphRun> ret;
1828  for (int i=0; i<layout->lineCount(); ++i) {
1829  QTextLine textLine = layout->lineAt(i);
1830  ret += textLine.glyphs(pos, len);
1831  }
1832 
1833  return ret;
1834 }
1835 #endif // QT_NO_RAWFONT
1836 
1841 {
1842  if (!p || !n)
1843  return 0; // ### -1 instead?
1844 
1845  return p->fragmentMap().position(n);
1846 }
1847 
1854 {
1855  if (!p || !n)
1856  return 0;
1857 
1858  int len = 0;
1859  int f = n;
1860  while (f != ne) {
1861  len += p->fragmentMap().size(f);
1862  f = p->fragmentMap().next(f);
1863  }
1864  return len;
1865 }
1866 
1872 {
1873  if (!p || !n)
1874  return false;
1875  int pos = this->position();
1876  return position >= pos && position < pos + length();
1877 }
1878 
1885 {
1886  if (!p || !n)
1887  return QTextCharFormat();
1888  const QTextFragmentData *data = p->fragmentMap().fragment(n);
1889  return p->formatCollection()->charFormat(data->format);
1890 }
1891 
1899 {
1900  if (!p || !n)
1901  return -1;
1902  const QTextFragmentData *data = p->fragmentMap().fragment(n);
1903  return data->format;
1904 }
1905 
1912 {
1913  if (!p || !n)
1914  return QString();
1915 
1916  QString result;
1917  QString buffer = p->buffer();
1918  int f = n;
1919  while (f != ne) {
1920  const QTextFragmentData * const frag = p->fragmentMap().fragment(f);
1921  result += QString(buffer.constData() + frag->stringPosition, frag->size_array[0]);
1922  f = p->fragmentMap().next(f);
1923  }
1924  return result;
1925 }
1926 
void setRevision(int rev)
Sets a blocks revision to rev.
double d
Definition: qnumeric_p.h:62
iterator()
Constructs an invalid iterator.
int revision() const
Returns the blocks revision.
QString text() const
Returns the block&#39;s contents as plain text.
int type
Definition: qmetatype.cpp:239
int formatIndex() const
Returns the index of the object&#39;s format in the document&#39;s internal list of formats.
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
bool contains(int position) const
Returns true if the text fragment contains the text at the given position in the document; otherwise ...
unsigned char c[8]
Definition: qnumeric_p.h:62
int blockFormatIndex() const
Returns an index into the document&#39;s internal list of block formats for the text block&#39;s format...
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
int charFormatIndex() const
Returns an index into the document&#39;s internal list of character formats for the text fragment&#39;s chara...
QTextList * textList() const
If the block represents a list item, returns the list that the item belongs to; otherwise returns 0...
virtual ~QTextFrameLayoutData()
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
void setUserState(int state)
Stores the specified state integer value in the text block.
void setLineCount(int count)
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
#define it(className, varName)
iterator end() const
Returns a text block iterator pointing to the end of the text block.
QList< QGlyphRun > glyphs(int from, int length) const
Returns the glyph indexes and positions for all glyphs in this QTextLine which reside in QScriptItems...
The QTextFrame class represents a frame in a QTextDocument.
Definition: qtextobject.h:122
void deleteObject(QTextObject *object)
QTextFrame * currentFrame() const
Returns the current frame pointed to by the iterator, or 0 if the iterator currently points to a bloc...
The QTextLine class represents a line of text inside a QTextLayout.
Definition: qtextlayout.h:197
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
QString text() const
Returns the text fragment&#39;s as plain text.
QTextDocument * document() const
Returns the document this object belongs to.
iterator begin() const
Returns a text block iterator pointing to the beginning of the text block.
void insert(int i, const T &t)
Inserts value at index position i in the list.
Definition: qlist.h:575
#define QTextBeginningOfFrame
virtual ~QTextBlockUserData()
Destroys the user data.
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
void clearLayout()
Clears the QTextLayout that is used to lay out and display the block&#39;s contents.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
int firstPosition() const
Returns the first document position inside the frame.
#define Q_D(Class)
Definition: qglobal.h:2482
QTextObject * objectForFormat(const QTextFormat &) const
Returns the text object associated with the format f.
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
static QString fromRawData(const QChar *, int size)
Constructs a QString that uses the first size Unicode characters in the array unicode.
Definition: qstring.cpp:7673
FragmentMap::ConstIterator FragmentIterator
iterator Iterator
Qt-style synonym for QList::iterator.
Definition: qlist.h:278
QTextBlock next() const
Returns the text block in the document after this block, or an empty text block if this is the last o...
int lineCount() const
#define Q_Q(Class)
Definition: qglobal.h:2483
int position() const
Returns the index of the block&#39;s first character within the document.
QTextBlock previous() const
Returns the text block in the document before this block, or an empty text block if this is the first...
void reserve(int size)
Attempts to allocate memory for at least size characters.
Definition: qstring.h:881
iterator & operator++()
Moves the iterator to the next frame or block.
QTextCharFormat charFormat() const
Returns the text fragment&#39;s character format.
bool isVisible() const
Returns true if the block is visible; otherwise returns false.
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
FragmentIterator find(int pos) const
iterator & operator--()
The prefix – operator (–i) makes the preceding item current and returns an iterator pointing to the...
QTextObject(QTextDocument *doc)
Creates a new QTextObject for the given document.
Definition: qtextobject.cpp:93
~QTextObject()
Destroys the text object.
virtual void fragmentAdded(const QChar &type, uint fragment)
int objectIndex() const
Returns the object index of this object.
QTextFrameLayoutData * layoutData() const
int lastPosition() const
Returns the last document position inside the frame.
The QTextFormat class provides formatting information for a QTextDocument.
Definition: qtextformat.h:129
QTextFrame * parentFrame() const
Returns the frame&#39;s parent frame.
QTextDocumentPrivate * docHandle() const
So that not all classes have to be friends of each other.
The QTextCursor class offers an API to access and modify QTextDocuments.
Definition: qtextcursor.h:70
QTextDocumentPrivate * docHandle() const
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QTextObject * objectForFormat(int formatIndex) const
const char * layout
LayoutDirection
Definition: qnamespace.h:1580
bool contains(int position) const
Returns true if the given position is located within the text block; otherwise returns false...
QTextLayout * layout
void setUserData(QTextBlockUserData *data)
Attaches the given data object to the text block.
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
QTextBlockFormat toBlockFormat() const
Returns this format as a block format.
uint position(uint node, uint field=0) const
void clear()
Removes all items from the list.
Definition: qlist.h:764
int length() const
Returns the length of the block in characters.
const BlockMap & blockMap() const
~QTextBlockGroup()
Destroys this block group; the blocks are not deleted, they simply don&#39;t belong to this block anymore...
QList< QGlyphRun > glyphRuns() const
Returns the glyphs of this text fragment.
int length() const
Returns the number of characters in the text fragment.
The QTextFragment class holds a piece of text in a QTextDocument with a single QTextCharFormat.
Definition: qtextobject.h:297
uint next(uint n) const
QTextLine lineAt(int i) const
Returns the {i}-th line of text in this text layout.
The QTextBlock::iterator class provides an iterator for reading the contents of a QTextBlock...
Definition: qtextobject.h:251
QTextCharFormat charFormat() const
Returns the QTextCharFormat that describes the block&#39;s character format.
virtual void blockInserted(const QTextBlock &block)
Appends the given block to the end of the group.
int firstLineNumber() const
Returns the first line number of this block, or -1 if the block is invalid.
The iterator class provides an iterator for reading the contents of a QTextFrame. ...
Definition: qtextobject.h:144
The QTextBlockUserData class is used to associate custom data with blocks of text.
Definition: qtextobject.h:194
iterator & operator++()
The prefix ++ operator (++i) advances the iterator to the next item in the hash and returns an iterat...
QTextFormat format() const
Returns the text object&#39;s format.
QList< QTextFrame * > childFrames() const
Returns a (possibly empty) list of the frame&#39;s child frames.
QList< QTextBlock > blockList() const
Returns a (possibly empty) list of all the blocks that are part of the block group.
int userState() const
Returns the integer value previously set with setUserState() or -1.
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
Definition: qalgorithms.h:227
int position() const
Returns the position of this text fragment in the document.
QTextBlockUserData * userData
virtual void blockRemoved(const QTextBlock &block)
Removes the given block from the group; the block itself is not deleted, it simply isn&#39;t a member of ...
The QTextLayout class is used to lay out and render text.
Definition: qtextlayout.h:105
~QTextFrame()
Destroys the frame, and removes it from the document&#39;s layout.
int indexOf(const T &t, int from=0) const
Returns the index position of the first occurrence of value in the list, searching forward from index...
Definition: qlist.h:847
void setFormat(const QTextFormat &format)
Sets the text object&#39;s format.
QTextCursor firstCursorPosition() const
Returns the first cursor position inside the frame.
The QTextBlockGroup class provides a container for text blocks within a QTextDocument.
Definition: qtextobject.h:94
QString buffer() const
uint previous(uint n) const
uint findNode(int k, uint field=0) const
quint32 size_array[N]
QObject * parent() const
Returns a pointer to the parent object.
Definition: qobject.h:273
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument...
Definition: qtextformat.h:545
static const QMetaObjectPrivate * priv(const uint *data)
Qt::LayoutDirection textDirection() const
Returns the resolved text direction.
quint16 index
iterator & operator=(const iterator &o)
Assigns other to this iterator and returns a reference to this iterator.
QTextCursor lastCursorPosition() const
Returns the last cursor position inside the frame.
void clearLayout()
Clears the line information in the layout.
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
QTextBlockGroup(QTextDocument *doc)
Creates a new new block group for the given document.
friend class iterator
Definition: qtextobject.h:175
The QTextList class provides a decorated list of items in a QTextDocument.
Definition: qtextlist.h:57
QTextCharFormat toCharFormat() const
Returns this format as a character format.
int charFormatIndex() const
Returns an index into the document&#39;s internal list of character formats for the text block&#39;s characte...
iterator & operator--()
Moves the iterator to the previous frame or block.
virtual void blockFormatChanged(const QTextBlock &block)
This function is called whenever the specified block of text is changed.
Direction direction() const
Returns the character&#39;s direction.
Definition: qchar.cpp:889
virtual void fragmentRemoved(const QChar &type, uint fragment)
void setLayoutData(QTextFrameLayoutData *data)
QTextFragment fragment() const
Returns the text fragment the iterator currently points to.
The QTextObject class is a base class for different kinds of objects that can group parts of a QTextD...
Definition: qtextobject.h:64
QTextBlock currentBlock() const
Returns the current block the iterator points to.
const QTextDocument * document() const
Returns the text document this text block belongs to, or 0 if the text block does not belong to any d...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
void setVisible(bool visible)
Sets the block&#39;s visibility to visible.
iterator end() const
Returns an iterator pointing to the position past the last document element inside the frame...
QTextBlockFormat blockFormat() const
Returns the QTextBlockFormat that describes block-specific properties.
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712
QTextFrame(QTextDocument *doc)
Creates a new empty frame for the text document.
int blockNumber() const
Returns the number of this block, or -1 if the block is invalid.
#define text
Definition: qobjectdefs.h:80
int lineCount() const
Returns the number of lines in this text layout.
iterator begin() const
Returns an iterator pointing to the first document element inside the frame.
#define QTextEndOfFrame
QTextBlockUserData * userData() const
Returns a pointer to a QTextBlockUserData object if previously set with setUserData() or a null point...
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480
QTextLayout * layout() const
Returns the QTextLayout that is used to lay out and display the block&#39;s contents. ...