src/hbinput/inputwidgets/hbinput12keytouchkeypad.cpp
changeset 2 06ff229162e9
parent 1 f7ac710697a9
child 3 11d3954df52a
child 4 ae1717029441
equal deleted inserted replaced
1:f7ac710697a9 2:06ff229162e9
     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 HbInput 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 <QGraphicsGridLayout>
       
    27 #include <hbinputmethod.h>
       
    28 #include <hbinputkeymap.h>
       
    29 #include <hbinpututils.h>
       
    30 #include <hbframedrawer.h>
       
    31 #include <hbaction.h>
       
    32 #include "hbinputvkbwidget_p.h"
       
    33 #include "hbinput12keytouchkeypad.h"
       
    34 #include "hbinput12keytouchkeypad_p.h"
       
    35 #include "hbinputtouchkeypadbutton.h"
       
    36 
       
    37 const int HbVirtual12KeyNumberOfRows = 4;
       
    38 const int HbVirtual12KeyNumberOfColumn = 4;
       
    39 const int HbKey7Location = 6;
       
    40 const int HbKey9Location = 8;
       
    41 const qreal HbVirtual12KeyButtonPreferredHeight = 70.0;
       
    42 const QSizeF HbVirtual12KeyInitialLayoutDimensions(90.0, HbVirtual12KeyButtonPreferredHeight);
       
    43 const int HbButtonToKeyCodeTable[HbNum12KeypadBaseButtons] =
       
    44 {
       
    45     Qt::Key_1,
       
    46     Qt::Key_2,
       
    47     Qt::Key_3,
       
    48     Qt::Key_4,
       
    49     Qt::Key_5,
       
    50     Qt::Key_6,
       
    51     Qt::Key_7,
       
    52     Qt::Key_8,
       
    53     Qt::Key_9,
       
    54     Qt::Key_Asterisk,
       
    55     Qt::Key_0,
       
    56     Qt::Key_Shift,
       
    57     Qt::Key_Delete,
       
    58     Qt::Key_Control
       
    59 };
       
    60 
       
    61 const QString HbButtonObjName = "ITU ";
       
    62 const QString HbDelButtonObjName = "ITU delete";
       
    63 const QString HbCustomButtonObjName = "ITU custom button ";
       
    64 
       
    65 const QString Hb12KeyButtonTextLayout = "_hb_12key_button_text_layout";
       
    66 const QString Hb12KeyButtonIconLayout = "_hb_12key_button_icon_layout";
       
    67 const QString Hb12KeyButtonNumberLayout = "_hb_12key_button_number_layout";
       
    68 
       
    69 /*!
       
    70 @proto
       
    71 @hbinput
       
    72 \class Hb12KeyTouchKeypad
       
    73 \deprecated class Hb12KeyTouchKeypad
       
    74 \brief Touch keypad for 12 key ITU-T layout
       
    75 
       
    76 Implements touch key pad for 12 key ITU-T keypad. The key pad know how to operate
       
    77 in alphabet, numeric modes. it knows how to set up button titles according to
       
    78 given key map data object and it also supports editor specific custom buttons.
       
    79 
       
    80 \sa HbInputVkbWidget
       
    81 \sa HbTouchKeypadButton
       
    82 */
       
    83 
       
    84 Hb12KeyTouchKeypadPrivate::Hb12KeyTouchKeypadPrivate()
       
    85 : mKeypadCreated(false),
       
    86 mKeymapChanged(false)
       
    87 {
       
    88 }
       
    89 
       
    90 int Hb12KeyTouchKeypadPrivate::keyCode(int buttonId)
       
    91 {
       
    92     return HbButtonToKeyCodeTable[buttonId];
       
    93 }
       
    94 
       
    95 Hb12KeyTouchKeypadPrivate::~Hb12KeyTouchKeypadPrivate()
       
    96 {
       
    97 }
       
    98 
       
    99 void Hb12KeyTouchKeypadPrivate::setKeyMappingTitle(int key, HbTouchKeypadButton* button, HbModifiers modifiers)
       
   100 {
       
   101     QString title;
       
   102 
       
   103     int numberOfCharacters = 3;
       
   104     if (key == HbKey7Location || key == HbKey9Location) {
       
   105         numberOfCharacters = 4;
       
   106     }
       
   107 
       
   108     QString keydata = mKeymap->keyboard(HbKeyboardVirtual12Key)->keys.at(key)->characters(modifiers);
       
   109 
       
   110     QChar numChr = findFirstNumberCharacterBoundToKey(key);
       
   111 
       
   112     if(mOwner && mOwner->focusObject()) {
       
   113         // First we filter all the data that is mapped to the button, then get the firt 3/4 allowed characters and set that string
       
   114         // as additionaltext to button.
       
   115         QString allowedData;
       
   116         mOwner->focusObject()->filterStringWithEditorFilter(keydata,allowedData);
       
   117         title.append(allowedData.left(numberOfCharacters));
       
   118     } else {
       
   119         title.append(keydata.left(numberOfCharacters));
       
   120     }
       
   121 
       
   122     button->setVisible(true);
       
   123     button->setText(QString(numChr));
       
   124     button->setAdditionalText(title);
       
   125     button->setProperty(HbStyleRulesCacheId::hbStyleRulesForNodeCache, Hb12KeyButtonTextLayout);
       
   126 }
       
   127 
       
   128 void Hb12KeyTouchKeypadPrivate::setKeyMappingTitleNumeric(int key, HbTouchKeypadButton* button, HbModifiers modifiers)
       
   129 {
       
   130     Q_UNUSED(modifiers);
       
   131     QChar numChr = findFirstNumberCharacterBoundToKey(key);
       
   132 
       
   133     if (numChr > 0) {
       
   134         button->setText(numChr);
       
   135     } else {
       
   136         button->setText(QString());
       
   137     }
       
   138     button->setAdditionalText(QString());
       
   139     button->setProperty(HbStyleRulesCacheId::hbStyleRulesForNodeCache, Hb12KeyButtonNumberLayout);
       
   140 }
       
   141 
       
   142 void Hb12KeyTouchKeypadPrivate::createKeypad()
       
   143 {
       
   144     Q_Q(Hb12KeyTouchKeypad);
       
   145     for (int i = 0; i < HbNum12KeypadBaseButtons; i++) {
       
   146         if (i == 13) {
       
   147             HbIcon icon("qtg_mono_sym_itut");
       
   148             mButtons[i] = new HbTouchKeypadButton(q, icon, textForKey(i), q);
       
   149             mButtons[i]->setProperty(HbStyleRulesCacheId::hbStyleRulesForNodeCache, Hb12KeyButtonIconLayout);
       
   150         } else if ( i == 12) {
       
   151             HbIcon icon("qtg_mono_backspace2");
       
   152             mButtons[i] = new HbTouchKeypadButton(q, icon, textForKey(i), q);
       
   153             mButtons[i]->setAutoRepeatDelay(HbRepeatTimeout);
       
   154             mButtons[i]->setAutoRepeatInterval(HbRepeatTimeoutShort);
       
   155             mButtons[i]->setAutoRepeat(true);
       
   156             mButtons[i]->setProperty(HbStyleRulesCacheId::hbStyleRulesForNodeCache, Hb12KeyButtonIconLayout);
       
   157         } else if (i == 11) {
       
   158             HbIcon icon("qtg_mono_shift");
       
   159             mButtons[i] = new HbTouchKeypadButton(q, icon, textForKey(i), q);
       
   160         } else {
       
   161             mButtons[i] = new HbTouchKeypadButton(q, textForKey(i), q);
       
   162         }
       
   163         mButtons[i]->setAdditionalText(additionalTextForKey(i));
       
   164         QObject::connect(mButtons[i], SIGNAL(pressed()), mPressMapper, SLOT(map()));
       
   165         QObject::connect(mButtons[i], SIGNAL(released()), mReleaseMapper, SLOT(map()));
       
   166         mPressMapper->setMapping(mButtons[i], i);
       
   167         mReleaseMapper->setMapping(mButtons[i], i);
       
   168     }
       
   169 
       
   170     QObject::connect(mPressMapper, SIGNAL(mapped(int)), q, SLOT(mappedKeyPress(int)));
       
   171     QObject::connect(mReleaseMapper, SIGNAL(mapped(int)), q, SLOT(mappedKeyRelease(int)));
       
   172 
       
   173     mKeypadCreated = true;
       
   174 }
       
   175 
       
   176 QString Hb12KeyTouchKeypadPrivate::textForKey(int key)
       
   177 {
       
   178     // Key 10 is 0-key on keypad, which is defined as the ninth key
       
   179     // Key nine is the star key, which has "+" mapped to it
       
   180     if (key == 10) {
       
   181         key = 9;
       
   182     } else if (key == 9) {
       
   183         return QString("+");
       
   184     } else if(key ==11) {
       
   185         return QString("#");
       
   186     }
       
   187     if (key >= mKeymap->keyboard(HbKeyboardVirtual12Key)->keys.count()) {
       
   188         return QString();
       
   189     }
       
   190     QChar numChr = findFirstNumberCharacterBoundToKey(key);
       
   191     if (!numChr.isNull()) {
       
   192         return QString(numChr);
       
   193     } else {
       
   194         return QString();
       
   195     }
       
   196 }
       
   197 
       
   198 QString Hb12KeyTouchKeypadPrivate::additionalTextForKey(int key)
       
   199 {
       
   200     // Key 10 is 0-key on keypad, which is defined as the ninth key
       
   201     // Key nine is the star key, "*" mapped to it
       
   202     if (key == 10) {
       
   203         key = 9;
       
   204     } else if (key == 9) {
       
   205         return QString("*");
       
   206     }  else if (key == 11) {
       
   207         return QString();
       
   208     }
       
   209 
       
   210     if (key >= mKeymap->keyboard(HbKeyboardVirtual12Key)->keys.count()) {
       
   211         return QString();
       
   212     }
       
   213 
       
   214     if (mMode == EModeNumeric) {
       
   215         return QString();
       
   216     } else {
       
   217         QString title;
       
   218 
       
   219         int numberOfCharacters = 3;
       
   220         if (key == 6 || key == 8) {
       
   221             numberOfCharacters = 4;
       
   222         }
       
   223 
       
   224         QString keydata = mKeymap->keyboard(HbKeyboardVirtual12Key)->keys.at(key)->characters(mModifiers);
       
   225 
       
   226         title.append(keydata.left(numberOfCharacters));
       
   227 
       
   228         return title;
       
   229     }
       
   230 }
       
   231 
       
   232 int Hb12KeyTouchKeypadPrivate::keyCode(HbTouchKeypadButton *button)
       
   233 {
       
   234     int keycode = -1;
       
   235     for (int i = 0; i < HbNum12KeypadBaseButtons; i++) {
       
   236         if(button->text() == textForKey(i)) {
       
   237             keycode = i+1;
       
   238             break;
       
   239         }
       
   240     }
       
   241     return keycode;
       
   242 }
       
   243 
       
   244 void Hb12KeyTouchKeypadPrivate::createLayout()
       
   245 {
       
   246     Q_Q(Hb12KeyTouchKeypad);
       
   247 
       
   248     // The layout is already created. So just return.
       
   249     if ( mButtonLayout ) {
       
   250         return;
       
   251     }
       
   252 
       
   253     mButtonLayout = new QGraphicsGridLayout();
       
   254     q->setContentsMargins(0.0, 0.0, 0.0, 0.0);
       
   255     mButtonLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0);
       
   256     mButtonLayout->setHorizontalSpacing(HorizontalSpacing);
       
   257     mButtonLayout->setVerticalSpacing(VerticalSpacing);
       
   258 
       
   259     mButtonLayout->addItem(mButtons[0], 0, 0);    // key 1
       
   260     mButtonLayout->addItem(mButtons[1], 0, 1);    // key 2
       
   261     mButtonLayout->addItem(mButtons[2], 0, 2);    // key 3
       
   262     mButtonLayout->addItem(mButtons[12], 0, 3);   // key delete
       
   263     mButtonLayout->addItem(mButtons[3], 1, 0);    // key 4
       
   264     mButtonLayout->addItem(mButtons[4], 1, 1);    // key 5
       
   265     mButtonLayout->addItem(mButtons[5], 1, 2);    // key 6
       
   266     mButtonLayout->addItem(mButtons[6], 2, 0);    // key 7
       
   267     mButtonLayout->addItem(mButtons[7], 2, 1);    // key 8
       
   268     mButtonLayout->addItem(mButtons[8], 2, 2);    // key 9
       
   269     mButtonLayout->addItem(mButtons[9], 3, 0);    // key sym
       
   270     mButtonLayout->addItem(mButtons[10], 3, 1);   // key 0
       
   271     mButtonLayout->addItem(mButtons[11], 3, 2);   // key #
       
   272     mButtonLayout->addItem(mButtons[13], 1, 3);   // key sym (second)
       
   273     mButtonLayout->addItem(mSettingsButton, 2, 3);   // Settings key
       
   274     mButtonLayout->addItem(mApplicationButton, 3, 3);   // Application specific key
       
   275 
       
   276     mButtons[0]->setObjectName(HbButtonObjName + "1,1");
       
   277     mButtons[1]->setObjectName(HbButtonObjName + "1,2");
       
   278     mButtons[2]->setObjectName(HbButtonObjName + "1,3");
       
   279     mButtons[3]->setObjectName(HbButtonObjName + "2,1");
       
   280     mButtons[4]->setObjectName(HbButtonObjName + "2,2");
       
   281     mButtons[5]->setObjectName(HbButtonObjName + "2,3");
       
   282     mButtons[6]->setObjectName(HbButtonObjName + "3,1");
       
   283     mButtons[7]->setObjectName(HbButtonObjName + "3,2");
       
   284     mButtons[8]->setObjectName(HbButtonObjName + "3,3");
       
   285     mButtons[9]->setObjectName(HbButtonObjName + "4,1");
       
   286     mButtons[10]->setObjectName(HbButtonObjName + "4,2");
       
   287     mButtons[11]->setObjectName(HbButtonObjName + "4,3");
       
   288     mButtons[12]->setObjectName(HbDelButtonObjName);
       
   289     mButtons[13]->setObjectName(HbCustomButtonObjName + QString::number(1));
       
   290     if (mSettingsButton) {
       
   291         mSettingsButton->setObjectName(HbCustomButtonObjName + QString::number(2));
       
   292     }
       
   293     if (mApplicationButton) {
       
   294         mApplicationButton->setObjectName(HbCustomButtonObjName + QString::number(3));
       
   295     }
       
   296 
       
   297     mButtons[12]->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction);
       
   298     mButtons[11]->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction);
       
   299     mButtons[9]->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction);
       
   300     mButtons[13]->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction);
       
   301     mButtons[12]->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
       
   302     mButtons[11]->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
       
   303     mButtons[9]->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
       
   304     mButtons[13]->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
       
   305 }
       
   306 
       
   307 /*!
       
   308 Apply editor constraints to the vkb
       
   309 */
       
   310 void Hb12KeyTouchKeypadPrivate::applyEditorConstraints()
       
   311 {
       
   312     HbInputFocusObject *focusedObject = 0;
       
   313     if (mOwner) {
       
   314         focusedObject = mOwner->focusObject();
       
   315     }
       
   316 
       
   317     if(!focusedObject || isKeyboardDimmed()) {
       
   318     // dont need to apply constraints when keypad is dimmed.
       
   319     // applyEditorConstraints will be called from setKeyboardDimmed(false)
       
   320         return;
       
   321     }
       
   322 
       
   323     for (int i = 0; i < HbNum12KeypadBaseButtons ; i++) {
       
   324         if(Hb::ItemType_InputCharacterButton == mButtons[i]->type()) {
       
   325             bool disableButton = false;
       
   326             if(EModeNumeric == mMode){
       
   327                 QString data  = mButtons[i]->text();
       
   328                 if (data.isEmpty() || !focusedObject->characterAllowedInEditor(data[0])) {
       
   329                     disableButton = true;
       
   330                 }
       
   331             } else if(EModeAbc == mMode) {
       
   332                 if((mButtons[i]->additionalText()).isEmpty() ) {
       
   333                     disableButton = true;
       
   334                 }
       
   335             }
       
   336             mButtons[i]->setFade(disableButton);
       
   337         }
       
   338     }
       
   339 
       
   340 	QString allowedSctCharacters;
       
   341 	getAllowedSctCharcters(allowedSctCharacters);
       
   342 	if (allowedSctCharacters.isNull() && (Qt::ImhDigitsOnly & focusedObject->inputMethodHints())) {
       
   343 		mButtons[9]->setFade(true);
       
   344 		mButtons[11]->setFade(true);
       
   345 		mButtons[13]->setFade(true);
       
   346 	}
       
   347 	else if (Qt::ImhDialableCharactersOnly & focusedObject->inputMethodHints()) {
       
   348 		mButtons[9]->setFade(false);
       
   349 		mButtons[11]->setFade(false);
       
   350 		mButtons[13]->setFade(true);
       
   351 	}
       
   352 	else {
       
   353 		mButtons[9]->setFade(false);
       
   354 		mButtons[11]->setFade(false);
       
   355 		mButtons[13]->setFade(false);
       
   356 	}
       
   357 }
       
   358 /*! returns first number character mapped bound to the key
       
   359 */
       
   360 
       
   361 QChar Hb12KeyTouchKeypadPrivate::findFirstNumberCharacterBoundToKey(int key)
       
   362 {
       
   363     QChar numChr = 0;
       
   364     if (!mKeymap) {
       
   365         return numChr;
       
   366     }
       
   367 	
       
   368     HbInputLanguage language = mKeymap->language();
       
   369 	HbInputFocusObject *focusObject = 0;
       
   370 
       
   371 	if (mOwner) {
       
   372         focusObject = mOwner->focusObject();
       
   373 	}
       
   374 	bool isNumericEditor = false;
       
   375 
       
   376 	if (focusObject) {
       
   377         isNumericEditor = focusObject->editorInterface().isNumericEditor();
       
   378 	}
       
   379 	
       
   380     HbInputDigitType digitType = HbInputUtils::inputDigitType(language);
       
   381 
       
   382     if (language.language()  != (QLocale::Language)0) {
       
   383         if (isNumericEditor) {
       
   384             QLocale::Language systemLanguage = QLocale::system().language();
       
   385             // show native digits only when the device language and writing language are same, 
       
   386             // else show latin digits
       
   387             if (language.language() != systemLanguage) {
       
   388                 digitType = HbDigitTypeLatin;
       
   389             }	
       
   390         }	
       
   391         numChr = HbInputUtils::findFirstNumberCharacterBoundToKey(mKeymap->keyboard(HbKeyboardVirtual12Key)->keys.at(key),
       
   392             language, digitType);
       
   393     }
       
   394     return numChr;
       
   395 }
       
   396 
       
   397 /*!
       
   398 Get the allowed sct Characters
       
   399 */
       
   400 void Hb12KeyTouchKeypadPrivate::getAllowedSctCharcters(QString& allowedSctCharacters)
       
   401 {
       
   402 	QString sctCharacters;
       
   403 	if (mKeymap) {
       
   404 		const HbKeyboardMap* keymap = mKeymap->keyboard(HbKeyboardSctPortrait);
       
   405 		if (keymap == 0) {
       
   406 			return;
       
   407 		}
       
   408 		foreach (const HbMappedKey* mappedKey, keymap->keys) {
       
   409 			sctCharacters.append(mappedKey->characters(HbModifierNone));
       
   410 		}
       
   411 	}
       
   412 	HbInputFocusObject* focusObject = mOwner->focusObject();
       
   413 	QString tempAllowedSctCharacters;
       
   414 	if (focusObject) {
       
   415 		focusObject->filterStringWithEditorFilter(sctCharacters,tempAllowedSctCharacters);
       
   416 	}
       
   417 	allowedSctCharacters.clear();
       
   418 	for(int i=0; i<tempAllowedSctCharacters.length() ;i++) {
       
   419 		// dont add duplicates to the list
       
   420 		if(!allowedSctCharacters.contains(tempAllowedSctCharacters[i])) {
       
   421 			allowedSctCharacters.append(tempAllowedSctCharacters[i]);
       
   422 		}
       
   423 	}
       
   424 }
       
   425 
       
   426 /*!
       
   427 \deprecated Hb12KeyTouchKeypad::Hb12KeyTouchKeypad(HbInputMethod*, QGraphicsItem*)
       
   428      is deprecated.
       
   429 Constructs the object.
       
   430 */
       
   431 Hb12KeyTouchKeypad::Hb12KeyTouchKeypad(HbInputMethod* aOwner,
       
   432                                        QGraphicsItem* aParent)
       
   433                                        : HbInputVkbWidget(*new Hb12KeyTouchKeypadPrivate, aParent)
       
   434 {
       
   435     if (0 == aOwner) {
       
   436         return;
       
   437     }
       
   438     Q_D(Hb12KeyTouchKeypad);
       
   439     d->q_ptr = this;
       
   440     d->mOwner = aOwner;
       
   441 }
       
   442 
       
   443 /*!
       
   444 \deprecated Hb12KeyTouchKeypad::keyboardType() const
       
   445     is deprecated.
       
   446 Returns keyboard type.
       
   447 */
       
   448 HbKeyboardType Hb12KeyTouchKeypad::keyboardType() const
       
   449 {
       
   450     return HbKeyboardVirtual12Key;
       
   451 }
       
   452 
       
   453 /*!
       
   454 \deprecated Hb12KeyTouchKeypad::~Hb12KeyTouchKeypad()
       
   455     is deprecated.
       
   456 Destructs the object.
       
   457 */
       
   458 Hb12KeyTouchKeypad::~Hb12KeyTouchKeypad()
       
   459 {
       
   460 }
       
   461 
       
   462 /*!
       
   463 \deprecated Hb12KeyTouchKeypad::mappedKeyPress(int)
       
   464     is deprecated.
       
   465 Handles virtual key press
       
   466 */
       
   467 void Hb12KeyTouchKeypad::mappedKeyPress(int buttonid)
       
   468 {
       
   469     Q_D(Hb12KeyTouchKeypad);
       
   470 	if(buttonid >= 0 && d->mButtons[buttonid] && !d->mButtons[buttonid]->isFaded()) {
       
   471         HbInputVkbWidget::mappedKeyPress(buttonid);
       
   472     }
       
   473 }
       
   474 
       
   475 /*!
       
   476 \deprecated Hb12KeyTouchKeypad::mappedKeyRelease(int)
       
   477     is deprecated.
       
   478 Handles virtual key release
       
   479 */
       
   480 void Hb12KeyTouchKeypad::mappedKeyRelease(int buttonid)
       
   481 {
       
   482     Q_D(Hb12KeyTouchKeypad);
       
   483     if(buttonid >= 0 && d->mButtons[buttonid] && !d->mButtons[buttonid]->isFaded()) {
       
   484         HbInputVkbWidget::mappedKeyRelease(buttonid);
       
   485     }
       
   486 }
       
   487 /*!
       
   488 \deprecated Hb12KeyTouchKeypad::setMode(HbKeypadMode, QFlags<HbModifier>)
       
   489     is deprecated.
       
   490 Sets the keypad to given mode. Possible values are EModeAbc, EModeNumeric and EModeSct.
       
   491 */
       
   492 void Hb12KeyTouchKeypad::setMode(HbKeypadMode mode, HbModifiers modifiers)
       
   493 {
       
   494     Q_D(Hb12KeyTouchKeypad);
       
   495     d->mModifiers = modifiers;
       
   496     d->mMode = mode;
       
   497 
       
   498     if (!d->mKeypadCreated) {
       
   499         d->createKeypad();
       
   500         setupToolCluster();
       
   501         d->createLayout();
       
   502         d->applyEditorConstraints();
       
   503         return;
       
   504     }
       
   505     setupToolCluster();
       
   506     if (mode == EModeNumeric) {
       
   507         d->setKeyMappingTitleNumeric(0, d->mButtons[0], 0);
       
   508         d->setKeyMappingTitleNumeric(1, d->mButtons[1], 0);
       
   509         d->setKeyMappingTitleNumeric(2, d->mButtons[2], 0);
       
   510         d->setKeyMappingTitleNumeric(3, d->mButtons[3], 0);
       
   511         d->setKeyMappingTitleNumeric(4, d->mButtons[4], 0);
       
   512         d->setKeyMappingTitleNumeric(5, d->mButtons[5], 0);
       
   513         d->setKeyMappingTitleNumeric(6, d->mButtons[6], 0);
       
   514         d->setKeyMappingTitleNumeric(7, d->mButtons[7], 0);
       
   515         d->setKeyMappingTitleNumeric(8, d->mButtons[8], 0);
       
   516         d->setKeyMappingTitleNumeric(9, d->mButtons[10], 0);
       
   517     } else {
       
   518         if (d->mKeymap) {
       
   519             d->setKeyMappingTitle(0, d->mButtons[0], d->mModifiers);
       
   520             d->setKeyMappingTitle(1, d->mButtons[1], d->mModifiers);
       
   521             d->setKeyMappingTitle(2, d->mButtons[2], d->mModifiers);
       
   522             d->setKeyMappingTitle(3, d->mButtons[3], d->mModifiers);
       
   523             d->setKeyMappingTitle(4, d->mButtons[4], d->mModifiers);
       
   524             d->setKeyMappingTitle(5, d->mButtons[5], d->mModifiers);
       
   525             d->setKeyMappingTitle(6, d->mButtons[6], d->mModifiers);
       
   526             d->setKeyMappingTitle(7, d->mButtons[7], d->mModifiers);
       
   527             d->setKeyMappingTitle(8, d->mButtons[8], d->mModifiers);
       
   528             d->setKeyMappingTitle(9, d->mButtons[10], d->mModifiers);
       
   529         } else {
       
   530             // Default fallback.
       
   531             d->mButtons[0]->setText(QString(".,!"));
       
   532             d->mButtons[1]->setText(QString("abc"));
       
   533             d->mButtons[2]->setText(QString("def"));
       
   534             d->mButtons[3]->setText(QString("ghi"));
       
   535             d->mButtons[4]->setText(QString("jkl"));
       
   536             d->mButtons[5]->setText(QString("mno"));
       
   537             d->mButtons[6]->setText(QString("pqrs"));
       
   538             d->mButtons[7]->setText(QString("tuv"));
       
   539             d->mButtons[8]->setText(QString("wxyz"));
       
   540             d->mButtons[10]->setText(QString("0_"));
       
   541         }
       
   542     }
       
   543 
       
   544     d->applyEditorConstraints();
       
   545 }
       
   546 
       
   547 /*!
       
   548 \reimp
       
   549 \deprecated Hb12KeyTouchKeypad::setKeymap(const HbKeymap*)
       
   550     is deprecated.
       
   551 */
       
   552 void Hb12KeyTouchKeypad::setKeymap(const HbKeymap* keymap)
       
   553 {
       
   554     Q_D(Hb12KeyTouchKeypad);
       
   555     if (keymap) {
       
   556         d->mKeymap = keymap;
       
   557         d->mKeymapChanged = true;
       
   558         // let's change the button text depending on the new keymapping.
       
   559         HbInputState newState = d->mOwner->inputState();
       
   560         if (newState.textCase() == HbTextCaseUpper || newState.textCase() == HbTextCaseAutomatic) {
       
   561             setMode(d->mMode, HbModifierShiftPressed);
       
   562         } else {
       
   563             setMode(d->mMode, HbModifierNone);
       
   564         }
       
   565         d->mKeymapChanged = false;
       
   566     }
       
   567 }
       
   568 
       
   569 /*!
       
   570 \reimp
       
   571 \deprecated Hb12KeyTouchKeypad::aboutToOpen(HbVkbHost*)
       
   572     is deprecated.
       
   573 */
       
   574 void Hb12KeyTouchKeypad::aboutToOpen(HbVkbHost *host)
       
   575 {
       
   576     Q_D(Hb12KeyTouchKeypad);
       
   577 
       
   578     HbInputVkbWidget::aboutToOpen(host);
       
   579 
       
   580     QSizeF keypadSize = keypadButtonAreaSize();
       
   581 
       
   582     keypadSize.setWidth(keypadSize.width() / (qreal)HbVirtual12KeyNumberOfColumn);
       
   583     keypadSize.setHeight(keypadSize.height() / (qreal)HbVirtual12KeyNumberOfRows);
       
   584 
       
   585     for (int i=0; i < 4 ;i++) {
       
   586         d->mButtonLayout->setColumnFixedWidth(i, keypadSize.width());
       
   587         d->mButtonLayout->setRowFixedHeight(i, keypadSize.height());
       
   588     }
       
   589 
       
   590     for (int i = 0; i < HbNum12KeypadBaseButtons; ++i) {
       
   591         d->mButtons[i]->setInitialSize(keypadSize);
       
   592     }
       
   593     if (d->mSettingsButton) {
       
   594         d->mSettingsButton->setInitialSize(keypadSize);
       
   595     }
       
   596     if (d->mApplicationButton) {
       
   597         d->mApplicationButton->setInitialSize(keypadSize);
       
   598     }
       
   599 
       
   600 }
       
   601 
       
   602 /*!
       
   603 \deprecated Hb12KeyTouchKeypad::initSctModeList()
       
   604     is deprecated. Sct mode list is not supported anymore.
       
   605 */
       
   606 void Hb12KeyTouchKeypad::initSctModeList()
       
   607 {
       
   608 }
       
   609 
       
   610 /*!
       
   611 \deprecated Hb12KeyTouchKeypad::sctModeListClosed()
       
   612     is deprecated. Sct mode list is not supported anymore.
       
   613 */
       
   614 void Hb12KeyTouchKeypad::sctModeListClosed()
       
   615 {
       
   616 }
       
   617 
       
   618 // End of file