|
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: Custom widget derived from HbTextEdit which provides rich text |
|
15 * processing |
|
16 * |
|
17 */ |
|
18 #ifndef UNI_VIEWER_ADDRESS_WIDGET_H |
|
19 #define UNI_VIEWER_ADDRESS_WIDGET_H |
|
20 |
|
21 #include <HbTextEdit> |
|
22 |
|
23 #include "unidatamodelplugininterface.h" |
|
24 |
|
25 /** |
|
26 * UniViewerAddressWidget provides support for rich text processing |
|
27 */ |
|
28 class UniViewerAddressWidget : public HbTextEdit |
|
29 { |
|
30 Q_OBJECT |
|
31 |
|
32 public: |
|
33 /** |
|
34 * Constructor |
|
35 */ |
|
36 UniViewerAddressWidget(QGraphicsItem * parent = 0); |
|
37 |
|
38 /** |
|
39 * Destructor |
|
40 */ |
|
41 ~UniViewerAddressWidget(); |
|
42 |
|
43 /** |
|
44 * Populates the addresses and creates the anchors on them. |
|
45 * @param label Label of the address like - "From" |
|
46 * @param address Address string to be populated. |
|
47 */ |
|
48 void populate(const QString &label, const QString &address, const QString &alias); |
|
49 |
|
50 /** |
|
51 * Populates the addresses and creates the anchors on them. |
|
52 * @param label Label of the address like - "To", "Cc" |
|
53 * @param addressList List of addresses to be populated. |
|
54 */ |
|
55 void populate(const QString &label,ConvergedMessageAddressList addressList); |
|
56 |
|
57 /** |
|
58 * Clears the contents of the widget. |
|
59 */ |
|
60 void clearContent(); |
|
61 |
|
62 protected: |
|
63 /** |
|
64 * Gesture event, overridden from base class. |
|
65 */ |
|
66 void gestureEvent(QGestureEvent* event); |
|
67 |
|
68 private: |
|
69 /** |
|
70 * Helper method to highlight find item on tap. |
|
71 * @param highlight, if true highlight else dont. |
|
72 */ |
|
73 void highlightText(bool highlight); |
|
74 |
|
75 /** |
|
76 * short tap handler. |
|
77 * @param anchor anchor at cursor position. |
|
78 * @param pos tap position. |
|
79 */ |
|
80 void shortTapAction(QString anchor,const QPointF& pos); |
|
81 |
|
82 /** Helper method to get contact id against phone number or e-mail id. |
|
83 * @param value phone number or email id. |
|
84 * @param fieldName name of field to be matched. |
|
85 * @param fieldType type of field to be matched. |
|
86 */ |
|
87 int resolveContactId(const QString& value, |
|
88 const QString& fieldName, |
|
89 const QString& fieldType); |
|
90 |
|
91 /** |
|
92 * Helper method to populate menu items. |
|
93 * @param contextMenu menu to be populated. |
|
94 * @param data, highlighted number. |
|
95 */ |
|
96 void populateMenu(HbMenu* contextMenu, const QString& data); |
|
97 |
|
98 private slots: |
|
99 |
|
100 /** |
|
101 * called when aboutToShowContextMenu signal is emitted. |
|
102 */ |
|
103 void aboutToShowContextMenu(HbMenu *contextMenu, const QPointF &pos); |
|
104 |
|
105 /** |
|
106 * Called when option menu is closed. |
|
107 */ |
|
108 void menuClosed(); |
|
109 |
|
110 /** |
|
111 * handlers for phone number specific menu items. |
|
112 */ |
|
113 void openContactInfo(); |
|
114 void call(); |
|
115 void saveToContacts(); |
|
116 void sendMessage(); |
|
117 void copyToClipboard(); |
|
118 |
|
119 /** |
|
120 * called after service request is completed. |
|
121 */ |
|
122 void onServiceRequestCompleted(); |
|
123 |
|
124 /** |
|
125 * Slot for handling valid returns from the framework. |
|
126 * |
|
127 * @param result const QVariant& |
|
128 */ |
|
129 void handleOk(const QVariant& result); |
|
130 |
|
131 /** |
|
132 * Slot for handling errors. Error ids are provided as |
|
133 * 32-bit integers. |
|
134 * @param errorCode qint32 |
|
135 */ |
|
136 void handleError(int errorCode, const QString& errorMessage); |
|
137 |
|
138 |
|
139 signals: |
|
140 /** |
|
141 * this signal is emitted when send message is triggered for a highlighted number. |
|
142 */ |
|
143 void sendMessage(const QString& phoneNumber,const QString& alias); |
|
144 |
|
145 private: |
|
146 //Current cursor position. |
|
147 int mCursorPos; |
|
148 |
|
149 //char formats for highlight. |
|
150 QTextCharFormat mFormatHighlight; |
|
151 QTextCharFormat mFormatNormal; |
|
152 |
|
153 }; |
|
154 |
|
155 #endif // UNI_VIEWER_ADDRESS_WIDGET_H |
|
156 // EOF |