src/hbinput/inputwidgets/hbinputsctlandscape.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 <QSignalMapper>
       
    28 #include <QKeyEvent>
       
    29 #include <math.h>
       
    30 
       
    31 #include <hbinstance.h>
       
    32 #include <hbinputmethod.h>
       
    33 #include <hbinputkeymap.h>
       
    34 #include <hbinputsettingproxy.h>
       
    35 #include <hbabstractedit.h>
       
    36 
       
    37 #include "hbinputsctlandscape.h"
       
    38 #include "hbinputtouchkeypadbutton.h"
       
    39 #include "hbinputvkbwidget.h"
       
    40 #include "hbinputcharpreviewpane.h"
       
    41 
       
    42 // private includes
       
    43 #include "hbinputsctlandscape_p.h"
       
    44 #include "hbinputvkbwidget_p.h"
       
    45 
       
    46 /*!
       
    47     @proto
       
    48     @hbinput
       
    49     \class HbInputSctLandscape
       
    50     \deprecated class HbInputSctLandscape
       
    51     \brief A widget for displaying special character table in landscape mode.
       
    52     
       
    53     This widget displays special character table. Characters are organized in grid
       
    54     format and there is also separate are for displaying most frquently used special
       
    55     characters. The widget inherits from touch keypad base class. When a character
       
    56     is selected it will emit signal sctCharacterSelected.
       
    57     
       
    58     \sa HbInputVkbWidget
       
    59 */
       
    60 
       
    61 /// @cond
       
    62 
       
    63 const int HbSctNumberOfColumns = 10;
       
    64 const int HbSctNumberOfRows = 4;
       
    65 const int HbNumberOfSctButtons = 39;
       
    66 // this includes space and other buttons which are not going to be part of the special characters
       
    67 const int HbNumberOfOtherButtons = 7;
       
    68 const qreal HbSctButtonPreferredHeight = 52.5;
       
    69 const QSizeF HbSctInitialDimensions(64.0, HbSctButtonPreferredHeight);
       
    70 
       
    71 const QString HbSctLandscapeButtonTextLayout = "_hb_sctl_button_text_layout";
       
    72 const QString HbSctLandscapeButtonIconLayout = "_hb_sctl_button_icon_layout";
       
    73 
       
    74 const int HbSmileyRangeButton = Qt::Key_F1;
       
    75 const int HbSpecialCharacterRangeButton = Qt::Key_F2;
       
    76 const QString HbSmileyButtonObjName = "SCT smiley";
       
    77 const int HbSmileyButtonIndex = 9;
       
    78 struct HbVirtualSctKey
       
    79 {
       
    80     int mKey;
       
    81     int mRow;
       
    82     int mColumn;
       
    83     int mRowSpan;
       
    84     int mColumnSpan;
       
    85 };
       
    86 
       
    87 // this is a template keymapping table which will be used to 
       
    88 // layout buttons. Qt::Key_Question represnts a button which can 
       
    89 // be mapped to a special character / Smiley.
       
    90 HbVirtualSctKey sctVkbTable[] =
       
    91 {
       
    92     // first row
       
    93     {Qt::Key_Question,0,0,1,1 },
       
    94     {Qt::Key_Question,0,1,1,1 },
       
    95     {Qt::Key_Question,0,2,1,1 },
       
    96     {Qt::Key_Question,0,3,1,1 },
       
    97     {Qt::Key_Question,0,4,1,1 },
       
    98     {Qt::Key_Question,0,5,1,1 },
       
    99     {Qt::Key_Question,0,6,1,1},
       
   100     {Qt::Key_Question,0,7,1,1},
       
   101     {Qt::Key_Question,0,8,1,1},
       
   102     // Smiley button
       
   103     {Qt::Key_F1,0,9,1,1},
       
   104 
       
   105     // seKey_Questioncond row
       
   106     {Qt::Key_Question,1,0,1,1 },
       
   107     {Qt::Key_Question,1,1,1,1 },
       
   108     {Qt::Key_Question,1,2,1,1 },
       
   109     {Qt::Key_Question,1,3,1,1 },
       
   110     {Qt::Key_Question,1,4,1,1 },
       
   111     {Qt::Key_Question,1,5,1,1 },
       
   112     {Qt::Key_Question,1,6,1,1 },
       
   113     {Qt::Key_Question ,1,7,1,1 },
       
   114     {Qt::Key_Question,1,8,1,1 },
       
   115     {Qt::Key_Backspace, 1, 9, 1, 1 },
       
   116 
       
   117     // third row
       
   118     {Qt::Key_Question,2,0,1,1 },
       
   119     {Qt::Key_Question,2,1,1,1 },
       
   120     {Qt::Key_Question,2,2,1,1 },
       
   121     {Qt::Key_Question,2,3,1,1 },
       
   122     {Qt::Key_Question,2,4,1,1 },
       
   123     {Qt::Key_Question,2,5,1,1 },
       
   124     {Qt::Key_Question,2,6,1,1 },
       
   125     {Qt::Key_Question,2,7,1,1 },
       
   126     {Qt::Key_Question,2,8,1,1 },
       
   127     {Qt::Key_Enter, 2, 9, 1, 1 },
       
   128 
       
   129     // fourth row
       
   130     // Character range button
       
   131     {Qt::Key_F2, 3, 0, 1, 1 },
       
   132     {Qt::Key_Control, 3, 1, 1, 1 },
       
   133     {Qt::Key_Question,3,2,1,1 },
       
   134     {Qt::Key_Question,3,3,1,1 },
       
   135     {Qt::Key_Space, 3, 4, 1, 2 },
       
   136     {Qt::Key_Question,3,6,1,1 },
       
   137     {Qt::Key_Question,3,7,1,1 },
       
   138     {Qt::Key_Question,3,8,1,1 },
       
   139     // application button
       
   140     {Qt::Key_F3,3,9,1,1 }
       
   141 };
       
   142 
       
   143 HbInputSctLandscapePrivate::HbInputSctLandscapePrivate()
       
   144 :mStartIndex(0),
       
   145 mCurrentPage(0),
       
   146 mActiveView(HbInputSctLandscape::HbSctViewSpecialCharacter),
       
   147 mPreviewPane(0),
       
   148 mClickMapper(0),
       
   149 mSize(QSizeF())
       
   150 {
       
   151     mFlickAnimation = true;
       
   152 }
       
   153 
       
   154 /*
       
   155 This function sets a keypad button as a function button with given parameters.
       
   156 */
       
   157 void HbInputSctLandscapePrivate::setAsFunctionButton(int index, const HbIcon &icon, const QString &text)
       
   158 {
       
   159     mSctButtons.at(index)->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction);
       
   160     mSctButtons.at(index)->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
       
   161     mSctButtons.at(index)->setIcon(icon);
       
   162     mSctButtons.at(index)->setText(text);
       
   163     mSctButtons.at(index)->setAsStickyButton(false);
       
   164 }
       
   165 
       
   166 /*
       
   167 This function latches keypad button with given index. Since there could be only one
       
   168 latch button. We need to reset others.
       
   169 */
       
   170 void HbInputSctLandscapePrivate::latchRangeButton(int buttonId)
       
   171 {
       
   172     // we need to latch only one out of available range buttons.
       
   173     for (int i = HbNumberOfSctButtons - 2; ; i--) {
       
   174         // iterate till we get a character key. since character should not be latched.
       
   175         if (mSctButtons.at(i)->type() == Hb::ItemType_InputFunctionButton) {
       
   176             mSctButtons.at(i)->setLatch(buttonId == sctVkbTable[i].mKey);
       
   177         } else {
       
   178             break;
       
   179         }
       
   180     }
       
   181 }
       
   182 
       
   183 /*
       
   184 This function defines the layout porperties for sct.
       
   185 */
       
   186 void HbInputSctLandscapePrivate::createSctButtons()
       
   187 {
       
   188     Q_Q(HbInputSctLandscape);
       
   189 
       
   190     q->setupToolCluster();
       
   191 
       
   192     for (int i = 0; i < HbNumberOfSctButtons-1; i++) {
       
   193         HbTouchKeypadButton *button = new HbTouchKeypadButton(q, QString(""), q);
       
   194         q->connect(button, SIGNAL(pressed()), mPressMapper, SLOT(map()));
       
   195         mPressMapper->setMapping(button, i);
       
   196         q->connect(button, SIGNAL(released()), mReleaseMapper, SLOT(map()));
       
   197         mReleaseMapper->setMapping(button, i);
       
   198         q->connect(button, SIGNAL(clicked()), mClickMapper, SLOT(map()));
       
   199         mClickMapper->setMapping(button, i);
       
   200 
       
   201         mSctButtons.append(button);
       
   202         mButtonLayout->addItem(button, sctVkbTable[i].mRow, sctVkbTable[i].mColumn, 
       
   203             sctVkbTable[i].mRowSpan, sctVkbTable[i].mColumnSpan);
       
   204         if (sctVkbTable[i].mKey != Qt::Key_Question) {
       
   205             button->setButtonType(HbTouchKeypadButton::HbTouchButtonFunction);
       
   206             button->setBackgroundAttributes(HbTouchKeypadButton::HbTouchButtonReleased);
       
   207         } else {
       
   208             button->setAsStickyButton(true);
       
   209             q->connect(button, SIGNAL(enteredInNonStickyRegion()), q, SLOT(_q_enteredInNonStickyRegion()));
       
   210             button->setProperty(HbStyleRulesCacheId::hbStyleRulesForNodeCache, HbSctLandscapeButtonTextLayout);
       
   211         }
       
   212         HbIcon icon;
       
   213         switch (sctVkbTable[i].mKey) {
       
   214             case Qt::Key_Backspace:
       
   215                 icon.setIconName("qtg_mono_backspace1");
       
   216                 button->setIcon( icon );
       
   217                 button->setAutoRepeatDelay(HbRepeatTimeout);
       
   218                 button->setAutoRepeatInterval(HbRepeatTimeoutShort);
       
   219                 button->setAutoRepeat(true);
       
   220                 button->setProperty(HbStyleRulesCacheId::hbStyleRulesForNodeCache, HbSctLandscapeButtonIconLayout);
       
   221                 break;
       
   222             case Qt::Key_Enter:
       
   223                 icon.setIconName("qtg_mono_enter");
       
   224                 button->setIcon( icon );
       
   225                 button->setAutoRepeatDelay(HbRepeatTimeout);
       
   226                 button->setAutoRepeatInterval(HbRepeatTimeoutShort);
       
   227                 button->setAutoRepeat(true);
       
   228                 button->setProperty(HbStyleRulesCacheId::hbStyleRulesForNodeCache, HbSctLandscapeButtonIconLayout);
       
   229                 break;
       
   230             case Qt::Key_Space:
       
   231                 button->setFrameIcon("qtg_mono_space");
       
   232                 button->setAutoRepeatDelay(HbRepeatTimeout);
       
   233                 button->setAutoRepeatInterval(HbRepeatTimeoutShort);
       
   234                 button->setAutoRepeat(true);
       
   235                 break;
       
   236             case Qt::Key_Shift:
       
   237                 icon.setIconName("qtg_mono_shift");
       
   238                 button->setIcon(icon);
       
   239                 button->setProperty(HbStyleRulesCacheId::hbStyleRulesForNodeCache, HbSctLandscapeButtonIconLayout);
       
   240                 break;
       
   241             case Qt::Key_Control:
       
   242                 icon.setIconName("qtg_mono_alpha_mode");
       
   243                 button->setIcon(icon);
       
   244                 button->setProperty(HbStyleRulesCacheId::hbStyleRulesForNodeCache, HbSctLandscapeButtonIconLayout);
       
   245                 break;
       
   246             case Qt::Key_F1:
       
   247                 button->setIcon(HbIcon("qtg_mono_smiley"));
       
   248                 button->setObjectName(HbSmileyButtonObjName);
       
   249                 button->setProperty(HbStyleRulesCacheId::hbStyleRulesForNodeCache, HbSctLandscapeButtonIconLayout);
       
   250                 break;
       
   251             case Qt::Key_F2:
       
   252                 button->setIcon(HbIcon("qtg_mono_special_characters_qwerty"));
       
   253                 button->setObjectName(HbSmileyButtonObjName);
       
   254                 button->setProperty(HbStyleRulesCacheId::hbStyleRulesForNodeCache, HbSctLandscapeButtonIconLayout);
       
   255                 break;
       
   256             default:
       
   257                 break;
       
   258         }
       
   259     }
       
   260 
       
   261     mSctButtons.append(mApplicationButton);
       
   262     mButtonLayout->addItem(mApplicationButton,
       
   263                            sctVkbTable[HbNumberOfSctButtons-1].mRow,
       
   264                            sctVkbTable[HbNumberOfSctButtons-1].mColumn,
       
   265                            sctVkbTable[HbNumberOfSctButtons-1].mRowSpan,
       
   266                            sctVkbTable[HbNumberOfSctButtons-1].mColumnSpan);
       
   267 }
       
   268 
       
   269 /*
       
   270 This function defines the layout porperties for sct.
       
   271 */
       
   272 void HbInputSctLandscapePrivate::setLayoutDimensions(QSizeF dimensions)
       
   273 {
       
   274     // only update the dimensions if they are not previously set
       
   275     if (mSize == dimensions) {
       
   276         return;
       
   277     }
       
   278     mSize = dimensions;
       
   279 
       
   280     mButtonLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0);
       
   281 
       
   282     for (int i = 0; i < HbSctNumberOfColumns; i++) {
       
   283         mButtonLayout->setColumnFixedWidth(i, dimensions.width());
       
   284     }
       
   285 
       
   286     for (int i = 0; i < HbSctNumberOfRows; i++) {
       
   287         mButtonLayout->setRowFixedHeight(i, dimensions.height());
       
   288     }
       
   289 
       
   290     mButtonLayout->setHorizontalSpacing(0.0);
       
   291     mButtonLayout->setVerticalSpacing(0.0);
       
   292     foreach (HbTouchKeypadButton* button, mSctButtons) {
       
   293         if (button) {
       
   294             button->setInitialSize(dimensions);
       
   295         }
       
   296     }
       
   297 }
       
   298 
       
   299 /*
       
   300 Sets the sct button. Once sct character buttons are set it latches the active range 
       
   301 button.
       
   302 */
       
   303 void HbInputSctLandscapePrivate::setActiveView(HbInputVkbWidget::HbSctView view)
       
   304 {
       
   305     Q_Q(HbInputSctLandscape);
       
   306     mActiveView = view;
       
   307 
       
   308     switch (mActiveView) {
       
   309         case HbInputSctLandscape::HbSctViewSpecialCharacter:
       
   310             setSctButtons(mSpecialCharacterSet);
       
   311             latchRangeButton(HbSpecialCharacterRangeButton);
       
   312             break;
       
   313         case HbInputSctLandscape::HbSctViewSmiley:
       
   314             q->showSmileyPicker(HbSctNumberOfRows, HbSctNumberOfColumns);
       
   315             break;
       
   316         default:
       
   317             break;
       
   318     };
       
   319 }
       
   320 
       
   321 /*
       
   322 apply editor constraints on buttons
       
   323 */
       
   324 void HbInputSctLandscapePrivate::applyEditorConstraints()
       
   325 {
       
   326     HbInputFocusObject *focusedObject = 0;
       
   327     if (mOwner) {
       
   328         focusedObject = mOwner->focusObject();
       
   329     }
       
   330 
       
   331     if(!focusedObject || isKeyboardDimmed()) {
       
   332     // dont need to apply constraints when keypad is dimmed.
       
   333     // applyEditorConstraints will be called from setKeyboardDimmed(false)
       
   334         return;
       
   335     }
       
   336 
       
   337     for (int i=0; i < mSctButtons.size(); i++) {
       
   338         if (sctVkbTable[i].mKey == Qt::Key_Question || sctVkbTable[i].mKey == Qt::Key_Space) {
       
   339             QString buttonText = (sctVkbTable[i].mKey == Qt::Key_Space) ? QString(" ") : mSctButtons.at(i)->text();
       
   340             if (buttonText.isEmpty() || !focusedObject->characterAllowedInEditor(buttonText[0])) {
       
   341                 // if the data mapped to button is empty or the data mapped is not allowed to the editor 
       
   342                 mSctButtons.at(i)->setFade(true);
       
   343             } else {
       
   344                 mSctButtons.at(i)->setFade(false);
       
   345             }
       
   346         }
       
   347     }
       
   348 
       
   349     // now set latch buttons
       
   350     switch (mActiveView) {
       
   351         case HbInputSctLandscape::HbSctViewSpecialCharacter:
       
   352             latchRangeButton(HbSpecialCharacterRangeButton);
       
   353             break;
       
   354         case HbInputSctLandscape::HbSctViewSmiley:
       
   355             latchRangeButton(HbSmileyRangeButton);
       
   356             break;
       
   357         default:
       
   358             break;
       
   359     };
       
   360 
       
   361     // we should disable smiley range button in case we have editor which is url/email/password etc editor.
       
   362     mSctButtons.at(HbSmileyButtonIndex)->setFade(focusedObject->editorInterface().editorClass() != HbInputEditorClassUnknown
       
   363         ||!isSmileysEnabled());
       
   364 }
       
   365 
       
   366 /*
       
   367 Sets passed characters on sct buttons.
       
   368 */
       
   369 void HbInputSctLandscapePrivate::setSctButtons(const QString& aCharSet)
       
   370 {
       
   371     int i = 0;
       
   372     int j = 0;
       
   373 
       
   374     for (; i < mSctButtons.size() && (j + mStartIndex) < aCharSet.size(); i++) {
       
   375         // we need to map only on a character type button.
       
   376         if (sctVkbTable[i].mKey == Qt::Key_Question || sctVkbTable[i].mKey == Qt::Key_Space) {
       
   377             const QChar &character = (sctVkbTable[i].mKey == Qt::Key_Space) ? ' ' : aCharSet[(j++) + mStartIndex];
       
   378             mSctButtons.at(i)->setIcon(HbIcon());
       
   379             mSctButtons.at(i)->setText(character);
       
   380         }
       
   381     }
       
   382 
       
   383     for (; i < mSctButtons.size(); i++) {
       
   384         if (sctVkbTable[i].mKey == Qt::Key_Question) {
       
   385             mSctButtons.at(i)->setText(QString(""));
       
   386         }
       
   387     }
       
   388 
       
   389     mCurrentPage = mStartIndex/(HbNumberOfSctButtons-HbNumberOfOtherButtons);
       
   390     mStartIndex += j;
       
   391     if (mStartIndex == aCharSet.size()) {
       
   392         // We have reached end of special character list, reset the mStartIndex to 0
       
   393         // so that we show first set of special characters next time
       
   394         mStartIndex = 0;
       
   395     }
       
   396     applyEditorConstraints();
       
   397 }
       
   398 
       
   399 /*
       
   400 Gets the special character sets from set keymapping.
       
   401 */
       
   402 void HbInputSctLandscapePrivate::getSpecialCharacters()
       
   403 {
       
   404     mSpecialCharacterSet.clear();
       
   405     if (mKeymap) {
       
   406         const HbKeyboardMap* keymap = mKeymap->keyboard(HbKeyboardSctLandscape);
       
   407         if (keymap == 0) {
       
   408             return;
       
   409         }
       
   410         foreach (const HbMappedKey* mappedKey, keymap->keys) {
       
   411             mSpecialCharacterSet.append(mappedKey->characters(HbModifierNone));
       
   412         }
       
   413     }
       
   414 }
       
   415 
       
   416 /*
       
   417 This function returns the keyCode for the given index.
       
   418 */
       
   419 int HbInputSctLandscapePrivate::keyCode(int buttonId)
       
   420 {
       
   421     return sctVkbTable[buttonId].mKey;
       
   422 }
       
   423 
       
   424 /*
       
   425 Handles button press events.
       
   426 */
       
   427 void HbInputSctLandscapePrivate::handleStandardButtonPress(int buttonId)
       
   428 {
       
   429     // A new button is pressed so we should close 
       
   430     // preview pane on the previous button.
       
   431     if (mPreviewPane->isVisible()) {
       
   432         mPreviewPane->hide();
       
   433     }
       
   434 
       
   435     if (buttonId < 0) {
       
   436         return;
       
   437     }
       
   438 
       
   439     // if the button is not faded, then show character preview popup.
       
   440     if ((HbInputSettingProxy::instance()->isCharacterPreviewForQwertyEnabled()) && !(mSctButtons.at(buttonId)->isFaded())) {
       
   441         if (sctVkbTable[buttonId].mKey == Qt::Key_Question) {
       
   442             const QString &text = mSctButtons.at(buttonId)->text();
       
   443             if (text.size()) {
       
   444                 QStringList list(text);
       
   445                 mPreviewPane->showCharacters(list, mSctButtons.at(buttonId)->sceneBoundingRect());
       
   446                 return;
       
   447             }
       
   448         }
       
   449     }
       
   450 
       
   451 }
       
   452 
       
   453 /*
       
   454 Handles button clicks.
       
   455 */
       
   456 void HbInputSctLandscapePrivate::handleStandardButtonClick(int buttonId)
       
   457 {
       
   458     Q_Q(HbInputSctLandscape);
       
   459 
       
   460     switch (sctVkbTable[buttonId].mKey) {
       
   461     case Qt::Key_Question: {
       
   462             QString buttonText = mSctButtons.at(buttonId)->text();
       
   463             if (buttonText.length() > 0) {
       
   464                 emit q->sctCharacterSelected(buttonText.at(0));
       
   465             }
       
   466             break;
       
   467         }
       
   468     case HbSpecialCharacterRangeButton:
       
   469         if(mActiveView != HbInputVkbWidget::HbSctViewSpecialCharacter) {
       
   470             //first time coming to special character view.
       
   471             mStartIndex = 0;
       
   472         }
       
   473         setActiveView(HbInputSctLandscape::HbSctViewSpecialCharacter);
       
   474         break;
       
   475     case HbSmileyRangeButton:
       
   476         if(mActiveView != HbInputVkbWidget::HbSctViewSmiley) {
       
   477             //first time coming to special character view.
       
   478             mStartIndex = 0;
       
   479         }
       
   480         // dont show the smiley picker if the button is inactive
       
   481         if (!mSctButtons[HbSmileyButtonIndex]->isFaded()) {
       
   482             setActiveView(HbInputSctLandscape::HbSctViewSmiley);
       
   483         }
       
   484         break;
       
   485     default:
       
   486         // left are enter, backspace and space buttons. they should be handled by plugins.
       
   487         // we should pass both the press and release event. As mode handlers work according to
       
   488         // the press and release event.
       
   489         QKeyEvent pressEvent(QEvent::KeyPress, sctVkbTable[buttonId].mKey, Qt::NoModifier);
       
   490         if (mOwner) {
       
   491             mOwner->filterEvent(&pressEvent);
       
   492             QKeyEvent releaseEvent(QEvent::KeyRelease, sctVkbTable[buttonId].mKey, Qt::NoModifier);
       
   493             mOwner->filterEvent(&releaseEvent);
       
   494         }
       
   495     };
       
   496 }
       
   497 
       
   498 /*
       
   499 Handles the sct keypad button releas. Internally it hides character preview pane
       
   500 if visible.
       
   501 */
       
   502 void HbInputSctLandscapePrivate::handleStandardButtonRelease(int buttonId)
       
   503 {
       
   504     Q_UNUSED(buttonId);
       
   505     if (mPreviewPane->isVisible()) {
       
   506         mPreviewPane->hide();
       
   507     }
       
   508 }
       
   509 
       
   510 /*!
       
   511 This slot is called when we slide our fingures on top of the keypad buttons and 
       
   512 while sliding our fingure comes on top of a non sticky button Or on a region outside
       
   513 the keypad area.
       
   514 */
       
   515 void HbInputSctLandscapePrivate::_q_enteredInNonStickyRegion()
       
   516 {
       
   517     if (mPreviewPane->isVisible()) {
       
   518         mPreviewPane->hide();
       
   519     }
       
   520 }
       
   521 
       
   522 /*!
       
   523 Handles virtual key clicks
       
   524 */
       
   525 void HbInputSctLandscapePrivate::_q_mappedKeyClick(int buttonid)
       
   526 {
       
   527     handleStandardButtonClick(buttonid);
       
   528 }
       
   529 
       
   530 /// @endcond
       
   531 
       
   532 /*!
       
   533 \deprecated HbInputSctLandscape::HbInputSctLandscape(HbInputMethod*, const HbKeymap*, QGraphicsItem*)
       
   534     is deprecated.
       
   535 */
       
   536 HbInputSctLandscape::HbInputSctLandscape(HbInputMethod* owner, const HbKeymap *keymap, QGraphicsItem* parent)
       
   537                     : HbInputVkbWidget(*new HbInputSctLandscapePrivate, parent)
       
   538 {
       
   539     Q_D(HbInputSctLandscape);
       
   540     d->q_ptr = this;
       
   541     d->mOwner = owner;
       
   542 
       
   543     d->mButtonLayout = new QGraphicsGridLayout();
       
   544 
       
   545     d->mClickMapper = new QSignalMapper(this);
       
   546 
       
   547     // create buttons.
       
   548     d->createSctButtons();
       
   549 
       
   550     // preview pane
       
   551     d->mPreviewPane = new HbCharPreviewPane();
       
   552     d->mPreviewPane->hide();
       
   553 
       
   554     // connect mappers.
       
   555     connect(d->mPressMapper, SIGNAL(mapped(int)), this, SLOT(mappedKeyPress(int)));
       
   556     connect(d->mReleaseMapper, SIGNAL(mapped(int)), this, SLOT(mappedKeyRelease(int)));
       
   557     connect(d->mClickMapper, SIGNAL(mapped(int)), this, SLOT(_q_mappedKeyClick(int)));
       
   558 
       
   559     connect(this, SIGNAL(flickEvent(HbInputVkbWidget::HbFlickDirection)), this, SLOT(flickTriggered(HbInputVkbWidget::HbFlickDirection)));
       
   560 
       
   561     // now set the keymap data.
       
   562     setKeymap(keymap);
       
   563 }
       
   564 
       
   565 /*!
       
   566 \deprecated HbInputSctLandscape::HbInputSctLandscape(HbInputSctLandscapePrivate&, QGraphicsItem*)
       
   567     is deprecated.
       
   568 */
       
   569 HbInputSctLandscape::HbInputSctLandscape(HbInputSctLandscapePrivate &dd, QGraphicsItem* parent)
       
   570             : HbInputVkbWidget(dd, parent)
       
   571 {
       
   572 }
       
   573 
       
   574 /*!
       
   575 \deprecated HbInputSctLandscape::~HbInputSctLandscape()
       
   576     is deprecated.
       
   577 */
       
   578 HbInputSctLandscape::~HbInputSctLandscape()
       
   579 {
       
   580 }
       
   581 
       
   582 /*!
       
   583 \reimp
       
   584 \deprecated HbInputSctLandscape::keyboardType() const
       
   585     is deprecated.
       
   586 */
       
   587 HbKeyboardType HbInputSctLandscape::keyboardType() const
       
   588 {
       
   589     return HbKeyboardSctLandscape;
       
   590 }
       
   591 
       
   592 /*!
       
   593 \deprecated HbInputSctLandscape::setSct(HbSctView, bool)
       
   594     is deprecated.
       
   595 */
       
   596 void HbInputSctLandscape::setSct(HbSctView view , bool enableMostUsedCharacterPane)
       
   597 {
       
   598     // for the time being disabling 
       
   599     // most used character pane
       
   600     Q_UNUSED(enableMostUsedCharacterPane);
       
   601     Q_D(HbInputSctLandscape);
       
   602 
       
   603     d->mStartIndex  = 0;
       
   604     setupToolCluster();
       
   605     d->mStartIndex = 0;
       
   606     d->setActiveView(view);
       
   607 }
       
   608 
       
   609 /*!
       
   610 \reimp
       
   611 \deprecated HbInputSctLandscape::setKeymap(const HbKeymap*)
       
   612     is deprecated.
       
   613 */
       
   614 void HbInputSctLandscape::setKeymap(const HbKeymap* keymap)
       
   615 {
       
   616     Q_D(HbInputSctLandscape);
       
   617     HbInputVkbWidget::setKeymap(keymap);
       
   618     d->getSpecialCharacters();
       
   619 }
       
   620 
       
   621 /*!
       
   622 \reimp
       
   623 \deprecated HbInputSctLandscape::keypadLayout()
       
   624     is deprecated.
       
   625 */
       
   626 QGraphicsLayout *HbInputSctLandscape::keypadLayout()
       
   627 {
       
   628     Q_D(HbInputSctLandscape);
       
   629     return d->mButtonLayout;
       
   630 }
       
   631 
       
   632 /*!
       
   633 \reimp
       
   634 \deprecated HbInputSctLandscape::aboutToOpen(HbVkbHost*)
       
   635     is deprecated.
       
   636 */
       
   637 void HbInputSctLandscape::aboutToOpen(HbVkbHost *host)
       
   638 {
       
   639     Q_D(HbInputSctLandscape);
       
   640     HbInputVkbWidget::aboutToOpen(host);
       
   641 
       
   642     // calculate each button width and height
       
   643     QSizeF keypadSize = keypadButtonAreaSize();
       
   644 
       
   645     keypadSize.setWidth(keypadSize.width() / (qreal)HbSctNumberOfColumns);
       
   646     keypadSize.setHeight(keypadSize.height() / (qreal)HbSctNumberOfRows);
       
   647 
       
   648     d->setLayoutDimensions(keypadSize);
       
   649 }
       
   650 
       
   651 /*!
       
   652 \reimp
       
   653 \deprecated HbInputSctLandscape::aboutToClose(HbVkbHost*)
       
   654     is deprecated.
       
   655 */
       
   656 void HbInputSctLandscape::aboutToClose(HbVkbHost *host)
       
   657 {
       
   658     Q_D(HbInputSctLandscape);
       
   659     HbInputVkbWidget::aboutToClose(host);
       
   660     if (d->mPreviewPane->isVisible()) {
       
   661         d->mPreviewPane->hide();
       
   662     }
       
   663 }
       
   664 
       
   665 /*!
       
   666 \deprecated HbInputSctLandscape::flickTriggered(HbInputVkbWidget::HbFlickDirection)
       
   667     is deprecated.
       
   668 */
       
   669 void HbInputSctLandscape::flickTriggered(HbInputVkbWidget::HbFlickDirection direction)
       
   670 {
       
   671     Q_D(HbInputSctLandscape);
       
   672 
       
   673     // left/right flick event has occured, hence hide the preview pane
       
   674     if (d->mPreviewPane->isVisible()) {
       
   675         d->mPreviewPane->hide();
       
   676     }
       
   677 
       
   678     // total number of actual buttons available for displaying special characters
       
   679     int iNumSctButtons = HbNumberOfSctButtons-HbNumberOfOtherButtons;
       
   680     if(direction == HbInputVkbWidget::HbFlickDirectionLeft) {
       
   681         d->mCurrentPage--;
       
   682         if(d->mCurrentPage<0) {
       
   683             if (d->mSpecialCharacterSet.size()) {
       
   684                 d->mCurrentPage = (int)ceil((float)d->mSpecialCharacterSet.size()/iNumSctButtons)-1;
       
   685             } else {
       
   686                 d->mCurrentPage = 0;
       
   687             }
       
   688         }
       
   689         d->mStartIndex = d->mCurrentPage*iNumSctButtons;
       
   690     }
       
   691     d->setActiveView(HbInputSctLandscape::HbSctViewSpecialCharacter);
       
   692 }
       
   693 
       
   694 #include "moc_hbinputsctlandscape.cpp"
       
   695 // End of file