src/hbwidgets/editors/hbabstractedit.cpp
changeset 2 06ff229162e9
parent 1 f7ac710697a9
child 3 11d3954df52a
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
    26 #include "hbabstractedit.h"
    26 #include "hbabstractedit.h"
    27 #include "hbabstractedit_p.h"
    27 #include "hbabstractedit_p.h"
    28 
    28 
    29 #include "hbvalidator.h"
    29 #include "hbvalidator.h"
    30 #include "hbstyle.h"
    30 #include "hbstyle.h"
    31 #include "hbstyleoption.h"
    31 #include "hbstyleoption_p.h"
    32 #include "hbwidget.h"
    32 #include "hbwidget.h"
    33 #include "hbscrollarea.h"
    33 #include "hbscrollarea.h"
    34 #include "hbevent.h"
    34 #include "hbevent.h"
    35 #include "hbwidgetfeedback.h"
    35 #include "hbwidgetfeedback.h"
    36 #include "hbmenu.h"
    36 #include "hbmenu.h"
  1010     bool hasData = false;
  1010     bool hasData = false;
  1011     QTextDocumentFragment fragment;
  1011     QTextDocumentFragment fragment;
  1012 #ifndef QT_NO_TEXTHTMLPARSER
  1012 #ifndef QT_NO_TEXTHTMLPARSER
  1013     if (source->hasFormat(QLatin1String("application/x-qrichtext"))) {
  1013     if (source->hasFormat(QLatin1String("application/x-qrichtext"))) {
  1014         QString richtext = QString::fromUtf8(source->data(QLatin1String("application/x-qrichtext")));
  1014         QString richtext = QString::fromUtf8(source->data(QLatin1String("application/x-qrichtext")));
  1015         richtext.prepend(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />"));
  1015         richtext.prepend(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />"));        
  1016         fragment = QTextDocumentFragment::fromHtml(richtext, d->doc);
  1016         fragment = QTextDocumentFragment::fromHtml(filterInputText(richtext), d->doc);
  1017         hasData = true;
  1017         hasData = true;
  1018     } else if (source->hasHtml()) {
  1018     } else if (source->hasHtml()) {
  1019         fragment = QTextDocumentFragment::fromHtml(source->html(), d->doc);
  1019         fragment = QTextDocumentFragment::fromHtml(filterInputText(source->html()), d->doc);
  1020         hasData = true;
  1020         hasData = true;
  1021     } else
  1021     } else
  1022 #endif //QT_NO_TEXTHTMLPARSER
  1022 #endif //QT_NO_TEXTHTMLPARSER
  1023     {
  1023     {
  1024         QString text = source->text();
  1024         QString text = source->text();
  1025         if (!text.isNull()) {
  1025         if (!text.isNull()) {
  1026             fragment = QTextDocumentFragment::fromPlainText(text);
  1026             fragment = QTextDocumentFragment::fromPlainText(filterInputText(text));
  1027             hasData = true;
  1027             hasData = true;
  1028         }
  1028         }
  1029     }
  1029     }
  1030 
  1030 
  1031     if (hasData) {
  1031     if (hasData) {
  1325             this, SLOT(format()));
  1325             this, SLOT(format()));
  1326     }
  1326     }
  1327 
  1327 
  1328     emit aboutToShowContextMenu(menu, d->tapPosition);
  1328     emit aboutToShowContextMenu(menu, d->tapPosition);
  1329 
  1329 
  1330     d->minimizeInputPanel();
       
  1331 
       
  1332     if(menu->actions().count() > 0){
  1330     if(menu->actions().count() > 0){
       
  1331         d->minimizeInputPanel();
  1333         menu->setPreferredPos(position);
  1332         menu->setPreferredPos(position);
  1334         menu->show();
  1333         menu->show();
  1335     }
  1334     }
  1336 }
  1335 }
  1337 
  1336 
  1709         event->accept();
  1708         event->accept();
  1710     } else {
  1709     } else {
  1711         event->ignore();
  1710         event->ignore();
  1712     }
  1711     }
  1713 }
  1712 }
       
  1713 
       
  1714 /*!
       
  1715   Returns the filtered text, or \a text if no input filter attached to editor.
       
  1716 */
       
  1717 QString HbAbstractEdit::filterInputText(const QString &text)
       
  1718 {
       
  1719     HbEditorInterface editorInterface(this);
       
  1720     HbInputFilter *inputFilter = editorInterface.filter();
       
  1721     if (!text.isEmpty() && inputFilter) {
       
  1722         QString filteredText;
       
  1723         foreach(QChar c, text) {
       
  1724             if (inputFilter->filter(c)) {
       
  1725                 filteredText.append(c);
       
  1726             }
       
  1727         }
       
  1728         return filteredText;
       
  1729     }
       
  1730     return text;
       
  1731 }