src/hbcore/inputfw/hbinputpredictionengine.h
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 #ifndef HB_PREDICTION_ENGINE_H
       
    27 #define HB_PREDICTION_ENGINE_H
       
    28 
       
    29 #include <QStringList>
       
    30 #include <QKeyEvent>
       
    31 
       
    32 #include <hbinputlanguage.h>
       
    33 
       
    34 class HbUserDictionary;
       
    35 class HbPredictionCallback;
       
    36 struct HbKeyPressProbability;
       
    37 
       
    38 /*!
       
    39 Enumerates bits for predictione engine features.
       
    40 */
       
    41 enum HbInputPredictionFeatureFlag {
       
    42     HbPredFeatureNone               = 0x00000000,
       
    43     HbPredFeatureReordering         = 0x00000001,  /**< Candidates are reordered accoriding to the frequency. */
       
    44     HbPredFeatureUserDictionary     = 0x00000002,  /**< User dictionary is used for storing user specific words. */
       
    45     HbPredFeatureWordCompletion     = 0x00000004,  /**< Auto word completion feature is used. */
       
    46     HbPredFeatureNextWordPrediction = 0x00000008,  /**< Next word prediction feature is used. */
       
    47     HbPredFeatureExtraDictionaries  = 0x00000010,  /**< The engine supports additional language databases. */
       
    48     HbPredfeatureErrorCorrection    = 0x00000020   /**< The engine supports typing correction feature. */
       
    49 };
       
    50 
       
    51 Q_DECLARE_FLAGS(HbInputPredictionFeature, HbInputPredictionFeatureFlag)
       
    52 
       
    53 /*!
       
    54 Enumerates bits for prediction engine interface types
       
    55 */
       
    56 enum HbPredictionInterfaceTypeFlag {
       
    57     HbPredInterfaceNone       = 0x00000000,
       
    58     HbPredInterfaceLatinBased = 0x00000001,
       
    59     HbPredInterfaceChinese    = 0x00000002,
       
    60     HbPredInterfaceJapanese   = 0x00000004,
       
    61     HbPredInterfaceHidden     = 0x00000008     /**< The engine is exluded from factory queries and must be instantiated directly */
       
    62 };
       
    63 
       
    64 Q_DECLARE_FLAGS(HbPredictionInterfaceType, HbPredictionInterfaceTypeFlag)
       
    65 
       
    66 
       
    67 class HB_CORE_EXPORT HbPredictionBase
       
    68 {        
       
    69 public:
       
    70     virtual ~HbPredictionBase();
       
    71 
       
    72 protected:
       
    73     HbPredictionBase();
       
    74 
       
    75 public:
       
    76     virtual QList<HbInputLanguage> languages() const = 0;
       
    77     virtual void setWord(const QString& word, HbPredictionCallback* callback = 0) = 0;
       
    78     virtual void updateCandidates(int& bestGuessLocation, bool& noMoreCandidates) = 0;
       
    79     virtual void appendKeyPress(const int keycode, const Qt::KeyboardModifiers modifiers, const HbTextCase textCase = HbTextCaseNone, HbPredictionCallback* callback = 0) = 0;
       
    80     virtual void deleteKeyPress(HbPredictionCallback* callback = 0) = 0;
       
    81     virtual void commit(const QString &word = QString()) = 0;
       
    82     virtual void clear() = 0;
       
    83     virtual void addUsedWord(const QString& word) = 0;
       
    84     virtual HbInputPredictionFeature features() const = 0;
       
    85     virtual QString vendorIdString() const = 0;
       
    86     virtual QString engineVersion() const = 0;
       
    87     virtual bool supportsKeyboardType(const HbInputLanguage& language, HbKeyboardType keyboard) const = 0;
       
    88 
       
    89     virtual HbUserDictionary* userDictionary() const;
       
    90     virtual void setExtraUserDictionary(int id);
       
    91     virtual void setExtraUserDictionaries(const QList<int>& idList);
       
    92     virtual bool setLanguage(const HbInputLanguage &language, HbInputModeType inputMode = HbInputModeNone);
       
    93     virtual HbInputLanguage language() const;
       
    94     virtual void setKeyboard(HbKeyboardType keyboardType) = 0;
       
    95     virtual HbKeyboardType keyboardType() const;
       
    96 };
       
    97 
       
    98 
       
    99 class HB_CORE_EXPORT HbPredictionEngine : public HbPredictionBase
       
   100 {
       
   101 public:
       
   102     /*!
       
   103     Specifies error correction levels. 
       
   104     */
       
   105     enum HbErrorCorrectionLevel {
       
   106         HbErrorCorrectionLevelNone = 0,
       
   107         HbErrorCorrectionLevelLow,
       
   108         HbErrorCorrectionLevelMedium,
       
   109         HbErrorCorrectionLevelHigh
       
   110     };
       
   111 
       
   112 public:
       
   113     virtual void setCandidateList(QStringList* candidateList) = 0;
       
   114     virtual QStringList candidateList() = 0;
       
   115     virtual int inputLength() = 0;
       
   116     virtual void appendCharacter(const QChar aChar, const HbTextCase textCase = HbTextCaseNone, HbPredictionCallback* callback = 0) = 0;
       
   117 
       
   118     virtual QStringList nextWordCandidateList(HbPredictionCallback* callback = 0);
       
   119     virtual bool setErrorCorrectionLevel(HbErrorCorrectionLevel level);
       
   120     virtual HbErrorCorrectionLevel errorCorrectionLevel() const;
       
   121     virtual bool setSecondaryLanguage(const HbInputLanguage& language);
       
   122     virtual HbInputLanguage secondaryLanguage() const;
       
   123     virtual QString currentWord() const;
       
   124     virtual bool enableFeature(HbInputPredictionFeature feature);
       
   125     virtual bool isFeatureEnabled(HbInputPredictionFeature feature);
       
   126     virtual bool disableFeature(HbInputPredictionFeature feature);
       
   127 };
       
   128 
       
   129 
       
   130 class HB_CORE_EXPORT HbPredictionEngineChinese : public HbPredictionEngine
       
   131 {
       
   132 public:
       
   133     virtual void setInputMode(HbInputModeType imMode) = 0;
       
   134     virtual HbInputModeType inputMode() const = 0;
       
   135 
       
   136     virtual bool spelling(int index, QString &out) = 0;
       
   137     virtual bool selectSpelling(int index) = 0;
       
   138     virtual QStringList allSpellings() = 0;
       
   139     virtual int spellingCount() const = 0;
       
   140 
       
   141     virtual QStringList getCandidates(int startIndex, int count) = 0;
       
   142     virtual bool selectCandidate(int index) = 0;
       
   143     virtual bool selectCandidate(const QString& candidate) = 0; 
       
   144     virtual bool candidateExist(int index) = 0;
       
   145 
       
   146     virtual bool pressKey(const int keycode, const Qt::KeyboardModifiers modifiers, const int textCase = 0) = 0;
       
   147     virtual bool isInputModeSupported(HbInputModeType imMode) = 0;
       
   148     // used for hwr engine
       
   149     virtual bool addStroke(const QList<QPointF>& traceData) = 0;
       
   150     virtual bool inlineSpelling(int idx, QString &out) = 0;
       
   151 };
       
   152 
       
   153 #endif // HB_PREDICTION_ENGINE
       
   154 
       
   155 // End of file