equal
deleted
inserted
replaced
27 #include "hblineedit_p.h" |
27 #include "hblineedit_p.h" |
28 |
28 |
29 #include "hbstyleoption_p.h" |
29 #include "hbstyleoption_p.h" |
30 #include "hbscrollarea.h" |
30 #include "hbscrollarea.h" |
31 #ifdef HB_TEXT_MEASUREMENT_UTILITY |
31 #ifdef HB_TEXT_MEASUREMENT_UTILITY |
32 #include "hbtextmeasurementutility_p.h" |
32 #include "hbtextmeasurementutility_r.h" |
33 #include "hbfeaturemanager_r.h" |
33 #include "hbtextmeasurementutility_r_p.h" |
34 #endif //HB_TEXT_MEASUREMENT_UTILITY |
34 #endif //HB_TEXT_MEASUREMENT_UTILITY |
35 #include "hbevent.h" |
35 #include "hbevent.h" |
36 |
36 |
37 #include <QFontMetrics> |
37 #include <QFontMetrics> |
38 #include <QPainter> |
38 #include <QPainter> |
257 } else { |
257 } else { |
258 updateGeometry(); |
258 updateGeometry(); |
259 } |
259 } |
260 |
260 |
261 #ifdef HB_TEXT_MEASUREMENT_UTILITY |
261 #ifdef HB_TEXT_MEASUREMENT_UTILITY |
262 if ( HbFeatureManager::instance()->featureStatus( HbFeatureManager::TextMeasurement ) ) { |
262 if (HbTextMeasurementUtility::instance()->locTestMode()) { |
263 setProperty( HbTextMeasurementUtilityNameSpace::textMaxLines, d->maximumRows ); |
263 setProperty( HbTextMeasurementUtilityNameSpace::textMaxLines, d->maximumRows ); |
264 } |
264 } |
265 #endif |
265 #endif |
266 } |
266 } |
267 } |
267 } |
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 } |
294 |
294 |
295 if (e->commitString().contains("\n")) { |
295 if (e->commitString().contains("\n")) { |
296 QString str = e->commitString(); |
296 QString str = e->commitString(); |
297 str.replace("\n", " "); |
297 str.replace("\n", ""); |
298 e->setCommitString(str, e->replacementStart(), e->replacementLength()); |
298 e->setCommitString(str, e->replacementStart(), e->replacementLength()); |
299 } |
299 } |
300 |
300 |
301 if (!e->commitString().isEmpty() || e->replacementLength()) { |
301 if (!e->commitString().isEmpty() || e->replacementLength()) { |
302 // change the commit string and update the password string in case we are in password mode |
302 // change the commit string and update the password string in case we are in password mode |
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 */ |
586 Q_D(HbLineEdit); |
587 Q_D(HbLineEdit); |
587 |
588 |
588 QString txt( text ); |
589 QString txt( text ); |
589 |
590 |
590 #ifdef HB_TEXT_MEASUREMENT_UTILITY |
591 #ifdef HB_TEXT_MEASUREMENT_UTILITY |
591 if ( HbFeatureManager::instance()->featureStatus( HbFeatureManager::TextMeasurement ) ) { |
592 if (HbTextMeasurementUtility::instance()->locTestMode()) { |
592 if (text.endsWith(QChar(LOC_TEST_END))) { |
593 if (text.endsWith(QChar(LOC_TEST_END))) { |
593 int index = text.indexOf(QChar(LOC_TEST_START)); |
594 int index = text.indexOf(QChar(LOC_TEST_START)); |
594 setProperty( HbTextMeasurementUtilityNameSpace::textIdPropertyName, text.mid(index + 1, text.indexOf(QChar(LOC_TEST_END)) - index - 1) ); |
595 setProperty( HbTextMeasurementUtilityNameSpace::textIdPropertyName, text.mid(index + 1, text.indexOf(QChar(LOC_TEST_END)) - index - 1) ); |
595 setProperty( HbTextMeasurementUtilityNameSpace::textMaxLines, d->maximumRows ); |
596 setProperty( HbTextMeasurementUtilityNameSpace::textMaxLines, d->maximumRows ); |
596 txt = text.left(index); |
597 txt = text.left(index); |