src/gui/widgets/qtextedit.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   114 {
   114 {
   115     ignoreAutomaticScrollbarAdjustment = false;
   115     ignoreAutomaticScrollbarAdjustment = false;
   116     preferRichText = false;
   116     preferRichText = false;
   117     showCursorOnInitialShow = true;
   117     showCursorOnInitialShow = true;
   118     inDrag = false;
   118     inDrag = false;
   119 #ifdef Q_WS_WIN
       
   120     setSingleFingerPanEnabled(true);
       
   121 #endif
       
   122 }
   119 }
   123 
   120 
   124 void QTextEditPrivate::createAutoBulletList()
   121 void QTextEditPrivate::createAutoBulletList()
   125 {
   122 {
   126     QTextCursor cursor = control->textCursor();
   123     QTextCursor cursor = control->textCursor();
   158     QObject::connect(control, SIGNAL(undoAvailable(bool)), q, SIGNAL(undoAvailable(bool)));
   155     QObject::connect(control, SIGNAL(undoAvailable(bool)), q, SIGNAL(undoAvailable(bool)));
   159     QObject::connect(control, SIGNAL(redoAvailable(bool)), q, SIGNAL(redoAvailable(bool)));
   156     QObject::connect(control, SIGNAL(redoAvailable(bool)), q, SIGNAL(redoAvailable(bool)));
   160     QObject::connect(control, SIGNAL(copyAvailable(bool)), q, SIGNAL(copyAvailable(bool)));
   157     QObject::connect(control, SIGNAL(copyAvailable(bool)), q, SIGNAL(copyAvailable(bool)));
   161     QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged()));
   158     QObject::connect(control, SIGNAL(selectionChanged()), q, SIGNAL(selectionChanged()));
   162     QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));
   159     QObject::connect(control, SIGNAL(cursorPositionChanged()), q, SIGNAL(cursorPositionChanged()));
       
   160 
       
   161     QObject::connect(control, SIGNAL(textChanged()), q, SLOT(updateMicroFocus()));
   163 
   162 
   164     QTextDocument *doc = control->document();
   163     QTextDocument *doc = control->document();
   165     // set a null page size initially to avoid any relayouting until the textedit
   164     // set a null page size initially to avoid any relayouting until the textedit
   166     // is shown. relayoutDocument() will take care of setting the page size to the
   165     // is shown. relayoutDocument() will take care of setting the page size to the
   167     // viewport dimensions later.
   166     // viewport dimensions later.
   183     q->setAttribute(Qt::WA_KeyCompression);
   182     q->setAttribute(Qt::WA_KeyCompression);
   184     q->setAttribute(Qt::WA_InputMethodEnabled);
   183     q->setAttribute(Qt::WA_InputMethodEnabled);
   185 
   184 
   186 #ifndef QT_NO_CURSOR
   185 #ifndef QT_NO_CURSOR
   187     viewport->setCursor(Qt::IBeamCursor);
   186     viewport->setCursor(Qt::IBeamCursor);
       
   187 #endif
       
   188 #ifdef Q_WS_WIN
       
   189     setSingleFingerPanEnabled(true);
   188 #endif
   190 #endif
   189 }
   191 }
   190 
   192 
   191 void QTextEditPrivate::_q_repaintContents(const QRectF &contentsRect)
   193 void QTextEditPrivate::_q_repaintContents(const QRectF &contentsRect)
   192 {
   194 {
   528     This property gets and sets the text editor's contents as plain
   530     This property gets and sets the text editor's contents as plain
   529     text. Previous contents are removed and undo/redo history is reset
   531     text. Previous contents are removed and undo/redo history is reset
   530     when the property is set.
   532     when the property is set.
   531 
   533 
   532     If the text edit has another content type, it will not be replaced
   534     If the text edit has another content type, it will not be replaced
   533     by plain text if you call toPlainText().
   535     by plain text if you call toPlainText(). The only exception to this
       
   536     is the non-break space, \e{nbsp;}, that will be converted into
       
   537     standard space.
   534 
   538 
   535     By default, for an editor with no contents, this property contains
   539     By default, for an editor with no contents, this property contains
   536     an empty string.
   540     an empty string.
   537 
   541 
   538     \sa html
   542     \sa html
  1208         default:
  1212         default:
  1209             if (QApplication::keypadNavigationEnabled()) {
  1213             if (QApplication::keypadNavigationEnabled()) {
  1210                 if (!hasEditFocus() && !(e->modifiers() & Qt::ControlModifier)) {
  1214                 if (!hasEditFocus() && !(e->modifiers() & Qt::ControlModifier)) {
  1211                     if (e->text()[0].isPrint()) {
  1215                     if (e->text()[0].isPrint()) {
  1212                         setEditFocus(true);
  1216                         setEditFocus(true);
       
  1217 #ifndef Q_OS_SYMBIAN
  1213                         clear();
  1218                         clear();
       
  1219 #endif
  1214                     } else {
  1220                     } else {
  1215                         e->ignore();
  1221                         e->ignore();
  1216                         return;
  1222                         return;
  1217                     }
  1223                     }
  1218                 }
  1224                 }
  1244             e->accept();
  1250             e->accept();
  1245             d->pageUpDown(QTextCursor::Down, QTextCursor::MoveAnchor);
  1251             d->pageUpDown(QTextCursor::Down, QTextCursor::MoveAnchor);
  1246             return;
  1252             return;
  1247         }
  1253         }
  1248     }
  1254     }
  1249 #endif // QT_NO_SHORTCUT
       
  1250 
  1255 
  1251     if (!(tif & Qt::TextEditable)) {
  1256     if (!(tif & Qt::TextEditable)) {
  1252         switch (e->key()) {
  1257         switch (e->key()) {
  1253             case Qt::Key_Space:
  1258             case Qt::Key_Space:
  1254                 e->accept();
  1259                 e->accept();
  1272                     QAbstractScrollArea::keyPressEvent(e);
  1277                     QAbstractScrollArea::keyPressEvent(e);
  1273                 }
  1278                 }
  1274         }
  1279         }
  1275         return;
  1280         return;
  1276     }
  1281     }
       
  1282 #endif // QT_NO_SHORTCUT
  1277 
  1283 
  1278     {
  1284     {
  1279         QTextCursor cursor = d->control->textCursor();
  1285         QTextCursor cursor = d->control->textCursor();
  1280         const QString text = e->text();
  1286         const QString text = e->text();
  1281         if (cursor.atBlockStart()
  1287         if (cursor.atBlockStart()
  1572     d->sendControlEvent(e);
  1578     d->sendControlEvent(e);
  1573     if (d->autoScrollTimer.isActive()) {
  1579     if (d->autoScrollTimer.isActive()) {
  1574         d->autoScrollTimer.stop();
  1580         d->autoScrollTimer.stop();
  1575         ensureCursorVisible();
  1581         ensureCursorVisible();
  1576     }
  1582     }
  1577     d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus);
  1583     if (!isReadOnly() && rect().contains(e->pos()))
       
  1584         d->handleSoftwareInputPanel(e->button(), d->clickCausedFocus);
  1578     d->clickCausedFocus = 0;
  1585     d->clickCausedFocus = 0;
  1579 }
  1586 }
  1580 
  1587 
  1581 /*! \reimp
  1588 /*! \reimp
  1582 */
  1589 */
  1670 #ifdef QT_KEYPAD_NAVIGATION
  1677 #ifdef QT_KEYPAD_NAVIGATION
  1671     if (d->control->textInteractionFlags() & Qt::TextEditable
  1678     if (d->control->textInteractionFlags() & Qt::TextEditable
  1672         && QApplication::keypadNavigationEnabled()
  1679         && QApplication::keypadNavigationEnabled()
  1673         && !hasEditFocus()) {
  1680         && !hasEditFocus()) {
  1674         setEditFocus(true);
  1681         setEditFocus(true);
       
  1682 #ifndef Q_OS_SYMBIAN
  1675         selectAll();    // so text is replaced rather than appended to
  1683         selectAll();    // so text is replaced rather than appended to
       
  1684 #endif
  1676     }
  1685     }
  1677 #endif
  1686 #endif
  1678     d->sendControlEvent(e);
  1687     d->sendControlEvent(e);
  1679     ensureCursorVisible();
  1688     ensureCursorVisible();
  1680 }
  1689 }
  1897 /*!
  1906 /*!
  1898     \property QTextEdit::tabStopWidth
  1907     \property QTextEdit::tabStopWidth
  1899     \brief the tab stop width in pixels
  1908     \brief the tab stop width in pixels
  1900     \since 4.1
  1909     \since 4.1
  1901 
  1910 
  1902     By default, this property contains a value of 80.
  1911     By default, this property contains a value of 80 pixels.
  1903 */
  1912 */
  1904 
  1913 
  1905 int QTextEdit::tabStopWidth() const
  1914 int QTextEdit::tabStopWidth() const
  1906 {
  1915 {
  1907     Q_D(const QTextEdit);
  1916     Q_D(const QTextEdit);