telutils/dialpad/inc/dialpadkeypad.h
branchRCL_3
changeset 20 987c9837762f
parent 19 7d48bed6ce0c
child 21 0a6dd2dc9970
equal deleted inserted replaced
19:7d48bed6ce0c 20:987c9837762f
     1 /*!
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: Dialpad keypad
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef DIALPADKEYPAD_H
       
    19 #define DIALPADKEYPAD_H
       
    20 
       
    21 #include <QTextLayout>
       
    22 #include <QColor>
       
    23 #include <hbinputbuttongroup.h>
       
    24 
       
    25 class DialpadInputField;
       
    26 class DialpadButton;
       
    27 class DialpadNumericButton;
       
    28 class QSignalMapper;
       
    29 class QGraphicsGridLayout;
       
    30 
       
    31 class DialpadKeypad : public HbInputButtonGroup
       
    32 {
       
    33     Q_OBJECT
       
    34 
       
    35 public:
       
    36     explicit DialpadKeypad(
       
    37         const HbMainWindow& mainWindow,
       
    38         DialpadInputField& inputField,
       
    39         QGraphicsItem* parent=0);
       
    40 
       
    41     ~DialpadKeypad();
       
    42 
       
    43 public:
       
    44     void setCallButtonEnabled(bool enabled);
       
    45 
       
    46     void resetButtons();
       
    47 
       
    48     DialpadButton& callButton() const;
       
    49 
       
    50 protected slots:
       
    51     void setButtonTexts();
       
    52 
       
    53     void handleKeyClicked(int key);
       
    54     void sendKeyPressEvent(const QKeyEvent& event);
       
    55     void sendKeyReleaseEvent(const QKeyEvent& event);
       
    56     void sendLongPressEvent(const QKeyEvent& event);
       
    57     void handleKeyChangeEvent(const QKeyEvent& releaseEvent,
       
    58                               const QKeyEvent& pressEvent);
       
    59     void cancelButtonPress();
       
    60 
       
    61 protected:
       
    62     void postKeyEvent(QEvent::Type type, int key);
       
    63     void sendKeyEventToEditor(QEvent::Type type, int key);
       
    64 
       
    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:
       
    79     void paint(QPainter* painter,
       
    80                const QStyleOptionGraphicsItem* option,
       
    81                QWidget* widget);
       
    82     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 
       
    98 private:
       
    99     const HbMainWindow& mMainWindow;
       
   100     DialpadInputField& mInputField;
       
   101     QSignalMapper* mKeyClickedSignalMapper;
       
   102     QMap<int,QChar> mGeneratedChar;
       
   103     int mPressedNumericKey;
       
   104     DialpadButton* mCallButton;
       
   105     QList<QColor> mColors;
       
   106     QList<QTextLayout*> mTextLayouts;
       
   107     qreal mUnit;
       
   108     qreal mMaxPrimaryLineWidth;
       
   109 };
       
   110 
       
   111 #endif // DIALPADKEYPAD_H