|
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 MSG_UNIFIED_EDITOR_LINEEDIT_H |
|
19 #define MSG_UNIFIED_EDITOR_LINEEDIT_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 |
|
74 private slots: |
|
75 void selectionChanged(const QTextCursor &oldCursor, const QTextCursor& newCursor); |
|
76 void onContentsChanged(); |
|
77 void aboutToShowContextMenu(HbMenu *contextMenu, const QPointF &pos); |
|
78 |
|
79 protected: // from HbLineEdit |
|
80 void inputMethodEvent(QInputMethodEvent *event); |
|
81 void keyPressEvent(QKeyEvent *event); |
|
82 void gestureEvent(QGestureEvent* event); |
|
83 void focusInEvent(QFocusEvent* event); |
|
84 void focusOutEvent(QFocusEvent *event); |
|
85 void timerEvent (QTimerEvent *event); |
|
86 |
|
87 |
|
88 private: |
|
89 void setHighlight(int currentPos); |
|
90 QString text() const; |
|
91 void handleTap(); |
|
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 // MSG_UNIFIED_EDITOR_LINEEDIT_H |