src/hbinput/inputwidgets/hbinputbutton.cpp
branchGCC_SURGE
changeset 15 f378acbc9cfb
parent 7 923ff622b8b9
child 21 4633027730f5
child 34 ed14f46c0e55
--- a/src/hbinput/inputwidgets/hbinputbutton.cpp	Thu Jul 15 14:03:49 2010 +0100
+++ b/src/hbinput/inputwidgets/hbinputbutton.cpp	Thu Jul 22 16:36:53 2010 +0100
@@ -51,8 +51,8 @@
 };
 
 HbInputButtonPrivate::HbInputButtonPrivate()
- : mType(HbInputButton::ButtonTypeNormal), mState(HbInputButton::ButtonStateReleased),
-   mPosition(0, 0), mSize(1, 1), mKeyCode(-1), mAutoRepeat(false)
+    : mType(HbInputButton::ButtonTypeNormal), mState(HbInputButton::ButtonStateReleased),
+      mPosition(0, 0), mSize(1, 1), mKeyCode(-1), mAutoRepeat(false)
 {
     for (int i = 0; i < HbInputButton::ButtonTextIndexCount; ++i) {
         mTexts.append("");
@@ -64,8 +64,8 @@
 }
 
 HbInputButtonPrivate::HbInputButtonPrivate(int keyCode, const QPoint &position, const QSize &size)
- : mType(HbInputButton::ButtonTypeNormal), mState(HbInputButton::ButtonStateReleased),
-   mPosition(position), mSize(size), mKeyCode(keyCode), mAutoRepeat(false)
+    : mType(HbInputButton::ButtonTypeNormal), mState(HbInputButton::ButtonStateReleased),
+      mPosition(position), mSize(size), mKeyCode(keyCode), mAutoRepeat(false)
 {
     for (int i = 0; i < HbInputButton::ButtonTextIndexCount; ++i) {
         mTexts.append("");
@@ -75,7 +75,8 @@
         mIcons.append(HbIcon());
     }
 
-    if (keyCode != HbInputButton::ButtonKeyCodeCharacter) {
+    if (keyCode != HbInputButton::ButtonKeyCodeCharacter &&
+        keyCode != HbInputButton::ButtonKeyCodeSpace) {
         mType = HbInputButton::ButtonTypeFunction;
     }
 
@@ -94,10 +95,10 @@
 }
 
 HbInputButtonPrivate::HbInputButtonPrivate(HbInputButton::HbInputButtonType type, HbInputButton::HbInputButtonState state,
-                                           const QPoint &position, const QSize &size, int keyCode, bool autoRepeat,
-                                           const QList<QString> &texts, const QString &mappedCharacters, const QList<HbIcon> &icons)
- : mType(type), mState(state), mPosition(position), mSize(size), mKeyCode(keyCode), mAutoRepeat(autoRepeat),
-   mMappedCharacters(mappedCharacters)
+        const QPoint &position, const QSize &size, int keyCode, bool autoRepeat,
+        const QList<QString> &texts, const QString &mappedCharacters, const QList<HbIcon> &icons)
+    : mType(type), mState(state), mPosition(position), mSize(size), mKeyCode(keyCode), mAutoRepeat(autoRepeat),
+      mMappedCharacters(mappedCharacters)
 {
     for (int i = 0; i < HbInputButton::ButtonTextIndexCount; ++i) {
         if (i < texts.count()) {
@@ -125,22 +126,30 @@
 
 void HbInputButtonPrivate::setDefaultGraphics(int keyCode)
 {
-    if (keyCode == HbInputButton::ButtonKeyCodeDelete) {
-        mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconDelete));
-    } else if (keyCode == HbInputButton::ButtonKeyCodeShift) {
-        mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconShift));
-    } else if (keyCode == HbInputButton::ButtonKeyCodeSymbol) {
-        mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSymbol));
-    } else if (keyCode == HbInputButton::ButtonKeyCodeEnter) {
-        mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconEnter));
-    } else if (keyCode == HbInputButton::ButtonKeyCodeSpace) {
-        mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSpace));
-    } else if (keyCode == HbInputButton::ButtonKeyCodeAlphabet) {
-        mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconAlphabet));
-    } else if (keyCode == HbInputButton::ButtonKeyCodePageChange) {
-        mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconPageChange));
-    } else if (keyCode == HbInputButton::ButtonKeyCodeSmiley) {
-        mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSmiley));
+    switch(keyCode) {
+        case HbInputButton::ButtonKeyCodeDelete:
+            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconDelete));
+            break;
+        case HbInputButton::ButtonKeyCodeShift:
+            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconShift));
+            break;
+        case HbInputButton::ButtonKeyCodeSymbol:
+            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSymbol));
+            break;
+        case HbInputButton::ButtonKeyCodeEnter:
+            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconEnter));
+            break;
+        case HbInputButton::ButtonKeyCodeSpace:
+            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSpace));
+            break;
+        case HbInputButton::ButtonKeyCodeAlphabet:
+            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSymbol));
+            break;
+        case HbInputButton::ButtonKeyCodeSmiley:
+            mIcons.replace(HbInputButton::ButtonTextIndexPrimary, HbIcon(HbInputButtonIconSmiley));
+            break;
+        default:
+            break;
     }
 }
 
@@ -150,7 +159,7 @@
 Constructor
 */
 HbInputButton::HbInputButton()
- : d_ptr(new HbInputButtonPrivate)
+    : d_ptr(new HbInputButtonPrivate)
 {
 }
 
@@ -163,7 +172,7 @@
 size is button's size in grid cell units.
 */
 HbInputButton::HbInputButton(int keyCode, const QPoint &position, const QSize &size)
- : d_ptr(new HbInputButtonPrivate(keyCode, position, size))
+    : d_ptr(new HbInputButtonPrivate(keyCode, position, size))
 {
 }
 
@@ -176,7 +185,7 @@
 }
 
 /*!
-Updates buttons type.
+Updates button's type.
 
 \sa type
 */
@@ -188,7 +197,7 @@
 }
 
 /*!
-Returns buttons type.
+Returns button's type.
 
 \sa setType
 */
@@ -200,7 +209,7 @@
 }
 
 /*!
-Updates buttons state.
+Updates button's state.
 
 \sa state
 */
@@ -212,7 +221,7 @@
 }
 
 /*!
-Returns buttons state.
+Returns button's state.
 
 \sa setState
 */
@@ -224,7 +233,7 @@
 }
 
 /*!
-Updates buttons position.
+Updates button's position.
 
 position is button's position in grid cell units.
 
@@ -238,7 +247,7 @@
 }
 
 /*!
-Returns buttons position.
+Returns button's position.
 
 \sa setPosition
 */
@@ -250,7 +259,7 @@
 }
 
 /*!
-Updates buttons size.
+Updates button's size.
 
 size is button's size in grid cell units.
 
@@ -264,7 +273,7 @@
 }
 
 /*!
-Returns buttons size.
+Returns button's size.
 
 \sa setSize
 */
@@ -276,7 +285,7 @@
 }
 
 /*!
-Updates buttons key code.
+Updates button's key code.
 
 \sa keyCode
 */
@@ -288,7 +297,7 @@
 }
 
 /*!
-Returns buttons key code.
+Returns button's key code.
 
 \sa setKeyCode
 */
@@ -300,7 +309,7 @@
 }
 
 /*!
-Updates buttons auto repeat status.
+Updates button's auto repeat status.
 
 \sa autoRepeat
 */
@@ -312,7 +321,7 @@
 }
 
 /*!
-Returns buttons auto repeat status.
+Returns button's auto repeat status.
 
 \sa setAutoRepeat
 */
@@ -340,11 +349,11 @@
 }
 
 /*!
-Updates all button texts.
+Updates all button's texts.
 Button can have three different texts. Text position and size
-will depend of other buttons texts and icons. If list contains
+will depend on other buttons texts and icons. If list contains
 more strings, then the rest will be ignored. Icon with same index
-than text will override the text.
+as text will override the text.
 
 \sa text
 \sa texts
@@ -357,7 +366,7 @@
         if (i < texts.count()) {
             d->mTexts.replace(i, texts.at(i));
         } else {
-            d->mTexts.replace(i, QString());
+            d->mTexts[i].clear();
         }
     }
 }
@@ -380,7 +389,7 @@
 }
 
 /*!
-Returns all button texts.
+Returns all button's texts.
 
 \sa setText
 \sa setTexts
@@ -434,10 +443,10 @@
 
 /*!
 Updates all button icons.
-Button can have three different icons. Icon position 
-will depend of other buttons icons and texts. If list contains
+Button can have three different icons. Icon position
+will depend on other buttons icons and texts. If list contains
 more icons, then the rest will be ignored. Icon with same index
-than text will override the text.
+as text will override the text.
 
 \sa icon
 \sa icons
@@ -472,7 +481,7 @@
 }
 
 /*!
-Returns all button icon.
+Returns all button's icons.
 
 \sa setIcon
 \sa setIcons
@@ -497,7 +506,7 @@
 }
 
 /*!
-Returns buttons bounding rectangle.
+Returns button's bounding rectangle.
 
 \sa setBoundingRect
 */