31
|
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 |
/**
|
|
65 |
* called when mouse is pressed.
|
|
66 |
*/
|
|
67 |
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
68 |
|
|
69 |
/**
|
|
70 |
* called when mouse is released.
|
|
71 |
*/
|
|
72 |
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
|
73 |
|
|
74 |
private:
|
|
75 |
/**
|
|
76 |
* Helper method to highlight find item on tap.
|
|
77 |
* @param highlight, if true highlight else dont.
|
|
78 |
*/
|
|
79 |
void highlightText(bool highlight);
|
|
80 |
|
|
81 |
/**
|
|
82 |
* short tap handler.
|
|
83 |
* @param anchor anchor at cursor position.
|
|
84 |
*/
|
|
85 |
void shortTapAction(QString anchor);
|
|
86 |
|
|
87 |
/** Helper method to get contact id against phone number or e-mail id.
|
|
88 |
* @param value phone number or email id.
|
|
89 |
* @param fieldName name of field to be matched.
|
|
90 |
* @param fieldType type of field to be matched.
|
|
91 |
*/
|
|
92 |
int resolveContactId(const QString& value,
|
|
93 |
const QString& fieldName,
|
|
94 |
const QString& fieldType);
|
|
95 |
|
|
96 |
|
|
97 |
private slots:
|
|
98 |
|
|
99 |
/**
|
|
100 |
* called when aboutToShowContextMenu signal is emitted.
|
|
101 |
*/
|
|
102 |
void aboutToShowContextMenu(HbMenu *contextMenu, const QPointF &pos);
|
|
103 |
|
|
104 |
/**
|
|
105 |
* Called when option menu is closed.
|
|
106 |
*/
|
|
107 |
void menuClosed();
|
|
108 |
|
|
109 |
//handlers for phone number specific menu items.
|
|
110 |
void openContactInfo();
|
|
111 |
void call();
|
|
112 |
void saveToContacts();
|
|
113 |
void sendMessage();
|
|
114 |
void copyToClipboard();
|
|
115 |
|
|
116 |
//called after service request is completed.
|
|
117 |
void onServiceRequestCompleted();
|
|
118 |
|
|
119 |
/**
|
|
120 |
* Slot for handling valid returns from the framework.
|
|
121 |
*
|
|
122 |
* @param result const QVariant&
|
|
123 |
*/
|
|
124 |
void handleOk(const QVariant& result);
|
|
125 |
|
|
126 |
/**
|
|
127 |
* Slot for handling errors. Error ids are provided as
|
|
128 |
* 32-bit integers.
|
|
129 |
* @param errorCode qint32
|
|
130 |
*/
|
|
131 |
void handleError(int errorCode, const QString& errorMessage);
|
|
132 |
|
|
133 |
|
|
134 |
signals:
|
|
135 |
/**
|
|
136 |
* this signal is emitted when send message is triggered for a highlighted number.
|
|
137 |
*/
|
|
138 |
void sendMessage(const QString& phoneNumber,const QString& alias);
|
|
139 |
|
|
140 |
private:
|
|
141 |
//Current cursor position.
|
|
142 |
int mCursorPos;
|
|
143 |
|
|
144 |
//char formats for highlight.
|
|
145 |
QTextCharFormat mFormatHighlight;
|
|
146 |
QTextCharFormat mFormatNormal;
|
|
147 |
|
|
148 |
};
|
|
149 |
|
|
150 |
#endif // UNI_VIEWER_ADDRESS_WIDGET_H
|
|
151 |
// EOF
|