src/hbwidgets/editors/hbabstractedit.cpp
changeset 2 06ff229162e9
parent 1 f7ac710697a9
child 3 11d3954df52a
--- a/src/hbwidgets/editors/hbabstractedit.cpp	Mon May 03 12:48:33 2010 +0300
+++ b/src/hbwidgets/editors/hbabstractedit.cpp	Fri May 14 16:09:54 2010 +0300
@@ -28,7 +28,7 @@
 
 #include "hbvalidator.h"
 #include "hbstyle.h"
-#include "hbstyleoption.h"
+#include "hbstyleoption_p.h"
 #include "hbwidget.h"
 #include "hbscrollarea.h"
 #include "hbevent.h"
@@ -1012,18 +1012,18 @@
 #ifndef QT_NO_TEXTHTMLPARSER
     if (source->hasFormat(QLatin1String("application/x-qrichtext"))) {
         QString richtext = QString::fromUtf8(source->data(QLatin1String("application/x-qrichtext")));
-        richtext.prepend(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />"));
-        fragment = QTextDocumentFragment::fromHtml(richtext, d->doc);
+        richtext.prepend(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />"));        
+        fragment = QTextDocumentFragment::fromHtml(filterInputText(richtext), d->doc);
         hasData = true;
     } else if (source->hasHtml()) {
-        fragment = QTextDocumentFragment::fromHtml(source->html(), d->doc);
+        fragment = QTextDocumentFragment::fromHtml(filterInputText(source->html()), d->doc);
         hasData = true;
     } else
 #endif //QT_NO_TEXTHTMLPARSER
     {
         QString text = source->text();
         if (!text.isNull()) {
-            fragment = QTextDocumentFragment::fromPlainText(text);
+            fragment = QTextDocumentFragment::fromPlainText(filterInputText(text));
             hasData = true;
         }
     }
@@ -1327,9 +1327,8 @@
 
     emit aboutToShowContextMenu(menu, d->tapPosition);
 
-    d->minimizeInputPanel();
-
     if(menu->actions().count() > 0){
+        d->minimizeInputPanel();
         menu->setPreferredPos(position);
         menu->show();
     }
@@ -1711,3 +1710,22 @@
         event->ignore();
     }
 }
+
+/*!
+  Returns the filtered text, or \a text if no input filter attached to editor.
+*/
+QString HbAbstractEdit::filterInputText(const QString &text)
+{
+    HbEditorInterface editorInterface(this);
+    HbInputFilter *inputFilter = editorInterface.filter();
+    if (!text.isEmpty() && inputFilter) {
+        QString filteredText;
+        foreach(QChar c, text) {
+            if (inputFilter->filter(c)) {
+                filteredText.append(c);
+            }
+        }
+        return filteredText;
+    }
+    return text;
+}