src/hbwidgets/editors/hbdatetimeedit.cpp
changeset 6 c3690ec91ef8
parent 0 16d8024aca5e
child 7 923ff622b8b9
--- a/src/hbwidgets/editors/hbdatetimeedit.cpp	Fri Jun 11 13:58:22 2010 +0300
+++ b/src/hbwidgets/editors/hbdatetimeedit.cpp	Wed Jun 23 18:33:25 2010 +0300
@@ -24,6 +24,7 @@
 ****************************************************************************/
 
 #include <QDateTime>
+#include <QMetaMethod>
 
 #include "hblineedit.h"
 #include "hbdatetimevalidator_p.h"
@@ -235,11 +236,24 @@
 */
 void HbDateTimeEdit::focusOutEvent(QFocusEvent *event)
 {
-    HbAbstractEdit::focusOutEvent(event);
+    Q_D(HbDateTimeEdit);
 
-    Q_D(HbDateTimeEdit);
     if(d->validator->fixDate(&d->cursor, true)) {
         // fixing so restore focus to editor
-        setFocus(event->reason());
+        // do it asynchronously by private slot:
+        int metodIndex = metaObject()->indexOfMethod("_q_regainFocus()");
+        if (metodIndex<0) {
+            qWarning("HbDateTimeEdit::focusOutEvent private method "
+                     "_q_regainFocus() NOT FOUND");
+        } else {
+            if (!metaObject()->method(metodIndex).invoke(this, Qt::QueuedConnection)) {
+                qWarning("HbDateTimeEdit::focusOutEvent failed to call "
+                         "private method _q_regainFocus()");
+            }
+        }
+        // prevent emmiting signal editingFinished so omnit HbLineEdit
+        HbAbstractEdit::focusOutEvent(event);
+    } else {
+        HbLineEdit::focusOutEvent(event);
     }
 }