Qt 4.8
qdeclarativetextinput.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "private/qdeclarativetextinput_p.h"
43 #include "private/qdeclarativetextinput_p_p.h"
44 
45 #include <private/qdeclarativeglobal_p.h>
46 #include <qdeclarativeinfo.h>
47 
48 #include <QValidator>
49 #include <QTextCursor>
50 #include <QApplication>
51 #include <QFontMetrics>
52 #include <QPainter>
53 #include <QTextBoundaryFinder>
54 #include <QInputContext>
55 #include <qstyle.h>
56 
57 #ifndef QT_NO_LINEEDIT
58 
60 
85 {
87  d->init();
88 }
89 
91 {
92 }
93 
104 {
105  Q_D(const QDeclarativeTextInput);
106  return d->control->text();
107 }
108 
110 {
112  if(s == text())
113  return;
114  d->control->setText(s);
115 }
116 
256 {
257  Q_D(const QDeclarativeTextInput);
258  return d->sourceFont;
259 }
260 
262 {
264  if (d->sourceFont == font)
265  return;
266 
267  d->sourceFont = font;
268  QFont oldFont = d->font;
269  d->font = font;
270  if (d->font.pointSizeF() != -1) {
271  // 0.5pt resolution
272  qreal size = qRound(d->font.pointSizeF()*2.0);
273  d->font.setPointSizeF(size/2.0);
274  }
275 
276  if (oldFont != d->font) {
277  d->control->setFont(d->font);
278  updateSize();
280  if(d->cursorItem){
281  d->cursorItem->setHeight(QFontMetrics(d->font).height());
282  }
283  }
284  emit fontChanged(d->sourceFont);
285 }
286 
296 {
297  Q_D(const QDeclarativeTextInput);
298  return d->color;
299 }
300 
302 {
304  if (c != d->color) {
305  d->color = c;
306  clearCache();
307  update();
308  emit colorChanged(c);
309  }
310 }
311 
312 
322 {
323  Q_D(const QDeclarativeTextInput);
324  return d->selectionColor;
325 }
326 
328 {
330  if (d->selectionColor == color)
331  return;
332 
333  d->selectionColor = color;
334  QPalette p = d->control->palette();
335  p.setColor(QPalette::Highlight, d->selectionColor);
336  d->control->setPalette(p);
337  if (d->control->hasSelectedText()) {
338  clearCache();
339  update();
340  }
342 }
343 
353 {
354  Q_D(const QDeclarativeTextInput);
355  return d->selectedTextColor;
356 }
357 
359 {
361  if (d->selectedTextColor == color)
362  return;
363 
364  d->selectedTextColor = color;
365  QPalette p = d->control->palette();
366  p.setColor(QPalette::HighlightedText, d->selectedTextColor);
367  d->control->setPalette(p);
368  if (d->control->hasSelectedText()) {
369  clearCache();
370  update();
371  }
373 }
374 
401 {
402  Q_D(const QDeclarativeTextInput);
403  return d->hAlign;
404 }
405 
407 {
409  bool forceAlign = d->hAlignImplicit && d->effectiveLayoutMirror;
410  d->hAlignImplicit = false;
411  if (d->setHAlign(align, forceAlign) && isComponentComplete()) {
413  }
414 }
415 
417 {
419  d->hAlignImplicit = true;
420  if (d->determineHorizontalAlignment() && isComponentComplete()) {
422  }
423 }
424 
426 {
427  Q_D(const QDeclarativeTextInput);
428  QDeclarativeTextInput::HAlignment effectiveAlignment = d->hAlign;
429  if (!d->hAlignImplicit && d->effectiveLayoutMirror) {
430  switch (d->hAlign) {
432  effectiveAlignment = QDeclarativeTextInput::AlignRight;
433  break;
435  effectiveAlignment = QDeclarativeTextInput::AlignLeft;
436  break;
437  default:
438  break;
439  }
440  }
441  return effectiveAlignment;
442 }
443 
445 {
447  if ((hAlign != alignment || forceAlign) && alignment <= QDeclarativeTextInput::AlignHCenter) { // justify not supported
448  hAlign = alignment;
449  emit q->horizontalAlignmentChanged(alignment);
450  return true;
451  }
452  return false;
453 }
454 
456 {
457  if (hAlignImplicit) {
458  // if no explicit alignment has been set, follow the natural layout direction of the text
459  QString text = control->text();
460  if (text.isEmpty())
461  text = control->preeditAreaText();
462  bool isRightToLeft = text.isEmpty()
464  : text.isRightToLeft();
466  }
467  return false;
468 }
469 
471 {
473  if (q->isComponentComplete()) {
475  q->updateCursorRectangle();
476  updateHorizontalScroll();
477  }
478  }
479 }
480 
495 {
496  Q_D(const QDeclarativeTextInput);
497  return d->control->isReadOnly();
498 }
499 
501 {
503  if (d->control->isReadOnly() == ro)
504  return;
505 
507  d->control->setReadOnly(ro);
508 
509  emit readOnlyChanged(ro);
510 }
511 
524 {
525  Q_D(const QDeclarativeTextInput);
526  return d->control->maxLength();
527 }
528 
530 {
532  if (d->control->maxLength() == ml)
533  return;
534 
535  d->control->setMaxLength(ml);
536 
538 }
539 
570 {
571  Q_D(const QDeclarativeTextInput);
572  return d->cursorVisible;
573 }
574 
576 {
578  if (d->cursorVisible == on)
579  return;
580  d->cursorVisible = on;
581  d->control->setCursorBlinkPeriod(on?QApplication::cursorFlashTime():0);
582  QRect r = d->control->cursorRect();
583  if (d->control->inputMask().isEmpty())
584  updateRect(r);
585  else
586  updateRect();
587  emit cursorVisibleChanged(d->cursorVisible);
588 }
589 
598 {
599  Q_D(const QDeclarativeTextInput);
600  return d->control->cursor();
601 }
603 {
605  if (cp < 0 || cp > d->control->text().length())
606  return;
607  d->control->moveCursor(cp);
608 }
609 
615 {
616  Q_D(const QDeclarativeTextInput);
617  QRect r = d->control->cursorRect();
618  // Scroll and make consistent with TextEdit
619  // QLineControl inexplicably adds 1 to the height and horizontal padding
620  // for unicode direction markers.
621  r.adjust(5 - d->hscroll, 0, -4 - d->hscroll, -1);
622  return r;
623 }
624 
639 {
640  Q_D(const QDeclarativeTextInput);
641  return d->lastSelectionStart;
642 }
643 
658 {
659  Q_D(const QDeclarativeTextInput);
660  return d->lastSelectionEnd;
661 }
662 
679 void QDeclarativeTextInput::select(int start, int end)
680 {
682  if (start < 0 || end < 0 || start > d->control->text().length() || end > d->control->text().length())
683  return;
684  d->control->setSelection(start, end-start);
685 }
686 
705 {
706  Q_D(const QDeclarativeTextInput);
707  return d->control->selectedText();
708 }
709 
720 {
721  Q_D(const QDeclarativeTextInput);
722  return d->focusOnPress;
723 }
724 
726 {
728  if (d->focusOnPress == b)
729  return;
730 
731  d->focusOnPress = b;
732 
733  emit activeFocusOnPressChanged(d->focusOnPress);
734 }
735 
746 {
747  Q_D(const QDeclarativeTextInput);
748  return d->autoScroll;
749 }
750 
752 {
754  if (d->autoScroll == b)
755  return;
756 
757  d->autoScroll = b;
758  //We need to repaint so that the scrolling is taking into account.
759  updateSize(true);
761  emit autoScrollChanged(d->autoScroll);
762 }
763 
897 #ifndef QT_NO_VALIDATOR
899 {
900  Q_D(const QDeclarativeTextInput);
901  //###const cast isn't good, but needed for property system?
902  return const_cast<QValidator*>(d->control->validator());
903 }
904 
906 {
908  if (d->control->validator() == v)
909  return;
910 
911  d->control->setValidator(v);
912  if(!d->control->hasAcceptableInput()){
913  d->oldValidity = false;
915  }
916 
918 }
919 #endif // QT_NO_VALIDATOR
920 
934 {
935  Q_D(const QDeclarativeTextInput);
936  return d->control->inputMask();
937 }
938 
940 {
942  if (d->control->inputMask() == im)
943  return;
944 
945  d->control->setInputMask(im);
946  emit inputMaskChanged(d->control->inputMask());
947 }
948 
961 {
962  Q_D(const QDeclarativeTextInput);
963  return d->control->hasAcceptableInput();
964 }
965 
979 {
981  Qt::InputMethodHints hints = inputMethodHints;
982  uint echo = control->echoMode();
984  hints |= Qt::ImhHiddenText;
986  hints &= ~Qt::ImhHiddenText;
987  if (echo != QDeclarativeTextInput::Normal)
989  q->setInputMethodHints(hints);
990 }
991 
1008 {
1009  Q_D(const QDeclarativeTextInput);
1010  return (QDeclarativeTextInput::EchoMode)d->control->echoMode();
1011 }
1012 
1014 {
1016  if (echoMode() == echo)
1017  return;
1018  d->control->setEchoMode((uint)echo);
1019  d->updateInputMethodHints();
1020  q_textChanged();
1022 }
1023 
1024 Qt::InputMethodHints QDeclarativeTextInput::imHints() const
1025 {
1026  Q_D(const QDeclarativeTextInput);
1027  return d->inputMethodHints;
1028 }
1029 
1030 void QDeclarativeTextInput::setIMHints(Qt::InputMethodHints hints)
1031 {
1033  if (d->inputMethodHints == hints)
1034  return;
1035  d->inputMethodHints = hints;
1036  d->updateInputMethodHints();
1037 }
1038 
1056 {
1057  Q_D(const QDeclarativeTextInput);
1058  return d->cursorComponent;
1059 }
1060 
1062 {
1064  if (d->cursorComponent == c)
1065  return;
1066 
1067  d->cursorComponent = c;
1068  if(!c){
1069  //note that the components are owned by something else
1070  delete d->cursorItem;
1071  }else{
1072  d->startCreatingCursor();
1073  }
1074 
1076 }
1077 
1079 {
1081  if(cursorComponent->isReady()){
1082  q->createCursor();
1083  }else if(cursorComponent->isLoading()){
1084  q->connect(cursorComponent, SIGNAL(statusChanged(int)),
1085  q, SLOT(createCursor()));
1086  }else {//isError
1087  qmlInfo(q, cursorComponent->errors()) << QDeclarativeTextInput::tr("Could not load cursor delegate");
1088  }
1089 }
1090 
1092 {
1094  if(d->cursorComponent->isError()){
1095  qmlInfo(this, d->cursorComponent->errors()) << tr("Could not load cursor delegate");
1096  return;
1097  }
1098 
1099  if(!d->cursorComponent->isReady())
1100  return;
1101 
1102  if(d->cursorItem)
1103  delete d->cursorItem;
1104  d->cursorItem = qobject_cast<QDeclarativeItem*>(d->cursorComponent->create());
1105  if(!d->cursorItem){
1106  qmlInfo(this, d->cursorComponent->errors()) << tr("Could not instantiate cursor delegate");
1107  return;
1108  }
1109 
1110  QDeclarative_setParent_noEvent(d->cursorItem, this);
1111  d->cursorItem->setParentItem(this);
1112  d->cursorItem->setX(d->control->cursorToX());
1113  d->cursorItem->setHeight(d->control->height()-1); // -1 to counter QLineControl's +1 which is not consistent with Text.
1114 }
1115 
1129 {
1130  Q_D(const QDeclarativeTextInput);
1131  if (pos > d->control->cursorPosition())
1132  pos += d->control->preeditAreaText().length();
1133  return QRectF(d->control->cursorToX(pos)-d->hscroll,
1134  0.0,
1135  d->control->cursorWidth(),
1136  cursorRectangle().height());
1137 }
1138 
1140 {
1142 }
1143 
1167 {
1168  Q_D(const QDeclarativeTextInput);
1169  int pos = d->control->xToPos(x + d->hscroll, QTextLine::CursorPosition(position));
1170  const int cursor = d->control->cursor();
1171  if (pos > cursor) {
1172  const int preeditLength = d->control->preeditAreaText().length();
1173  pos = pos > cursor + preeditLength
1174  ? pos - preeditLength
1175  : cursor;
1176  }
1177  return pos;
1178 }
1179 
1181 {
1183  focused = hasFocus;
1184  q->setCursorVisible(hasFocus && scene && scene->hasFocus());
1185  if(!hasFocus && control->passwordEchoEditing())
1186  control->updatePasswordEchoEditing(false);//QLineControl sets it on key events, but doesn't deal with focus events
1187  if (!hasFocus)
1188  control->deselect();
1190 }
1191 
1193 {
1195  keyPressPreHandler(ev);
1196  if (ev->isAccepted())
1197  return;
1198 
1199  // Don't allow MacOSX up/down support, and we don't allow a completer.
1200  bool ignore = (ev->key() == Qt::Key_Up || ev->key() == Qt::Key_Down) && ev->modifiers() == Qt::NoModifier;
1201  if (!ignore && (d->lastSelectionStart == d->lastSelectionEnd) && (ev->key() == Qt::Key_Right || ev->key() == Qt::Key_Left)) {
1202  // Ignore when moving off the end unless there is a selection,
1203  // because then moving will do something (deselect).
1204  int cursorPosition = d->control->cursor();
1205  if (cursorPosition == 0)
1206  ignore = ev->key() == (d->control->layoutDirection() == Qt::LeftToRight ? Qt::Key_Left : Qt::Key_Right);
1207  if (!ignore && cursorPosition == d->control->text().length())
1208  ignore = ev->key() == (d->control->layoutDirection() == Qt::LeftToRight ? Qt::Key_Right : Qt::Key_Left);
1209  }
1210  if (ignore) {
1211  ev->ignore();
1212  } else {
1213  d->control->processKeyEvent(ev);
1214  }
1215  if (!ev->isAccepted())
1217 }
1218 
1220 {
1222  ev->ignore();
1223  const bool wasComposing = d->control->preeditAreaText().length() > 0;
1225  if (!ev->isAccepted()) {
1226  if (d->control->isReadOnly()) {
1227  ev->ignore();
1228  } else {
1229  d->control->processInputMethodEvent(ev);
1230  }
1231  }
1232  if (!ev->isAccepted())
1234 
1235  if (wasComposing != (d->control->preeditAreaText().length() > 0))
1237 }
1238 
1244 {
1246  if (d->sendMouseEventToInputContext(event, QEvent::MouseButtonDblClick))
1247  return;
1248  if (d->selectByMouse) {
1249  int cursor = d->xToPos(event->pos().x());
1250  d->control->selectWordAtPos(cursor);
1251  event->setAccepted(true);
1252  } else {
1254  }
1255 }
1256 
1258 {
1260  if (d->sendMouseEventToInputContext(event, QEvent::MouseButtonPress))
1261  return;
1262  if(d->focusOnPress){
1263  bool hadActiveFocus = hasActiveFocus();
1264  forceActiveFocus();
1265  if (d->showInputPanelOnFocus) {
1266  if (hasActiveFocus() && hadActiveFocus && !isReadOnly()) {
1267  // re-open input panel on press if already focused
1269  }
1270  } else { // show input panel on click
1271  if (hasActiveFocus() && !hadActiveFocus) {
1272  d->clickCausedFocus = true;
1273  }
1274  }
1275  }
1276  if (d->selectByMouse) {
1277  setKeepMouseGrab(false);
1278  d->selectPressed = true;
1279  d->pressPos = event->pos();
1280  }
1281  bool mark = (event->modifiers() & Qt::ShiftModifier) && d->selectByMouse;
1282  int cursor = d->xToPos(event->pos().x());
1283  d->control->moveCursor(cursor, mark);
1284  event->setAccepted(true);
1285 }
1286 
1288 {
1290  if (d->sendMouseEventToInputContext(event, QEvent::MouseMove))
1291  return;
1292  if (d->selectPressed) {
1293  if (qAbs(int(event->pos().x() - d->pressPos.x())) > QApplication::startDragDistance())
1294  setKeepMouseGrab(true);
1295  moveCursorSelection(d->xToPos(event->pos().x()), d->mouseSelectionMode);
1296  event->setAccepted(true);
1297  } else {
1299  }
1300 }
1301 
1307 {
1309  if (d->sendMouseEventToInputContext(event, QEvent::MouseButtonRelease))
1310  return;
1311  if (d->selectPressed) {
1312  d->selectPressed = false;
1313  setKeepMouseGrab(false);
1314  }
1315  if (!d->showInputPanelOnFocus) { // input panel on click
1316  if (d->focusOnPress && !isReadOnly() && boundingRect().contains(event->pos())) {
1317  if (QGraphicsView * view = qobject_cast<QGraphicsView*>(qApp->focusWidget())) {
1318  if (view->scene() && view->scene() == scene()) {
1319  qt_widget_private(view)->handleSoftwareInputPanel(event->button(), d->clickCausedFocus);
1320  }
1321  }
1322  }
1323  }
1324  d->clickCausedFocus = false;
1325  d->control->processEvent(event);
1326  if (!event->isAccepted())
1328 }
1329 
1332 {
1333 #if !defined QT_NO_IM
1335 
1336  QWidget *widget = event->widget();
1337  // event->widget() is null, if this is delayed event from QDeclarativeFlickable.
1338  if (!widget && qApp) {
1339  QGraphicsView *view = qobject_cast<QGraphicsView*>(qApp->focusWidget());
1340  if (view && view->scene() && view->scene() == q->scene())
1341  widget = view->viewport();
1342  }
1343 
1344  if (widget && control->composeMode()) {
1345  int tmp_cursor = xToPos(event->pos().x());
1346  int mousePos = tmp_cursor - control->cursor();
1347  if (mousePos < 0 || mousePos > control->preeditAreaText().length()) {
1348  mousePos = -1;
1349  // don't send move events outside the preedit area
1350  if (eventType == QEvent::MouseMove)
1351  return true;
1352  }
1353 
1354  QInputContext *qic = widget->inputContext();
1355  if (qic) {
1357  eventType,
1358  widget->mapFromGlobal(event->screenPos()),
1359  event->screenPos(),
1360  event->button(),
1361  event->buttons(),
1362  event->modifiers());
1363  // may be causing reset() in some input methods
1364  qic->mouseHandler(mousePos, &mouseEvent);
1365  event->setAccepted(mouseEvent.isAccepted());
1366  }
1367  if (!control->preeditAreaText().isEmpty())
1368  return true;
1369  }
1370 #else
1371  Q_UNUSED(event);
1372  Q_UNUSED(eventType)
1373 #endif
1374 
1375  return false;
1376 }
1377 
1379 {
1381  bool rv = QDeclarativeItem::sceneEvent(event);
1382  if (event->type() == QEvent::UngrabMouse) {
1383  d->selectPressed = false;
1384  setKeepMouseGrab(false);
1385  }
1386  return rv;
1387 }
1388 
1390 {
1392  //Anything we don't deal with ourselves, pass to the control
1393  bool handled = false;
1394  switch(ev->type()){
1395  case QEvent::KeyPress:
1396  case QEvent::KeyRelease://###Should the control be doing anything with release?
1397  case QEvent::InputMethod:
1402  break;
1403  default:
1404  handled = d->control->processEvent(ev);
1405  }
1406  if(!handled)
1407  handled = QDeclarativePaintedItem::event(ev);
1408  return handled;
1409 }
1410 
1412  const QRectF &oldGeometry)
1413 {
1414  if (newGeometry.width() != oldGeometry.width()) {
1415  updateSize();
1417  }
1418  QDeclarativePaintedItem::geometryChanged(newGeometry, oldGeometry);
1419 }
1420 
1422 {
1423  return qRound(control->naturalTextWidth());
1424 }
1425 
1427 {
1429  const int preeditLength = control->preeditAreaText().length();
1430  int cix = qRound(control->cursorToX(control->cursor() + preeditLength));
1431  QRect br(q->boundingRect().toRect());
1432  int widthUsed = calculateTextWidth();
1433 
1434  QDeclarativeTextInput::HAlignment effectiveHAlign = q->effectiveHAlign();
1435  if (autoScroll) {
1436  if (widthUsed <= br.width()) {
1437  // text fits in br; use hscroll for alignment
1438  switch (effectiveHAlign & ~(Qt::AlignAbsolute|Qt::AlignVertical_Mask)) {
1439  case Qt::AlignRight:
1440  hscroll = widthUsed - br.width() - 1;
1441  break;
1442  case Qt::AlignHCenter:
1443  hscroll = (widthUsed - br.width()) / 2;
1444  break;
1445  default:
1446  // Left
1447  hscroll = 0;
1448  break;
1449  }
1450  } else if (cix - hscroll >= br.width()) {
1451  // text doesn't fit, cursor is to the right of br (scroll right)
1452  hscroll = cix - br.width() + 1;
1453  } else if (cix - hscroll < 0 && hscroll < widthUsed) {
1454  // text doesn't fit, cursor is to the left of br (scroll left)
1455  hscroll = cix;
1456  } else if (widthUsed - hscroll < br.width()) {
1457  // text doesn't fit, text document is to the left of br; align
1458  // right
1459  hscroll = widthUsed - br.width() + 1;
1460  }
1461  if (preeditLength > 0) {
1462  // check to ensure long pre-edit text doesn't push the cursor
1463  // off to the left
1464  cix = qRound(control->cursorToX(
1465  control->cursor() + qMax(0, control->preeditCursor() - 1)));
1466  if (cix < hscroll)
1467  hscroll = cix;
1468  }
1469  } else {
1470  switch (effectiveHAlign) {
1472  hscroll = q->width() - widthUsed;
1473  break;
1475  hscroll = (q->width() - widthUsed) / 2;
1476  break;
1477  default:
1478  // Left
1479  hscroll = 0;
1480  break;
1481  }
1482  }
1483 }
1484 
1486 {
1489  p->save();
1490  p->setPen(QPen(d->color));
1492  if(!isReadOnly() && d->cursorVisible && !d->cursorItem)
1493  flags |= QLineControl::DrawCursor;
1494  if (d->control->hasSelectedText())
1496  QPoint offset = QPoint(0,0);
1497  QFontMetrics fm = QFontMetrics(d->font);
1498  QRect br(boundingRect().toRect());
1499  if (d->autoScroll) {
1500  // the y offset is there to keep the baseline constant in case we have script changes in the text.
1501  offset = br.topLeft() - QPoint(d->hscroll, d->control->ascent() - fm.ascent());
1502  } else {
1503  offset = QPoint(d->hscroll, 0);
1504  }
1505  d->control->draw(p, offset, r, flags);
1506  p->restore();
1507 }
1508 
1514 {
1515  Q_D(const QDeclarativeTextInput);
1516  switch(property) {
1517  case Qt::ImMicroFocus:
1518  return cursorRectangle();
1519  case Qt::ImFont:
1520  return font();
1521  case Qt::ImCursorPosition:
1522  return QVariant(d->control->cursor());
1523  case Qt::ImSurroundingText:
1524  if (d->control->echoMode() == PasswordEchoOnEdit && !d->control->passwordEchoEditing())
1525  return QVariant(displayText());
1526  else
1527  return QVariant(text());
1529  return QVariant(selectedText());
1531  return QVariant(maxLength());
1532  case Qt::ImAnchorPosition:
1533  if (d->control->selectionStart() == d->control->selectionEnd())
1534  return QVariant(d->control->cursor());
1535  else if (d->control->selectionStart() == d->control->cursor())
1536  return QVariant(d->control->selectionEnd());
1537  else
1538  return QVariant(d->control->selectionStart());
1539  default:
1540  return QVariant();
1541  }
1542 }
1543 
1554 {
1556  d->control->deselect();
1557 }
1558 
1568 {
1570  d->control->setSelection(0, d->control->text().length());
1571 }
1572 
1583 {
1585  if (start > end) {
1586  qmlInfo(this) << "isRightToLeft(start, end) called with the end property being smaller than the start.";
1587  return false;
1588  } else {
1589  return d->control->text().mid(start, end - start).isRightToLeft();
1590  }
1591 }
1592 
1593 #ifndef QT_NO_CLIPBOARD
1594 
1603 {
1605  d->control->copy();
1606  d->control->del();
1607 }
1608 
1618 {
1620  d->control->copy();
1621 }
1622 
1632 {
1634  if(!d->control->isReadOnly())
1635  d->control->paste();
1636 }
1637 #endif // QT_NO_CLIPBOARD
1638 
1648 {
1650  d->control->selectWordAtPos(d->control->cursor());
1651 }
1652 
1684 {
1685  Q_D(const QDeclarativeTextInput);
1686  return QString(d->control->passwordCharacter());
1687 }
1688 
1690 {
1692  if(str.length() < 1)
1693  return;
1694  d->control->setPasswordCharacter(str.constData()[0]);
1695  EchoMode echoMode_ = echoMode();
1696  if (echoMode_ == Password || echoMode_ == PasswordEchoOnEdit) {
1697  updateSize();
1698  }
1700 }
1701 
1716 {
1717  Q_D(const QDeclarativeTextInput);
1718  return d->control->displayText();
1719 }
1720 
1735 {
1736  Q_D(const QDeclarativeTextInput);
1737  return d->selectByMouse;
1738 }
1739 
1741 {
1743  if (d->selectByMouse != on) {
1744  d->selectByMouse = on;
1746  }
1747 }
1748 
1767 {
1768  Q_D(const QDeclarativeTextInput);
1769  return d->mouseSelectionMode;
1770 }
1771 
1773 {
1775  if (d->mouseSelectionMode != mode) {
1776  d->mouseSelectionMode = mode;
1778  }
1779 }
1780 
1792 {
1793  Q_D(const QDeclarativeTextInput);
1794  return d->canPaste;
1795 }
1796 
1798 {
1800  d->control->moveCursor(position, true);
1801 }
1802 
1845 {
1847 
1848  if (mode == SelectCharacters) {
1849  d->control->moveCursor(pos, true);
1850  } else if (pos != d->control->cursor()){
1851  const int cursor = d->control->cursor();
1852  int anchor;
1853  if (!d->control->hasSelectedText())
1854  anchor = d->control->cursor();
1855  else if (d->control->selectionStart() == d->control->cursor())
1856  anchor = d->control->selectionEnd();
1857  else
1858  anchor = d->control->selectionStart();
1859 
1860  if (anchor < pos || (anchor == pos && cursor < pos)) {
1861  const QString text = d->control->text();
1863  finder.setPosition(anchor);
1864 
1865  const QTextBoundaryFinder::BoundaryReasons reasons = finder.boundaryReasons();
1866  if (anchor < text.length() && (!(reasons & QTextBoundaryFinder::StartWord)
1867  || ((reasons & QTextBoundaryFinder::EndWord) && anchor > cursor))) {
1868  finder.toPreviousBoundary();
1869  }
1870  anchor = finder.position() != -1 ? finder.position() : 0;
1871 
1872  finder.setPosition(pos);
1873  if (pos > 0 && !finder.boundaryReasons())
1874  finder.toNextBoundary();
1875  const int cursor = finder.position() != -1 ? finder.position() : text.length();
1876 
1877  d->control->setSelection(anchor, cursor - anchor);
1878  } else if (anchor > pos || (anchor == pos && cursor > pos)) {
1879  const QString text = d->control->text();
1881  finder.setPosition(anchor);
1882 
1883  const QTextBoundaryFinder::BoundaryReasons reasons = finder.boundaryReasons();
1884  if (anchor > 0 && (!(reasons & QTextBoundaryFinder::EndWord)
1885  || ((reasons & QTextBoundaryFinder::StartWord) && anchor < cursor))) {
1886  finder.toNextBoundary();
1887  }
1888  anchor = finder.position() != -1 ? finder.position() : text.length();
1889 
1890  finder.setPosition(pos);
1891  if (pos < text.length() && !finder.boundaryReasons())
1892  finder.toPreviousBoundary();
1893  const int cursor = finder.position() != -1 ? finder.position() : 0;
1894 
1895  d->control->setSelection(anchor, cursor - anchor);
1896  }
1897  }
1898 }
1899 
1943 {
1945  if (qApp) {
1946  if (QGraphicsView * view = qobject_cast<QGraphicsView*>(qApp->focusWidget())) {
1947  if (view->scene() && view->scene() == scene()) {
1948  QApplication::sendEvent(view, &event);
1949  }
1950  }
1951  }
1952 }
1953 
1997 {
1999  if (qApp) {
2001  if (QGraphicsView * view = qobject_cast<QGraphicsView*>(qApp->focusWidget())) {
2002  if (view->scene() && view->scene() == scene()) {
2003  QApplication::sendEvent(view, &event);
2004  }
2005  }
2006  }
2007 }
2008 
2010 {
2011  Q_D(const QDeclarativeTextInput);
2012  if (d->showInputPanelOnFocus) {
2013  if (d->focusOnPress && !isReadOnly()) {
2015  }
2016  }
2018 }
2019 
2037 {
2038  Q_D(const QDeclarativeTextInput);
2039  return d->control->preeditAreaText().length() > 0;
2040 }
2041 
2043 {
2045  control->setParent(q);
2046  control->setCursorWidth(1);
2047  control->setPasswordCharacter(QLatin1Char('*'));
2048  q->setSmooth(smooth);
2049  q->setAcceptedMouseButtons(Qt::LeftButton);
2050  q->setFlag(QGraphicsItem::ItemHasNoContents, false);
2052  q->connect(control, SIGNAL(cursorPositionChanged(int,int)),
2053  q, SLOT(cursorPosChanged()));
2054  q->connect(control, SIGNAL(selectionChanged()),
2055  q, SLOT(selectionChanged()));
2056  q->connect(control, SIGNAL(textChanged(QString)),
2057  q, SLOT(q_textChanged()));
2058  q->connect(control, SIGNAL(accepted()),
2059  q, SIGNAL(accepted()));
2060  q->connect(control, SIGNAL(updateNeeded(QRect)),
2061  q, SLOT(updateRect(QRect)));
2062 #ifndef QT_NO_CLIPBOARD
2063  q->connect(q, SIGNAL(readOnlyChanged(bool)),
2064  q, SLOT(q_canPasteChanged()));
2065  q->connect(QApplication::clipboard(), SIGNAL(dataChanged()),
2066  q, SLOT(q_canPasteChanged()));
2067  canPaste = !control->isReadOnly() && QApplication::clipboard()->text().length() != 0;
2068 #endif // QT_NO_CLIPBOARD
2069  q->connect(control, SIGNAL(updateMicroFocus()),
2070  q, SLOT(updateCursorRectangle()));
2071  q->connect(control, SIGNAL(displayTextChanged(QString)),
2072  q, SLOT(updateRect()));
2073  q->updateSize();
2074  oldValidity = control->hasAcceptableInput();
2075  lastSelectionStart = 0;
2076  lastSelectionEnd = 0;
2077  QPalette p = control->palette();
2080  determineHorizontalAlignment();
2081 }
2082 
2084 {
2088  d->control->resetCursorBlinkTimer();
2089 
2090  if(!d->control->hasSelectedText()){
2091  if(d->lastSelectionStart != d->control->cursor()){
2092  d->lastSelectionStart = d->control->cursor();
2094  }
2095  if(d->lastSelectionEnd != d->control->cursor()){
2096  d->lastSelectionEnd = d->control->cursor();
2098  }
2099  }
2100 }
2101 
2103 {
2105  d->determineHorizontalAlignment();
2106  d->updateHorizontalScroll();
2107  updateRect();//TODO: Only update rect between pos's
2108  updateMicroFocus();
2110  if (d->cursorItem)
2111  d->cursorItem->setX(d->control->cursorToX() - d->hscroll);
2112 }
2113 
2115 {
2117  updateRect();//TODO: Only update rect in selection
2119 
2120  if(d->lastSelectionStart != d->control->selectionStart()){
2121  d->lastSelectionStart = d->control->selectionStart();
2122  if(d->lastSelectionStart == -1)
2123  d->lastSelectionStart = d->control->cursor();
2125  }
2126  if(d->lastSelectionEnd != d->control->selectionEnd()){
2127  d->lastSelectionEnd = d->control->selectionEnd();
2128  if(d->lastSelectionEnd == -1)
2129  d->lastSelectionEnd = d->control->cursor();
2131  }
2132 }
2133 
2135 {
2137  emit textChanged();
2139  updateSize();
2140  d->determineHorizontalAlignment();
2141  d->updateHorizontalScroll();
2142  updateMicroFocus();
2143  if(hasAcceptableInput() != d->oldValidity){
2144  d->oldValidity = hasAcceptableInput();
2146  }
2147 }
2148 
2150 {
2152  if(r == QRect())
2153  clearCache();
2154  else
2155  dirtyCache(QRect(r.x() - d->hscroll, r.y(), r.width(), r.height()));
2156  update();
2157 }
2158 
2160 {
2161  Q_D(const QDeclarativeTextInput);
2163 
2164  int cursorWidth = d->cursorItem ? d->cursorItem->width() : d->control->cursorWidth();
2165 
2166  // Could include font max left/right bearings to either side of rectangle.
2167 
2168  r.setRight(r.right() + cursorWidth);
2169  return r;
2170 }
2171 
2173 {
2175  int w = width();
2176  int h = height();
2177  setImplicitHeight(d->control->height()-1); // -1 to counter QLineControl's +1 which is not consistent with Text.
2178  setImplicitWidth(d->calculateTextWidth());
2179  setContentsSize(QSize(width(), height()));//Repaints if changed
2180  if(w==width() && h==height() && needsRedraw){
2181  clearCache();
2182  update();
2183  }
2184 }
2185 
2187 {
2189  bool old = d->canPaste;
2190 #ifndef QT_NO_CLIPBOARD
2191  d->canPaste = !d->control->isReadOnly() && QApplication::clipboard()->text().length() != 0;
2192 #endif
2193  if(d->canPaste != old)
2195 }
2196 
2198 
2199 #endif // QT_NO_LINEEDIT
2200 
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
int selectionStart() const
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Q_INVOKABLE void closeSoftwareInputPanel()
QDeclarativeComponent * cursorDelegate() const
qreal right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:527
The QKeyEvent class describes a key event.
Definition: qevent.h:224
QPoint screenPos() const
Returns the mouse cursor position in screen coordinates.
double qreal
Definition: qglobal.h:1193
unsigned char c[8]
Definition: qnumeric_p.h:62
bool sceneEvent(QEvent *event)
int cursorPosition() const
The QFontMetrics class provides font metrics information.
Definition: qfontmetrics.h:65
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPointer< QWidget > widget
bool autoScroll() const
QDeclarativeParserStatus ** d
QColor color() const
bool selectByMouse() const
bool isComponentComplete() const
Returns true if construction of the QML component is complete; otherwise returns false.
void maximumLengthChanged(int maximumLength)
virtual bool event(QEvent *)
void setContentsSize(const QSize &)
Sets the size of the contents to the given size.
int length() const
Returns the number of characters in this string.
Definition: qstring.h:696
#define SLOT(a)
Definition: qobjectdefs.h:226
void drawContents(QPainter *p, const QRect &r)
This function is called when the cache needs to be refreshed.
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
void setColor(const QColor &c)
int toPreviousBoundary()
Moves the QTextBoundaryFinder to the previous boundary position and returns that position.
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
void restore()
Restores the current painter state (pops a saved state off the stack).
Definition: qpainter.cpp:1620
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
void setText(const QString &)
Qt::MouseButton button() const
Returns the mouse button (if any) that caused the event.
static bool ignore(const char *test, const char *const *table)
Definition: qaxserver.cpp:660
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
virtual void keyPressEvent(QKeyEvent *event)
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QPointF pos() const
Returns the position of the item in parent coordinates.
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse doubleclick events for thi...
void mousePressEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse press events for this item...
static int cursorFlashTime()
void updateMicroFocus()
Updates the item&#39;s micro focus.
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
The QString class provides a Unicode character string.
Definition: qstring.h:83
T * qobject_cast(QObject *object)
Definition: qobject.h:375
QString passwordCharacter() const
void update(const QRectF &rect=QRectF())
Schedules a redraw of the area covered by rect in this item.
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
#define Q_D(Class)
Definition: qglobal.h:2482
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition: qpalette.h:107
The QPen class defines how a QPainter should draw lines and outlines of shapes.
Definition: qpen.h:64
int position() const
Returns the current position of the QTextBoundaryFinder.
QValidator * validator() const
void setRight(qreal pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:672
Q_INVOKABLE int positionAt(int x) const
void save()
Saves the current painter state (pushes the state onto a stack).
Definition: qpainter.cpp:1590
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
#define Q_Q(Class)
Definition: qglobal.h:2483
void selectedTextColorChanged(const QColor &color)
virtual void focusInEvent(QFocusEvent *event)
This event handler, for event event, can be reimplemented to receive focus in events for this item...
void keyPressEvent(QKeyEvent *ev)
int ascent() const
Returns the ascent of the font.
QCursor cursor() const
Returns the current cursor shape for the item.
QWidget * viewport() const
Returns the viewport widget.
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition: qevent.cpp:999
int key() const
Returns the code of the key that was pressed or released.
Definition: qevent.h:231
#define SIGNAL(a)
Definition: qobjectdefs.h:227
QRect cursorRectangle() const
void setRenderHint(RenderHint hint, bool on=true)
Sets the given render hint on the painter if on is true; otherwise clears the render hint...
Definition: qpainter.cpp:7620
virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
This function is called to handle this item&#39;s changes in geometry from oldGeometry to newGeometry...
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
The QValidator class provides validation of input text.
Definition: qvalidator.h:60
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
BoundaryReasons boundaryReasons() const
Returns the reasons for the boundary finder to have chosen the current position as a boundary...
void setValidator(QValidator *v)
bool isAccepted() const
Definition: qcoreevent.h:307
The QDeclarativeComponent class encapsulates a QML component definition.
void inputMethodComposingChanged()
void fontChanged(const QFont &font)
The QDeclarativeItem class provides the most basic of all visual items in QML.
static QClipboard * clipboard()
Returns a pointer to the application global clipboard.
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse move events for this item...
void mouseMoveEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse move events for this item...
void setPasswordCharacter(const QString &str)
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
#define qApp
void readOnlyChanged(bool isReadOnly)
void echoModeChanged(EchoMode echoMode)
void inputMaskChanged(const QString &inputMask)
void selectionColorChanged(const QColor &color)
bool isRightToLeft() const
Returns true if the string is read right to left.
Definition: qstring.cpp:7528
void selectByMouseChanged(bool selectByMouse)
#define emit
Definition: qobjectdefs.h:76
void adjust(int x1, int y1, int x2, int y2)
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition: qrect.h:434
bool hasActiveFocus() const
void updateSize(bool needsRedraw=true)
void inputMethodPreHandler(QInputMethodEvent *)
void setPosition(int position)
Sets the current position of the QTextBoundaryFinder to position.
unsigned int uint
Definition: qglobal.h:996
void handleSoftwareInputPanel(Qt::MouseButton button, bool clickCausedFocus)
Definition: qwidget_p.h:669
void focusInEvent(QFocusEvent *event)
This event handler, for event event, can be reimplemented to receive focus in events for this item...
qreal width() const
Returns the width of the rectangle.
Definition: qrect.h:707
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
void select(int start, int end)
QCursor cursor
the cursor shape for this widget
Definition: qwidget.h:183
void setHAlign(HAlignment align)
Qt::InputMethodHints inputMethodHints() const
Returns the current input method hints of this item.
void dirtyCache(const QRect &)
Marks areas of the cache that intersect with the given rect as dirty and in need of being refreshed...
static int startDragDistance()
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.
GraphicsItemFlags flags() const
Returns this item&#39;s flags.
void colorChanged(const QColor &color)
void setImplicitWidth(qreal)
Sets the implied width of the item to w.
void setIMHints(Qt::InputMethodHints hints)
void cursorVisibleChanged(bool isCursorVisible)
Qt::InputMethodHints imHints() const
HAlignment effectiveHAlign() const
SelectionMode mouseSelectionMode() const
void setSelectionColor(const QColor &c)
QInputContext * inputContext()
This function returns the QInputContext for this widget.
Definition: qwidget.cpp:474
void mouseSelectionModeChanged(SelectionMode mode)
QDeclarativeTextInput(QDeclarativeItem *parent=0)
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
This is an overloaded member function, provided for convenience. It differs from the above function o...
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
virtual void focusChanged(bool)
InputMethodQuery
Definition: qnamespace.h:1541
The QInputMethodEvent class provides parameters for input method events.
Definition: qevent.h:431
QString inputMask() const
void updateRect(const QRect &r=QRect())
virtual void inputMethodEvent(QInputMethodEvent *)
bool smooth() const
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
void setInputMask(const QString &im)
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
bool hasFocus() const
Returns true if the scene has focus; otherwise returns false.
void QDeclarative_setParent_noEvent(QObject *object, QObject *parent)
Makes the object a child of parent.
QString displayText() const
int x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:252
void setCursorDelegate(QDeclarativeComponent *)
qreal x() const
This convenience function is equivalent to calling pos().
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
int toNextBoundary()
Moves the QTextBoundaryFinder to the next boundary position and returns that position.
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
bool canPaste() const
void setPen(const QColor &color)
Sets the painter&#39;s pen to have style Qt::SolidLine, width 0 and the specified color.
Definition: qpainter.cpp:4047
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
Definition: qnamespace.h:54
void updateInputMethodHints()
This handler is called when the Return or Enter key is pressed.
QVariant inputMethodQuery(Qt::InputMethodQuery property) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual bool contains(const QPointF &point) const
Returns true if this item contains point, which is in local coordinates; otherwise, false is returned.
static void mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
Definition: qtestmouse.h:71
virtual bool sceneEvent(QEvent *)
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
The QGraphicsView class provides a widget for displaying the contents of a QGraphicsScene.
Definition: qgraphicsview.h:64
void clearCache()
Marks the entirety of the contents cache as dirty.
QPointF pos() const
Returns the mouse cursor position in item coordinates.
QString text() const
int selectionEnd() const
void ignore()
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Definition: qcoreevent.h:310
void setFont(const QFont &font)
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
QGraphicsScene * scene() const
Returns the current scene for the item, or 0 if the item is not stored in a scene.
Q_INVOKABLE void moveCursorSelection(int pos)
bool setHAlign(QDeclarativeTextInput::HAlignment, bool forceAlign=false)
Q_INVOKABLE void openSoftwareInputPanel()
void setEchoMode(EchoMode echo)
bool sendMouseEventToInputContext(QGraphicsSceneMouseEvent *event, QEvent::Type eventType)
Q_GUI_EXPORT QWidgetPrivate * qt_widget_private(QWidget *widget)
Definition: qwidget.cpp:12920
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83
QString selectedText() const
QDeclarativeInfo qmlInfo(const QObject *me)
static Qt::LayoutDirection keyboardInputDirection()
Returns the current keyboard input direction.
int height() const
Returns the height of the font.
void setImplicitHeight(qreal)
Sets the implied height of the item to h.
void inputMethodEvent(QInputMethodEvent *)
void autoScrollChanged(bool autoScroll)
void setMouseSelectionMode(SelectionMode mode)
static const KeyPair *const end
void setFlag(GraphicsItemFlag flag, bool enabled=true)
If enabled is true, the item flag flag is enabled; otherwise, it is disabled.
The QEvent class is the base class of all event classes.
Definition: qcoreevent.h:56
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
QGraphicsScene * scene() const
Returns a pointer to the scene that is currently visualized in the view.
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
QFont font() const
virtual void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
This function is called to handle this item&#39;s changes in geometry from oldGeometry to newGeometry...
The QTextBoundaryFinder class provides a way of finding Unicode text boundaries in a string...
Q_INVOKABLE void forceActiveFocus()
Forces active focus on the item.
QString text(Mode mode=Clipboard) const
Returns the clipboard text as plain text, or an empty string if the clipboard does not contain any te...
Definition: qclipboard.cpp:357
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
bool isRightToLeft(int start, int end)
void setSelectedTextColor(const QColor &c)
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
This event handler, for event event, can be reimplemented to receive mouse release events for this it...
const QChar * constData() const
Returns a pointer to the data stored in the QString.
Definition: qstring.h:712
The QFocusEvent class contains event parameters for widget focus events.
Definition: qevent.h:275
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203
void setKeepMouseGrab(bool)
The flag indicating whether the mouse should remain with this item is set to keep.
void activeFocusOnPressChanged(bool activeFocusOnPress)
void keyPressPreHandler(QKeyEvent *)
QPoint topLeft() const
Returns the position of the rectangle&#39;s top-left corner.
Definition: qrect.h:288
QColor selectedTextColor() const
Q_INVOKABLE QRectF positionToRectangle(int pos) const
EchoMode echoMode() const
The QPalette class contains color groups for each widget state.
Definition: qpalette.h:61
QColor selectionColor() const