src/declarative/graphicsitems/qdeclarativetextinput.cpp
changeset 37 758a864f9613
parent 33 3e2da88830cd
equal deleted inserted replaced
36:ef0373b55136 37:758a864f9613
    49 #include <QTextCursor>
    49 #include <QTextCursor>
    50 #include <QApplication>
    50 #include <QApplication>
    51 #include <QFontMetrics>
    51 #include <QFontMetrics>
    52 #include <QPainter>
    52 #include <QPainter>
    53 
    53 
       
    54 #ifndef QT_NO_LINEEDIT
       
    55 
    54 QT_BEGIN_NAMESPACE
    56 QT_BEGIN_NAMESPACE
    55 
    57 
    56 /*!
    58 /*!
    57     \qmlclass TextInput QDeclarativeTextInput
    59     \qmlclass TextInput QDeclarativeTextInput
       
    60     \ingroup qml-basic-visual-elements
    58     \since 4.7
    61     \since 4.7
    59     \brief The TextInput item displays an editable line of text.
    62     \brief The TextInput item displays an editable line of text.
    60     \inherits Item
    63     \inherits Item
    61 
    64 
    62     The TextInput element displays a single line of editable plain text.
    65     The TextInput element displays a single line of editable plain text.
   272 
   275 
   273     d->selectionColor = color;
   276     d->selectionColor = color;
   274     QPalette p = d->control->palette();
   277     QPalette p = d->control->palette();
   275     p.setColor(QPalette::Highlight, d->selectionColor);
   278     p.setColor(QPalette::Highlight, d->selectionColor);
   276     d->control->setPalette(p);
   279     d->control->setPalette(p);
   277     clearCache();
   280     if (d->control->hasSelectedText()) {
   278     update();
   281         clearCache();
       
   282         update();
       
   283     }
   279     emit selectionColorChanged(color);
   284     emit selectionColorChanged(color);
   280 }
   285 }
   281 
   286 
   282 /*!
   287 /*!
   283     \qmlproperty color TextInput::selectedTextColor
   288     \qmlproperty color TextInput::selectedTextColor
   298 
   303 
   299     d->selectedTextColor = color;
   304     d->selectedTextColor = color;
   300     QPalette p = d->control->palette();
   305     QPalette p = d->control->palette();
   301     p.setColor(QPalette::HighlightedText, d->selectedTextColor);
   306     p.setColor(QPalette::HighlightedText, d->selectedTextColor);
   302     d->control->setPalette(p);
   307     d->control->setPalette(p);
   303     clearCache();
   308     if (d->control->hasSelectedText()) {
   304     update();
   309         clearCache();
       
   310         update();
       
   311     }
   305     emit selectedTextColorChanged(color);
   312     emit selectedTextColorChanged(color);
   306 }
   313 }
   307 
   314 
   308 /*!
   315 /*!
   309     \qmlproperty enumeration TextInput::horizontalAlignment
   316     \qmlproperty enumeration TextInput::horizontalAlignment
   428     Q_D(QDeclarativeTextInput);
   435     Q_D(QDeclarativeTextInput);
   429     d->control->moveCursor(cp);
   436     d->control->moveCursor(cp);
   430 }
   437 }
   431 
   438 
   432 /*!
   439 /*!
   433   \internal
       
   434 
       
   435   Returns a Rect which encompasses the cursor, but which may be larger than is
   440   Returns a Rect which encompasses the cursor, but which may be larger than is
   436   required. Ignores custom cursor delegates.
   441   required. Ignores custom cursor delegates.
   437 */
   442 */
   438 QRect QDeclarativeTextInput::cursorRectangle() const
   443 QRect QDeclarativeTextInput::cursorRectangle() const
   439 {
   444 {
   557     emit autoScrollChanged(d->autoScroll);
   562     emit autoScrollChanged(d->autoScroll);
   558 }
   563 }
   559 
   564 
   560 /*!
   565 /*!
   561     \qmlclass IntValidator QIntValidator
   566     \qmlclass IntValidator QIntValidator
       
   567     \ingroup qml-basic-visual-elements
   562 
   568 
   563     This element provides a validator for integer values.
   569     This element provides a validator for integer values.
   564 */
   570 */
   565 /*!
   571 /*!
   566     \qmlproperty int IntValidator::top
   572     \qmlproperty int IntValidator::top
   575     By default, this property's value is derived from the lowest signed integer available (typically -2147483647).
   581     By default, this property's value is derived from the lowest signed integer available (typically -2147483647).
   576 */
   582 */
   577 
   583 
   578 /*!
   584 /*!
   579     \qmlclass DoubleValidator QDoubleValidator
   585     \qmlclass DoubleValidator QDoubleValidator
       
   586     \ingroup qml-basic-visual-elements
   580 
   587 
   581     This element provides a validator for non-integer numbers.
   588     This element provides a validator for non-integer numbers.
   582 */
   589 */
   583 
   590 
   584 /*!
   591 /*!
   613     If this property is set to DoubleValidator.ScientificNotation, the written number may have an exponent part (e.g. 1.5E-2).
   620     If this property is set to DoubleValidator.ScientificNotation, the written number may have an exponent part (e.g. 1.5E-2).
   614 */
   621 */
   615 
   622 
   616 /*!
   623 /*!
   617     \qmlclass RegExpValidator QRegExpValidator
   624     \qmlclass RegExpValidator QRegExpValidator
       
   625     \ingroup qml-basic-visual-elements
   618 
   626 
   619     This element provides a validator, which counts as valid any string which
   627     This element provides a validator, which counts as valid any string which
   620     matches a specified regular expression.
   628     matches a specified regular expression.
   621 */
   629 */
   622 /*!
   630 /*!
  1225 void QDeclarativeTextInput::setPasswordCharacter(const QString &str)
  1233 void QDeclarativeTextInput::setPasswordCharacter(const QString &str)
  1226 {
  1234 {
  1227     Q_D(QDeclarativeTextInput);
  1235     Q_D(QDeclarativeTextInput);
  1228     if(str.length() < 1)
  1236     if(str.length() < 1)
  1229         return;
  1237         return;
       
  1238     d->control->setPasswordCharacter(str.constData()[0]);
       
  1239     EchoMode echoMode_ = echoMode();
       
  1240     if (echoMode_ == Password || echoMode_ == PasswordEchoOnEdit) {
       
  1241         updateSize();
       
  1242     }
  1230     emit passwordCharacterChanged();
  1243     emit passwordCharacterChanged();
  1231     d->control->setPasswordCharacter(str.constData()[0]);
       
  1232 }
  1244 }
  1233 
  1245 
  1234 /*!
  1246 /*!
  1235    \qmlproperty string TextInput::displayText
  1247    \qmlproperty string TextInput::displayText
  1236 
  1248 
  1535     }
  1547     }
  1536 }
  1548 }
  1537 
  1549 
  1538 QT_END_NAMESPACE
  1550 QT_END_NAMESPACE
  1539 
  1551 
       
  1552 #endif // QT_NO_LINEEDIT
       
  1553