src/gui/widgets/qlineedit_p.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
child 7 f7bc934e204c
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   101 }
   101 }
   102 
   102 
   103 void QLineEditPrivate::_q_textEdited(const QString &text)
   103 void QLineEditPrivate::_q_textEdited(const QString &text)
   104 {
   104 {
   105     Q_Q(QLineEdit);
   105     Q_Q(QLineEdit);
       
   106     emit q->textEdited(text);
   106 #ifndef QT_NO_COMPLETER
   107 #ifndef QT_NO_COMPLETER
   107     if (control->completer() &&
   108     if (control->completer()
   108             control->completer()->completionMode() != QCompleter::InlineCompletion)
   109         && control->completer()->completionMode() != QCompleter::InlineCompletion)
   109         control->complete(-1); // update the popup on cut/paste/del
   110         control->complete(-1); // update the popup on cut/paste/del
   110 #endif
   111 #endif
   111     emit q->textEdited(text);
       
   112 }
   112 }
   113 
   113 
   114 void QLineEditPrivate::_q_cursorPositionChanged(int from, int to)
   114 void QLineEditPrivate::_q_cursorPositionChanged(int from, int to)
   115 {
   115 {
   116     Q_Q(QLineEdit);
   116     Q_Q(QLineEdit);
   124     Q_Q(QLineEdit);
   124     Q_Q(QLineEdit);
   125     q->setEditFocus(e);
   125     q->setEditFocus(e);
   126 }
   126 }
   127 #endif
   127 #endif
   128 
   128 
       
   129 void QLineEditPrivate::_q_selectionChanged()
       
   130 {
       
   131     Q_Q(QLineEdit);
       
   132     if (control->preeditAreaText().isEmpty()) {
       
   133         QStyleOptionFrameV2 opt;
       
   134         q->initStyleOption(&opt);
       
   135         bool showCursor = control->hasSelectedText() ?
       
   136                           q->style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, q):
       
   137                           true;
       
   138         setCursorVisible(showCursor);
       
   139     }
       
   140 
       
   141     emit q->selectionChanged();
       
   142 }
       
   143 
   129 void QLineEditPrivate::init(const QString& txt)
   144 void QLineEditPrivate::init(const QString& txt)
   130 {
   145 {
   131     Q_Q(QLineEdit);
   146     Q_Q(QLineEdit);
   132     control = new QLineControl(txt);
   147     control = new QLineControl(txt);
   133     control->setFont(q->font());
   148     control->setFont(q->font());
   134     QObject::connect(control, SIGNAL(textChanged(const QString &)),
   149     QObject::connect(control, SIGNAL(textChanged(QString)),
   135             q, SIGNAL(textChanged(const QString &)));
   150             q, SIGNAL(textChanged(QString)));
   136     QObject::connect(control, SIGNAL(textEdited(const QString &)),
   151     QObject::connect(control, SIGNAL(textEdited(QString)),
   137             q, SLOT(_q_textEdited(const QString &)));
   152             q, SLOT(_q_textEdited(QString)));
   138     QObject::connect(control, SIGNAL(cursorPositionChanged(int, int)),
   153     QObject::connect(control, SIGNAL(cursorPositionChanged(int,int)),
   139             q, SLOT(_q_cursorPositionChanged(int, int)));
   154             q, SLOT(_q_cursorPositionChanged(int,int)));
   140     QObject::connect(control, SIGNAL(selectionChanged()),
   155     QObject::connect(control, SIGNAL(selectionChanged()),
   141             q, SIGNAL(selectionChanged()));
   156             q, SLOT(_q_selectionChanged()));
   142     QObject::connect(control, SIGNAL(accepted()),
   157     QObject::connect(control, SIGNAL(accepted()),
   143             q, SIGNAL(returnPressed()));
   158             q, SIGNAL(returnPressed()));
   144     QObject::connect(control, SIGNAL(editingFinished()),
   159     QObject::connect(control, SIGNAL(editingFinished()),
   145             q, SIGNAL(editingFinished()));
   160             q, SIGNAL(editingFinished()));
   146 #ifdef QT_KEYPAD_NAVIGATION
   161 #ifdef QT_KEYPAD_NAVIGATION
   147     QObject::connect(control, SIGNAL(editFocusChange(bool)),
   162     QObject::connect(control, SIGNAL(editFocusChange(bool)),
   148             q, SLOT(_q_editFocusChange(bool)));
   163             q, SLOT(_q_editFocusChange(bool)));
   149 #endif
   164 #endif
   150     QObject::connect(control, SIGNAL(cursorPositionChanged(int, int)),
   165     QObject::connect(control, SIGNAL(cursorPositionChanged(int,int)),
       
   166             q, SLOT(updateMicroFocus()));
       
   167     
       
   168     QObject::connect(control, SIGNAL(textChanged(const QString &)),
   151             q, SLOT(updateMicroFocus()));
   169             q, SLOT(updateMicroFocus()));
   152 
   170 
   153     // for now, going completely overboard with updates.
   171     // for now, going completely overboard with updates.
   154     QObject::connect(control, SIGNAL(selectionChanged()),
   172     QObject::connect(control, SIGNAL(selectionChanged()),
   155             q, SLOT(update()));
   173             q, SLOT(update()));
   156 
   174 
   157     QObject::connect(control, SIGNAL(displayTextChanged(const QString &)),
   175     QObject::connect(control, SIGNAL(displayTextChanged(QString)),
   158             q, SLOT(update()));
   176             q, SLOT(update()));
   159 
   177 
   160     QObject::connect(control, SIGNAL(updateNeeded(const QRect &)),
   178     QObject::connect(control, SIGNAL(updateNeeded(QRect)),
   161             q, SLOT(update()));
   179             q, SLOT(update()));
   162 
   180 
   163     QStyleOptionFrameV2 opt;
   181     QStyleOptionFrameV2 opt;
   164     q->initStyleOption(&opt);
   182     q->initStyleOption(&opt);
   165     control->setPasswordCharacter(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, q));
   183     control->setPasswordCharacter(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, q));