src/hbwidgets/editors/hblineedit.cpp
changeset 28 b7da29130b0e
parent 21 4633027730f5
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
   283  */
   283  */
   284 void HbLineEdit::inputMethodEvent(QInputMethodEvent *e)
   284 void HbLineEdit::inputMethodEvent(QInputMethodEvent *e)
   285 {
   285 {
   286     Q_D(HbLineEdit);
   286     Q_D(HbLineEdit);
   287     
   287     
   288     if((!e->commitString().isEmpty() || e->replacementLength()) &&
   288     if((!e->commitString().isEmpty() || e->replacementLength() || !e->preeditString().isEmpty()) &&
   289          d->echoMode == HbLineEdit::PasswordEchoOnEdit && d->clearOnEdit) {
   289          d->echoMode == HbLineEdit::PasswordEchoOnEdit && d->clearOnEdit) {
   290         d->doc->clear();
   290         d->doc->clear();
   291         d->passwordText.clear();
   291         d->passwordText.clear();
   292         d->clearOnEdit = false;
   292         d->clearOnEdit = false;
   293     }
   293     }
   341         d->doc->clear();
   341         d->doc->clear();
   342         d->passwordText.clear();
   342         d->passwordText.clear();
   343         d->clearOnEdit = false;
   343         d->clearOnEdit = false;
   344     }
   344     }
   345 
   345 
       
   346 
   346     if(d->forwardKeyEvent(event)) {
   347     if(d->forwardKeyEvent(event)) {
   347         HbAbstractEdit::keyPressEvent(event);
   348         HbAbstractEdit::keyPressEvent(event);
   348     } else if (d->echoMode == HbLineEdit::Password || d->echoMode == HbLineEdit::NoEcho){
   349     } else if (d->isPasswordMode()){
   349         // Keep doc and passwordText in sync
   350         // Keep doc and passwordText in sync
   350         bool update = false;
   351         bool update = false;
   351         if (event->key() == Qt::Key_Backspace && !(event->modifiers() & ~Qt::ShiftModifier)) {
   352         if (event->key() == Qt::Key_Backspace && !(event->modifiers() & ~Qt::ShiftModifier)) {
   352             update = true;
   353             update = true;
   353             d->passwordText.remove(d->passwordText.length()-1,1);
   354             d->passwordText.remove(d->passwordText.length()-1,1);
   355             update = true;
   356             update = true;
   356             d->passwordText.append(event->text());
   357             d->passwordText.append(event->text());
   357         }
   358         }
   358 
   359 
   359         if (update) {
   360         if (update) {
   360             setPlainText(((d->echoMode == HbLineEdit::Password)?d->passwordString(d->passwordText):""));
   361             if(d->echoMode == HbLineEdit::PasswordEchoOnEdit) {
       
   362                 setPlainText(d->passwordText);
       
   363             } else {
       
   364                 setPlainText(((d->echoMode == HbLineEdit::Password)?d->passwordString(d->passwordText):""));
       
   365             }
   361         }
   366         }
   362         setCursorPosition(d->passwordText.length());
   367         setCursorPosition(d->passwordText.length());
   363     }
   368     }
   364     if (d->echoMode == HbLineEdit::PasswordEchoOnEdit) {
       
   365         // Keep doc and passwordText in sync
       
   366         d->passwordText = toPlainText();
       
   367     }    
       
   368 }
   369 }
   369 
   370 
   370 /*!
   371 /*!
   371  \reimp
   372  \reimp
   372  */
   373  */