src/hbcore/inputfw/hbinputeditorinterface.cpp
changeset 28 b7da29130b0e
parent 23 e6ad4ef83b23
child 30 80e4d18b72f5
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
    62 Constructs the object and attaches given editor.
    62 Constructs the object and attaches given editor.
    63 */
    63 */
    64 HbEditorInterface::HbEditorInterface(QObject *editor)
    64 HbEditorInterface::HbEditorInterface(QObject *editor)
    65 {
    65 {
    66     mPrivate = HbEditorInterfacePrivateCache::instance()->attachEditor(editor, this);
    66     mPrivate = HbEditorInterfacePrivateCache::instance()->attachEditor(editor, this);
    67     connect(mPrivate, SIGNAL(destroyed(QObject *)), this, SLOT(backendDestroyed(QObject *)));
    67     if (mPrivate) {
       
    68         connect(mPrivate, SIGNAL(destroyed(QObject *)), this, SLOT(backendDestroyed(QObject *)));
       
    69     }
    68 }
    70 }
    69 
    71 
    70 /*!
    72 /*!
    71 Destructs the object.
    73 Destructs the object.
    72 */
    74 */
   292         // Remove the action first if it's already in the list
   294         // Remove the action first if it's already in the list
   293         int index = mPrivate->mActions.indexOf(action);
   295         int index = mPrivate->mActions.indexOf(action);
   294         if (index >= 0) {
   296         if (index >= 0) {
   295             mPrivate->mActions.removeAt(index);
   297             mPrivate->mActions.removeAt(index);
   296             disconnect(action, SIGNAL(destroyed(QObject *)),
   298             disconnect(action, SIGNAL(destroyed(QObject *)),
   297                        HbEditorInterfacePrivateCache::instance(), SLOT(actionDestroyed(QObject * object)));
   299                        HbEditorInterfacePrivateCache::instance(), SLOT(actionDestroyed(QObject *)));
   298         }
   300         }
   299 
   301 
   300         int pos = mPrivate->mActions.indexOf(before);
   302         int pos = mPrivate->mActions.indexOf(before);
   301         if (pos < 0) {
   303         if (pos < 0) {
   302             pos = mPrivate->mActions.size();
   304             pos = mPrivate->mActions.size();
   325     }
   327     }
   326     if (mPrivate) {
   328     if (mPrivate) {
   327         mPrivate->lock();
   329         mPrivate->lock();
   328         mPrivate->mActions.removeAll(action);
   330         mPrivate->mActions.removeAll(action);
   329         disconnect(action, SIGNAL(destroyed(QObject *)),
   331         disconnect(action, SIGNAL(destroyed(QObject *)),
   330                    HbEditorInterfacePrivateCache::instance(), SLOT(actionDestroyed(QObject * object)));
   332                    HbEditorInterfacePrivateCache::instance(), SLOT(actionDestroyed(QObject *)));
   331         mPrivate->unlock();
   333         mPrivate->unlock();
   332         HbEditorInterfacePrivateCache::instance()->notifyValueChanged(mPrivate->mHostEditor);
   334         HbEditorInterfacePrivateCache::instance()->notifyValueChanged(mPrivate->mHostEditor);
   333     }
   335     }
   334 }
   336 }
   335 
   337 
   616 If either Qt::ImhLowercaseOnly or Qt::ImhUppercaseOnly is also set, then the editor is not numeric editor and
   618 If either Qt::ImhLowercaseOnly or Qt::ImhUppercaseOnly is also set, then the editor is not numeric editor and
   617 this method returns false.
   619 this method returns false.
   618 */
   620 */
   619 bool HbEditorInterface::isNumericEditor() const
   621 bool HbEditorInterface::isNumericEditor() const
   620 {
   622 {
   621     return ((mPrivate->inputMethodHints() & (Qt::ImhDigitsOnly | Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly)) &&
   623     return mPrivate && ((mPrivate->inputMethodHints() & (Qt::ImhDigitsOnly | Qt::ImhDialableCharactersOnly | Qt::ImhFormattedNumbersOnly)) &&
   622             !(mPrivate->inputMethodHints() & (Qt::ImhLowercaseOnly | Qt::ImhUppercaseOnly)));
   624             !(mPrivate->inputMethodHints() & (Qt::ImhLowercaseOnly | Qt::ImhUppercaseOnly)));
   623 }
   625 }
   624 
   626 
   625 /*!
   627 /*!
   626 Returns true if predictive input mode is allowed in attached editor.
   628 Returns true if predictive input mode is allowed in attached editor.
   627 */
   629 */
   628 bool HbEditorInterface::isPredictionAllowed() const
   630 bool HbEditorInterface::isPredictionAllowed() const
   629 {
   631 {
   630     return !(mPrivate->inputMethodHints() & Qt::ImhNoPredictiveText);
   632     return mPrivate && !(mPrivate->inputMethodHints() & Qt::ImhNoPredictiveText);
   631 }
   633 }
   632 
   634 
   633 /*!
   635 /*!
   634 Returns true if there is existing data record for given object. This method can
   636 Returns true if there is existing data record for given object. This method can
   635 be used for testing whether someone has set editor data for given object without
   637 be used for testing whether someone has set editor data for given object without