Qt 4.8
Public Types | Public Functions | Public Variables | List of all members
QTextCursorPrivate Class Reference

#include <qtextcursor_p.h>

Inheritance diagram for QTextCursorPrivate:
QSharedData

Public Types

enum  AdjustResult { CursorMoved, CursorUnchanged }
 

Public Functions

void aboutToRemoveCell (int from, int to)
 
void adjustCursor (QTextCursor::MoveOperation m)
 
AdjustResult adjustPosition (int positionOfChange, int charsAddedOrRemoved, QTextUndoCommand::Operation op)
 
QTextBlock block () const
 
QTextBlockFormat blockFormat () const
 
QTextLayoutblockLayout (QTextBlock &block) const
 
bool canDelete (int pos) const
 
void clearCells (QTextTable *table, int startRow, int startCol, int numRows, int numCols, QTextUndoCommand::Operation op)
 
QTextTablecomplexSelectionTable () const
 
void insertBlock (const QTextBlockFormat &format, const QTextCharFormat &charFormat)
 
bool movePosition (QTextCursor::MoveOperation op, QTextCursor::MoveMode mode=QTextCursor::MoveAnchor)
 
 QTextCursorPrivate (QTextDocumentPrivate *p)
 
 QTextCursorPrivate (const QTextCursorPrivate &rhs)
 
void remove ()
 
void selectedTableCells (int *firstRow, int *numRows, int *firstColumn, int *numColumns) const
 
void setBlockCharFormat (const QTextCharFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode)
 
void setBlockFormat (const QTextBlockFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode)
 
void setCharFormat (const QTextCharFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode)
 
bool setPosition (int newPosition)
 
void setX ()
 
 ~QTextCursorPrivate ()
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 

Public Variables

int adjusted_anchor
 
int anchor
 
uint changed: 1
 
int currentCharFormat
 
uint keepPositionOnInsert: 1
 
int position
 
QTextDocumentPrivatepriv
 
uint visualNavigation: 1
 
qreal x
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

Definition at line 64 of file qtextcursor_p.h.

Enumerations

◆ AdjustResult

Enumerator
CursorMoved 
CursorUnchanged 

Definition at line 71 of file qtextcursor_p.h.

Constructors and Destructors

◆ QTextCursorPrivate() [1/2]

QTextCursorPrivate::QTextCursorPrivate ( QTextDocumentPrivate p)

Definition at line 65 of file qtextcursor.cpp.

66  : priv(p), x(0), position(0), anchor(0), adjusted_anchor(0),
68  changed(false)
69 {
70  priv->addCursor(this);
71 }
void addCursor(QTextCursorPrivate *c)
QTextDocumentPrivate * priv

◆ QTextCursorPrivate() [2/2]

QTextCursorPrivate::QTextCursorPrivate ( const QTextCursorPrivate rhs)

Definition at line 73 of file qtextcursor.cpp.

74  : QSharedData(rhs)
75 {
76  position = rhs.position;
77  anchor = rhs.anchor;
79  priv = rhs.priv;
80  x = rhs.x;
84  changed = rhs.changed;
85  priv->addCursor(this);
86 }
QSharedData()
Constructs a QSharedData object with a reference count of 0.
Definition: qshareddata.h:61
void addCursor(QTextCursorPrivate *c)
QTextDocumentPrivate * priv

◆ ~QTextCursorPrivate()

QTextCursorPrivate::~QTextCursorPrivate ( )

Definition at line 88 of file qtextcursor.cpp.

89 {
90  if (priv)
91  priv->removeCursor(this);
92 }
void removeCursor(QTextCursorPrivate *c)
QTextDocumentPrivate * priv

Functions

◆ aboutToRemoveCell()

void QTextCursorPrivate::aboutToRemoveCell ( int  from,
int  to 
)

Definition at line 299 of file qtextcursor.cpp.

Referenced by QTextDocumentPrivate::aboutToRemoveCell(), and blockFormat().

300 {
301  Q_ASSERT(from <= to);
302  if (position == anchor)
303  return;
304 
306  if (!t)
307  return;
308  QTextTableCell removedCellFrom = t->cellAt(from);
309  QTextTableCell removedCellEnd = t->cellAt(to);
310  if (! removedCellFrom.isValid() || !removedCellEnd.isValid())
311  return;
312 
313  int curFrom = position;
314  int curTo = adjusted_anchor;
315  if (curTo < curFrom)
316  qSwap(curFrom, curTo);
317 
318  QTextTableCell cellStart = t->cellAt(curFrom);
319  QTextTableCell cellEnd = t->cellAt(curTo);
320 
321  if (cellStart.row() >= removedCellFrom.row() && cellEnd.row() <= removedCellEnd.row()
322  && cellStart.column() >= removedCellFrom.column()
323  && cellEnd.column() <= removedCellEnd.column()) { // selection is completely removed
324  // find a new position, as close as possible to where we were.
325  QTextTableCell cell;
326  if (removedCellFrom.row() == 0 && removedCellEnd.row() == t->rows()-1) // removed n columns
327  cell = t->cellAt(cellStart.row(), removedCellEnd.column()+1);
328  else if (removedCellFrom.column() == 0 && removedCellEnd.column() == t->columns()-1) // removed n rows
329  cell = t->cellAt(removedCellEnd.row() + 1, cellStart.column());
330 
331  int newPosition;
332  if (cell.isValid())
333  newPosition = cell.firstPosition();
334  else
335  newPosition = t->lastPosition()+1;
336 
337  setPosition(newPosition);
338  anchor = newPosition;
339  adjusted_anchor = newPosition;
340  x = 0;
341  }
342  else if (cellStart.row() >= removedCellFrom.row() && cellStart.row() <= removedCellEnd.row()
343  && cellEnd.row() > removedCellEnd.row()) {
344  int newPosition = t->cellAt(removedCellEnd.row() + 1, cellStart.column()).firstPosition();
345  if (position < anchor)
346  position = newPosition;
347  else
348  anchor = adjusted_anchor = newPosition;
349  }
350  else if (cellStart.column() >= removedCellFrom.column() && cellStart.column() <= removedCellEnd.column()
351  && cellEnd.column() > removedCellEnd.column()) {
352  int newPosition = t->cellAt(cellStart.row(), removedCellEnd.column()+1).firstPosition();
353  if (position < anchor)
354  position = newPosition;
355  else
356  anchor = adjusted_anchor = newPosition;
357  }
358 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
int columns() const
Returns the number of columns in the table.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
bool setPosition(int newPosition)
Definition: qtextcursor_p.h:78
QTextTableCell cellAt(int row, int col) const
Returns the table cell at the given row and column in the table.
Definition: qtexttable.cpp:630
int column() const
Returns the number of the column in the table that contains this cell.
Definition: qtexttable.cpp:201
QTextFrame * frameAt(int pos) const
int lastPosition() const
Returns the last document position inside the frame.
int row() const
Returns the number of the row in the table that contains this cell.
Definition: qtexttable.cpp:184
The QTextTable class represents a table in a QTextDocument.
Definition: qtexttable.h:103
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181
int firstPosition() const
Returns the first valid position in the document occupied by this cell.
Definition: qtexttable.cpp:273
int rows() const
Returns the number of rows in the table.
The QTextTableCell class represents the properties of a cell in a QTextTable.
Definition: qtexttable.h:59
QTextDocumentPrivate * priv
bool isValid() const
Returns true if this is a valid table cell; otherwise returns false.
Definition: qtexttable.h:77

◆ adjustCursor()

void QTextCursorPrivate::adjustCursor ( QTextCursor::MoveOperation  m)

Definition at line 215 of file qtextcursor.cpp.

Referenced by movePosition(), and QTextCursor::setPosition().

216 {
218  if (position == anchor)
219  return;
220 
221  QTextFrame *f_position = priv->frameAt(position);
222  QTextFrame *f_anchor = priv->frameAt(adjusted_anchor);
223 
224  if (f_position != f_anchor) {
225  // find common parent frame
226  QList<QTextFrame *> positionChain;
227  QList<QTextFrame *> anchorChain;
228  QTextFrame *f = f_position;
229  while (f) {
230  positionChain.prepend(f);
231  f = f->parentFrame();
232  }
233  f = f_anchor;
234  while (f) {
235  anchorChain.prepend(f);
236  f = f->parentFrame();
237  }
238  Q_ASSERT(positionChain.at(0) == anchorChain.at(0));
239  int i = 1;
240  int l = qMin(positionChain.size(), anchorChain.size());
241  for (; i < l; ++i) {
242  if (positionChain.at(i) != anchorChain.at(i))
243  break;
244  }
245 
246  if (m <= QTextCursor::WordLeft) {
247  if (i < positionChain.size())
248  position = positionChain.at(i)->firstPosition() - 1;
249  } else {
250  if (i < positionChain.size())
251  position = positionChain.at(i)->lastPosition() + 1;
252  }
253  if (position < adjusted_anchor) {
254  if (i < anchorChain.size())
255  adjusted_anchor = anchorChain.at(i)->lastPosition() + 1;
256  } else {
257  if (i < anchorChain.size())
258  adjusted_anchor = anchorChain.at(i)->firstPosition() - 1;
259  }
260 
261  f_position = positionChain.at(i-1);
262  }
263 
264  // same frame, either need to adjust to cell boundaries or return
265  QTextTable *table = qobject_cast<QTextTable *>(f_position);
266  if (!table)
267  return;
268 
269  QTextTableCell c_position = table->cellAt(position);
270  QTextTableCell c_anchor = table->cellAt(adjusted_anchor);
271  if (c_position != c_anchor) {
272  bool before;
273  int col_position = c_position.column();
274  int col_anchor = c_anchor.column();
275  if (col_position == col_anchor) {
276  before = c_position.row() < c_anchor.row();
277  } else {
278  before = col_position < col_anchor;
279  }
280 
281  // adjust to cell boundaries
282  if (m <= QTextCursor::WordLeft) {
283  position = c_position.firstPosition();
284  if (!before)
285  --position;
286  } else {
287  position = c_position.lastPosition();
288  if (before)
289  ++position;
290  }
292  adjusted_anchor = c_anchor.lastPosition();
293  else
294  adjusted_anchor = c_anchor.firstPosition();
295  }
296  currentCharFormat = -1;
297 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
The QTextFrame class represents a frame in a QTextDocument.
Definition: qtextobject.h:122
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int firstPosition() const
Returns the first document position inside the frame.
QTextTableCell cellAt(int row, int col) const
Returns the table cell at the given row and column in the table.
Definition: qtexttable.cpp:630
int column() const
Returns the number of the column in the table that contains this cell.
Definition: qtexttable.cpp:201
QTextFrame * frameAt(int pos) const
int lastPosition() const
Returns the last document position inside the frame.
QTextFrame * parentFrame() const
Returns the frame&#39;s parent frame.
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
int row() const
Returns the number of the row in the table that contains this cell.
Definition: qtexttable.cpp:184
The QTextTable class represents a table in a QTextDocument.
Definition: qtexttable.h:103
int firstPosition() const
Returns the first valid position in the document occupied by this cell.
Definition: qtexttable.cpp:273
The QTextTableCell class represents the properties of a cell in a QTextTable.
Definition: qtexttable.h:59
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QFactoryLoader * l
QTextDocumentPrivate * priv
int lastPosition() const
Returns the last valid position in the document occupied by this cell.
Definition: qtexttable.cpp:287
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ adjustPosition()

QTextCursorPrivate::AdjustResult QTextCursorPrivate::adjustPosition ( int  positionOfChange,
int  charsAddedOrRemoved,
QTextUndoCommand::Operation  op 
)

Definition at line 94 of file qtextcursor.cpp.

Referenced by QTextDocumentPrivate::adjustDocumentChangesAndCursors(), and QTextDocumentPrivate::remove().

95 {
97  // not(!) <= , so that inserting text adjusts the cursor correctly
98  if (position < positionOfChange
99  || (position == positionOfChange
102  )
103  ) {
104  result = CursorUnchanged;
105  } else {
106  if (charsAddedOrRemoved < 0 && position < positionOfChange - charsAddedOrRemoved)
107  position = positionOfChange;
108  else
109  position += charsAddedOrRemoved;
110 
111  currentCharFormat = -1;
112  }
113 
114  if (anchor >= positionOfChange
115  && (anchor != positionOfChange || op != QTextUndoCommand::KeepCursor)) {
116  if (charsAddedOrRemoved < 0 && anchor < positionOfChange - charsAddedOrRemoved)
117  anchor = positionOfChange;
118  else
119  anchor += charsAddedOrRemoved;
120  }
121 
122  if (adjusted_anchor >= positionOfChange
123  && (adjusted_anchor != positionOfChange || op != QTextUndoCommand::KeepCursor)) {
124  if (charsAddedOrRemoved < 0 && adjusted_anchor < positionOfChange - charsAddedOrRemoved)
125  adjusted_anchor = positionOfChange;
126  else
127  adjusted_anchor += charsAddedOrRemoved;
128  }
129 
130  return result;
131 }

◆ block()

QTextBlock QTextCursorPrivate::block ( ) const
inline

◆ blockFormat()

QTextBlockFormat QTextCursorPrivate::blockFormat ( ) const
inline

Definition at line 95 of file qtextcursor_p.h.

96  { return block().blockFormat(); }
QTextBlock block() const
Definition: qtextcursor_p.h:93
QTextBlockFormat blockFormat() const
Returns the QTextBlockFormat that describes block-specific properties.

◆ blockLayout()

QTextLayout * QTextCursorPrivate::blockLayout ( QTextBlock block) const

Definition at line 886 of file qtextcursor.cpp.

Referenced by blockFormat(), QTextCursor::columnNumber(), movePosition(), and setX().

886  {
887  QTextLayout *tl = block.layout();
888  if (!tl->lineCount() && priv->layout())
889  priv->layout()->blockBoundingRect(block);
890  return tl;
891 }
QAbstractTextDocumentLayout * layout() const
The QTextLayout class is used to lay out and render text.
Definition: qtextlayout.h:105
virtual QRectF blockBoundingRect(const QTextBlock &block) const =0
Returns the bounding rectangle of block.
QTextDocumentPrivate * priv
int lineCount() const
Returns the number of lines in this text layout.
QTextLayout * layout() const
Returns the QTextLayout that is used to lay out and display the block&#39;s contents. ...

◆ canDelete()

bool QTextCursorPrivate::canDelete ( int  pos) const

Definition at line 198 of file qtextcursor.cpp.

Referenced by QTextCursor::deleteChar(), QTextCursor::deletePreviousChar(), and setPosition().

199 {
201  QTextCharFormat fmt = priv->formatCollection()->charFormat((*fit)->format);
202  return (fmt.objectIndex() == -1 || fmt.objectType() == QTextFormat::ImageObject);
203 }
int objectIndex() const
Returns the index of the format object, or -1 if the format object is invalid.
QTextCharFormat charFormat(int index) const
Definition: qtextformat_p.h:85
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
FragmentMap::ConstIterator FragmentIterator
FragmentIterator find(int pos) const
int objectType() const
Returns the text format&#39;s object type.
Definition: qtextformat.h:315
QTextFormatCollection * formatCollection()
QTextDocumentPrivate * priv

◆ clearCells()

void QTextCursorPrivate::clearCells ( QTextTable table,
int  startRow,
int  startCol,
int  numRows,
int  numCols,
QTextUndoCommand::Operation  op 
)

Definition at line 182 of file qtextcursor.cpp.

Referenced by remove().

183 {
184  priv->beginEditBlock();
185 
186  for (int row = startRow; row < startRow + numRows; ++row)
187  for (int col = startCol; col < startCol + numCols; ++col) {
188  QTextTableCell cell = table->cellAt(row, col);
189  const int startPos = cell.firstPosition();
190  const int endPos = cell.lastPosition();
191  Q_ASSERT(startPos <= endPos);
192  priv->remove(startPos, endPos - startPos, op);
193  }
194 
195  priv->endEditBlock();
196 }
void remove(int pos, int length, QTextUndoCommand::Operation=QTextUndoCommand::MoveCursor)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QTextTableCell cellAt(int row, int col) const
Returns the table cell at the given row and column in the table.
Definition: qtexttable.cpp:630
int firstPosition() const
Returns the first valid position in the document occupied by this cell.
Definition: qtexttable.cpp:273
The QTextTableCell class represents the properties of a cell in a QTextTable.
Definition: qtexttable.h:59
QTextDocumentPrivate * priv
int lastPosition() const
Returns the last valid position in the document occupied by this cell.
Definition: qtexttable.cpp:287

◆ complexSelectionTable()

QTextTable * QTextCursorPrivate::complexSelectionTable ( ) const

Definition at line 686 of file qtextcursor.cpp.

Referenced by blockFormat(), QTextCursor::hasComplexSelection(), remove(), QTextCursor::selectedText(), setBlockCharFormat(), setBlockFormat(), and setCharFormat().

687 {
688  if (position == anchor)
689  return 0;
690 
692  if (t) {
693  QTextTableCell cell_pos = t->cellAt(position);
694  QTextTableCell cell_anchor = t->cellAt(adjusted_anchor);
695 
696  Q_ASSERT(cell_anchor.isValid());
697 
698  if (cell_pos == cell_anchor)
699  t = 0;
700  }
701  return t;
702 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QTextTableCell cellAt(int row, int col) const
Returns the table cell at the given row and column in the table.
Definition: qtexttable.cpp:630
QTextFrame * frameAt(int pos) const
The QTextTable class represents a table in a QTextDocument.
Definition: qtexttable.h:103
The QTextTableCell class represents the properties of a cell in a QTextTable.
Definition: qtexttable.h:59
QTextDocumentPrivate * priv
bool isValid() const
Returns true if this is a valid table cell; otherwise returns false.
Definition: qtexttable.h:77

◆ insertBlock()

void QTextCursorPrivate::insertBlock ( const QTextBlockFormat format,
const QTextCharFormat charFormat 
)

Definition at line 205 of file qtextcursor.cpp.

Referenced by QTextCursor::insertBlock(), QTextCursor::insertText(), and setPosition().

206 {
208  int idx = formats->indexForFormat(format);
209  Q_ASSERT(formats->format(idx).isBlockFormat());
210 
211  priv->insertBlock(position, idx, formats->indexForFormat(charFormat));
212  currentCharFormat = -1;
213 }
QTextFormat format(int idx) const
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int insertBlock(int pos, int blockFormat, int charFormat, QTextUndoCommand::Operation=QTextUndoCommand::MoveCursor)
QTextFormatCollection * formatCollection()
bool isBlockFormat() const
Returns true if this text format is a BlockFormat; otherwise returns false.
Definition: qtextformat.h:319
QTextDocumentPrivate * priv
int indexForFormat(const QTextFormat &f)

◆ movePosition()

bool QTextCursorPrivate::movePosition ( QTextCursor::MoveOperation  op,
QTextCursor::MoveMode  mode = QTextCursor::MoveAnchor 
)

Definition at line 360 of file qtextcursor.cpp.

Referenced by QTextCursor::movePosition(), and setPosition().

361 {
362  currentCharFormat = -1;
363  bool adjustX = true;
364  QTextBlock blockIt = block();
365  bool visualMovement = priv->defaultCursorMoveStyle == Qt::VisualMoveStyle;
366 
367  if (!blockIt.isValid())
368  return false;
369 
370  if (blockIt.textDirection() == Qt::RightToLeft) {
371  if (op == QTextCursor::WordLeft)
373  else if (op == QTextCursor::WordRight)
375 
376  if (!visualMovement) {
377  if (op == QTextCursor::Left)
379  else if (op == QTextCursor::Right)
381  }
382  }
383 
384  const QTextLayout *layout = blockLayout(blockIt);
385  int relativePos = position - blockIt.position();
386  QTextLine line;
387  if (!priv->isInEditBlock())
388  line = layout->lineForTextPosition(relativePos);
389 
391 
392  int newPosition = position;
393 
394  if (x == -1 && !priv->isInEditBlock() && (op == QTextCursor::Up || op == QTextCursor::Down))
395  setX();
396 
397  switch(op) {
398  case QTextCursor::NoMove:
399  return true;
400 
401  case QTextCursor::Start:
402  newPosition = 0;
403  break;
405  newPosition = blockIt.position();
406  if (line.isValid())
407  newPosition += line.textStart();
408 
409  break;
410  }
412  newPosition = blockIt.position();
413  break;
414  }
416  if (blockIt == priv->blocksBegin())
417  return false;
418  blockIt = blockIt.previous();
419 
420  newPosition = blockIt.position();
421  break;
422  }
424 #ifdef Q_WS_MAC
426  newPosition = qMin(position, adjusted_anchor);
427  else
428 #endif
430  break;
431  case QTextCursor::Left:
432 #ifdef Q_WS_MAC
434  newPosition = visualMovement ? qMax(position, adjusted_anchor)
436  else
437 #endif
438  newPosition = visualMovement ? priv->leftCursorPosition(position)
440  break;
442  if (relativePos == 0)
443  break;
444 
445  // skip if already at word start
446  QTextEngine *engine = layout->engine();
447  engine->attributes();
448  if ((relativePos == blockIt.length() - 1)
449  && (engine->atSpace(relativePos - 1) || engine->atWordSeparator(relativePos - 1)))
450  return false;
451 
452  if (relativePos < blockIt.length()-1)
453  ++position;
454 
455  // FALL THROUGH!
456  }
460  break;
461  case QTextCursor::Up: {
462  int i = line.lineNumber() - 1;
463  if (i == -1) {
464  if (blockIt == priv->blocksBegin())
465  return false;
466  int blockPosition = blockIt.position();
467  QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(blockPosition));
468  if (table) {
469  QTextTableCell cell = table->cellAt(blockPosition);
470  if (cell.firstPosition() == blockPosition) {
471  int row = cell.row() - 1;
472  if (row >= 0) {
473  blockPosition = table->cellAt(row, cell.column()).lastPosition();
474  } else {
475  // move to line above the table
476  blockPosition = table->firstPosition() - 1;
477  }
478  blockIt = priv->blocksFind(blockPosition);
479  } else {
480  blockIt = blockIt.previous();
481  }
482  } else {
483  blockIt = blockIt.previous();
484  }
485  layout = blockLayout(blockIt);
486  i = layout->lineCount()-1;
487  }
488  if (layout->lineCount()) {
489  QTextLine line = layout->lineAt(i);
490  newPosition = line.xToCursor(x) + blockIt.position();
491  } else {
492  newPosition = blockIt.position();
493  }
494  adjustX = false;
495  break;
496  }
497 
498  case QTextCursor::End:
499  newPosition = priv->length() - 1;
500  break;
501  case QTextCursor::EndOfLine: {
502  if (!line.isValid() || line.textLength() == 0) {
503  if (blockIt.length() >= 1)
504  // position right before the block separator
505  newPosition = blockIt.position() + blockIt.length() - 1;
506  break;
507  }
508  newPosition = blockIt.position() + line.textStart() + line.textLength();
509  if (line.lineNumber() < layout->lineCount() - 1) {
510  const QString text = blockIt.text();
511  // ###### this relies on spaces being the cause for linebreaks.
512  // this doesn't work with japanese
513  if (text.at(line.textStart() + line.textLength() - 1).isSpace())
514  --newPosition;
515  }
516  break;
517  }
518  case QTextCursor::EndOfWord: {
519  QTextEngine *engine = layout->engine();
520  engine->attributes();
521  const int len = blockIt.length() - 1;
522  if (relativePos >= len)
523  return false;
524  if (engine->atWordSeparator(relativePos)) {
525  ++relativePos;
526  while (relativePos < len && engine->atWordSeparator(relativePos))
527  ++relativePos;
528  } else {
529  while (relativePos < len && !engine->atSpace(relativePos) && !engine->atWordSeparator(relativePos))
530  ++relativePos;
531  }
532  newPosition = blockIt.position() + relativePos;
533  break;
534  }
536  if (blockIt.length() >= 1)
537  // position right before the block separator
538  newPosition = blockIt.position() + blockIt.length() - 1;
539  break;
540  case QTextCursor::NextBlock: {
541  blockIt = blockIt.next();
542  if (!blockIt.isValid())
543  return false;
544 
545  newPosition = blockIt.position();
546  break;
547  }
549 #ifdef Q_WS_MAC
551  newPosition = qMax(position, adjusted_anchor);
552  else
553 #endif
555  break;
556  case QTextCursor::Right:
557 #ifdef Q_WS_MAC
559  newPosition = visualMovement ? qMin(position, adjusted_anchor)
560  : qMax(position, adjusted_anchor);
561  else
562 #endif
563  newPosition = visualMovement ? priv->rightCursorPosition(position)
565  break;
569  break;
570 
571  case QTextCursor::Down: {
572  int i = line.lineNumber() + 1;
573 
574  if (i >= layout->lineCount()) {
575  int blockPosition = blockIt.position() + blockIt.length() - 1;
576  QTextTable *table = qobject_cast<QTextTable *>(priv->frameAt(blockPosition));
577  if (table) {
578  QTextTableCell cell = table->cellAt(blockPosition);
579  if (cell.lastPosition() == blockPosition) {
580  int row = cell.row() + cell.rowSpan();
581  if (row < table->rows()) {
582  blockPosition = table->cellAt(row, cell.column()).firstPosition();
583  } else {
584  // move to line below the table
585  blockPosition = table->lastPosition() + 1;
586  }
587  blockIt = priv->blocksFind(blockPosition);
588  } else {
589  blockIt = blockIt.next();
590  }
591  } else {
592  blockIt = blockIt.next();
593  }
594 
595  if (blockIt == priv->blocksEnd())
596  return false;
597  layout = blockLayout(blockIt);
598  i = 0;
599  }
600  if (layout->lineCount()) {
601  QTextLine line = layout->lineAt(i);
602  newPosition = line.xToCursor(x) + blockIt.position();
603  } else {
604  newPosition = blockIt.position();
605  }
606  adjustX = false;
607  break;
608  }
609  case QTextCursor::NextCell: // fall through
610  case QTextCursor::PreviousCell: // fall through
611  case QTextCursor::NextRow: // fall through
614  if (!table)
615  return false;
616 
617  QTextTableCell cell = table->cellAt(position);
618  Q_ASSERT(cell.isValid());
619  int column = cell.column();
620  int row = cell.row();
621  const int currentRow = row;
622  if (op == QTextCursor::NextCell || op == QTextCursor::NextRow) {
623  do {
624  column += cell.columnSpan();
625  if (column >= table->columns()) {
626  column = 0;
627  ++row;
628  }
629  cell = table->cellAt(row, column);
630  // note we also continue while we have not reached a cell thats not merged with one above us
631  } while (cell.isValid()
632  && ((op == QTextCursor::NextRow && currentRow == cell.row())
633  || cell.row() < row));
634  }
635  else if (op == QTextCursor::PreviousCell || op == QTextCursor::PreviousRow) {
636  do {
637  --column;
638  if (column < 0) {
639  column = table->columns()-1;
640  --row;
641  }
642  cell = table->cellAt(row, column);
643  // note we also continue while we have not reached a cell thats not merged with one above us
644  } while (cell.isValid()
645  && ((op == QTextCursor::PreviousRow && currentRow == cell.row())
646  || cell.row() < row));
647  }
648  if (cell.isValid())
649  newPosition = cell.firstPosition();
650  break;
651  }
652  }
653 
654  if (mode == QTextCursor::KeepAnchor) {
656  if (table && ((op >= QTextCursor::PreviousBlock && op <= QTextCursor::WordLeft)
657  || (op >= QTextCursor::NextBlock && op <= QTextCursor::WordRight))) {
658  int oldColumn = table->cellAt(position).column();
659 
660  const QTextTableCell otherCell = table->cellAt(newPosition);
661  if (!otherCell.isValid())
662  return false;
663 
664  int newColumn = otherCell.column();
665  if ((oldColumn > newColumn && op >= QTextCursor::End)
666  || (oldColumn < newColumn && op <= QTextCursor::WordLeft))
667  return false;
668  }
669  }
670 
671  const bool moved = setPosition(newPosition);
672 
673  if (mode == QTextCursor::MoveAnchor) {
674  anchor = position;
676  } else {
677  adjustCursor(op);
678  }
679 
680  if (adjustX)
681  setX();
682 
683  return moved;
684 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
int columns() const
Returns the number of columns in the table.
QTextEngine * engine() const
Definition: qtextlayout.h:180
QString text() const
Returns the block&#39;s contents as plain text.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
bool atWordSeparator(int position) const
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
QTextBlock block() const
Definition: qtextcursor_p.h:93
The QTextLine class represents a line of text inside a QTextLayout.
Definition: qtextlayout.h:197
int textLength() const
Returns the length of the text in the line.
QTextLayout * blockLayout(QTextBlock &block) const
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const HB_CharAttributes * attributes() const
int firstPosition() const
Returns the first document position inside the frame.
bool isValid() const
Returns true if this text line is valid; otherwise returns false.
Definition: qtextlayout.h:201
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QTextBlock next() const
Returns the text block in the document after this block, or an empty text block if this is the last o...
QTextLine lineForTextPosition(int pos) const
Returns the line that contains the cursor position specified by pos.
int rowSpan() const
Returns the number of rows this cell spans.
Definition: qtexttable.cpp:218
bool isInEditBlock() const
int position() const
Returns the index of the block&#39;s first character within the document.
int leftCursorPosition(int position) const
QTextBlock previous() const
Returns the text block in the document before this block, or an empty text block if this is the first...
bool setPosition(int newPosition)
Definition: qtextcursor_p.h:78
QTextTableCell cellAt(int row, int col) const
Returns the table cell at the given row and column in the table.
Definition: qtexttable.cpp:630
int column() const
Returns the number of the column in the table that contains this cell.
Definition: qtexttable.cpp:201
QTextFrame * frameAt(int pos) const
QTextBlock blocksBegin() const
int lastPosition() const
Returns the last document position inside the frame.
int lineNumber() const
Returns the position of the line in the text engine.
Definition: qtextlayout.h:243
const char * layout
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
int row() const
Returns the number of the row in the table that contains this cell.
Definition: qtexttable.cpp:184
int length() const
Returns the length of the block in characters.
The QTextTable class represents a table in a QTextDocument.
Definition: qtexttable.h:103
QTextLine lineAt(int i) const
Returns the {i}-th line of text in this text layout.
int rightCursorPosition(int position) const
The QTextLayout class is used to lay out and render text.
Definition: qtextlayout.h:105
int previousCursorPosition(int position, QTextLayout::CursorMode mode) const
int nextCursorPosition(int position, QTextLayout::CursorMode mode) const
int firstPosition() const
Returns the first valid position in the document occupied by this cell.
Definition: qtexttable.cpp:273
The QTextTableCell class represents the properties of a cell in a QTextTable.
Definition: qtexttable.h:59
QTextDocumentPrivate * priv
int lastPosition() const
Returns the last valid position in the document occupied by this cell.
Definition: qtexttable.cpp:287
Qt::LayoutDirection textDirection() const
Returns the resolved text direction.
void adjustCursor(QTextCursor::MoveOperation m)
bool isValid() const
Returns true if this is a valid table cell; otherwise returns false.
Definition: qtexttable.h:77
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
Definition: qtextobject.h:208
bool atSpace(int position) const
Qt::CursorMoveStyle defaultCursorMoveStyle
QTextBlock blocksFind(int pos) const
int columnSpan() const
Returns the number of columns this cell spans.
Definition: qtexttable.cpp:228
int xToCursor(qreal x, CursorPosition=CursorBetweenCharacters) const
Converts the x-coordinate x, to the nearest matching cursor position, depending on the cursor positio...
int textStart() const
Returns the start of the line from the beginning of the string passed to the QTextLayout.
#define text
Definition: qobjectdefs.h:80
int lineCount() const
Returns the number of lines in this text layout.
QTextBlock blocksEnd() const

◆ remove()

void QTextCursorPrivate::remove ( )

Definition at line 151 of file qtextcursor.cpp.

Referenced by QTextCursor::deleteChar(), QTextCursor::deletePreviousChar(), QTextCursor::insertBlock(), QTextCursor::insertFragment(), QTextCursor::insertImage(), QTextCursor::insertText(), and QTextCursor::removeSelectedText().

152 {
153  if (anchor == position)
154  return;
155  currentCharFormat = -1;
156  int pos1 = position;
157  int pos2 = adjusted_anchor;
159  if (pos1 > pos2) {
160  pos1 = adjusted_anchor;
161  pos2 = position;
163  }
164 
165  // deleting inside table? -> delete only content
167  if (table) {
168  priv->beginEditBlock();
169  int startRow, startCol, numRows, numCols;
170  selectedTableCells(&startRow, &numRows, &startCol, &numCols);
171  clearCells(table, startRow, startCol, numRows, numCols, op);
173  priv->endEditBlock();
174  } else {
175  priv->remove(pos1, pos2-pos1, op);
177  priv->finishEdit();
178  }
179 
180 }
QTextTable * complexSelectionTable() const
void remove(int pos, int length, QTextUndoCommand::Operation=QTextUndoCommand::MoveCursor)
The QTextTable class represents a table in a QTextDocument.
Definition: qtexttable.h:103
QTextDocumentPrivate * priv
void selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const
void clearCells(QTextTable *table, int startRow, int startCol, int numRows, int numCols, QTextUndoCommand::Operation op)

◆ selectedTableCells()

void QTextCursorPrivate::selectedTableCells ( int *  firstRow,
int *  numRows,
int *  firstColumn,
int *  numColumns 
) const

Definition at line 704 of file qtextcursor.cpp.

Referenced by blockFormat(), remove(), QTextCursor::selectedTableCells(), setBlockCharFormat(), setBlockFormat(), and setCharFormat().

705 {
706  *firstRow = -1;
707  *firstColumn = -1;
708  *numRows = -1;
709  *numColumns = -1;
710 
711  if (position == anchor)
712  return;
713 
715  if (!t)
716  return;
717 
718  QTextTableCell cell_pos = t->cellAt(position);
719  QTextTableCell cell_anchor = t->cellAt(adjusted_anchor);
720 
721  Q_ASSERT(cell_anchor.isValid());
722 
723  if (cell_pos == cell_anchor)
724  return;
725 
726  *firstRow = qMin(cell_pos.row(), cell_anchor.row());
727  *firstColumn = qMin(cell_pos.column(), cell_anchor.column());
728  *numRows = qMax(cell_pos.row() + cell_pos.rowSpan(), cell_anchor.row() + cell_anchor.rowSpan()) - *firstRow;
729  *numColumns = qMax(cell_pos.column() + cell_pos.columnSpan(), cell_anchor.column() + cell_anchor.columnSpan()) - *firstColumn;
730 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
int rowSpan() const
Returns the number of rows this cell spans.
Definition: qtexttable.cpp:218
QTextTableCell cellAt(int row, int col) const
Returns the table cell at the given row and column in the table.
Definition: qtexttable.cpp:630
int column() const
Returns the number of the column in the table that contains this cell.
Definition: qtexttable.cpp:201
QTextFrame * frameAt(int pos) const
int row() const
Returns the number of the row in the table that contains this cell.
Definition: qtexttable.cpp:184
The QTextTable class represents a table in a QTextDocument.
Definition: qtexttable.h:103
The QTextTableCell class represents the properties of a cell in a QTextTable.
Definition: qtexttable.h:59
QTextDocumentPrivate * priv
bool isValid() const
Returns true if this is a valid table cell; otherwise returns false.
Definition: qtexttable.h:77
int columnSpan() const
Returns the number of columns this cell spans.
Definition: qtexttable.cpp:228

◆ setBlockCharFormat()

void QTextCursorPrivate::setBlockCharFormat ( const QTextCharFormat format,
QTextDocumentPrivate::FormatChangeMode  changeMode 
)

Definition at line 745 of file qtextcursor.cpp.

Referenced by blockFormat(), QTextCursor::mergeBlockCharFormat(), and QTextCursor::setBlockCharFormat().

747 {
748  priv->beginEditBlock();
749 
750  QTextCharFormat format = _format;
752 
754  if (table) {
755  int row_start, col_start, num_rows, num_cols;
756  selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
757 
758  Q_ASSERT(row_start != -1);
759  for (int r = row_start; r < row_start + num_rows; ++r) {
760  for (int c = col_start; c < col_start + num_cols; ++c) {
761  QTextTableCell cell = table->cellAt(r, c);
762  int rspan = cell.rowSpan();
763  int cspan = cell.columnSpan();
764  if (rspan != 1) {
765  int cr = cell.row();
766  if (cr != r)
767  continue;
768  }
769  if (cspan != 1) {
770  int cc = cell.column();
771  if (cc != c)
772  continue;
773  }
774 
775  int pos1 = cell.firstPosition();
776  int pos2 = cell.lastPosition();
777  setBlockCharFormatHelper(priv, pos1, pos2, format, changeMode);
778  }
779  }
780  } else {
781  int pos1 = position;
782  int pos2 = adjusted_anchor;
783  if (pos1 > pos2) {
784  pos1 = adjusted_anchor;
785  pos2 = position;
786  }
787 
788  setBlockCharFormatHelper(priv, pos1, pos2, format, changeMode);
789  }
790  priv->endEditBlock();
791 }
QTextTable * complexSelectionTable() const
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
unsigned char c[8]
Definition: qnumeric_p.h:62
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int rowSpan() const
Returns the number of rows this cell spans.
Definition: qtexttable.cpp:218
QTextTableCell cellAt(int row, int col) const
Returns the table cell at the given row and column in the table.
Definition: qtexttable.cpp:630
int column() const
Returns the number of the column in the table that contains this cell.
Definition: qtexttable.cpp:201
int row() const
Returns the number of the row in the table that contains this cell.
Definition: qtexttable.cpp:184
The QTextTable class represents a table in a QTextDocument.
Definition: qtexttable.h:103
int firstPosition() const
Returns the first valid position in the document occupied by this cell.
Definition: qtexttable.cpp:273
The QTextTableCell class represents the properties of a cell in a QTextTable.
Definition: qtexttable.h:59
QTextDocumentPrivate * priv
int lastPosition() const
Returns the last valid position in the document occupied by this cell.
Definition: qtexttable.cpp:287
void clearProperty(int propertyId)
Clears the value of the property given by propertyId.
int columnSpan() const
Returns the number of columns this cell spans.
Definition: qtexttable.cpp:228
static void setBlockCharFormatHelper(QTextDocumentPrivate *priv, int pos1, int pos2, const QTextCharFormat &format, QTextDocumentPrivate::FormatChangeMode changeMode)
void selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const

◆ setBlockFormat()

void QTextCursorPrivate::setBlockFormat ( const QTextBlockFormat format,
QTextDocumentPrivate::FormatChangeMode  changeMode 
)

Definition at line 794 of file qtextcursor.cpp.

Referenced by blockFormat(), QTextCursor::mergeBlockFormat(), and QTextCursor::setBlockFormat().

795 {
797  if (table) {
798  priv->beginEditBlock();
799  int row_start, col_start, num_rows, num_cols;
800  selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
801 
802  Q_ASSERT(row_start != -1);
803  for (int r = row_start; r < row_start + num_rows; ++r) {
804  for (int c = col_start; c < col_start + num_cols; ++c) {
805  QTextTableCell cell = table->cellAt(r, c);
806  int rspan = cell.rowSpan();
807  int cspan = cell.columnSpan();
808  if (rspan != 1) {
809  int cr = cell.row();
810  if (cr != r)
811  continue;
812  }
813  if (cspan != 1) {
814  int cc = cell.column();
815  if (cc != c)
816  continue;
817  }
818 
819  int pos1 = cell.firstPosition();
820  int pos2 = cell.lastPosition();
821  priv->setBlockFormat(priv->blocksFind(pos1), priv->blocksFind(pos2), format, changeMode);
822  }
823  }
824  priv->endEditBlock();
825  } else {
826  int pos1 = position;
827  int pos2 = adjusted_anchor;
828  if (pos1 > pos2) {
829  pos1 = adjusted_anchor;
830  pos2 = position;
831  }
832 
833  priv->setBlockFormat(priv->blocksFind(pos1), priv->blocksFind(pos2), format, changeMode);
834  }
835 }
QTextTable * complexSelectionTable() const
unsigned char c[8]
Definition: qnumeric_p.h:62
void setBlockFormat(const QTextBlock &from, const QTextBlock &to, const QTextBlockFormat &newFormat, FormatChangeMode mode=SetFormat)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int rowSpan() const
Returns the number of rows this cell spans.
Definition: qtexttable.cpp:218
QTextTableCell cellAt(int row, int col) const
Returns the table cell at the given row and column in the table.
Definition: qtexttable.cpp:630
int column() const
Returns the number of the column in the table that contains this cell.
Definition: qtexttable.cpp:201
int row() const
Returns the number of the row in the table that contains this cell.
Definition: qtexttable.cpp:184
The QTextTable class represents a table in a QTextDocument.
Definition: qtexttable.h:103
int firstPosition() const
Returns the first valid position in the document occupied by this cell.
Definition: qtexttable.cpp:273
The QTextTableCell class represents the properties of a cell in a QTextTable.
Definition: qtexttable.h:59
QTextDocumentPrivate * priv
int lastPosition() const
Returns the last valid position in the document occupied by this cell.
Definition: qtexttable.cpp:287
QTextBlock blocksFind(int pos) const
int columnSpan() const
Returns the number of columns this cell spans.
Definition: qtexttable.cpp:228
void selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const

◆ setCharFormat()

void QTextCursorPrivate::setCharFormat ( const QTextCharFormat format,
QTextDocumentPrivate::FormatChangeMode  changeMode 
)

Definition at line 837 of file qtextcursor.cpp.

Referenced by blockFormat(), QTextCursor::mergeCharFormat(), and QTextCursor::setCharFormat().

838 {
840 
841  QTextCharFormat format = _format;
843 
845  if (table) {
846  priv->beginEditBlock();
847  int row_start, col_start, num_rows, num_cols;
848  selectedTableCells(&row_start, &num_rows, &col_start, &num_cols);
849 
850  Q_ASSERT(row_start != -1);
851  for (int r = row_start; r < row_start + num_rows; ++r) {
852  for (int c = col_start; c < col_start + num_cols; ++c) {
853  QTextTableCell cell = table->cellAt(r, c);
854  int rspan = cell.rowSpan();
855  int cspan = cell.columnSpan();
856  if (rspan != 1) {
857  int cr = cell.row();
858  if (cr != r)
859  continue;
860  }
861  if (cspan != 1) {
862  int cc = cell.column();
863  if (cc != c)
864  continue;
865  }
866 
867  int pos1 = cell.firstPosition();
868  int pos2 = cell.lastPosition();
869  priv->setCharFormat(pos1, pos2-pos1, format, changeMode);
870  }
871  }
872  priv->endEditBlock();
873  } else {
874  int pos1 = position;
875  int pos2 = adjusted_anchor;
876  if (pos1 > pos2) {
877  pos1 = adjusted_anchor;
878  pos2 = position;
879  }
880 
881  priv->setCharFormat(pos1, pos2-pos1, format, changeMode);
882  }
883 }
QTextTable * complexSelectionTable() const
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
Definition: qtextformat.h:372
unsigned char c[8]
Definition: qnumeric_p.h:62
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
int rowSpan() const
Returns the number of rows this cell spans.
Definition: qtexttable.cpp:218
QTextTableCell cellAt(int row, int col) const
Returns the table cell at the given row and column in the table.
Definition: qtexttable.cpp:630
int column() const
Returns the number of the column in the table that contains this cell.
Definition: qtexttable.cpp:201
int row() const
Returns the number of the row in the table that contains this cell.
Definition: qtexttable.cpp:184
The QTextTable class represents a table in a QTextDocument.
Definition: qtexttable.h:103
int firstPosition() const
Returns the first valid position in the document occupied by this cell.
Definition: qtexttable.cpp:273
The QTextTableCell class represents the properties of a cell in a QTextTable.
Definition: qtexttable.h:59
QTextDocumentPrivate * priv
int lastPosition() const
Returns the last valid position in the document occupied by this cell.
Definition: qtexttable.cpp:287
void clearProperty(int propertyId)
Clears the value of the property given by propertyId.
int columnSpan() const
Returns the number of columns this cell spans.
Definition: qtexttable.cpp:228
void setCharFormat(int pos, int length, const QTextCharFormat &newFormat, FormatChangeMode mode=SetFormat)
void selectedTableCells(int *firstRow, int *numRows, int *firstColumn, int *numColumns) const

◆ setPosition()

bool QTextCursorPrivate::setPosition ( int  newPosition)
inline

Definition at line 78 of file qtextcursor_p.h.

Referenced by aboutToRemoveCell(), QTextDocumentPrivate::clear(), QTextCursor::insertTable(), movePosition(), QTextCursor::movePosition(), and QTextCursor::setPosition().

78  {
79  Q_ASSERT(newPosition >= 0 && newPosition < priv->length());
80  bool moved = position != newPosition;
81  if (moved) {
82  position = newPosition;
83  currentCharFormat = -1;
84  }
85  return moved;
86  }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

◆ setX()

void QTextCursorPrivate::setX ( )

Definition at line 133 of file qtextcursor.cpp.

Referenced by QTextCursor::deleteChar(), QTextCursor::deletePreviousChar(), QTextCursor::insertBlock(), QTextCursor::insertText(), movePosition(), QTextCursor::QTextCursor(), QTextCursor::removeSelectedText(), setPosition(), and QTextCursor::setPosition().

134 {
135  if (priv->isInEditBlock()) {
136  x = -1; // mark dirty
137  return;
138  }
139 
140  QTextBlock block = this->block();
141  const QTextLayout *layout = blockLayout(block);
142  int pos = position - block.position();
143 
144  QTextLine line = layout->lineForTextPosition(pos);
145  if (line.isValid())
146  x = line.cursorToX(pos);
147  else
148  x = -1; // delayed init. Makes movePosition() call setX later on again.
149 }
QTextBlock block() const
Definition: qtextcursor_p.h:93
The QTextLine class represents a line of text inside a QTextLayout.
Definition: qtextlayout.h:197
QTextLayout * blockLayout(QTextBlock &block) const
bool isValid() const
Returns true if this text line is valid; otherwise returns false.
Definition: qtextlayout.h:201
QTextLine lineForTextPosition(int pos) const
Returns the line that contains the cursor position specified by pos.
bool isInEditBlock() const
int position() const
Returns the index of the block&#39;s first character within the document.
qreal cursorToX(int *cursorPos, Edge edge=Leading) const
Converts the cursor position cursorPos to the corresponding x position inside the line...
const char * layout
The QTextBlock class provides a container for text fragments in a QTextDocument.
Definition: qtextobject.h:199
The QTextLayout class is used to lay out and render text.
Definition: qtextlayout.h:105
QTextDocumentPrivate * priv

Properties

◆ adjusted_anchor

int QTextCursorPrivate::adjusted_anchor

◆ anchor

int QTextCursorPrivate::anchor

◆ changed

uint QTextCursorPrivate::changed

◆ currentCharFormat

int QTextCursorPrivate::currentCharFormat

◆ keepPositionOnInsert

uint QTextCursorPrivate::keepPositionOnInsert

◆ position

int QTextCursorPrivate::position

◆ priv

QTextDocumentPrivate* QTextCursorPrivate::priv

Definition at line 109 of file qtextcursor_p.h.

Referenced by aboutToRemoveCell(), adjustCursor(), QTextCursor::anchor(), QTextCursor::atBlockEnd(), QTextCursor::atBlockStart(), QTextCursor::atEnd(), QTextCursor::atStart(), QTextCursor::beginEditBlock(), block(), QTextCursor::block(), QTextCursor::blockCharFormat(), QTextCursor::blockFormat(), blockLayout(), QTextCursor::blockNumber(), canDelete(), QTextCursor::charFormat(), clearCells(), QTextCursor::columnNumber(), complexSelectionTable(), QTextCursor::createList(), QTextCursor::currentFrame(), QTextCursor::currentList(), QTextCursor::currentTable(), QTextCursor::deleteChar(), QTextCursor::deletePreviousChar(), QTextCursor::document(), QTextCursor::endEditBlock(), QTextDocumentFragmentPrivate::insert(), insertBlock(), QTextCursor::insertBlock(), QTextCursor::insertFragment(), QTextCursor::insertFrame(), QTextCursor::insertHtml(), QTextCursor::insertImage(), QTextCursor::insertTable(), QTextCursor::insertText(), QTextCursor::isNull(), QTextCursor::joinPreviousEditBlock(), QTextCursor::mergeBlockCharFormat(), QTextCursor::mergeBlockFormat(), QTextCursor::mergeCharFormat(), movePosition(), QTextCursor::movePosition(), QTextCursor::operator<(), QTextCursor::operator<=(), QTextCursor::operator==(), QTextCursor::operator>(), QTextCursor::operator>=(), QTextCursor::position(), QTextCursor::positionInBlock(), QTextCopyHelper::QTextCopyHelper(), QTextCursorPrivate(), QTextDocumentFragmentPrivate::QTextDocumentFragmentPrivate(), remove(), QTextCursor::removeSelectedText(), QTextCursor::select(), selectedTableCells(), QTextCursor::selectedText(), QTextCursor::selectionEnd(), QTextCursor::selectionStart(), setBlockCharFormat(), QTextCursor::setBlockCharFormat(), setBlockFormat(), QTextCursor::setBlockFormat(), setCharFormat(), QTextCursor::setCharFormat(), QTextCursor::setPosition(), setX(), ~QTextCursorPrivate(), and QTextDocumentPrivate::~QTextDocumentPrivate().

◆ visualNavigation

uint QTextCursorPrivate::visualNavigation

◆ x

qreal QTextCursorPrivate::x

The documentation for this class was generated from the following files: