45 #ifndef QT_NO_TEXTCONTROL 58 #include "private/qtextdocumentlayout_p.h" 59 #include "private/qabstracttextdocumentlayout_p.h" 60 #include "private/qtextedit_p.h" 62 #include "private/qtextdocument_p.h" 64 #include "private/qtextcontrol_p.h" 68 #include "private/qtextcursor_p.h" 82 #include <QtGui/qlineedit.h> 83 #include <QtGui/qaccessible.h> 85 #ifndef QT_NO_SHORTCUT 86 #include "private/qapplication_p.h" 87 #include "private/qshortcutmap_p.h" 89 #define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? QLatin1Char('\t') + QString(QKeySequence(k)) : QString()) 91 #define ACCEL_KEY(k) QString() 96 #ifndef QT_NO_CONTEXTMENU 97 #if defined(Q_WS_WIN) || defined(Q_WS_X11) 118 : doc(0), cursorOn(false), cursorIsFocusIndicator(false),
122 mousePressed(false), mightStartDrag(false),
124 lastSelectionState(false), ignoreAutomaticScrollbarAdjustement(false),
125 overwriteMode(false),
126 acceptRichText(true),
127 preeditCursor(0), hideCursor(false),
129 #ifdef QT_KEYPAD_NAVIGATION
133 hadSelectionOnMousePress(false),
134 ignoreUnusedNavigationEvents(false),
135 openExternalLinks(false),
136 wordSelectionEnabled(false)
141 #ifdef QT_NO_SHORTCUT 157 #ifndef QT_NO_SHORTCUT 253 #endif // QT_NO_SHORTCUT 272 q->ensureCursorVisible();
277 #ifdef QT_KEYPAD_NAVIGATION 278 ignoreNavigationEvents = ignoreNavigationEvents || QApplication::keypadNavigationEnabled();
279 isNavigationEvent = isNavigationEvent ||
288 emit q->cursorPositionChanged();
289 emit q->microFocusChanged();
290 }
else if (ignoreNavigationEvents && isNavigationEvent && oldSelection.
anchor() ==
cursor.
anchor()) {
310 emit q->currentCharFormatChanged(fmt);
311 emit q->microFocusChanged();
359 if (newColumn >= table->
columns()) {
362 if (newRow >= table->
rows())
366 cell = table->
cellAt(newRow, newColumn);
375 int newColumn = cell.
column() - 1;
379 newColumn = table->
columns() - 1;
385 cell = table->
cellAt(newRow, newColumn);
422 bool clearDocument =
true;
426 clearDocument =
false;
477 #ifndef QT_NO_TEXTHTMLPARSER 485 }
else if (clearDocument) {
491 emit q->textChanged();
498 q->ensureCursorVisible();
499 emit q->cursorPositionChanged();
504 #ifndef QT_NO_DRAGANDDROP 566 emit q->updateRequest(q->selectionRect(differenceSelection));
568 if (!oldSelection.
isNull())
577 if (forceEmitSelectionChanged) {
578 emit q->selectionChanged();
579 #ifndef QT_NO_ACCESSIBILITY 590 emit q->copyAvailable(current);
591 if (!forceEmitSelectionChanged) {
592 emit q->selectionChanged();
593 #ifndef QT_NO_ACCESSIBILITY 598 emit q->microFocusChanged();
607 #ifndef QT_NO_CLIPBOARD 623 emit q->cursorPositionChanged();
624 emit q->microFocusChanged();
668 const int wordStartPos = curs.
position();
671 const QPointF blockCoordinates = q->blockBoundingRect(curs.
block()).topLeft();
681 const int wordEndPos = curs.
position();
685 || wordEndPos == wordStartPos)
709 const qreal differenceToStart = mouseXPosition - wordStartX;
710 const qreal differenceToEnd = wordEndX - mouseXPosition;
712 if (differenceToStart < differenceToEnd)
719 #ifndef QT_NO_CLIPBOARD 749 #ifndef QT_NO_CLIPBOARD 766 d->repaintSelection();
767 const int oldCursorPos =
d->cursor.position();
768 d->doc->undo(&
d->cursor);
769 if (
d->cursor.position() != oldCursorPos)
770 emit cursorPositionChanged();
771 emit microFocusChanged();
772 ensureCursorVisible();
778 d->repaintSelection();
779 const int oldCursorPos =
d->cursor.position();
780 d->doc->redo(&
d->cursor);
781 if (
d->cursor.position() != oldCursorPos)
782 emit cursorPositionChanged();
783 emit microFocusChanged();
784 ensureCursorVisible();
815 if (
d->doc == document)
818 d->doc->disconnect(
this);
819 d->doc->documentLayout()->disconnect(
this);
820 d->doc->documentLayout()->setPaintDevice(0);
822 if (
d->doc->parent() ==
this)
838 d->cursorIsFocusIndicator =
false;
839 const bool posChanged = cursor.
position() !=
d->cursor.position();
843 d->_q_updateCurrentCharFormatAndSelection();
845 d->repaintOldAndNewSelection(oldSelection);
856 #ifndef QT_NO_CLIPBOARD 864 d->cursor.removeSelectedText();
870 if (!
d->cursor.hasSelection())
888 d->extraSelections.clear();
896 const int selectionLength =
qAbs(
d->cursor.position() -
d->cursor.anchor());
898 d->selectionChanged(selectionLength !=
qAbs(
d->cursor.position() -
d->cursor.anchor()));
899 d->cursorIsFocusIndicator =
false;
906 m.
translate(coordinateOffset.
x(), coordinateOffset.
y());
918 d->contextWidget = contextWidget;
920 if (!
d->contextWidget) {
922 #ifndef QT_NO_GRAPHICSVIEW 937 d->contextWidget = ev->
widget();
940 #endif // QT_NO_GRAPHICSVIEW 947 d->keyPressEvent(static_cast<QKeyEvent *>(e));
970 d->inputMethodEvent(static_cast<QInputMethodEvent *>(e));
972 #ifndef QT_NO_CONTEXTMENU 977 #endif // QT_NO_CONTEXTMENU 980 d->focusEvent(static_cast<QFocusEvent *>(e));
987 #ifndef QT_NO_TOOLTIP 993 #endif // QT_NO_TOOLTIP 995 #ifndef QT_NO_DRAGANDDROP 998 if (
d->dragEnterEvent(e, ev->
mimeData()))
1003 d->dragLeaveEvent();
1019 #ifndef QT_NO_GRAPHICSVIEW 1042 d->contextMenuEvent(ev->
screenPos(), matrix.
map(ev->
pos()), contextWidget);
1053 if (
d->dragEnterEvent(e, ev->
mimeData()))
1057 d->dragLeaveEvent();
1069 #endif // QT_NO_GRAPHICSVIEW 1070 #ifdef QT_KEYPAD_NAVIGATION 1071 case QEvent::EnterEditFocus:
1072 case QEvent::LeaveEditFocus:
1073 if (QApplication::keypadNavigationEnabled())
1074 d->editFocusEvent(e);
1086 switch (ke->
key()) {
1103 #ifndef QT_NO_SHORTCUT 1141 if (e->
timerId() ==
d->cursorBlinkTimer.timerId()) {
1142 d->cursorOn = !
d->cursorOn;
1144 if (
d->cursor.hasSelection())
1149 }
else if (e->
timerId() ==
d->trippleClickTimer.timerId()) {
1150 d->trippleClickTimer.stop();
1169 #ifndef QT_NO_SHORTCUT 1175 #ifndef QT_NO_CLIPBOARD 1182 #endif // QT_NO_SHORTCUT 1185 && cursorMoveKeyEvent(e))
1191 #ifdef QT_KEYPAD_NAVIGATION 1195 && cursor.hasSelection()) {
1198 activateLinkUnderCursor();
1211 cursor.mergeBlockFormat(fmt);
1224 if (list && cursor.atBlockStart() && !cursor.hasSelection()) {
1225 list->
remove(cursor.block());
1226 }
else if (cursor.atBlockStart() && blockFmt.
indent() > 0) {
1228 cursor.setBlockFormat(blockFmt);
1235 #ifndef QT_NO_SHORTCUT 1237 cursor.insertBlock();
1248 #ifndef QT_NO_SHORTCUT 1255 #ifndef QT_NO_CLIPBOARD 1273 if (!cursor.hasSelection())
1275 cursor.removeSelectedText();
1278 if (!cursor.hasSelection())
1280 cursor.removeSelectedText();
1288 cursor.removeSelectedText();
1290 #endif // QT_NO_SHORTCUT 1303 && !cursor.hasSelection()
1304 && !cursor.atBlockEnd())
1305 cursor.deleteChar();
1307 cursor.insertText(text);
1320 q->ensureCursorVisible();
1322 updateCurrentCharFormat();
1327 #ifdef QT_NO_TEXTEDIT 1332 QUrl resolvedName = textEdit->d_func()->resolveUrl(name);
1333 return textEdit->loadResource(type, resolvedName);
1342 QRectF br = q->blockBoundingRect(block);
1344 emit q->updateRequest(br);
1350 const QTextBlock block = doc->findBlock(position);
1355 const QPointF layoutPos = q->blockBoundingRect(block).topLeft();
1356 int relativePos = position - block.
position();
1357 if (preeditCursor != 0) {
1359 if (relativePos == preeditPos)
1360 relativePos += preeditCursor;
1361 else if (relativePos > preeditPos)
1369 #ifndef QT_NO_PROPERTIES 1370 cursorWidth = docLayout->
property(
"cursorWidth").
toInt(&ok);
1383 w = line.
cursorToX(relativePos + 1) - x;
1387 r =
QRectF(layoutPos.
x() + x, layoutPos.
y() + line.
y(),
1388 cursorWidth + w, line.
height());
1432 r =
d->doc->documentLayout()->frameBoundingRect(table);
1477 const QTextBlock posBlock =
d->doc->findBlock(position);
1478 const QTextBlock anchorBlock =
d->doc->findBlock(anchor);
1487 for (
int i = firstLine; i <= lastLine; ++i) {
1488 r |= layout->lineAt(i).rect();
1489 r |= layout->lineAt(i).naturalTextRect();
1518 if (sendMouseEventToInputContext(
1524 anchorOnMousePress = q->anchorAt(pos);
1529 cursor.clearSelection();
1540 const int oldCursorPos = cursor.
position();
1543 #ifndef QT_NO_DRAGANDDROP 1544 mightStartDrag =
false;
1547 if (trippleClickTimer.isActive()
1553 selectedBlockOnTrippleClick = cursor;
1555 anchorOnMousePress =
QString();
1557 trippleClickTimer.stop();
1560 if (cursorPos == -1) {
1565 if (modifiers ==
Qt::ShiftModifier && (interactionFlags & Qt::TextSelectableByMouse)) {
1566 if (wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) {
1567 selectedWordOnDoubleClick = cursor;
1571 if (selectedBlockOnTrippleClick.hasSelection())
1572 extendBlockwiseSelection(cursorPos);
1573 else if (selectedWordOnDoubleClick.hasSelection())
1574 extendWordwiseSelection(cursorPos, pos.
x());
1575 else if (!wordSelectionEnabled)
1580 && cursor.hasSelection()
1582 && cursorPos >= cursor.selectionStart()
1583 && cursorPos <= cursor.selectionEnd()
1585 #ifndef QT_NO_DRAGANDDROP 1586 mightStartDrag =
true;
1592 setCursorPosition(cursorPos);
1596 if (interactionFlags & Qt::TextEditable) {
1597 q->ensureCursorVisible();
1598 if (cursor.position() != oldCursorPos)
1599 emit q->cursorPositionChanged();
1600 _q_updateCurrentCharFormatAndSelection();
1602 if (cursor.position() != oldCursorPos) {
1603 emit q->cursorPositionChanged();
1604 emit q->microFocusChanged();
1608 repaintOldAndNewSelection(oldSelection);
1609 hadSelectionOnMousePress = cursor.hasSelection();
1617 if (sendMouseEventToInputContext(
1623 QString anchor = q->anchorAt(mousePos);
1624 if (anchor != highlightedAnchor) {
1625 highlightedAnchor = anchor;
1626 emit q->linkHovered(anchor);
1638 || selectedWordOnDoubleClick.hasSelection()
1639 || selectedBlockOnTrippleClick.hasSelection()))
1643 const int oldCursorPos = cursor.
position();
1645 if (mightStartDrag) {
1654 if (newCursorPos == -1)
1657 if (mousePressed && wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) {
1658 selectedWordOnDoubleClick = cursor;
1662 if (selectedBlockOnTrippleClick.hasSelection())
1663 extendBlockwiseSelection(newCursorPos);
1664 else if (selectedWordOnDoubleClick.hasSelection())
1665 extendWordwiseSelection(newCursorPos, mouseX);
1666 else if (mousePressed)
1669 if (interactionFlags & Qt::TextEditable) {
1673 if (cursor.position() != oldCursorPos)
1674 emit q->cursorPositionChanged();
1675 _q_updateCurrentCharFormatAndSelection();
1677 if (contextWidget) {
1685 if (cursor.position() != oldCursorPos) {
1686 emit q->cursorPositionChanged();
1687 emit q->microFocusChanged();
1691 repaintOldAndNewSelection(oldSelection);
1699 if (sendMouseEventToInputContext(
1705 const int oldCursorPos = cursor.
position();
1707 #ifndef QT_NO_DRAGANDDROP 1709 mousePressed =
false;
1710 setCursorPosition(pos);
1711 cursor.clearSelection();
1716 mousePressed =
false;
1717 #ifndef QT_NO_CLIPBOARD 1718 setClipboardSelection();
1723 setCursorPosition(pos);
1726 q->insertFromMimeData(md);
1730 repaintOldAndNewSelection(oldSelection);
1732 if (cursor.position() != oldCursorPos) {
1733 emit q->cursorPositionChanged();
1734 emit q->microFocusChanged();
1738 if (!(button & Qt::LeftButton))
1741 const QString anchor = q->anchorAt(pos);
1746 if (!cursor.hasSelection()
1747 || (anchor == anchorOnMousePress && hadSelectionOnMousePress)) {
1750 if (anchorPos != -1) {
1751 cursor.setPosition(anchorPos);
1753 QString anchor = anchorOnMousePress;
1754 anchorOnMousePress =
QString();
1755 activateLinkUnderCursor(anchor);
1766 if (sendMouseEventToInputContext(
1777 #ifndef QT_NO_DRAGANDDROP 1778 mightStartDrag =
false;
1781 setCursorPosition(pos);
1783 bool doEmit =
false;
1788 repaintOldAndNewSelection(oldSelection);
1791 selectedWordOnDoubleClick = cursor;
1793 trippleClickPoint = pos;
1797 #ifndef QT_NO_CLIPBOARD 1798 setClipboardSelection();
1800 emit q->cursorPositionChanged();
1806 Qt::KeyboardModifiers modifiers, Qt::MouseButtons
buttons,
const QPoint &globalPos)
1808 #if !defined(QT_NO_IM) 1814 int cursorPos = q->hitTest(pos,
Qt::FuzzyHit) - cursor.position();
1823 QMouseEvent ev(eventType, contextWidget->mapFromGlobal(globalPos), globalPos,
1845 #ifdef QT_NO_CONTEXTMENU 1853 QMenu *menu = q->createStandardContextMenu(docPos, contextWidget);
1857 menu->
popup(screenPos);
1864 if (!(interactionFlags &
Qt::TextEditable) || !q->canInsertFromMimeData(mimeData)) {
1878 const QRectF crect = q->cursorRect(dndFeedbackCursor);
1882 emit q->updateRequest(crect);
1888 if (!(interactionFlags &
Qt::TextEditable) || !q->canInsertFromMimeData(mimeData)) {
1894 if (cursorPos != -1) {
1895 QRectF crect = q->cursorRect(dndFeedbackCursor);
1897 emit q->updateRequest(crect);
1899 dndFeedbackCursor = cursor;
1900 dndFeedbackCursor.setPosition(cursorPos);
1902 crect = q->cursorRect(dndFeedbackCursor);
1903 emit q->updateRequest(crect);
1914 if (!(interactionFlags &
Qt::TextEditable) || !q->canInsertFromMimeData(mimeData))
1919 QTextCursor insertionCursor = q->cursorForPosition(pos);
1923 cursor.removeSelectedText();
1925 cursor = insertionCursor;
1926 q->insertFromMimeData(mimeData);
1928 q->ensureCursorVisible();
1940 || e->
preeditString() != cursor.block().layout()->preeditAreaText()
1943 cursor.beginEditBlock();
1944 if (isGettingInput) {
1945 cursor.removeSelectedText();
1960 int blockStart = a.
start + cursor.block().position();
1963 q->ensureCursorVisible();
1964 repaintOldAndNewSelection(oldCursor);
1973 const int oldPreeditCursor = preeditCursor;
1979 preeditCursor = a.
start;
1999 cursor.endEditBlock();
2002 if (oldPreeditCursor != preeditCursor)
2003 emit q->microFocusChanged();
2014 return QVariant(
d->cursor.charFormat().font());
2020 return QVariant(
d->cursor.selectedText());
2040 emit q->updateRequest(q->selectionRect());
2042 #ifdef QT_KEYPAD_NAVIGATION 2050 #ifdef QT_KEYPAD_NAVIGATION 2054 setBlinkingCursorEnabled(
false);
2059 && cursor.hasSelection()) {
2060 cursor.clearSelection();
2080 #ifdef QT_KEYPAD_NAVIGATION 2081 void QTextControlPrivate::editFocusEvent(
QEvent *e)
2085 if (QApplication::keypadNavigationEnabled()) {
2088 const int oldCursorPos = cursor.
position();
2090 q->ensureCursorVisible();
2092 if (cursor.position() != oldCursorPos)
2093 emit q->cursorPositionChanged();
2094 emit q->microFocusChanged();
2097 repaintOldAndNewSelection(oldSelection);
2099 setBlinkingCursorEnabled(
true);
2101 setBlinkingCursorEnabled(
false);
2104 hasEditFocus = e->
type() == QEvent::EnterEditFocus ? true :
false;
2108 #ifndef QT_NO_CONTEXTMENU 2119 if (
d->linkToCopy.isEmpty() && !showTextSelectionActions)
2136 if (showTextSelectionActions) {
2144 a = menu->
addAction(
tr(
"Copy &Link Location"),
this,
SLOT(_q_copyLink()));
2149 #if !defined(QT_NO_CLIPBOARD) 2158 if (showTextSelectionActions) {
2164 #if !defined(QT_NO_IM) 2165 if (
d->contextWidget) {
2169 for (
int i = 0; i < imActions.
size(); ++i)
2175 #if defined(Q_WS_WIN) || defined(Q_WS_X11) 2182 menu->
addMenu(ctrlCharacterMenu);
2187 #endif // QT_NO_CONTEXTMENU 2193 if (cursorPos == -1)
2206 return d->rectForPosition(cursor.
position());
2220 return rectForPosition(cursor.
position()).adjusted(-4, 0, 4, 0);
2226 return d->doc->documentLayout()->anchorAt(pos);
2233 return d->anchorForCursor(
d->cursor);
2239 return d->overwriteMode;
2245 d->overwriteMode = overwrite;
2250 #ifndef QT_NO_PROPERTIES 2252 int width =
d->doc->documentLayout()->property(
"cursorWidth").toInt();
2264 #ifdef QT_NO_PROPERTIES 2267 d->doc->documentLayout()->setProperty(
"cursorWidth", width);
2275 return d->acceptRichText;
2281 d->acceptRichText = accept;
2284 #ifndef QT_NO_TEXTEDIT 2291 for (
int i = 0; i <
d->extraSelections.count(); ++i) {
2296 for (
int i = 0; i < selections.
count(); ++i) {
2299 if (it != hash.
end()) {
2325 d->extraSelections.resize(selections.
count());
2326 for (
int i = 0; i < selections.
count(); ++i) {
2327 d->extraSelections[i].cursor = selections.
at(i).
cursor;
2328 d->extraSelections[i].format = selections.
at(i).
format;
2336 for (
int i = 0; i <
d->extraSelections.count(); ++i) {
2338 sel.
cursor =
d->extraSelections.at(i).cursor;
2339 sel.
format =
d->extraSelections.at(i).format;
2345 #endif // QT_NO_TEXTEDIT 2350 d->doc->setTextWidth(width);
2356 return d->doc->textWidth();
2362 return d->doc->size();
2368 d->openExternalLinks =
open;
2374 return d->openExternalLinks;
2380 return d->ignoreUnusedNavigationEvents;
2386 d->ignoreUnusedNavigationEvents =
ignore;
2393 const bool moved =
d->cursor.movePosition(op, mode);
2394 d->_q_updateCurrentCharFormatAndSelection();
2396 d->repaintOldAndNewSelection(oldSelection);
2403 #ifndef QT_NO_CLIPBOARD 2416 d->cursorIsFocusIndicator = b;
2423 return d->cursorIsFocusIndicator;
2436 return d->dragEnabled;
2448 return d->wordSelectionEnabled;
2451 #ifndef QT_NO_PRINTER 2454 #ifndef QT_NO_PRINTER 2456 if (!printer || !printer->
isValid())
2461 if (!
d->cursor.hasSelection())
2463 tempDoc =
new QTextDocument(const_cast<QTextDocument *>(doc));
2472 doc->
documentLayout()->d_func()->handlers =
d->doc->documentLayout()->d_func()->handlers;
2474 doc->
print(printer);
2478 #endif // QT_NO_PRINTER 2490 if (
d->acceptRichText)
2505 bool hasData =
false;
2507 #ifndef QT_NO_TEXTHTMLPARSER 2514 }
else if (source->
hasHtml() &&
d->acceptRichText) {
2526 #endif // QT_NO_TEXTHTMLPARSER 2529 d->cursor.insertFragment(fragment);
2537 int anchorStart = -1;
2565 if (anchorStart != -1) {
2579 if (anchorEnd == -1)
2586 block = block.
next();
2598 if (startPos == block.
position()) {
2602 if (it == blockStart) {
2625 if (it == blockStart)
2629 }
while (!it.
atEnd());
2632 if (anchorStart != -1 && !it.
atEnd()) {
2644 if (it == blockStart)
2648 }
while (!it.
atEnd());
2650 if (anchorEnd == -1)
2658 if (it != block.
begin())
2660 blockStart = block.
begin();
2665 if (anchorStart != -1 && anchorEnd != -1) {
2666 newAnchor =
d->cursor;
2689 if (!cursor.hasSelection()) {
2691 const int cursorPos = cursor.
position();
2698 const int fragmentPos = fragment.
position();
2699 if (fragmentPos <= cursorPos &&
2700 fragmentPos + fragment.
length() > cursorPos) {
2706 if (!linkFragment.
atEnd()) {
2709 if (it != block.
begin()) {
2715 cursor.setPosition(fragment.
position());
2716 }
while (it != block.
begin());
2719 for (it = linkFragment; !it.
atEnd(); ++
it) {
2732 cursor.clearSelection();
2734 repaintOldAndNewSelection(oldCursor);
2736 #ifndef QT_NO_DESKTOPSERVICES 2741 emit q_func()->linkActivated(href);
2744 #ifndef QT_NO_TOOLTIP 2747 const QString toolTip = q_func()->cursorForPosition(pos).charFormat().toolTip();
2752 #endif // QT_NO_TOOLTIP 2765 if (!
d->cursor.hasSelection()) {
2775 d->cursor = newAnchor;
2776 d->cursorIsFocusIndicator =
true;
2778 d->cursor.clearSelection();
2781 if (
d->cursor.hasSelection()) {
2799 const QString anchorHref =
d->anchorForCursor(newCursor);
2809 d->cursorIsFocusIndicator =
true;
2820 if (flags ==
d->interactionFlags)
2822 d->interactionFlags = flags;
2831 return d->interactionFlags;
2837 d->cursor.mergeCharFormat(modifier);
2838 d->updateCurrentCharFormat();
2844 d->cursor.setCharFormat(format);
2845 d->updateCurrentCharFormat();
2851 return d->cursor.charFormat();
2857 d->cursor.insertText(text);
2860 #ifndef QT_NO_TEXTHTMLPARSER 2864 d->cursor.insertHtml(text);
2866 #endif // QT_NO_TEXTHTMLPARSER 2875 for (
QTextBlock block =
d->doc->begin(); block.isValid(); block = block.next()) {
2878 r =
d->rectForPosition(block.position());
2886 r =
d->rectForPosition(fragment.
position());
2900 d->doc->adjustSize();
2922 if (!doc->isEmpty())
2923 tmp.
insertBlock(cursor.blockFormat(), cursor.charFormat());
2930 #ifndef QT_NO_TEXTHTMLPARSER 2938 #endif // QT_NO_TEXTHTMLPARSER 2939 if (!cursor.hasSelection())
2940 cursor.setCharFormat(oldCharFormat);
2967 QRectF crect =
d->rectForPosition(
d->cursor.position()).adjusted(-5, 0, 5, 0);
2992 if (
d->cursorOn &&
d->isEnabled) {
2995 else if (
d->preeditCursor != 0)
3001 if (!
d->dndFeedbackCursor.isNull())
3003 #ifdef QT_KEYPAD_NAVIGATION 3004 if (!QApplication::keypadNavigationEnabled() ||
d->hasEditFocus)
3006 if (
d->cursor.hasSelection()) {
3009 if (
d->cursorIsFocusIndicator) {
3015 style = widget->
style();
3026 style = widget->
style();
3046 d->doc->documentLayout()->draw(p, ctx);
3052 #ifndef QT_NO_CLIPBOARD 3063 if (!ctx && contextWidget->parentWidget())
3064 ctx = contextWidget->parentWidget()->inputContext();
3072 return d->doc->documentLayout()->hitTest(point, accuracy);
3078 return d->doc->documentLayout()->blockBoundingRect(block);
3081 #ifndef QT_NO_CONTEXTMENU 3082 #define NUM_CONTROL_CHARACTERS 10 3087 {
QT_TRANSLATE_NOOP(
"QUnicodeControlCharacterMenu",
"LRM Left-to-right mark"), 0x200e },
3088 {
QT_TRANSLATE_NOOP(
"QUnicodeControlCharacterMenu",
"RLM Right-to-left mark"), 0x200f },
3089 {
QT_TRANSLATE_NOOP(
"QUnicodeControlCharacterMenu",
"ZWJ Zero width joiner"), 0x200d },
3090 {
QT_TRANSLATE_NOOP(
"QUnicodeControlCharacterMenu",
"ZWNJ Zero width non-joiner"), 0x200c },
3091 {
QT_TRANSLATE_NOOP(
"QUnicodeControlCharacterMenu",
"ZWSP Zero width space"), 0x200b },
3092 {
QT_TRANSLATE_NOOP(
"QUnicodeControlCharacterMenu",
"LRE Start of left-to-right embedding"), 0x202a },
3093 {
QT_TRANSLATE_NOOP(
"QUnicodeControlCharacterMenu",
"RLE Start of right-to-left embedding"), 0x202b },
3094 {
QT_TRANSLATE_NOOP(
"QUnicodeControlCharacterMenu",
"LRO Start of left-to-right override"), 0x202d },
3095 {
QT_TRANSLATE_NOOP(
"QUnicodeControlCharacterMenu",
"RLO Start of right-to-left override"), 0x202e },
3096 {
QT_TRANSLATE_NOOP(
"QUnicodeControlCharacterMenu",
"PDF Pop directional formatting"), 0x202c },
3100 :
QMenu(parent), editWidget(_editWidget)
3102 setTitle(
tr(
"Insert Unicode control character"));
3117 #ifndef QT_NO_TEXTEDIT 3119 edit->insertPlainText(str);
3124 control->insertPlainText(str);
3126 #ifndef QT_NO_LINEEDIT 3133 #endif // QT_NO_CONTEXTMENU 3137 if (!fragment.isEmpty())
3139 #ifndef QT_NO_TEXTODFWRITER 3149 if (!fragment.isEmpty())
3157 #ifndef QT_NO_TEXTHTMLPARSER 3160 #ifndef QT_NO_TEXTODFWRITER 3164 writer.
write(fragment);
3169 that->
setText(fragment.toPlainText());
3175 #include "moc_qtextcontrol_p.cpp" 3177 #endif // QT_NO_TEXTCONTROL The QVariant class acts like a union for the most common Qt data types.
Mode
This enum type is used to control which part of the system clipboard is used by QClipboard::mimeData(...
Qt::DropAction dropAction() const
Returns the action that was performed in this drag and drop.
bool dropEvent(const QMimeData *mimeData, const QPointF &pos, Qt::DropAction dropAction, QWidget *source)
const QMimeData * mimeData() const
This function returns the MIME data of the event.
The QPainter class performs low-level painting on widgets and other paint devices.
int columns() const
Returns the number of columns in the table.
QSizeF pageSize
the page size that should be used for laying out the document
void setAdditionalFormats(const QList< FormatRange > &overrides)
Sets the additional formats supported by the text layout to formatList.
static uint hash(const uchar *p, int n)
void acceptProposedAction()
Sets the drop action to be the proposed action.
QStringList anchorNames() const
Returns the anchor names associated with this text format, or an empty string list if none has been s...
void setCursorWidth(int width)
The QStyleHintReturnVariant class provides style hints that return a QVariant.
void mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons, const QPoint &globalPos)
void appendHtml(const QString &html)
int anchor() const
Returns the anchor position; this is the same as position() unless there is a selection in which case...
static void updateAccessibility(QObject *, int who, Event reason)
Notifies accessibility clients about a change in object's accessibility information.
static QWaylandClipboard * clipboard
The QTextLayout::FormatRange structure is used to apply extra formatting information for a specified ...
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
qreal right() const
Returns the x-coordinate of the rectangle's right edge.
qreal alphaF() const
Returns the alpha color component of this color.
void endEditBlock()
Indicates the end of a block of editing operations on the document that should appear as a single ope...
The QKeyEvent class describes a key event.
void setData(const QString &mimetype, const QByteArray &data)
Sets the data associated with the MIME type given by mimeType to the specified data.
bool findNextPrevAnchor(const QTextCursor &from, bool next, QTextCursor &newAnchor)
QString text() const
Returns the block's contents as plain text.
void setPlainText(const QString &text)
QPoint screenPos() const
Returns the mouse cursor position in screen coordinates.
void mousePressEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons, const QPoint &globalPos)
The QTextCharFormat class provides formatting information for characters in a QTextDocument.
virtual QRectF blockBoundingRect(const QTextBlock &block) const
virtual void ensureCursorVisible()
The QTextListFormat class provides formatting information for lists in a QTextDocument.
QTextCharFormat charFormat() const
Returns the format of the character immediately before the cursor position().
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
The QFontMetrics class provides font metrics information.
#define QT_END_NAMESPACE
This macro expands to.
qreal y() const
Returns the line's y position.
const QColor & color() const
Returns the brush color.
bool isDragEnabled() const
virtual QStringList formats() const
Returns a list of formats supported by the object.
The QDrag class provides support for MIME-based drag and drop data transfer.
void setMimeData(QMimeData *data)
Sets the data to be sent to the given MIME data.
QPointer< QWidget > widget
const QByteArray & data() const
Returns the data contained in the buffer.
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
const QChar at(int i) const
Returns the character at the given index position in the string.
bool ignoreUnusedNavigationEvents() const
QString anchorAtCursor() const
void setTextCursor(const QTextCursor &cursor)
QTextCharFormat format
the format of the selection
void setLeft(qreal pos)
Sets the left edge of the rectangle to the given x coordinate.
The QMatrix class specifies 2D transformations of a coordinate system.
#define it(className, varName)
QTextCharFormat lastCharFormat
iterator end() const
Returns a text block iterator pointing to the end of the text block.
void setProperty(int propertyId, const QVariant &value)
Sets the property specified by the propertyId to the given value.
void setTextInteractionFlags(Qt::TextInteractionFlags flags)
void extendWordwiseSelection(int suggestedNewPosition, qreal mouseXPosition)
The QTextFrame class represents a frame in a QTextDocument.
void setDocument(QTextDocument *document)
#define NUM_CONTROL_CHARACTERS
void keyPressEvent(QKeyEvent *e)
void insertRows(int pos, int num)
Inserts a number of rows before the row with the specified index.
QTextCursor selectedWordOnDoubleClick
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=0, const QWidget *widget=0) const =0
Returns the value of the given pixel metric.
void setCurrentCharFormat(const QTextCharFormat &format)
static bool cursorPosLessThanLastFramePos(int position, QTextFrame *frame)
void visibilityRequest(const QRectF &rect)
int selectionEnd() const
Returns the end of the selection or position() if the cursor doesn't have a selection.
bool hasHtml() const
Returns true if the object can return HTML (MIME type text/html); otherwise returns false...
void append(const QString &text)
QPoint screenPos() const
Returns the position of the mouse cursor in screen coordinates at the moment the hover event was sent...
bool atEnd() const
Returns true if the current item is the last item in the text block.
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation...
void setModified(bool m=true)
void setPalette(const QPalette &pal)
int length() const
Returns the number of characters in this string.
virtual bool canInsertFromMimeData(const QMimeData *source) const
void close()
Reimplemented Function
void setAccepted(bool accepted)
QTextControl(QObject *parent=0)
QString & prepend(QChar c)
virtual QVariant loadResource(int type, const QUrl &name)
The QPointF class defines a point in the plane using floating point precision.
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
qreal left() const
Returns the x-coordinate of the rectangle's left edge.
The QTextLine class represents a line of text inside a QTextLayout.
void setIndent(int indent)
Sets the list format's indentation.
static Qt::MouseButtons buttons
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
void restore()
Restores the current painter state (pops a saved state off the stack).
QTextList * createList(const QTextListFormat &format)
Creates and returns a new list with the given format, and makes the current paragraph the cursor is i...
int textLength() const
Returns the length of the text in the line.
Qt::DropAction dropAction() const
Returns the action to be performed on the data by the target.
Q_GUI_EXPORT bool mightBeRichText(const QString &)
Returns true if the string text is likely to be rich text; otherwise returns false.
virtual int styleHint(StyleHint stylehint, const QStyleOption *opt=0, const QWidget *widget=0, QStyleHintReturn *returnData=0) const =0
Returns an integer representing the specified style hint for the given widget described by the provid...
QRectF cursorRectPlusUnicodeDirectionMarkers(const QTextCursor &cursor) const
QList< QTextEdit::ExtraSelection > extraSelections() const
Qt::MouseButton button() const
Returns the mouse button (if any) that caused the event.
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
static bool ignore(const char *test, const char *const *table)
QTextBlockFormat blockFormat() const
Returns the block format of the block the cursor is in.
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
The QList::const_iterator class provides an STL-style const iterator for QList and QQueue...
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.
bool write(const QTextDocument *document)
Writes the given document to the assigned device or file and returns true if successful; otherwise re...
void _q_emitCursorPosChanged(const QTextCursor &someCursor)
#define QT_TRANSLATE_NOOP(scope, x)
Marks the string literal sourceText for dynamic translation in the given context; i...
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool wordSelectionEnabled
void setPageSize(const QSizeF &size)
QWidget * widget() const
Returns the widget where the event originated, or 0 if the event originates from another application...
QTextCursor cursor
the selection's cursor
QBasicTimer cursorBlinkTimer
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
static QPalette palette()
Returns the application palette.
static QStyle * style()
Returns the application's style object.
QString anchorHref() const
Returns the text format's hypertext link, or an empty string if none has been set.
QByteArray data(const QString &mimetype) const
Returns the data stored in the object in the format described by the MIME type specified by mimeType...
void setCharFormat(const QTextCharFormat &format)
Sets the cursor's current character format to the given format.
static QRectF boundingRectOfFloatsInSelection(const QTextCursor &cursor)
void print(QPrinter *printer) const
Prints the document to the given printer.
void paste(QClipboard::Mode mode=QClipboard::Clipboard)
static int cursorFlashTime()
int start
Specifies the beginning of the format range within the text layout's text.
The QBuffer class provides a QIODevice interface for a QByteArray.
void setBackground(const QBrush &brush)
Sets the brush use to paint the document's background to the brush specified.
void setFormat(const QTextListFormat &format)
Sets the list's format to format.
Qt::DropAction exec(Qt::DropActions supportedActions=Qt::MoveAction)
Starts the drag and drop operation and returns a value indicating the requested drop action when it i...
QRectF rectForPosition(int position) const
void setMimeData(QMimeData *data, Mode mode=Clipboard)
Sets the clipboard data to src.
The QUrl class provides a convenient interface for working with URLs.
The QString class provides a Unicode character string.
T * qobject_cast(QObject *object)
void mouseMoveEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons, const QPoint &globalPos)
bool isValid() const
Returns true if this character format is valid; otherwise returns false.
The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress...
QFont defaultFont
the default font used to display the document's text
QPointer< QWidget > contextWidget
bool dragMoveEvent(QEvent *e, const QMimeData *mimeData, const QPointF &pos)
QPalette palette
the default color that is used for the text, when no color is specified.
Q_DECL_CONSTEXPR T qAbs(const T &t)
int indent() const
Returns the paragraph's indent.
void append(const QString &text, Qt::TextFormat format=Qt::AutoText)
The QObject class is the base class of all Qt objects.
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
bool isPrint() const
Returns true if the character is a printable character; otherwise returns false.
int firstPosition() const
Returns the first document position inside the frame.
void mergeBlockFormat(const QTextBlockFormat &modifier)
Modifies the block format of the current block (or all blocks that are contained in the selection) wi...
QMatrix & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
int cursorPosition
the position within the document, where the cursor line should be drawn.
QFont font() const
Returns the current font that is used for the layout, or a default font if none is set...
bool isValid() const
Returns true if this text line is valid; otherwise returns false.
virtual QVariant inputMethodQuery(Qt::InputMethodQuery property) const
The QSizeF class defines the size of a two-dimensional object using floating point precision...
virtual void processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget=0)
QRectF selectionRect() const
The QChar class provides a 16-bit Unicode character.
Qt::TextInteractionFlags interactionFlags
virtual int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const
void insertText(const QString &text)
Inserts text at the current position, using the current character format.
virtual QList< QAction * > actions()
This is a preliminary interface for Qt 4.
virtual void insertFromMimeData(const QMimeData *source)
const T value(const Key &key) const
Returns the value associated with the key.
QTextCursor textCursor() const
void setRight(qreal pos)
Sets the right edge of the rectangle to the given x coordinate.
void save()
Saves the current painter state (pushes the state onto a stack).
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
void setMetaInformation(MetaInformation info, const QString &)
Sets the document's meta information of the type specified by info to the given string.
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
qreal x() const
Returns the x-coordinate of this point.
QObject * sender() const
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; othe...
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 toInt(bool *ok=0) const
Returns the variant as an int if the variant has type() Int , Bool , ByteArray , Char ...
int position() const
Returns the index of the block's first character within the document.
QTextCharFormat currentCharFormat() const
QMenu * createStandardContextMenu(const QPointF &pos, QWidget *parent)
QTextFrame * currentFrame() const
Returns a pointer to the current frame.
void init(Qt::TextFormat format=Qt::RichText, const QString &text=QString(), QTextDocument *document=0)
QTextBlock previous() const
Returns the text block in the document before this block, or an empty text block if this is the first...
The QAbstractTextDocumentLayout::Selection class is a convenience class defining the parameters of a ...
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
int key() const
Returns the code of the key that was pressed or released.
void inputMethodEvent(QInputMethodEvent *)
void setPlainText(const QString &text)
Replaces the entire contents of the document with the given plain text.
void setCursorPosition(const QPointF &pos)
bool hasProperty(int propertyId) const
Returns true if the text format has a property with the given propertyId; otherwise returns false...
QTextTableCell cellAt(int row, int col) const
Returns the table cell at the given row and column in the table.
void activateLinkUnderCursor(QString href=QString())
bool setFocusToNextOrPreviousAnchor(bool next)
QWidget * source() const
This function returns the QGraphicsView that created the QGraphicsSceneDragDropEvent.
void append(const T &t)
Inserts value at the end of the list.
QTextCharFormat charFormat() const
Returns the text fragment's character format.
qreal cursorToX(int *cursorPos, Edge edge=Leading) const
Converts the cursor position cursorPos to the corresponding x position inside the line...
const QMimeData * mimeData(Mode mode=Clipboard) const
Returns a reference to a QMimeData representation of the current clipboard data.
#define QT_BEGIN_NAMESPACE
This macro expands to.
bool cursorMoveKeyEvent(QKeyEvent *e)
MoveMode
If the anchor() is kept where it is and the position() is moved, the text in between will be selected...
The QRectF class defines a rectangle in the plane using floating point precision. ...
QString anchorAt(const QPointF &pos) const
bool isWordSelectionEnabled() const
void setClipboardSelection()
int column() const
Returns the number of the column in the table that contains this cell.
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifiers at the moment the hover event was sent.
int lastPosition() const
Returns the last document position inside the frame.
bool dragEnterEvent(QEvent *e, const QMimeData *mimeData)
static QTextDocumentFragment fromHtml(const QString &html)
Returns a QTextDocumentFragment based on the arbitrary piece of HTML in the given text...
bool hasSelection() const
Returns true if the cursor contains a selection; otherwise returns false.
bool sendMouseEventToInputContext(QEvent *e, QEvent::Type eventType, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons, const QPoint &globalPos)
QTextTable * currentTable() const
Returns a pointer to the current table if the cursor position() is inside a block that is part of a t...
QString text() const
Returns a plain text (MIME type text/plain) representation of the data.
bool isAnchor() const
Returns true if the text is formatted as an anchor; otherwise returns false.
static QClipboard * clipboard()
Returns a pointer to the application global clipboard.
The QStyleOption class stores the parameters used by QStyle functions.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
QString anchorForCursor(const QTextCursor &anchor) const
The QTextFormat class provides formatting information for a QTextDocument.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
void setBlockFormat(const QTextBlockFormat &format)
Sets the block format of the current block (or all blocks that are contained in the selection) to for...
The QTextCursor class offers an API to access and modify QTextDocuments.
void print(QPrinter *printer) const
Qt::TextInteractionFlags textInteractionFlags() const
void contextMenuEvent(const QPoint &screenPos, const QPointF &docPos, QWidget *contextWidget)
void initFrom(const QWidget *w)
The QPrinter class is a paint device that paints on a printer.
void updateRequest(const QRectF &rect=QRectF())
static bool firstFramePosLessThanCursorPos(QTextFrame *frame, int position)
const T & at(int i) const
Returns the item at index position i in the list.
int lineNumber() const
Returns the position of the line in the text engine.
bool isUndoRedoEnabled() const
bool visualNavigation() const
Returns true if the cursor does visual navigation; otherwise returns false.
QString html() const
Returns a string if the data stored in the object is HTML (MIME type text/html); otherwise returns an...
The QStringList class provides a list of strings.
void setHtml(const QString &text)
static QTextDocumentFragment fromPlainText(const QString &plainText)
Returns a document fragment that contains the given plainText.
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
static QTextLine currentTextLine(const QTextCursor &cursor)
bool isValid() const
Returns true if the printer currently selected is a valid printer in the system, or a pure PDF/PostSc...
void _q_documentLayoutChanged()
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
virtual void timerEvent(QTimerEvent *e)
This event handler can be reimplemented in a subclass to receive timer events for the object...
The QTextBlock class provides a container for text fragments in a QTextDocument.
static const char * data(const QByteArray &arr)
virtual QMimeData * createMimeDataFromSelection() const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Type
This enum type defines the types of variable that a QVariant can contain.
void moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode=QTextCursor::MoveAnchor)
PrintRange printRange() const
Returns the page range of the QPrinter.
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
int row() const
Returns the number of the row in the table that contains this cell.
void setHtml(const QString &html)
Replaces the entire contents of the document with the given HTML-formatted text in the html string...
void select(SelectionType selection)
Selects text in the document according to the given selection.
void insertFragment(const QTextDocumentFragment &fragment)
Inserts the text fragment at the current position().
The QClipboard class provides access to the window system clipboard.
The QGraphicsSceneEvent class provides a base class for all graphics view related events...
void setUseDesignMetrics(bool b)
static int startDragDistance()
QRectF clip
a hint to the layout specifying the area around paragraphs, frames or text require painting...
void setIgnoreUnusedNavigationEvents(bool ignore)
int position() const
Returns the absolute position of the cursor within the document.
int length() const
Returns the length of the block in characters.
virtual void mouseHandler(int x, QMouseEvent *event)
This function can be reimplemented in a subclass to handle mouse press, release, double-click, and move events within the preedit text.
QBrush background() const
Returns the brush used to paint the document's background.
Qt::BrushStyle style() const
Returns the brush style.
void setContent(Qt::TextFormat format=Qt::RichText, const QString &text=QString(), QTextDocument *document=0)
The QTextTable class represents a table in a QTextDocument.
int itemNumber(const QTextBlock &) const
Returns the index of the list item that corresponds to the given block.
QRectF cursorRect() const
The QMimeData class provides a container for data that records information about its MIME type...
int length() const
Returns the number of characters in the text fragment.
void _q_updateBlock(const QTextBlock &)
void translate(qreal dx, qreal dy)
Moves the rectangle dx along the x-axis and dy along the y-axis, relative to the current position...
virtual QRectF frameBoundingRect(QTextFrame *frame) const =0
Returns the bounding rectangle of frame.
The QTextFragment class holds a piece of text in a QTextDocument with a single QTextCharFormat.
Qt::MouseButton button() const
Returns the button that caused the event.
void acceptProposedAction()
Sets the proposed action as accepted, i.e, the drop action is set to the proposed action...
void setDragEnabled(bool enabled)
void removeSelectedText()
If there is a selection, its content is deleted; otherwise does nothing.
The QTextBlock::iterator class provides an iterator for reading the contents of a QTextBlock...
QTextList * currentList() const
Returns the current list if the cursor position() is inside a block that is part of a list; otherwise...
bool isCopyOf(const QTextCursor &other) const
Returns true if this cursor and other are copies of each other, i.e.
QTextBlock block() const
Returns the block that contains the cursor.
int preeditAreaPosition() const
Returns the position of the area in the text layout that will be processed before editing occurs...
void setAcceptRichText(bool accept)
const QBrush & brush(ColorGroup cg, ColorRole cr) const
Returns the brush in the specified color group, used for the given color role.
QTextDocument * document() const
#define QT_NO_DRAGANDDROP
bool supportsSelection() const
Returns true if the clipboard supports mouse selection; otherwise returns false.
void stop()
Stops the timer.
QInputContext * inputContext()
QAbstractTextDocumentLayout::PaintContext getPaintContext(QWidget *widget) const
The QMouseEvent class contains parameters that describe a mouse event.
QList< QTextFrame * > childFrames() const
Returns a (possibly empty) list of the frame's child frames.
QPalette palette
the palette that should be used when painting the control
bool isNull() const
Returns true if this string is null; otherwise returns false.
void insertBlock()
Inserts a new empty block at the cursor position() with the current blockFormat() and charFormat()...
virtual bool hasFormat(const QString &mimetype) const
Returns true if the object can return data for the MIME type specified by mimeType; otherwise returns...
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
void setDefaultFont(const QFont &font)
Sets the default font to use in the document layout.
void setCursorIsFocusIndicator(bool b)
int position() const
Returns the position of this text fragment in the document.
void setOverwriteMode(bool overwrite)
QString preeditAreaText() const
Returns the text that is inserted in the layout before editing occurs.
virtual QStringList formats() const
Returns a list of formats supported by the object.
The QTextLayout class is used to lay out and render text.
void remove(const QTextBlock &)
Removes the given block from the list.
void beginEditBlock()
Indicates the start of a block of editing operations on the document that should appear as a single o...
bool overwriteMode() const
The QDropEvent class provides an event which is sent when a drag and drop action is completed...
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
iterator Iterator
Qt-style synonym for QTextBlock::iterator.
bool acceptRichText() const
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...
void map(int x, int y, int *tx, int *ty) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const
Returns a variant with the given type containing data for the MIME type specified by mimeType...
The QGraphicsSceneDragDropEvent class provides events for drag and drop in the graphics view framewor...
bool qt_use_rtl_extensions
Type
This enum type defines the valid event types in Qt.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the hash...
The QTimerEvent class contains parameters that describe a timer event.
QString text() const
Returns the Unicode text that this key generated.
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
void focusEvent(QFocusEvent *e)
virtual QVariant retrieveData(const QString &mimetype, QVariant::Type preferredType) const
Returns a variant with the given type containing data for the MIME type specified by mimeType...
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
void adjust(qreal x1, qreal y1, qreal x2, qreal y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
void setFontUnderline(bool underline)
If underline is true, sets the text format's font to be underlined; otherwise it is displayed non-und...
QWidget * source() const
If the source of the drag operation is a widget in this application, this function returns that sourc...
QObject * parent() const
Returns a pointer to the parent object.
bool hasText() const
Returns true if the object can return plain text (MIME type text/plain); otherwise returns false...
The QDragEnterEvent class provides an event which is sent to a widget when a drag and drop action ent...
int rows() const
Returns the number of rows in the table.
QString metaInformation(MetaInformation info) const
Returns meta information about the document of the type specified by info.
The QPoint class defines a point in the plane using integer precision.
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
Q_DECL_CONSTEXPR const T & qBound(const T &min, const T &val, const T &max)
void deletePreviousChar()
If there is no selected text, deletes the character before the current cursor position; otherwise del...
The QTextTableCell class represents the properties of a cell in a QTextTable.
bool hasComplexSelection() const
Returns true if the cursor contains a selection that is not simply a range from selectionStart() to s...
The QAbstractTextDocumentLayout::PaintContext class is a convenience class defining the parameters us...
int size() const
Returns the number of items in the list.
The QTextBlockFormat class provides formatting information for blocks of text in a QTextDocument...
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI...
bool isNull() const
Returns true if the cursor is null; otherwise returns false.
bool find(const QString &exp, QTextDocument::FindFlags options=0)
bool boolProperty(int propertyId) const
Returns the value of the property specified by propertyId.
void setUndoRedoEnabled(bool enable)
virtual bool event(QEvent *e)
This virtual function receives events to an object and should return true if the event e was recogniz...
const QPoint & globalPos() const
Returns the mouse cursor position when the event was generated in global coordinates.
QPointF pos() const
Returns the position of the mouse cursor in item coordinates at the moment the hover event was sent...
iterator begin()
Returns an STL-style iterator pointing to the first item in the hash.
void setIndent(int indent)
Sets the paragraph's indentation.
bool isNull() const
Returns true if both the x and y coordinates are set to +0.
void _q_updateCurrentCharFormatAndSelection()
const QObjectList & children() const
Returns a list of child objects.
QTextCursor firstCursorPosition() const
Returns the first valid cursor position in this cell.
void gotoPreviousTableCell()
T qvariant_cast(const QVariant &)
bool movePosition(MoveOperation op, MoveMode=MoveAnchor, int n=1)
Moves the cursor by performing the given operation n times, using the specified mode, and returns true if all operations were completed successfully; otherwise returns false.
void setBlinkingCursorEnabled(bool enable)
The QLineEdit widget is a one-line text editor.
bool setFocusToAnchor(const QTextCursor &newCursor)
qreal y() const
Returns the y-coordinate of this point.
void setVisualNavigation(bool b)
Sets visual navigation to b.
QVariant property(const char *name) const
Returns the value of the object's name property.
QTextCursor cursorForPosition(const QPointF &pos) const
void setPosition(int pos, MoveMode mode=MoveAnchor)
Moves the cursor to the absolute position in the document specified by pos using a MoveMode specified...
QString stringProperty(int propertyId) const
Returns the value of the property given by propertyId; if the property isn't of QVariant::String type...
The QTextDocument class holds formatted text that can be viewed and edited using a QTextEdit...
void drawContents(QPainter *painter, const QRectF &rect=QRectF(), QWidget *widget=0)
void setText(const QString &text)
Sets text as the plain text (MIME type text/plain) used to represent the data.
void extendBlockwiseSelection(int suggestedNewPosition)
QPointF pos() const
Returns the mouse cursor position in item coordinates.
bool isValid() const
Returns true if this text block is valid; otherwise returns false.
qreal top() const
Returns the y-coordinate of the rectangle's top edge.
int length
Specifies the numer of characters the format range spans.
QTextCharFormat format
Specifies the format to apply.
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifiers in use at the time the event was sent.
The QTextList class provides a decorated list of items in a QTextDocument.
void setForeground(const QBrush &brush)
Sets the foreground brush to the specified brush.
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
void accept()
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
const QMimeData * mimeData() const
Returns the data that was dropped on the widget and its associated MIME type information.
The QTextDocumentWriter class provides a format-independent interface for writing a QTextDocument to ...
void appendPlainText(const QString &text)
void setWidth(qreal w)
Sets the width of the rectangle to the given width.
void createAutoBulletList()
void setFocus(bool focus, Qt::FocusReason=Qt::OtherFocusReason)
void setTextWidth(qreal width)
bool gotFocus() const
Returns true if type() is QEvent::FocusIn; otherwise returns false.
iterator find(const Key &key)
Returns an iterator pointing to the item with the key in the hash.
iterator insertMulti(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
int columnSpan() const
Returns the number of columns this cell spans.
void insertHtml(const QString &text)
void updateCurrentCharFormat()
The QInputContext class abstracts the input method dependent data and composing state.
void cursorPositionChanged()
QVector< Selection > selections
the collection of selections that will be rendered when passing this paint context to QAbstractTextDo...
void insertHtml(const QString &html)
Inserts the text html at the current position().
void deleteChar()
If there is no selected text, deletes the character at the current cursor position; otherwise deletes...
QTextFragment fragment() const
Returns the text fragment the iterator currently points to.
bool cursorIsFocusIndicator() const
void mouseReleaseEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons, const QPoint &globalPos)
void selectionChanged(bool forceEmitSelectionChanged=false)
Q_TESTLIB_EXPORT QTestData & newRow(const char *dataTag)
Appends a new row to the current test data.
void setStyle(Style style)
Sets the list format's style.
virtual void clear()
Clears the document.
The QEvent class is the base class of all event classes.
void setLayoutDirection(Qt::LayoutDirection direction)
Sets the document's layout direction to the specified direction.
void setUnderlineStyle(UnderlineStyle style)
Sets the style of underlining the text to style.
Type type() const
Returns the event type.
void setPreeditArea(int position, const QString &text)
Sets the position and text of the area in the layout that is processed before editing occurs...
const QPoint & globalPos() const
Returns the global position of the mouse cursor at the time of the event.
static int doubleClickInterval()
QTextCursor selectedBlockOnTrippleClick
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
void setWordSelectionEnabled(bool enabled)
int indent() const
Returns the list format's indentation.
iterator erase(iterator it)
Removes the (key, value) pair associated with the iterator pos from the hash, and returns an iterator...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
qreal height() const
Returns the line's height.
QPointF anchorPosition(const QString &name) const
The QTextDocumentFragment class represents a piece of formatted text from a QTextDocument.
The QFocusEvent class contains event parameters for widget focus events.
int selectionStart() const
Returns the start of the selection or position() if the cursor doesn't have a selection.
The QAction class provides an abstract user interface action that can be inserted into widgets...
void start(int msec, QObject *obj)
Starts (or restarts) the timer with a msec milliseconds timeout.
QVariant variant
the variant for style hints that return a QVariant
const struct QUnicodeControlCharacter qt_controlCharacters[NUM_CONTROL_CHARACTERS]
void showToolTip(const QPoint &globalPos, const QPointF &pos, QWidget *contextWidget)
The QTextEdit class provides a widget that is used to edit and display both plain and rich text...
int textStart() const
Returns the start of the line from the beginning of the string passed to the QTextLayout.
const QPoint & pos() const
Returns the position where the drop was made.
int open(const char *, int,...)
Qt::MouseButtons buttons() const
Returns the combination of mouse buttons that were pressed at the time the event was sent...
void repaintOldAndNewSelection(const QTextCursor &oldSelection)
int lineCount() const
Returns the number of lines in this text layout.
void insertPlainText(const QString &text)
bool useDesignMetrics
whether the document uses design metrics of fonts to improve the accuracy of text layout ...
QPointF pos() const
Returns the mouse position of the event relative to the view that sent the event. ...
The QList class is a template class that provides lists.
The QGraphicsSceneHoverEvent class provides hover events in the graphics view framework.
QWidget * target() const
Returns the target of the drag and drop operation.
bool openExternalLinks() const
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...
static bool openUrl(const QUrl &url)
Opens the given url in the appropriate Web browser for the user's desktop environment, and returns true if successful; otherwise returns false.
bool ignoreUnusedNavigationEvents
QTextListFormat format() const
Returns the list's format.
void mergeCurrentCharFormat(const QTextCharFormat &modifier)
The QHelpEvent class provides an event that is used to request helpful information about a particular...
The QAbstractTextDocumentLayout class is an abstract base class used to implement custom layouts for ...
void setExtraSelections(const QList< QTextEdit::ExtraSelection > &selections)
void setOpenExternalLinks(bool open)
The QPalette class contains color groups for each widget state.
QTextLayout * layout() const
Returns the QTextLayout that is used to lay out and display the block's contents. ...
const QPoint & pos() const
Returns the mouse cursor position when the event was generated, relative to the widget to which the e...