messagingapp/msgui/unifiededitor/inc/msgunifiededitorlineedit.h
changeset 34 84197e66a4bd
parent 31 ebfee66fde93
child 36 844a5921f85b
child 43 35b64624a9e7
equal deleted inserted replaced
31:ebfee66fde93 34:84197e66a4bd
     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: Derieved HbLineEdit class for custom address editor
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef MSGUNIFIEDEDITORLINEEDIT_H
       
    19 #define MSGUNIFIEDEDITORLINEEDIT_H
       
    20 
       
    21 #include <HbLineEdit>
       
    22 #include<QBasicTimer>
       
    23 
       
    24 
       
    25 class MsgUnifiedEditorLineEdit : public HbLineEdit
       
    26 {
       
    27     Q_OBJECT
       
    28 
       
    29 public:
       
    30     /**
       
    31      * Constructor
       
    32      */
       
    33     MsgUnifiedEditorLineEdit(const QString& label, QGraphicsItem* parent=0);
       
    34     
       
    35     /**
       
    36      * Destructor
       
    37      */
       
    38     ~MsgUnifiedEditorLineEdit();
       
    39     
       
    40     /**
       
    41      * seeker method for getting address list
       
    42      */
       
    43     QStringList addresses();
       
    44 
       
    45     /**
       
    46      * Flag to retain or override base-class behaviour
       
    47      * Needed because address & subject field classes derieve
       
    48      * from this class, but have different behaviour
       
    49      */
       
    50     void setDefaultBehaviour(bool defaultBehaviour = false);
       
    51     
       
    52     /**
       
    53      * seeker method for getting the text content held by editing field
       
    54      */
       
    55     QString content() const;
       
    56     
       
    57     /**
       
    58      * setter method to clear text content of the editing field
       
    59      */
       
    60     void clearContent();
       
    61     
       
    62     /**
       
    63      * set highlight on invalid contact
       
    64      * @param invalidStr, String to be highlighted
       
    65      */
       
    66     void highlightInvalidString(QString invalidStr);
       
    67 
       
    68 signals:
       
    69     void contentsChanged(const QString& text);
       
    70 
       
    71 public slots:
       
    72     void setText(const QString &text, bool underlined = true);
       
    73     void cut();
       
    74     void selectAll();
       
    75 
       
    76 private slots:
       
    77     void selectionChanged(const QTextCursor &oldCursor, const QTextCursor& newCursor);
       
    78     void onContentsChanged();
       
    79     
       
    80 protected: // from HbLineEdit
       
    81     void inputMethodEvent(QInputMethodEvent *event);
       
    82     void keyPressEvent(QKeyEvent *event);
       
    83     void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
       
    84     void focusInEvent(QFocusEvent* event);
       
    85     void focusOutEvent(QFocusEvent *event);
       
    86     void timerEvent (QTimerEvent *event);
       
    87 
       
    88 
       
    89 private:
       
    90     void setHighlight(int currentPos);
       
    91     QString text() const;
       
    92 
       
    93 private:
       
    94     QRegExp mLabelExpr;
       
    95     QString mLabel;
       
    96     QBasicTimer mSelectionSnapTimer;
       
    97 
       
    98     int mSelectionStart;
       
    99     int mSelectionEnd;
       
   100     bool mDefaultBehaviour;
       
   101 };
       
   102 
       
   103 #endif // MSGUNIFIEDEDITORLINEEDIT_H