telutils/dialpad/inc/dialpadkeypad.h
changeset 50 2313cb430f28
parent 39 cee7e9e0906c
equal deleted inserted replaced
45:61f927bc9441 50:2313cb430f28
     9 * Initial Contributors:
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    10 * Nokia Corporation - initial contribution.
    11 *
    11 *
    12 * Contributors:
    12 * Contributors:
    13 *
    13 *
    14 * Description: Dialpad keypad
    14 * Description: Number grid and dial key.
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 #ifndef DIALPADKEYPAD_H
    18 #ifndef DIALPADKEYPAD_H
    19 #define DIALPADKEYPAD_H
    19 #define DIALPADKEYPAD_H
    20 
    20 
    21 #include <QTextLayout>
    21 #include <hbwidget.h>
    22 #include <QColor>
       
    23 #include <hbinputbuttongroup.h>
       
    24 
    22 
    25 class DialpadInputField;
    23 class DialpadInputField;
    26 class DialpadButton;
    24 class DialpadButton;
    27 class DialpadNumericButton;
    25 class DialpadNumericButtonGrid;
    28 class QSignalMapper;
    26 class QSignalMapper;
    29 class QGraphicsGridLayout;
       
    30 
    27 
    31 class DialpadKeypad : public HbInputButtonGroup
    28 class DialpadKeypad : public HbWidget
    32 {
    29 {
    33     Q_OBJECT
    30     Q_OBJECT
    34 
    31 
    35 public:
    32 public:
    36     explicit DialpadKeypad(
    33     explicit DialpadKeypad(
    39         QGraphicsItem* parent=0);
    36         QGraphicsItem* parent=0);
    40 
    37 
    41     ~DialpadKeypad();
    38     ~DialpadKeypad();
    42 
    39 
    43 public:
    40 public:
       
    41     bool isCallButtonEnabled() const;
       
    42 
    44     void setCallButtonEnabled(bool enabled);
    43     void setCallButtonEnabled(bool enabled);
    45 
    44 
    46     void resetButtons();
    45     void resetButtons();
    47 
    46 
    48     DialpadButton& callButton() const;
       
    49 
       
    50 protected slots:
    47 protected slots:
    51     void setButtonTexts();
       
    52 
       
    53     void handleKeyClicked(int key);
    48     void handleKeyClicked(int key);
    54     void sendKeyPressEvent(const QKeyEvent& event);
    49     void sendKeyPressEvent(const QKeyEvent& event);
    55     void sendKeyReleaseEvent(const QKeyEvent& event);
    50     void sendKeyReleaseEvent(const QKeyEvent& event);
    56     void sendLongPressEvent(const QKeyEvent& event);
    51     void sendLongPressEvent(const QKeyEvent& event);
    57     void handleKeyChangeEvent(const QKeyEvent& releaseEvent,
    52     void handleKeyChangeEvent(const QKeyEvent& releaseEvent,
    58                               const QKeyEvent& pressEvent);
    53                               const QKeyEvent& pressEvent);
    59     void cancelButtonPress();
       
    60 
    54 
    61 protected:
    55 protected:
    62     void postKeyEvent(QEvent::Type type, int key);
    56     void postKeyEvent(QEvent::Type type, int key);
    63     void sendKeyEventToEditor(QEvent::Type type, int key);
    57     void sendKeyEventToEditor(QEvent::Type type, int key);
    64 
    58 
    65     inline DialpadNumericButton* button(int i) const;
       
    66     void updateButtonLabels();
       
    67     void updateColorArray();
       
    68     void updateIconColor();
       
    69     void updateTextLayouts(const QSizeF &size);
       
    70     void resolveTextContent(QList<QString> &content);
       
    71     void createTextLayouts(const QSizeF &size,
       
    72                            const QList<QString> &content);
       
    73     void layoutTextLines(const QSizeF &size,
       
    74                          QTextLayout &textLayout,
       
    75                          int state,
       
    76                          int type);
       
    77 
       
    78 protected:
    59 protected:
    79     void paint(QPainter* painter,
       
    80                const QStyleOptionGraphicsItem* option,
       
    81                QWidget* widget);
       
    82     void setGeometry(const QRectF &rect);
    60     void setGeometry(const QRectF &rect);
    83     void changeEvent(QEvent *event);
       
    84 
       
    85 private:
       
    86     enum ButtonState {
       
    87         Normal = 0,
       
    88         Pressed,
       
    89         StateCount
       
    90     };
       
    91 
       
    92     enum TextType {
       
    93         PrimaryText = 0,
       
    94         SecondaryText,
       
    95         TextTypeCount
       
    96     };
       
    97 
    61 
    98 private:
    62 private:
    99     const HbMainWindow& mMainWindow;
    63     const HbMainWindow& mMainWindow;
   100     DialpadInputField& mInputField;
    64     DialpadInputField& mInputField;
   101     QSignalMapper* mKeyClickedSignalMapper;
    65     QSignalMapper* mKeyClickedSignalMapper;
   102     QMap<int,QChar> mGeneratedChar;
       
   103     int mPressedNumericKey;
    66     int mPressedNumericKey;
   104     DialpadButton* mCallButton;
    67     DialpadButton* mCallButton;
   105     QList<QColor> mColors;
    68     DialpadNumericButtonGrid* mNumericButtonGrid;
   106     QList<QTextLayout*> mTextLayouts;
       
   107     qreal mUnit;
       
   108     qreal mMaxPrimaryLineWidth;
       
   109 };
    69 };
   110 
    70 
   111 #endif // DIALPADKEYPAD_H
    71 #endif // DIALPADKEYPAD_H