src/hbcore/inputfw/hbinputpredictionengine.cpp
changeset 0 16d8024aca5e
child 1 f7ac710697a9
equal deleted inserted replaced
-1:000000000000 0:16d8024aca5e
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (developer.feedback@nokia.com)
       
     6 **
       
     7 ** This file is part of the HbCore module of the UI Extensions for Mobile.
       
     8 **
       
     9 ** GNU Lesser General Public License Usage
       
    10 ** This file may be used under the terms of the GNU Lesser General Public
       
    11 ** License version 2.1 as published by the Free Software Foundation and
       
    12 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
       
    13 ** Please review the following information to ensure the GNU Lesser General
       
    14 ** Public License version 2.1 requirements will be met:
       
    15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    16 **
       
    17 ** In addition, as a special exception, Nokia gives you certain additional
       
    18 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    20 **
       
    21 ** If you have questions regarding the use of this file, please contact
       
    22 ** Nokia at developer.feedback@nokia.com.
       
    23 **
       
    24 ****************************************************************************/
       
    25 
       
    26 #include "hbinputpredictionengine.h"
       
    27 
       
    28 /*!
       
    29 @alpha
       
    30 @hbcore
       
    31 \class HbPredictionBase
       
    32 \brief A base class for prediction engine abstration layer.
       
    33 
       
    34 This API defines abstract interface for predictive text input engines.
       
    35 The base class is extended by language specific versions.
       
    36 
       
    37 \sa HbPredictionEngine
       
    38 \sa HbPredictionEngineChinese
       
    39 \sa HbPredictionCallback
       
    40 */
       
    41 
       
    42 /*!
       
    43 \fn virtual QList<HbInputLanguage> HbPredictionBase::languages() const
       
    44 Returns a list of languages the engine supports.
       
    45 */
       
    46 
       
    47 /*!
       
    48 \fn virtual void HbPredictionBase::setWord(const QString& word, HbPredictionCallback* callback = 0)
       
    49 Sets current word. Given word will be the active word.  
       
    50 */
       
    51 
       
    52 /*!
       
    53 \fn virtual void HbPredictionBase::updateCandidates(int& bestGuessLocation, bool& noMoreCandidates)
       
    54 
       
    55 */
       
    56 
       
    57 /*!
       
    58 \fn virtual void HbPredictionBase::appendKeyPress(const int keycode, const Qt::KeyboardModifiers modifiers, const HbTextCase textCase = HbTextCaseNone, HbPredictionCallback* callback = 0)
       
    59 Handles a key press event.
       
    60 
       
    61 \sa appendCharacter
       
    62 */ 
       
    63 
       
    64 /*!
       
    65 \fn virtual void HbPredictionBase::deleteKeyPress(HbPredictionCallback* callback = 0)
       
    66 Handles delete key press.
       
    67 */
       
    68 
       
    69 /*!
       
    70 \fn virtual void HbPredictionBase::commit(const QString &word = QString())
       
    71 Commits ongoing input operation and clears the active word. If the word is given as a parameter,
       
    72 the result is same as after calling setWord(word) and commit().
       
    73 */
       
    74 
       
    75 /*!
       
    76 \fn virtual void HbPredictionBase::clear()
       
    77 Clears the active word without commiting it.
       
    78 */
       
    79 
       
    80 /*!
       
    81 \fn virtual void HbPredictionBase::addUsedWord(const QString& word)
       
    82 Notifies the engine that a given word was used as part of the text. Commit
       
    83 will do this automatically.
       
    84 */
       
    85 
       
    86 /*!
       
    87 \fn virtual HbInputPredictionFeature HbPredictionBase::features() const
       
    88 Returns a bit vector of supported prediction features.
       
    89 
       
    90 \sa HbInputPredictionFeature
       
    91 */
       
    92 
       
    93 /*!
       
    94 \fn virtual QString HbPredictionBase::vendorIdString() const
       
    95 Returns vendor sepcific id string. The format of the returned string depends
       
    96 on the engine.
       
    97 */
       
    98 
       
    99 /*!
       
   100 \fn virtual QString HbPredictionBase::engineVersion() const
       
   101 Returns engine version. The format of the returned string depends on the
       
   102 engine.
       
   103 */
       
   104 
       
   105 /*!
       
   106 \fn virtual bool HbPredictionBase::supportsKeyboardType(const HbInputLanguage &language, HbKeyboardType keyboard)
       
   107 Returns true if the engine supports given combination of language and keyboard type.
       
   108 */
       
   109 
       
   110 // ---------------------------------------------------------------------------
       
   111 // HbPredictionBase::HbPredictionBase
       
   112 //
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 HbPredictionBase::HbPredictionBase()
       
   116 {
       
   117 }
       
   118 
       
   119 // ---------------------------------------------------------------------------
       
   120 // HbPredictionBase::~HbPredictionBase
       
   121 //
       
   122 // ---------------------------------------------------------------------------
       
   123 //
       
   124 HbPredictionBase::~HbPredictionBase()
       
   125 {
       
   126 }
       
   127 
       
   128 /*!
       
   129 Actives single extra user dictionary. Usable only if the engine supports extra user dictionaries
       
   130 (see HbPredFeatureExtraDictionaries feature flag). The default implementation is empty,
       
   131 orverride if the engine supports extra dictioanries.
       
   132 
       
   133 \sa setExtraUserDictionaries
       
   134 \sa HbExtraUserDictionary
       
   135 */
       
   136 void HbPredictionBase::setExtraUserDictionary(int id)
       
   137 {
       
   138     Q_UNUSED(id)
       
   139 }
       
   140 
       
   141 /*!
       
   142 Activates a collection of extra user dictionaries. Usable only if the engine supports extra user dictionaries
       
   143 (see HbPredFeatureExtraDictionaries feature flag). The default implementation is empty,
       
   144 orverride if the engine supports extra dictioanries.
       
   145 
       
   146 \sa setExtraUserDictionary
       
   147 \sa HbExtraUserDictionary
       
   148 */
       
   149 void HbPredictionBase::setExtraUserDictionaries(const QList<int>& idList)
       
   150 {
       
   151     Q_UNUSED(idList)
       
   152 }
       
   153 
       
   154 /*!
       
   155 Returns pointer to active user dictionary. There are two kind of user dictionaries, default and
       
   156 extra. This one returns the default user dictionary. Default implementation of this method is empty, 
       
   157 override if the engine supports user dictionaries.
       
   158 
       
   159 \sa setExtraUserDictionary
       
   160 \sa HbExtraUserDictionary
       
   161 */
       
   162 HbUserDictionary* HbPredictionBase::userDictionary() const
       
   163 {
       
   164     return 0;
       
   165 }
       
   166 
       
   167 /*!
       
   168 Sets active prediction language. Returns true if given language is recognized
       
   169 by the engine and was succesfully activated. 
       
   170 */
       
   171 bool HbPredictionBase::setLanguage(const HbInputLanguage &language, HbInputModeType inputMode)
       
   172 {
       
   173     Q_UNUSED(language); 
       
   174     Q_UNUSED(inputMode);
       
   175 
       
   176     return false;
       
   177 }
       
   178 
       
   179 /*!
       
   180 Returns active prediction language.  
       
   181 */
       
   182 HbInputLanguage HbPredictionBase::language() const
       
   183 {
       
   184     return HbInputLanguage();
       
   185 }
       
   186 
       
   187 /*!
       
   188 Returns the keyboard type engine is using.
       
   189 */
       
   190 HbKeyboardType HbPredictionBase::keyboardType() const
       
   191 {
       
   192     return HbKeyboardNone;
       
   193 }
       
   194 
       
   195 /*!
       
   196 \class HbPredictionEngine
       
   197 \brief Prediction API for latin based langauges.
       
   198 
       
   199 This interface defines abstract prediction API for latin-based languages. 
       
   200 Also some non-latin languages whose prediction features are functionally similar to
       
   201 latin-based languages use this API. Those are for example Arabic and Hebrew.
       
   202 */
       
   203 
       
   204 
       
   205 /*!
       
   206 \deprecated HbPredictionEngine::setCandidateList(QStringList*)
       
   207      is deprecated.
       
   208 */
       
   209 
       
   210 /*!
       
   211 \fn virtual QStringList HbPredictionEngine::candidateList()
       
   212 Returns the list of prediction candidates for current input sequence.
       
   213 */
       
   214 
       
   215 /*
       
   216 \fn virtual int HbPredictionEngine::inputLength()
       
   217 Returns the number of key presses since previous clear or commit operation.
       
   218 Candidate length may exceed this value if word completion is used.
       
   219 */
       
   220 
       
   221 /*!
       
   222 \fn virtual void HbPredictionEngine::setKeyboard(HbKeyboardType aKeyboardType)
       
   223 Sets the keyboard type.
       
   224 */
       
   225 
       
   226 /*!
       
   227 \fn virtual void appendCharacter(QChar aChar, const HbTextCase textCase = HbTextCaseNone, HbPredictionCallback* callback = 0)
       
   228 Appends a unicode character. The difference between this method and appendKeyPress is that the
       
   229 engine doesn't resolve character from key mappings but uses given character directly.
       
   230 
       
   231 \sa appendKeyPress
       
   232 */
       
   233 
       
   234 /*!
       
   235 Sets error correction level. Returns true if the given error correction level
       
   236 is supported and was successfully activated. This method works only if the engine
       
   237 supports error correction.
       
   238 
       
   239 \sa errorCorrectionLevel
       
   240 \sa supportedFeatures
       
   241 */
       
   242 bool HbPredictionEngine::setErrorCorrectionLevel(HbErrorCorrectionLevel level)
       
   243 {
       
   244     if (level == HbErrorCorrectionLevelNone) {
       
   245         return true;
       
   246     }
       
   247 
       
   248     return false;
       
   249 }
       
   250 
       
   251 /*!
       
   252 Returns active error correction level.
       
   253 */
       
   254 HbPredictionEngine::HbErrorCorrectionLevel HbPredictionEngine::errorCorrectionLevel() const
       
   255 {
       
   256     return HbErrorCorrectionLevelNone;
       
   257 }
       
   258 
       
   259 /*!
       
   260 Sets active secondary language for prediction engine. Returns true if given language is recognized
       
   261 by the engine and was succesfully activated. 
       
   262 */
       
   263 bool HbPredictionEngine::setSecondaryLanguage(const HbInputLanguage& language)
       
   264 {
       
   265     Q_UNUSED(language);
       
   266     return false;
       
   267 }
       
   268 
       
   269 /*!
       
   270 Returns active secondary prediction language.  
       
   271 */
       
   272 HbInputLanguage HbPredictionEngine::secondaryLanguage() const
       
   273 {
       
   274     return HbInputLanguage(QLocale::Language(0), QLocale::AnyCountry);
       
   275 }
       
   276 
       
   277 /*!
       
   278 Returns the topmost candidate for active input sequence.
       
   279 
       
   280 \sa candidateList
       
   281 */
       
   282 QString HbPredictionEngine::currentWord() const
       
   283 {
       
   284     return QString("");
       
   285 }
       
   286 
       
   287 /*!
       
   288 Enables a specified feature for the prediction engine. 
       
   289 Returns true if the engine supports the feature and is able to enable the feature,
       
   290 otherwise, returns false.
       
   291 
       
   292 \sa HbPredictionEngine::isFeatureEnabled()
       
   293 \sa HbPredictionEngine::disableFeature()
       
   294 */
       
   295 bool HbPredictionEngine::enableFeature(HbInputPredictionFeature feature)
       
   296 {
       
   297     Q_UNUSED(feature);
       
   298     return false;
       
   299 }
       
   300 
       
   301 /*!
       
   302 Returns true if the engine supports the feature and is enabled,
       
   303 otherwise, returns false.
       
   304 
       
   305 \sa HbPredictionEngine::enableFeature()
       
   306 \sa HbPredictionEngine::disableFeature()
       
   307 */
       
   308 bool HbPredictionEngine::isFeatureEnabled(HbInputPredictionFeature feature)
       
   309 {
       
   310     Q_UNUSED(feature);
       
   311     return false;
       
   312 }
       
   313 
       
   314 /*!
       
   315 Disables a specified feature for the prediction engine. 
       
   316 Returns true if the engine supports the feature and is able to disable the feature,
       
   317 otherwise, returns false.
       
   318 Note: There is temporary default implementation for this method. It will be made
       
   319 pure virtual after suitable transition period.
       
   320 
       
   321 \sa HbPredictionEngine::isFeatureEnabled()
       
   322 \sa HbPredictionEngine::enableFeature()
       
   323 */
       
   324 bool HbPredictionEngine::disableFeature(HbInputPredictionFeature feature)
       
   325 {
       
   326     Q_UNUSED(feature);
       
   327     return false;
       
   328 }
       
   329 
       
   330 /*!
       
   331 Returns list of next word candidates. The forms this list based on what has been
       
   332 written so far. This method will return candidates only if the engine
       
   333 supports next word prediction.
       
   334 
       
   335 \sa supportedFeatures
       
   336 */
       
   337 QStringList HbPredictionEngine::nextWordCandidateList(HbPredictionCallback* callback)
       
   338 {
       
   339     Q_UNUSED(callback);
       
   340     return QStringList();
       
   341 }
       
   342 
       
   343 /*!
       
   344 \class HbPredictionEngineChinese
       
   345 \brief Abstract API for predictive Chinese input.
       
   346 
       
   347 This interface extends predictiv einput abstraction layer with methods specific
       
   348 to predictive Chinese input. Those are mainly related to spelling candidates and candidate
       
   349 page handling.
       
   350 */
       
   351 
       
   352 // End of file