src/hbplugins/inputmethods/touchinput/hbinputqwertynumerictouchkeyboard.cpp
changeset 5 627c4a0fd0e7
parent 2 06ff229162e9
child 7 923ff622b8b9
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
   150     getCharacters(characters);
   150     getCharacters(characters);
   151 
   151 
   152     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(q->contentItem());
   152     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(q->contentItem());
   153     if (buttonGroup) {
   153     if (buttonGroup) {
   154         int key = 0;
   154         int key = 0;
       
   155         int charKeyCount = 0;
       
   156 
   155         QList<HbInputButton*> buttons = buttonGroup->buttons();
   157         QList<HbInputButton*> buttons = buttonGroup->buttons();
   156         for (int i = 0; i < buttons.count(); ++i) {
   158         for (int i = 0; i < buttons.count(); ++i) {
   157             if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) {
   159             if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) {
   158                 HbInputButton *item = buttons.at(i);
   160                 HbInputButton *item = buttons.at(i);
   159 
   161                 // digits always comes in the first row
   160                 if (key < characters.count()) { 
   162                 if (charKeyCount < 10) {
       
   163                     item->setKeyCode(numberCharacterBoundToKey((charKeyCount + 1) % 10).unicode());
       
   164                     charKeyCount++;
       
   165                 } else if (key < characters.count()) {
   161                     item->setKeyCode(characters.at(key).unicode());
   166                     item->setKeyCode(characters.at(key).unicode());
       
   167                     ++key;
   162                 }
   168                 }
   163                 ++key;
       
   164             }
   169             }
   165         }
   170         }
   166     }
   171     }
   167 }
   172 }
   168 
   173 
   174     getCharacters(characters);
   179     getCharacters(characters);
   175 
   180 
   176     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(q->contentItem());
   181     HbInputButtonGroup *buttonGroup = static_cast<HbInputButtonGroup*>(q->contentItem());
   177     if (buttonGroup) {
   182     if (buttonGroup) {
   178         int key = 0;
   183         int key = 0;
       
   184         int charKeyCount = 0;
       
   185 
   179         QList<HbInputButton*> buttons = buttonGroup->buttons();
   186         QList<HbInputButton*> buttons = buttonGroup->buttons();
   180         for (int i = 0; i < buttons.count(); ++i) {
   187         for (int i = 0; i < buttons.count(); ++i) {
   181             if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) {
   188             if (keyCode(i) == HbInputButton::ButtonKeyCodeCharacter) {
   182                 HbInputButton *item = buttons.at(i);
   189                 HbInputButton *item = buttons.at(i);
   183 
   190                 if (charKeyCount < 10) {
   184                 if (key < characters.count()) {
   191                     item->setText(numberCharacterBoundToKey((charKeyCount + 1) % 10),
   185                     item->setText(characters.at(key), HbInputButton::ButtonTextIndexPrimary);
   192                     HbInputButton::ButtonTextIndexPrimary);  
       
   193                     charKeyCount++;					
   186                 } else {
   194                 } else {
   187                     item->setText(QString(), HbInputButton::ButtonTextIndexPrimary);
   195                     if (key < characters.count()) {
   188                 }
   196                         item->setText(characters.at(key), HbInputButton::ButtonTextIndexPrimary);
   189                 ++key;
   197                     } else {
       
   198                         item->setText(QString(), HbInputButton::ButtonTextIndexPrimary);
       
   199                     }
       
   200                     ++key;
       
   201                 }					
   190             }
   202             }
   191         }
   203         }
   192         buttonGroup->setButtons(buttons);
   204         buttonGroup->setButtons(buttons);
   193     }
   205     }
   194 }
   206 }
   195 
   207 
   196 void HbQwertyNumericKeyboardPrivate::getCharacters(QString &characters)
   208 void HbQwertyNumericKeyboardPrivate::getCharacters(QString &characters)
   197 {
   209 {
   198     characters = QString("1234567890");
       
   199 
       
   200     if (mKeymap) {
   210     if (mKeymap) {
   201         const HbKeyboardMap* keyboardMap = mKeymap->keyboard(HbKeyboardSctLandscape);
   211         const HbKeyboardMap* keyboardMap = mKeymap->keyboard(HbKeyboardSctLandscape);
   202         if (!keyboardMap) {
   212         if (!keyboardMap) {
   203             return;
   213             return;
   204         }
   214         }
   205 
   215         QString chars;
       
   216 		
   206         foreach (const HbMappedKey* mappedKey, keyboardMap->keys) {
   217         foreach (const HbMappedKey* mappedKey, keyboardMap->keys) {
   207             QString chars = mappedKey->characters(HbModifierNone);
   218             chars.append(mappedKey->characters(HbModifierNone));
   208             
   219         }          
   209             HbInputFocusObject *focusedObject = mOwner->focusObject();
   220             HbInputFocusObject *focusedObject = mOwner->focusObject();
   210             QString allowedChars;
   221             QString allowedChars;
   211             if (focusedObject) {
   222             if (focusedObject) {
   212                 focusedObject->filterStringWithEditorFilter(chars, allowedChars);
   223                 focusedObject->filterStringWithEditorFilter(chars, allowedChars);
   213             }
   224             }
   214 
   225             // Remove digits from it ( digits always come in the first row )
       
   226             for (int i=0; i < 10; i++) {
       
   227                 allowedChars.remove(numberCharacterBoundToKey(i));
       
   228             }	
       
   229 			
   215             foreach (QChar sctChar, allowedChars) {
   230             foreach (QChar sctChar, allowedChars) {
   216                 if (!characters.contains(sctChar)) {
   231                 if (!characters.contains(sctChar)) {
   217                     characters.append(sctChar);
   232                     characters.append(sctChar);
   218                 }
   233                 }
   219             }
   234             }
   220         }
   235         
   221     }
   236     }
   222 }
   237 }
       
   238 
   223 
   239 
   224 /*!
   240 /*!
   225 Constructs the object. owner is the owning input method implementation. Keymap
   241 Constructs the object. owner is the owning input method implementation. Keymap
   226 is key mapping data to be used to display button texts. Key mapping data can be
   242 is key mapping data to be used to display button texts. Key mapping data can be
   227 changed later (for example when the input language changes) by calling
   243 changed later (for example when the input language changes) by calling