aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2011-12-15 13:18:27 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-15 07:03:53 +0100
commitc00cab34e5ee940f9559679025ea660a62ee4134 (patch)
treee95852daaa12b6b2689b6c06fb9467a9d78924e9 /src
parent7e2c152089e5f54b254d8dae7cbfe0f3bbd68293 (diff)
Remove unused code from QQuickTextControl.
QTextControl included a lot of functionality that was unused by TextEdit. Anything that is unused and therefore untested should go. Task-number: QTBUG-22627 Change-Id: Ie68b279cb8618bec0af76287c7c4db34d0642a0a Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquicktextcontrol.cpp916
-rw-r--r--src/quick/items/qquicktextcontrol_p.h45
-rw-r--r--src/quick/items/qquicktextcontrol_p_p.h60
-rw-r--r--src/quick/items/qquicktextedit.cpp11
4 files changed, 38 insertions, 994 deletions
diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp
index ec8abe9ea0..1a0f79adc4 100644
--- a/src/quick/items/qquicktextcontrol.cpp
+++ b/src/quick/items/qquicktextcontrol.cpp
@@ -99,22 +99,14 @@ static QTextLine currentTextLine(const QTextCursor &cursor)
QQuickTextControlPrivate::QQuickTextControlPrivate()
: doc(0), cursorOn(false), cursorIsFocusIndicator(false),
interactionFlags(Qt::TextEditorInteraction),
- dragEnabled(true),
-#ifndef QT_NO_DRAGANDDROP
- mousePressed(false), mightStartDrag(false),
-#endif
+ mousePressed(false),
lastSelectionState(false), ignoreAutomaticScrollbarAdjustement(false),
overwriteMode(false),
acceptRichText(true),
preeditCursor(0), hideCursor(false),
hasFocus(false),
-#ifdef QT_KEYPAD_NAVIGATION
- hasEditFocus(false),
-#endif
isEnabled(true),
hadSelectionOnMousePress(false),
- ignoreUnusedNavigationEvents(false),
- openExternalLinks(false),
wordSelectionEnabled(false)
{}
@@ -250,23 +242,17 @@ bool QQuickTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e)
cursor.setVisualNavigation(visualNavigation);
q->ensureCursorVisible();
- bool ignoreNavigationEvents = ignoreUnusedNavigationEvents;
- bool isNavigationEvent = e->key() == Qt::Key_Up || e->key() == Qt::Key_Down;
-
-#ifdef QT_KEYPAD_NAVIGATION
- ignoreNavigationEvents = ignoreNavigationEvents || QGuiApplication::keypadNavigationEnabled();
- isNavigationEvent = isNavigationEvent ||
- (QGuiApplication::navigationMode() == Qt::NavigationModeKeypadDirectional
- && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right));
-#else
- isNavigationEvent = isNavigationEvent || e->key() == Qt::Key_Left || e->key() == Qt::Key_Right;
-#endif
+ bool isNavigationEvent
+ = e->key() == Qt::Key_Up
+ || e->key() == Qt::Key_Down
+ || e->key() == Qt::Key_Left
+ || e->key() == Qt::Key_Right;
if (moved) {
if (cursor.position() != oldCursorPos)
emit q->cursorPositionChanged();
emit q->microFocusChanged();
- } else if (ignoreNavigationEvents && isNavigationEvent && oldSelection.anchor() == cursor.anchor()) {
+ } else if (isNavigationEvent && oldSelection.anchor() == cursor.anchor()) {
return false;
}
@@ -290,99 +276,6 @@ void QQuickTextControlPrivate::updateCurrentCharFormat()
emit q->microFocusChanged();
}
-void QQuickTextControlPrivate::indent()
-{
- QTextBlockFormat blockFmt = cursor.blockFormat();
-
- QTextList *list = cursor.currentList();
- if (!list) {
- QTextBlockFormat modifier;
- modifier.setIndent(blockFmt.indent() + 1);
- cursor.mergeBlockFormat(modifier);
- } else {
- QTextListFormat format = list->format();
- format.setIndent(format.indent() + 1);
-
- if (list->itemNumber(cursor.block()) == 1)
- list->setFormat(format);
- else
- cursor.createList(format);
- }
-}
-
-void QQuickTextControlPrivate::outdent()
-{
- QTextBlockFormat blockFmt = cursor.blockFormat();
-
- QTextList *list = cursor.currentList();
-
- if (!list) {
- QTextBlockFormat modifier;
- modifier.setIndent(blockFmt.indent() - 1);
- cursor.mergeBlockFormat(modifier);
- } else {
- QTextListFormat listFmt = list->format();
- listFmt.setIndent(listFmt.indent() - 1);
- list->setFormat(listFmt);
- }
-}
-
-void QQuickTextControlPrivate::gotoNextTableCell()
-{
- QTextTable *table = cursor.currentTable();
- QTextTableCell cell = table->cellAt(cursor);
-
- int newColumn = cell.column() + cell.columnSpan();
- int newRow = cell.row();
-
- if (newColumn >= table->columns()) {
- newColumn = 0;
- ++newRow;
- if (newRow >= table->rows())
- table->insertRows(table->rows(), 1);
- }
-
- cell = table->cellAt(newRow, newColumn);
- cursor = cell.firstCursorPosition();
-}
-
-void QQuickTextControlPrivate::gotoPreviousTableCell()
-{
- QTextTable *table = cursor.currentTable();
- QTextTableCell cell = table->cellAt(cursor);
-
- int newColumn = cell.column() - 1;
- int newRow = cell.row();
-
- if (newColumn < 0) {
- newColumn = table->columns() - 1;
- --newRow;
- if (newRow < 0)
- return;
- }
-
- cell = table->cellAt(newRow, newColumn);
- cursor = cell.firstCursorPosition();
-}
-
-void QQuickTextControlPrivate::createAutoBulletList()
-{
- cursor.beginEditBlock();
-
- QTextBlockFormat blockFmt = cursor.blockFormat();
-
- QTextListFormat listFmt;
- listFmt.setStyle(QTextListFormat::ListDisc);
- listFmt.setIndent(blockFmt.indent() + 1);
-
- blockFmt.setIndent(0);
- cursor.setBlockFormat(blockFmt);
-
- cursor.createList(listFmt);
-
- cursor.endEditBlock();
-}
-
void QQuickTextControlPrivate::init(Qt::TextFormat format, const QString &text, QTextDocument *document)
{
Q_Q(QQuickTextControl);
@@ -390,8 +283,6 @@ void QQuickTextControlPrivate::init(Qt::TextFormat format, const QString &text,
doc->setUndoRedoEnabled(interactionFlags & Qt::TextEditable);
q->setCursorWidth(-1);
-
- QObject::connect(q, SIGNAL(updateCursorRequest(QRectF)), q, SIGNAL(updateRequest(QRectF)));
}
void QQuickTextControlPrivate::setContent(Qt::TextFormat format, const QString &text, QTextDocument *document)
@@ -482,32 +373,6 @@ void QQuickTextControlPrivate::setContent(Qt::TextFormat format, const QString &
emit q->cursorPositionChanged();
}
-void QQuickTextControlPrivate::startDrag()
-{
-#ifndef QT_NO_DRAGANDDROP
- Q_Q(QQuickTextControl);
- mousePressed = false;
- if (!contextObject)
- return;
- QMimeData *data = q->createMimeDataFromSelection();
-
- QDrag *drag = new QDrag(contextObject);
- drag->setMimeData(data);
-
- Qt::DropActions actions = Qt::CopyAction;
- Qt::DropAction action;
- if (interactionFlags & Qt::TextEditable) {
- actions |= Qt::MoveAction;
- action = drag->exec(actions, Qt::MoveAction);
- } else {
- action = drag->exec(actions, Qt::CopyAction);
- }
-
- if (action == Qt::MoveAction && drag->target() != contextObject)
- cursor.removeSelectedText();
-#endif
-}
-
void QQuickTextControlPrivate::setCursorPosition(const QPointF &pos)
{
Q_Q(QQuickTextControl);
@@ -764,20 +629,6 @@ void QQuickTextControl::redo()
ensureCursorVisible();
}
-QQuickTextControl::QQuickTextControl(QObject *parent)
- : QObject(*new QQuickTextControlPrivate, parent)
-{
- Q_D(QQuickTextControl);
- d->init();
-}
-
-QQuickTextControl::QQuickTextControl(const QString &text, QObject *parent)
- : QObject(*new QQuickTextControlPrivate, parent)
-{
- Q_D(QQuickTextControl);
- d->init(Qt::RichText, text);
-}
-
QQuickTextControl::QQuickTextControl(QTextDocument *doc, QObject *parent)
: QObject(*new QQuickTextControlPrivate, parent)
{
@@ -801,23 +652,6 @@ QObject *QQuickTextControl::view() const
return d->contextObject;
}
-void QQuickTextControl::setDocument(QTextDocument *document)
-{
- Q_D(QQuickTextControl);
- if (d->doc == document)
- return;
-
- d->doc->disconnect(this);
- d->doc->documentLayout()->disconnect(this);
- d->doc->documentLayout()->setPaintDevice(0);
-
- if (d->doc->parent() == this)
- delete d->doc;
-
- d->doc = 0;
- d->setContent(Qt::RichText, QString(), document);
-}
-
QTextDocument *QQuickTextControl::document() const
{
Q_D(const QQuickTextControl);
@@ -878,7 +712,6 @@ void QQuickTextControl::clear()
{
Q_D(QQuickTextControl);
// clears and sets empty content
- d->extraSelections.clear();
d->setContent();
}
@@ -914,23 +747,19 @@ void QQuickTextControl::processEvent(QEvent *e, const QMatrix &matrix)
break;
case QEvent::MouseButtonPress: {
QMouseEvent *ev = static_cast<QMouseEvent *>(e);
- d->mousePressEvent(ev, ev->button(), matrix.map(ev->localPos()), ev->modifiers(),
- ev->buttons(), ev->screenPos().toPoint());
+ d->mousePressEvent(ev, matrix.map(ev->localPos()));
break; }
case QEvent::MouseMove: {
QMouseEvent *ev = static_cast<QMouseEvent *>(e);
- d->mouseMoveEvent(ev, ev->button(), matrix.map(ev->localPos()), ev->modifiers(),
- ev->buttons(), ev->screenPos().toPoint());
+ d->mouseMoveEvent(ev, matrix.map(ev->localPos()));
break; }
case QEvent::MouseButtonRelease: {
QMouseEvent *ev = static_cast<QMouseEvent *>(e);
- d->mouseReleaseEvent(ev, ev->button(), matrix.map(ev->localPos()), ev->modifiers(),
- ev->buttons(), ev->screenPos().toPoint());
+ d->mouseReleaseEvent(ev, matrix.map(ev->localPos()));
break; }
case QEvent::MouseButtonDblClick: {
QMouseEvent *ev = static_cast<QMouseEvent *>(e);
- d->mouseDoubleClickEvent(ev, ev->button(), matrix.map(ev->localPos()), ev->modifiers(),
- ev->buttons(), ev->screenPos().toPoint());
+ d->mouseDoubleClickEvent(ev, matrix.map(ev->localPos()));
break; }
case QEvent::InputMethod:
d->inputMethodEvent(static_cast<QInputMethodEvent *>(e));
@@ -944,37 +773,6 @@ void QQuickTextControl::processEvent(QEvent *e, const QMatrix &matrix)
d->isEnabled = e->isAccepted();
break;
-#ifndef QT_NO_DRAGANDDROP
- case QEvent::DragEnter: {
- QDragEnterEvent *ev = static_cast<QDragEnterEvent *>(e);
- if (d->dragEnterEvent(e, ev->mimeData()))
- ev->acceptProposedAction();
- break;
- }
- case QEvent::DragLeave:
- d->dragLeaveEvent();
- break;
- case QEvent::DragMove: {
- QDragMoveEvent *ev = static_cast<QDragMoveEvent *>(e);
- if (d->dragMoveEvent(e, ev->mimeData(), matrix.map(ev->pos())))
- ev->acceptProposedAction();
- break;
- }
- case QEvent::Drop: {
- QDropEvent *ev = static_cast<QDropEvent *>(e);
- if (d->dropEvent(ev->mimeData(), matrix.map(ev->pos()), ev->dropAction(), ev->source()))
- ev->acceptProposedAction();
- break;
- }
-#endif
-
-#ifdef QT_KEYPAD_NAVIGATION
- case QEvent::EnterEditFocus:
- case QEvent::LeaveEditFocus:
- if (QGuiApplication::keypadNavigationEnabled())
- d->editFocusEvent(e);
- break;
-#endif
case QEvent::ShortcutOverride:
if (d->interactionFlags & Qt::TextEditable) {
QKeyEvent* ke = static_cast<QKeyEvent *>(e);
@@ -1088,14 +886,7 @@ void QQuickTextControlPrivate::keyPressEvent(QKeyEvent *e)
goto accept;
if (interactionFlags & Qt::LinksAccessibleByKeyboard) {
- if ((e->key() == Qt::Key_Return
- || e->key() == Qt::Key_Enter
-#ifdef QT_KEYPAD_NAVIGATION
- || e->key() == Qt::Key_Select
-#endif
- )
- && cursor.hasSelection()) {
-
+ if ((e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && cursor.hasSelection()) {
e->accept();
activateLinkUnderCursor();
return;
@@ -1195,13 +986,6 @@ process:
{
QString text = e->text();
if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) {
- if (overwriteMode
- // no need to call deleteChar() if we have a selection, insertText
- // does it already
- && !cursor.hasSelection()
- && !cursor.atBlockEnd())
- cursor.deleteChar();
-
cursor.insertText(text);
selectionChanged();
} else {
@@ -1220,20 +1004,6 @@ process:
updateCurrentCharFormat();
}
-QVariant QQuickTextControl::loadResource(int type, const QUrl &name)
-{
-#if 1
- Q_UNUSED(type);
- Q_UNUSED(name);
-#else
- if (QTextEdit *textEdit = qobject_cast<QTextEdit *>(parent())) {
- QUrl resolvedName = textEdit->d_func()->resolveUrl(name);
- return textEdit->loadResource(type, resolvedName);
- }
-#endif
- return QVariant();
-}
-
void QQuickTextControlPrivate::_q_updateBlock(const QTextBlock &block)
{
Q_Q(QQuickTextControl);
@@ -1276,14 +1046,7 @@ QRectF QQuickTextControlPrivate::rectForPosition(int position) const
if (line.isValid()) {
qreal x = line.cursorToX(relativePos);
qreal w = 0;
- if (overwriteMode) {
- if (relativePos < line.textLength() - line.textStart())
- w = line.cursorToX(relativePos + 1) - x;
- else
- w = QFontMetrics(block.layout()->font()).width(QLatin1Char(' ')); // in sync with QTextLine::draw()
- }
- r = QRectF(layoutPos.x() + x, layoutPos.y() + line.y(),
- cursorWidth + w, line.height());
+ r = QRectF(layoutPos.x() + x, layoutPos.y() + line.y(), cursorWidth + w, line.height());
} else {
r = QRectF(layoutPos.x(), layoutPos.y(), cursorWidth, 10); // #### correct height
}
@@ -1408,21 +1171,15 @@ QRectF QQuickTextControl::selectionRect() const
return selectionRect(d->cursor);
}
-void QQuickTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons, const QPoint &globalPos)
+void QQuickTextControlPrivate::mousePressEvent(QMouseEvent *e, const QPointF &pos)
{
Q_Q(QQuickTextControl);
mousePressed = (interactionFlags & Qt::TextSelectableByMouse);
mousePressPos = pos.toPoint();
-#ifndef QT_NO_DRAGANDDROP
- mightStartDrag = false;
-#endif
- if (sendMouseEventToInputContext(
- e, QEvent::MouseButtonPress, button, pos, modifiers, buttons, globalPos)) {
+ if (sendMouseEventToInputContext(e, pos))
return;
- }
if (interactionFlags & Qt::LinksAccessibleByMouse) {
anchorOnMousePress = q->anchorAt(pos);
@@ -1433,7 +1190,7 @@ void QQuickTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button
cursor.clearSelection();
}
}
- if (!(button & Qt::LeftButton) ||
+ if (!(e->button() & Qt::LeftButton) ||
!((interactionFlags & Qt::TextSelectableByMouse) || (interactionFlags & Qt::TextEditable))) {
e->ignore();
return;
@@ -1463,7 +1220,7 @@ void QQuickTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button
return;
}
- if (modifiers == Qt::ShiftModifier && (interactionFlags & Qt::TextSelectableByMouse)) {
+ if (e->modifiers() == Qt::ShiftModifier && (interactionFlags & Qt::TextSelectableByMouse)) {
if (wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) {
selectedWordOnDoubleClick = cursor;
selectedWordOnDoubleClick.select(QTextCursor::WordUnderCursor);
@@ -1476,19 +1233,6 @@ void QQuickTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button
else if (!wordSelectionEnabled)
setCursorPosition(cursorPos, QTextCursor::KeepAnchor);
} else {
-
- if (dragEnabled
- && cursor.hasSelection()
- && !cursorIsFocusIndicator
- && cursorPos >= cursor.selectionStart()
- && cursorPos <= cursor.selectionEnd()
- && q->hitTest(pos, Qt::ExactHit) != -1) {
-#ifndef QT_NO_DRAGANDDROP
- mightStartDrag = true;
-#endif
- return;
- }
-
setCursorPosition(cursorPos);
}
}
@@ -1509,8 +1253,7 @@ void QQuickTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button
hadSelectionOnMousePress = cursor.hasSelection();
}
-void QQuickTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button, const QPointF &mousePos, Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons, const QPoint &globalPos)
+void QQuickTextControlPrivate::mouseMoveEvent(QMouseEvent *e, const QPointF &mousePos)
{
Q_Q(QQuickTextControl);
@@ -1522,12 +1265,11 @@ void QQuickTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button,
}
}
- if (buttons & Qt::LeftButton) {
+ if ((e->buttons() & Qt::LeftButton)) {
const bool editable = interactionFlags & Qt::TextEditable;
if (!(mousePressed
|| editable
- || mightStartDrag
|| selectedWordOnDoubleClick.hasSelection()
|| selectedBlockOnTrippleClick.hasSelection()))
return;
@@ -1535,12 +1277,6 @@ void QQuickTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button,
const QTextCursor oldSelection = cursor;
const int oldCursorPos = cursor.position();
- if (mightStartDrag) {
- if ((mousePos.toPoint() - mousePressPos).manhattanLength() > qApp->styleHints()->startDragDistance())
- startDrag();
- return;
- }
-
if (!mousePressed)
return;
@@ -1576,16 +1312,12 @@ void QQuickTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button,
setCursorPosition(newCursorPos, QTextCursor::KeepAnchor);
if (interactionFlags & Qt::TextEditable) {
- // don't call ensureVisible for the visible cursor to avoid jumping
- // scrollbars. the autoscrolling ensures smooth scrolling if necessary.
- //q->ensureCursorVisible();
if (cursor.position() != oldCursorPos)
emit q->cursorPositionChanged();
_q_updateCurrentCharFormatAndSelection();
if (qGuiApp)
qGuiApp->inputPanel()->update(Qt::ImQueryInput);
} else {
- //emit q->visibilityRequest(QRectF(mousePos, QSizeF(1, 1)));
if (cursor.position() != oldCursorPos) {
emit q->cursorPositionChanged();
emit q->microFocusChanged();
@@ -1595,36 +1327,25 @@ void QQuickTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button,
repaintOldAndNewSelection(oldSelection);
}
- sendMouseEventToInputContext(e, QEvent::MouseMove, button, mousePos, modifiers, buttons, globalPos);
+ sendMouseEventToInputContext(e, mousePos);
}
-void QQuickTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons, const QPoint &globalPos)
+void QQuickTextControlPrivate::mouseReleaseEvent(QMouseEvent *e, const QPointF &pos)
{
Q_Q(QQuickTextControl);
- if (sendMouseEventToInputContext(
- e, QEvent::MouseButtonRelease, button, pos, modifiers, buttons, globalPos)) {
+ if (sendMouseEventToInputContext(e, pos))
return;
- }
const QTextCursor oldSelection = cursor;
const int oldCursorPos = cursor.position();
-#ifndef QT_NO_DRAGANDDROP
- if (mightStartDrag && (button & Qt::LeftButton)) {
- mousePressed = false;
- setCursorPosition(pos);
- cursor.clearSelection();
- selectionChanged();
- }
-#endif
if (mousePressed) {
mousePressed = false;
#ifndef QT_NO_CLIPBOARD
setClipboardSelection();
selectionChanged(true);
- } else if (button == Qt::MidButton
+ } else if (e->button() == Qt::MidButton
&& (interactionFlags & Qt::TextEditable)
&& QGuiApplication::clipboard()->supportsSelection()) {
setCursorPosition(pos);
@@ -1642,7 +1363,7 @@ void QQuickTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton butt
}
if (interactionFlags & Qt::LinksAccessibleByMouse) {
- if (!(button & Qt::LeftButton))
+ if (!(e->button() & Qt::LeftButton))
return;
const QString anchor = q->anchorAt(pos);
@@ -1665,17 +1386,11 @@ void QQuickTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton butt
}
}
-void QQuickTextControlPrivate::mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons, const QPoint &globalPos)
+void QQuickTextControlPrivate::mouseDoubleClickEvent(QMouseEvent *e, const QPointF &pos)
{
Q_Q(QQuickTextControl);
- if (button == Qt::LeftButton
- && (interactionFlags & Qt::TextSelectableByMouse)) {
-
-#ifndef QT_NO_DRAGANDDROP
- mightStartDrag = false;
-#endif
+ if (e->button() == Qt::LeftButton && (interactionFlags & Qt::TextSelectableByMouse)) {
commitPreedit();
const QTextCursor oldSelection = cursor;
@@ -1700,31 +1415,24 @@ void QQuickTextControlPrivate::mouseDoubleClickEvent(QEvent *e, Qt::MouseButton
#endif
emit q->cursorPositionChanged();
}
- } else if (!sendMouseEventToInputContext(e, QEvent::MouseButtonDblClick, button, pos,
- modifiers, buttons, globalPos)) {
+ } else if (!sendMouseEventToInputContext(e, pos)) {
e->ignore();
}
}
-bool QQuickTextControlPrivate::sendMouseEventToInputContext(
- QEvent *e, QEvent::Type eventType, Qt::MouseButton button, const QPointF &pos,
- Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons, const QPoint &globalPos)
+bool QQuickTextControlPrivate::sendMouseEventToInputContext(QMouseEvent *e, const QPointF &pos)
{
#if !defined(QT_NO_IM)
Q_Q(QQuickTextControl);
Q_UNUSED(e);
- Q_UNUSED(button);
- Q_UNUSED(modifiers);
- Q_UNUSED(buttons);
- Q_UNUSED(globalPos);
if (contextObject && isPreediting()) {
QTextLayout *layout = cursor.block().layout();
int cursorPos = q->hitTest(pos, Qt::FuzzyHit) - cursor.position();
if (cursorPos >= 0 && cursorPos <= layout->preeditAreaText().length()) {
- if (eventType == QEvent::MouseButtonRelease) {
+ if (e->type() == QEvent::MouseButtonRelease) {
qApp->inputPanel()->invokeAction(QInputPanel::Click, cursorPos);
}
@@ -1733,87 +1441,11 @@ bool QQuickTextControlPrivate::sendMouseEventToInputContext(
}
#else
Q_UNUSED(e);
- Q_UNUSED(eventType);
- Q_UNUSED(button);
Q_UNUSED(pos);
- Q_UNUSED(modifiers);
- Q_UNUSED(buttons);
- Q_UNUSED(globalPos);
#endif
return false;
}
-bool QQuickTextControlPrivate::dragEnterEvent(QEvent *e, const QMimeData *mimeData)
-{
- Q_Q(QQuickTextControl);
- if (!(interactionFlags & Qt::TextEditable) || !q->canInsertFromMimeData(mimeData)) {
- e->ignore();
- return false;
- }
-
- dndFeedbackCursor = QTextCursor();
-
- return true; // accept proposed action
-}
-
-void QQuickTextControlPrivate::dragLeaveEvent()
-{
- Q_Q(QQuickTextControl);
-
- const QRectF crect = q->cursorRect(dndFeedbackCursor);
- dndFeedbackCursor = QTextCursor();
-
- if (crect.isValid())
- emit q->updateRequest(crect);
-}
-
-bool QQuickTextControlPrivate::dragMoveEvent(QEvent *e, const QMimeData *mimeData, const QPointF &pos)
-{
- Q_Q(QQuickTextControl);
- if (!(interactionFlags & Qt::TextEditable) || !q->canInsertFromMimeData(mimeData)) {
- e->ignore();
- return false;
- }
-
- const int cursorPos = q->hitTest(pos, Qt::FuzzyHit);
- if (cursorPos != -1) {
- QRectF crect = q->cursorRect(dndFeedbackCursor);
- if (crect.isValid())
- emit q->updateRequest(crect);
-
- dndFeedbackCursor = cursor;
- dndFeedbackCursor.setPosition(cursorPos);
-
- crect = q->cursorRect(dndFeedbackCursor);
- emit q->updateRequest(crect);
- }
-
- return true; // accept proposed action
-}
-
-bool QQuickTextControlPrivate::dropEvent(const QMimeData *mimeData, const QPointF &pos, Qt::DropAction dropAction, QObject *source)
-{
- Q_Q(QQuickTextControl);
- dndFeedbackCursor = QTextCursor();
-
- if (!(interactionFlags & Qt::TextEditable) || !q->canInsertFromMimeData(mimeData))
- return false;
-
- repaintSelection();
-
- QTextCursor insertionCursor = q->cursorForPosition(pos);
- insertionCursor.beginEditBlock();
-
- if (dropAction == Qt::MoveAction && source == contextObject)
- cursor.removeSelectedText();
-
- cursor = insertionCursor;
- q->insertFromMimeData(mimeData);
- insertionCursor.endEditBlock();
- q->ensureCursorVisible();
- return true; // accept proposed action
-}
-
void QQuickTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
{
Q_Q(QQuickTextControl);
@@ -1925,14 +1557,7 @@ void QQuickTextControlPrivate::focusEvent(QFocusEvent *e)
Q_Q(QQuickTextControl);
emit q->updateRequest(q->selectionRect());
if (e->gotFocus()) {
-#ifdef QT_KEYPAD_NAVIGATION
- if (!QGuiApplication::keypadNavigationEnabled() || (hasEditFocus && (e->reason() == Qt::PopupFocusReason
- ))) {
-#endif
- setBlinkingCursorEnabled(interactionFlags & (Qt::TextEditable | Qt::TextSelectableByKeyboard));
-#ifdef QT_KEYPAD_NAVIGATION
- }
-#endif
+ setBlinkingCursorEnabled(interactionFlags & (Qt::TextEditable | Qt::TextSelectableByKeyboard));
} else {
commitPreedit();
setBlinkingCursorEnabled(false);
@@ -1961,34 +1586,6 @@ QString QQuickTextControlPrivate::anchorForCursor(const QTextCursor &anchorCurso
return QString();
}
-#ifdef QT_KEYPAD_NAVIGATION
-void QQuickTextControlPrivate::editFocusEvent(QEvent *e)
-{
- Q_Q(QQuickTextControl);
-
- if (QGuiApplication::keypadNavigationEnabled()) {
- if (e->type() == QEvent::EnterEditFocus && interactionFlags & Qt::TextEditable) {
- const QTextCursor oldSelection = cursor;
- const int oldCursorPos = cursor.position();
- const bool moved = cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
- q->ensureCursorVisible();
- if (moved) {
- if (cursor.position() != oldCursorPos)
- emit q->cursorPositionChanged();
- emit q->microFocusChanged();
- }
- selectionChanged();
- repaintOldAndNewSelection(oldSelection);
-
- setBlinkingCursorEnabled(true);
- } else
- setBlinkingCursorEnabled(false);
- }
-
- hasEditFocus = e->type() == QEvent::EnterEditFocus ? true : false;
-}
-#endif
-
QTextCursor QQuickTextControl::cursorForPosition(const QPointF &pos) const
{
Q_D(const QQuickTextControl);
@@ -2036,18 +1633,6 @@ QString QQuickTextControl::anchorAtCursor() const
return d->anchorForCursor(d->cursor);
}
-bool QQuickTextControl::overwriteMode() const
-{
- Q_D(const QQuickTextControl);
- return d->overwriteMode;
-}
-
-void QQuickTextControl::setOverwriteMode(bool overwrite)
-{
- Q_D(QQuickTextControl);
- d->overwriteMode = overwrite;
-}
-
int QQuickTextControl::cursorWidth() const
{
#ifndef QT_NO_PROPERTIES
@@ -2083,54 +1668,6 @@ void QQuickTextControl::setAcceptRichText(bool accept)
d->acceptRichText = accept;
}
-void QQuickTextControl::setExtraSelections(const QVector<QAbstractTextDocumentLayout::Selection> &selections)
-{
- Q_D(QQuickTextControl);
-
- QHash<int, int> hash;
- for (int i = 0; i < d->extraSelections.count(); ++i) {
- const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(i);
- hash.insertMulti(esel.cursor.anchor(), i);
- }
-
- for (int i = 0; i < selections.count(); ++i) {
- const QAbstractTextDocumentLayout::Selection &sel = selections.at(i);
- QHash<int, int>::iterator it = hash.find(sel.cursor.anchor());
- if (it != hash.end()) {
- const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(it.value());
- if (esel.cursor.position() == sel.cursor.position()
- && esel.format == sel.format) {
- hash.erase(it);
- continue;
- }
- }
- QRectF r = selectionRect(sel.cursor);
- if (sel.format.boolProperty(QTextFormat::FullWidthSelection)) {
- r.setLeft(0);
- r.setWidth(qreal(INT_MAX));
- }
- emit updateRequest(r);
- }
-
- for (QHash<int, int>::iterator it = hash.begin(); it != hash.end(); ++it) {
- const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(it.value());
- QRectF r = selectionRect(esel.cursor);
- if (esel.format.boolProperty(QTextFormat::FullWidthSelection)) {
- r.setLeft(0);
- r.setWidth(qreal(INT_MAX));
- }
- emit updateRequest(r);
- }
-
- d->extraSelections = selections;
-}
-
-QVector<QAbstractTextDocumentLayout::Selection> QQuickTextControl::extraSelections() const
-{
- Q_D(const QQuickTextControl);
- return d->extraSelections;
-}
-
void QQuickTextControl::setTextWidth(qreal width)
{
Q_D(QQuickTextControl);
@@ -2149,30 +1686,6 @@ QSizeF QQuickTextControl::size() const
return d->doc->size();
}
-void QQuickTextControl::setOpenExternalLinks(bool open)
-{
- Q_D(QQuickTextControl);
- d->openExternalLinks = open;
-}
-
-bool QQuickTextControl::openExternalLinks() const
-{
- Q_D(const QQuickTextControl);
- return d->openExternalLinks;
-}
-
-bool QQuickTextControl::ignoreUnusedNavigationEvents() const
-{
- Q_D(const QQuickTextControl);
- return d->ignoreUnusedNavigationEvents;
-}
-
-void QQuickTextControl::setIgnoreUnusedNavigationEvents(bool ignore)
-{
- Q_D(QQuickTextControl);
- d->ignoreUnusedNavigationEvents = ignore;
-}
-
void QQuickTextControl::moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode)
{
Q_D(QQuickTextControl);
@@ -2210,19 +1723,6 @@ bool QQuickTextControl::cursorIsFocusIndicator() const
return d->cursorIsFocusIndicator;
}
-
-void QQuickTextControl::setDragEnabled(bool enabled)
-{
- Q_D(QQuickTextControl);
- d->dragEnabled = enabled;
-}
-
-bool QQuickTextControl::isDragEnabled() const
-{
- Q_D(const QQuickTextControl);
- return d->dragEnabled;
-}
-
void QQuickTextControl::setWordSelectionEnabled(bool enabled)
{
Q_D(QQuickTextControl);
@@ -2288,148 +1788,6 @@ void QQuickTextControl::insertFromMimeData(const QMimeData *source)
ensureCursorVisible();
}
-bool QQuickTextControl::findNextPrevAnchor(const QTextCursor &startCursor, bool next, QTextCursor &newAnchor)
-{
- Q_D(QQuickTextControl);
-
- int anchorStart = -1;
- QString anchorHref;
- int anchorEnd = -1;
-
- if (next) {
- const int startPos = startCursor.selectionEnd();
-
- QTextBlock block = d->doc->findBlock(startPos);
- QTextBlock::Iterator it = block.begin();
-
- while (!it.atEnd() && it.fragment().position() < startPos)
- ++it;
-
- while (block.isValid()) {
- anchorStart = -1;
-
- // find next anchor
- for (; !it.atEnd(); ++it) {
- const QTextFragment fragment = it.fragment();
- const QTextCharFormat fmt = fragment.charFormat();
-
- if (fmt.isAnchor() && fmt.hasProperty(QTextFormat::AnchorHref)) {
- anchorStart = fragment.position();
- anchorHref = fmt.anchorHref();
- break;
- }
- }
-
- if (anchorStart != -1) {
- anchorEnd = -1;
-
- // find next non-anchor fragment
- for (; !it.atEnd(); ++it) {
- const QTextFragment fragment = it.fragment();
- const QTextCharFormat fmt = fragment.charFormat();
-
- if (!fmt.isAnchor() || fmt.anchorHref() != anchorHref) {
- anchorEnd = fragment.position();
- break;
- }
- }
-
- if (anchorEnd == -1)
- anchorEnd = block.position() + block.length() - 1;
-
- // make found selection
- break;
- }
-
- block = block.next();
- it = block.begin();
- }
- } else {
- int startPos = startCursor.selectionStart();
- if (startPos > 0)
- --startPos;
-
- QTextBlock block = d->doc->findBlock(startPos);
- QTextBlock::Iterator blockStart = block.begin();
- QTextBlock::Iterator it = block.end();
-
- if (startPos == block.position()) {
- it = block.begin();
- } else {
- do {
- if (it == blockStart) {
- it = QTextBlock::Iterator();
- block = QTextBlock();
- } else {
- --it;
- }
- } while (!it.atEnd() && it.fragment().position() + it.fragment().length() - 1 > startPos);
- }
-
- while (block.isValid()) {
- anchorStart = -1;
-
- if (!it.atEnd()) {
- do {
- const QTextFragment fragment = it.fragment();
- const QTextCharFormat fmt = fragment.charFormat();
-
- if (fmt.isAnchor() && fmt.hasProperty(QTextFormat::AnchorHref)) {
- anchorStart = fragment.position() + fragment.length();
- anchorHref = fmt.anchorHref();
- break;
- }
-
- if (it == blockStart)
- it = QTextBlock::Iterator();
- else
- --it;
- } while (!it.atEnd());
- }
-
- if (anchorStart != -1 && !it.atEnd()) {
- anchorEnd = -1;
-
- do {
- const QTextFragment fragment = it.fragment();
- const QTextCharFormat fmt = fragment.charFormat();
-
- if (!fmt.isAnchor() || fmt.anchorHref() != anchorHref) {
- anchorEnd = fragment.position() + fragment.length();
- break;
- }
-
- if (it == blockStart)
- it = QTextBlock::Iterator();
- else
- --it;
- } while (!it.atEnd());
-
- if (anchorEnd == -1)
- anchorEnd = qMax(0, block.position());
-
- break;
- }
-
- block = block.previous();
- it = block.end();
- if (it != block.begin())
- --it;
- blockStart = block.begin();
- }
-
- }
-
- if (anchorStart != -1 && anchorEnd != -1) {
- newAnchor = d->cursor;
- newAnchor.setPosition(anchorStart);
- newAnchor.setPosition(anchorEnd, QTextCursor::KeepAnchor);
- return true;
- }
-
- return false;
-}
-
void QQuickTextControlPrivate::activateLinkUnderCursor(QString href)
{
QTextCursor oldCursor = cursor;
@@ -2491,12 +1849,7 @@ void QQuickTextControlPrivate::activateLinkUnderCursor(QString href)
}
repaintOldAndNewSelection(oldCursor);
-#if 0 // ###ndef QT_NO_DESKTOPSERVICES
- if (openExternalLinks)
- QDesktopServices::openUrl(href);
- else
-#endif
- emit q_func()->linkActivated(href);
+ emit q_func()->linkActivated(href);
}
bool QQuickTextControlPrivate::isPreediting() const
@@ -2529,69 +1882,6 @@ void QQuickTextControlPrivate::commitPreedit()
cursor.endEditBlock();
}
-bool QQuickTextControl::setFocusToNextOrPreviousAnchor(bool next)
-{
- Q_D(QQuickTextControl);
-
- if (!(d->interactionFlags & Qt::LinksAccessibleByKeyboard))
- return false;
-
- QRectF crect = selectionRect();
- emit updateRequest(crect);
-
- // If we don't have a current anchor, we start from the start/end
- if (!d->cursor.hasSelection()) {
- d->cursor = QTextCursor(d->doc);
- if (next)
- d->cursor.movePosition(QTextCursor::Start);
- else
- d->cursor.movePosition(QTextCursor::End);
- }
-
- QTextCursor newAnchor;
- if (findNextPrevAnchor(d->cursor, next, newAnchor)) {
- d->cursor = newAnchor;
- d->cursorIsFocusIndicator = true;
- } else {
- d->cursor.clearSelection();
- }
-
- if (d->cursor.hasSelection()) {
- crect = selectionRect();
- emit updateRequest(crect);
- emit visibilityRequest(crect);
- return true;
- } else {
- return false;
- }
-}
-
-bool QQuickTextControl::setFocusToAnchor(const QTextCursor &newCursor)
-{
- Q_D(QQuickTextControl);
-
- if (!(d->interactionFlags & Qt::LinksAccessibleByKeyboard))
- return false;
-
- // Verify that this is an anchor.
- const QString anchorHref = d->anchorForCursor(newCursor);
- if (anchorHref.isEmpty())
- return false;
-
- // and process it
- QRectF crect = selectionRect();
- emit updateRequest(crect);
-
- d->cursor.setPosition(newCursor.selectionStart());
- d->cursor.setPosition(newCursor.selectionEnd(), QTextCursor::KeepAnchor);
- d->cursorIsFocusIndicator = true;
-
- crect = selectionRect();
- emit updateRequest(crect);
- emit visibilityRequest(crect);
- return true;
-}
-
void QQuickTextControl::setTextInteractionFlags(Qt::TextInteractionFlags flags)
{
Q_D(QQuickTextControl);
@@ -2609,135 +1899,6 @@ Qt::TextInteractionFlags QQuickTextControl::textInteractionFlags() const
return d->interactionFlags;
}
-void QQuickTextControl::mergeCurrentCharFormat(const QTextCharFormat &modifier)
-{
- Q_D(QQuickTextControl);
- d->cursor.mergeCharFormat(modifier);
- d->updateCurrentCharFormat();
-}
-
-void QQuickTextControl::setCurrentCharFormat(const QTextCharFormat &format)
-{
- Q_D(QQuickTextControl);
- d->cursor.setCharFormat(format);
- d->updateCurrentCharFormat();
-}
-
-QTextCharFormat QQuickTextControl::currentCharFormat() const
-{
- Q_D(const QQuickTextControl);
- return d->cursor.charFormat();
-}
-
-void QQuickTextControl::insertPlainText(const QString &text)
-{
- Q_D(QQuickTextControl);
- d->cursor.insertText(text);
-}
-
-#ifndef QT_NO_TEXTHTMLPARSER
-void QQuickTextControl::insertHtml(const QString &text)
-{
- Q_D(QQuickTextControl);
- d->cursor.insertHtml(text);
-}
-#endif // QT_NO_TEXTHTMLPARSER
-
-QPointF QQuickTextControl::anchorPosition(const QString &name) const
-{
- Q_D(const QQuickTextControl);
- if (name.isEmpty())
- return QPointF();
-
- QRectF r;
- for (QTextBlock block = d->doc->begin(); block.isValid(); block = block.next()) {
- QTextCharFormat format = block.charFormat();
- if (format.isAnchor() && format.anchorNames().contains(name)) {
- r = d->rectForPosition(block.position());
- break;
- }
-
- for (QTextBlock::Iterator it = block.begin(); !it.atEnd(); ++it) {
- QTextFragment fragment = it.fragment();
- format = fragment.charFormat();
- if (format.isAnchor() && format.anchorNames().contains(name)) {
- r = d->rectForPosition(fragment.position());
- block = QTextBlock();
- break;
- }
- }
- }
- if (!r.isValid())
- return QPointF();
- return QPointF(0, r.top());
-}
-
-void QQuickTextControl::adjustSize()
-{
- Q_D(QQuickTextControl);
- d->doc->adjustSize();
-}
-
-bool QQuickTextControl::find(const QString &exp, QTextDocument::FindFlags options)
-{
- Q_D(QQuickTextControl);
- QTextCursor search = d->doc->find(exp, d->cursor, options);
- if (search.isNull())
- return false;
-
- setTextCursor(search);
- return true;
-}
-
-
-
-void QQuickTextControlPrivate::append(const QString &text, Qt::TextFormat format)
-{
- QTextCursor tmp(doc);
- tmp.beginEditBlock();
- tmp.movePosition(QTextCursor::End);
-
- if (!doc->isEmpty())
- tmp.insertBlock(cursor.blockFormat(), cursor.charFormat());
- else
- tmp.setCharFormat(cursor.charFormat());
-
- // preserve the char format
- QTextCharFormat oldCharFormat = cursor.charFormat();
-
-#ifndef QT_NO_TEXTHTMLPARSER
- if (format == Qt::RichText || (format == Qt::AutoText && Qt::mightBeRichText(text))) {
- tmp.insertHtml(text);
- } else {
- tmp.insertText(text);
- }
-#else
- tmp.insertText(text);
-#endif // QT_NO_TEXTHTMLPARSER
- if (!cursor.hasSelection())
- cursor.setCharFormat(oldCharFormat);
-
- tmp.endEditBlock();
-}
-
-void QQuickTextControl::append(const QString &text)
-{
- Q_D(QQuickTextControl);
- d->append(text, Qt::AutoText);
-}
-
-void QQuickTextControl::appendHtml(const QString &html)
-{
- Q_D(QQuickTextControl);
- d->append(html, Qt::RichText);
-}
-
-void QQuickTextControl::appendPlainText(const QString &text)
-{
- Q_D(QQuickTextControl);
- d->append(text, Qt::PlainText);
-}
-
QString QQuickTextControl::toPlainText() const
{
Q_D(const QQuickTextControl);
@@ -2787,7 +1948,6 @@ QAbstractTextDocumentLayout::PaintContext QQuickTextControl::getPaintContext() c
QAbstractTextDocumentLayout::PaintContext ctx;
- ctx.selections = d->extraSelections;
ctx.palette = d->palette;
if (d->cursorOn && d->isEnabled) {
if (d->hideCursor)
@@ -2798,11 +1958,6 @@ QAbstractTextDocumentLayout::PaintContext QQuickTextControl::getPaintContext() c
ctx.cursorPosition = d->cursor.position();
}
- if (!d->dndFeedbackCursor.isNull())
- ctx.cursorPosition = d->dndFeedbackCursor.position();
-#ifdef QT_KEYPAD_NAVIGATION
- if (!QGuiApplication::keypadNavigationEnabled() || d->hasEditFocus)
-#endif
if (d->cursor.hasSelection()) {
QAbstractTextDocumentLayout::Selection selection;
selection.cursor = d->cursor;
@@ -2844,15 +1999,6 @@ void QQuickTextControl::drawContents(QPainter *p, const QRectF &rect)
p->restore();
}
-void QQuickTextControlPrivate::_q_copyLink()
-{
-#ifndef QT_NO_CLIPBOARD
- QMimeData *md = new QMimeData;
- md->setText(linkToCopy);
- QGuiApplication::clipboard()->setMimeData(md);
-#endif
-}
-
int QQuickTextControl::hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const
{
Q_D(const QQuickTextControl);
diff --git a/src/quick/items/qquicktextcontrol_p.h b/src/quick/items/qquicktextcontrol_p.h
index 2e42625fdc..7768bd1230 100644
--- a/src/quick/items/qquicktextcontrol_p.h
+++ b/src/quick/items/qquicktextcontrol_p.h
@@ -84,22 +84,16 @@ class Q_AUTOTEST_EXPORT QQuickTextControl : public QObject
#ifndef QT_NO_TEXTHTMLPARSER
Q_PROPERTY(QString html READ toHtml WRITE setHtml NOTIFY textChanged USER true)
#endif
- Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
Q_PROPERTY(bool acceptRichText READ acceptRichText WRITE setAcceptRichText)
Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
- Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
- Q_PROPERTY(bool ignoreUnusedNavigationEvents READ ignoreUnusedNavigationEvents WRITE setIgnoreUnusedNavigationEvents)
public:
- explicit QQuickTextControl(QObject *parent = 0);
- explicit QQuickTextControl(const QString &text, QObject *parent = 0);
explicit QQuickTextControl(QTextDocument *doc, QObject *parent = 0);
virtual ~QQuickTextControl();
void setView(QObject *view);
QObject *view() const;
- void setDocument(QTextDocument *document);
QTextDocument *document() const;
void setTextCursor(const QTextCursor &cursor);
@@ -108,22 +102,14 @@ public:
void setTextInteractionFlags(Qt::TextInteractionFlags flags);
Qt::TextInteractionFlags textInteractionFlags() const;
- void mergeCurrentCharFormat(const QTextCharFormat &modifier);
-
- void setCurrentCharFormat(const QTextCharFormat &format);
- QTextCharFormat currentCharFormat() const;
-
- bool find(const QString &exp, QTextDocument::FindFlags options = 0);
-
QString toPlainText() const;
+
#ifndef QT_NO_TEXTHTMLPARSER
QString toHtml() const;
#endif
virtual void ensureCursorVisible();
- virtual QVariant loadResource(int type, const QUrl &name);
-
QTextCursor cursorForPosition(const QPointF &pos) const;
QRectF cursorRect(const QTextCursor &cursor) const;
QRectF cursorRect() const;
@@ -131,29 +117,19 @@ public:
QRectF selectionRect() const;
QString anchorAt(const QPointF &pos) const;
- QPointF anchorPosition(const QString &name) const;
QString anchorAtCursor() const;
- bool overwriteMode() const;
- void setOverwriteMode(bool overwrite);
-
int cursorWidth() const;
void setCursorWidth(int width);
bool acceptRichText() const;
void setAcceptRichText(bool accept);
- void setExtraSelections(const QVector<QAbstractTextDocumentLayout::Selection> &selections);
- QVector<QAbstractTextDocumentLayout::Selection> extraSelections() const;
-
void setTextWidth(qreal width);
qreal textWidth() const;
QSizeF size() const;
- void setOpenExternalLinks(bool open);
- bool openExternalLinks() const;
-
void setIgnoreUnusedNavigationEvents(bool ignore);
bool ignoreUnusedNavigationEvents() const;
@@ -164,9 +140,6 @@ public:
void setCursorIsFocusIndicator(bool b);
bool cursorIsFocusIndicator() const;
- void setDragEnabled(bool enabled);
- bool isDragEnabled() const;
-
bool isWordSelectionEnabled() const;
void setWordSelectionEnabled(bool enabled);
@@ -190,17 +163,6 @@ public Q_SLOTS:
void clear();
void selectAll();
- void insertPlainText(const QString &text);
-#ifndef QT_NO_TEXTHTMLPARSER
- void insertHtml(const QString &text);
-#endif
-
- void append(const QString &text);
- void appendHtml(const QString &html);
- void appendPlainText(const QString &text);
-
- void adjustSize();
-
Q_SIGNALS:
void textChanged();
void undoAvailable(bool b);
@@ -240,10 +202,6 @@ public:
virtual bool canInsertFromMimeData(const QMimeData *source) const;
virtual void insertFromMimeData(const QMimeData *source);
- bool setFocusToAnchor(const QTextCursor &newCursor);
- bool setFocusToNextOrPreviousAnchor(bool next);
- bool findNextPrevAnchor(const QTextCursor& from, bool next, QTextCursor& newAnchor);
-
bool cursorOn() const;
protected:
@@ -256,7 +214,6 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_updateCurrentCharFormatAndSelection())
Q_PRIVATE_SLOT(d_func(), void _q_emitCursorPosChanged(const QTextCursor &))
Q_PRIVATE_SLOT(d_func(), void _q_deleteSelected())
- Q_PRIVATE_SLOT(d_func(), void _q_copyLink())
Q_PRIVATE_SLOT(d_func(), void _q_updateBlock(const QTextBlock &))
Q_PRIVATE_SLOT(d_func(), void _q_documentLayoutChanged())
};
diff --git a/src/quick/items/qquicktextcontrol_p_p.h b/src/quick/items/qquicktextcontrol_p_p.h
index 2b2e9cb35a..1e9bdbbe61 100644
--- a/src/quick/items/qquicktextcontrol_p_p.h
+++ b/src/quick/items/qquicktextcontrol_p_p.h
@@ -76,19 +76,10 @@ public:
void updateCurrentCharFormat();
- void indent();
- void outdent();
-
- void gotoNextTableCell();
- void gotoPreviousTableCell();
-
- void createAutoBulletList();
-
void init(Qt::TextFormat format = Qt::RichText, const QString &text = QString(),
QTextDocument *document = 0);
void setContent(Qt::TextFormat format = Qt::RichText, const QString &text = QString(),
QTextDocument *document = 0);
- void startDrag();
void paste(const QMimeData *source);
@@ -128,37 +119,12 @@ public:
QString anchorForCursor(const QTextCursor &anchor) const;
void keyPressEvent(QKeyEvent *e);
- void mousePressEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
- Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons,
- const QPoint &globalPos);
- void mouseMoveEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
- Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons,
- const QPoint &globalPos);
- void mouseReleaseEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
- Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons,
- const QPoint &globalPos);
- void mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
- Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons,
- const QPoint &globalPos);
- bool sendMouseEventToInputContext(QEvent *e, QEvent::Type eventType, Qt::MouseButton button,
- const QPointF &pos,
- Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons,
- const QPoint &globalPos);
- void contextMenuEvent(const QPoint &screenPos, const QPointF &docPos, QWidget *contextWidget);
+ void mousePressEvent(QMouseEvent *event, const QPointF &pos);
+ void mouseMoveEvent(QMouseEvent *event, const QPointF &pos);
+ void mouseReleaseEvent(QMouseEvent *event, const QPointF &pos);
+ void mouseDoubleClickEvent(QMouseEvent *event, const QPointF &pos);
+ bool sendMouseEventToInputContext(QMouseEvent *event, const QPointF &pos);
void focusEvent(QFocusEvent *e);
-#ifdef QT_KEYPAD_NAVIGATION
- void editFocusEvent(QEvent *e);
-#endif
- bool dragEnterEvent(QEvent *e, const QMimeData *mimeData);
- void dragLeaveEvent();
- bool dragMoveEvent(QEvent *e, const QMimeData *mimeData, const QPointF &pos);
- bool dropEvent(const QMimeData *mimeData, const QPointF &pos, Qt::DropAction dropAction, QObject *source);
-
void inputMethodEvent(QInputMethodEvent *);
void activateLinkUnderCursor(QString href = QString());
@@ -166,28 +132,22 @@ public:
bool isPreediting() const;
void commitPreedit();
- void append(const QString &text, Qt::TextFormat format = Qt::AutoText);
-
QTextDocument *doc;
bool cursorOn;
QTextCursor cursor;
bool cursorIsFocusIndicator;
QTextCharFormat lastCharFormat;
- QTextCursor dndFeedbackCursor;
-
Qt::TextInteractionFlags interactionFlags;
QBasicTimer cursorBlinkTimer;
QBasicTimer trippleClickTimer;
QPointF trippleClickPoint;
- bool dragEnabled;
-
bool mousePressed;
- bool mightStartDrag;
QPoint mousePressPos;
+
QPointer<QObject> contextObject;
bool lastSelectionState;
@@ -204,22 +164,14 @@ public:
bool hideCursor; // used to hide the cursor in the preedit area
QString tentativeCommit;
- QVector<QAbstractTextDocumentLayout::Selection> extraSelections;
-
QPalette palette;
bool hasFocus;
-#ifdef QT_KEYPAD_NAVIGATION
- bool hasEditFocus;
-#endif
bool isEnabled;
QString highlightedAnchor; // Anchor below cursor
QString anchorOnMousePress;
bool hadSelectionOnMousePress;
- bool ignoreUnusedNavigationEvents;
- bool openExternalLinks;
-
bool wordSelectionEnabled;
QString linkToCopy;
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index f0679c4861..4b3dc6648b 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -1632,18 +1632,7 @@ void QQuickTextEditPrivate::init()
control = new QQuickTextControl(document, q);
control->setView(q);
- control->setIgnoreUnusedNavigationEvents(true);
control->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::TextSelectableByKeyboard | Qt::TextEditable);
- control->setDragEnabled(false);
-
- // By default, QQuickTextControl will issue both a updateCursorRequest() and an updateRequest()
- // when the cursor needs to be repainted. We need the signals to be separate to be able to
- // distinguish the cursor updates so that we can avoid updating the whole subtree when the
- // cursor blinks.
- if (!QObject::disconnect(control, SIGNAL(updateCursorRequest(QRectF)),
- control, SIGNAL(updateRequest(QRectF)))) {
- qWarning("QQuickTextEditPrivate::init: Failed to disconnect updateCursorRequest and updateRequest");
- }
// QQuickTextControl follows the default text color
// defined by the platform, declarative text