logsui/logscntfinder/src/logspredictivelatin12keytranslator.cpp
changeset 2 7119b73b84d6
child 4 e52d42f9500c
equal deleted inserted replaced
0:4a5361db8937 2:7119b73b84d6
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 #include <QObject>
       
    18 #include <QLocale>
       
    19 #include <QHash>
       
    20 #include <hbinputkeymapfactory.h>
       
    21 #include <hbinputkeymap.h>
       
    22 #include <hbinputsettingproxy.h>
       
    23 
       
    24 #include "logspredictivelatin12keytranslator.h"
       
    25 #include "logslogger.h"
       
    26 
       
    27 //mapping char,key(name)
       
    28 const QChar SpecialMapping[] = {'+', '*', '*', '*','#','#'};
       
    29 const int SpecialsCount = 3;
       
    30 const QChar SpaceSepar(' ');
       
    31 
       
    32 
       
    33 // -----------------------------------------------------------------------------
       
    34 // LogsPredictiveLatin12KeyTranslator::LogsPredictiveLatin12KeyTranslator()
       
    35 // -----------------------------------------------------------------------------
       
    36 //
       
    37 LogsPredictiveLatin12KeyTranslator::LogsPredictiveLatin12KeyTranslator()
       
    38     : LogsPredictive12KeyTranslator()
       
    39 {
       
    40     LOGS_QDEBUG( "logs [FINDER] -> LogsPredictiveLatin12KeyTranslator::\
       
    41 LogsPredictiveLatin12KeyTranslator()" )
       
    42     HbInputLanguage lang = 
       
    43             HbInputSettingProxy::instance()->globalInputLanguage();
       
    44     mKeyMap = HbKeymapFactory::instance()->keymap( lang.language(), 
       
    45                                                    lang.variant() );
       
    46     
       
    47     int index = 0;
       
    48     int arraySize = SpecialsCount * 2;
       
    49     while( index < arraySize ) {
       
    50         QChar character = SpecialMapping[ index++ ];
       
    51         QChar keycode = SpecialMapping[ index++ ];
       
    52         mSpecialKeyMap[ character ] = keycode;
       
    53     }
       
    54     
       
    55     LOGS_QDEBUG( "logs [FINDER] <- LogsPredictiveLatin12KeyTranslator::\
       
    56 LogsPredictiveLatin12KeyTranslator()" )
       
    57 }
       
    58 
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // LogsPredictiveLatin12KeyTranslator::~LogsPredictiveLatin12KeyTranslator()
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 LogsPredictiveLatin12KeyTranslator::~LogsPredictiveLatin12KeyTranslator()
       
    65 {
       
    66     LOGS_QDEBUG( "logs [FINDER] -> LogsPredictiveLatin12KeyTranslator::\
       
    67 ~LogsPredictiveLatin12KeyTranslator()" )
       
    68     mSpecialKeyMap.clear();
       
    69     LOGS_QDEBUG( "logs [FINDER] <- LogsPredictiveLatin12KeyTranslator::\
       
    70 ~LogsPredictiveLatin12KeyTranslator()" )
       
    71     
       
    72 }
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // LogsPredictiveLatin12KeyTranslator::translateChar()
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 const QChar LogsPredictiveLatin12KeyTranslator::translateChar( 
       
    79                                                     const QChar character ) const
       
    80 {
       
    81     QChar keycode = mSpecialKeyMap[ character ]; 
       
    82     if ( keycode.isNull() ) {
       
    83         keycode = LogsPredictive12KeyTranslator::translateChar( character );
       
    84         if ( keycode.isNull() ) {
       
    85             QString decomposed = character.decomposition();
       
    86             if (decomposed.isEmpty()) {
       
    87                 return keycode;
       
    88             }
       
    89             return translateChar (decomposed.at(0));
       
    90         }
       
    91     }
       
    92     return keycode;
       
    93 }
       
    94 
       
    95 
       
    96 
       
    97 // -----------------------------------------------------------------------------
       
    98 // LogsPredictiveLatin12KeyTranslator::nameTokens()
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 QStringList LogsPredictiveLatin12KeyTranslator::nameTokens( 
       
   102                                                     const QString& name ) const
       
   103 {
       
   104     return name.split( SpaceSepar, QString::SkipEmptyParts );
       
   105 }
       
   106