18 |
18 |
19 #include "univieweraddresswidget.h" |
19 #include "univieweraddresswidget.h" |
20 |
20 |
21 // SYSTEM INCLUDES |
21 // SYSTEM INCLUDES |
22 #include <QTextCursor> |
22 #include <QTextCursor> |
23 #include <HbMenu> |
|
24 #include <QGraphicsSceneMouseEvent> |
|
25 #include <HbAction> |
|
26 #include <HbFrameItem> |
|
27 #include <QTextBlock> |
23 #include <QTextBlock> |
28 #include <QApplication> |
24 #include <QApplication> |
29 #include <QClipBoard> |
25 #include <QClipboard> |
|
26 |
|
27 #include <HbMenu> |
|
28 #include <HbAction> |
|
29 #include <HbTapGesture> |
|
30 |
30 #include <xqservicerequest.h> |
31 #include <xqservicerequest.h> |
31 |
|
32 #include <xqappmgr.h> |
32 #include <xqappmgr.h> |
33 #include <cntservicescontact.h> |
33 #include <cntservicescontact.h> |
34 #include <qtcontacts.h> |
34 #include <qtcontacts.h> |
35 #include <XQServiceRequest.h> |
35 #include <xqservicerequest.h> |
36 #include <xqaiwrequest.h> |
36 #include <xqaiwrequest.h> |
37 #include "msgcontacthandler.h" |
37 #include "msgcontacthandler.h" |
38 |
|
39 |
|
40 |
|
41 |
|
42 |
38 |
43 // LOCAL CONSTANTS |
39 // LOCAL CONSTANTS |
44 const QString ADDRESS_SEPARATOR("; "); |
40 const QString ADDRESS_SEPARATOR("; "); |
45 const QString ADDRESS_OPEN(" ("); |
41 const QString ADDRESS_OPEN(" ("); |
46 const QString ADDRESS_CLOSE(")"); |
42 const QString ADDRESS_CLOSE(")"); |
61 //--------------------------------------------------------------- |
57 //--------------------------------------------------------------- |
62 UniViewerAddressWidget::UniViewerAddressWidget(QGraphicsItem * parent) : |
58 UniViewerAddressWidget::UniViewerAddressWidget(QGraphicsItem * parent) : |
63 HbTextEdit(parent), |
59 HbTextEdit(parent), |
64 mCursorPos(-1) |
60 mCursorPos(-1) |
65 { |
61 { |
66 this->setReadOnly(true); |
62 this->setReadOnly(true); |
|
63 this->setScrollable(false); |
|
64 this->setFlag(QGraphicsItem::ItemIsFocusable,false); |
67 this->setCursorVisibility(Hb::TextCursorHidden); |
65 this->setCursorVisibility(Hb::TextCursorHidden); |
68 this->setScrollable(false); |
66 this->setBackgroundItem(0); |
69 HbFrameItem *noBackground = new HbFrameItem(this); |
|
70 this->setBackgroundItem(noBackground); |
|
71 |
67 |
72 HbFontSpec fontSpec(HbFontSpec::Secondary); |
68 HbFontSpec fontSpec(HbFontSpec::Secondary); |
73 QFont font = fontSpec.font(); |
69 QFont font = fontSpec.font(); |
74 this->setFont(font); |
70 this->setFont(font); |
75 |
71 |
90 UniViewerAddressWidget::~UniViewerAddressWidget() |
86 UniViewerAddressWidget::~UniViewerAddressWidget() |
91 { |
87 { |
92 } |
88 } |
93 |
89 |
94 //--------------------------------------------------------------- |
90 //--------------------------------------------------------------- |
95 //UniViewerAddressWidget :: mousePressEvent |
91 //UniViewerAddressWidget :: gestureEvent |
96 // @see header file |
92 // @see header file |
97 //--------------------------------------------------------------- |
93 //--------------------------------------------------------------- |
98 void UniViewerAddressWidget::mousePressEvent(QGraphicsSceneMouseEvent *event) |
94 void UniViewerAddressWidget::gestureEvent(QGestureEvent* event) |
99 { |
95 { |
100 HbTextEdit::mousePressEvent(event); |
96 //handle gesture to highlight and dehighlight find item. |
101 |
97 |
102 QTextDocument* doc = this->document(); |
98 if(HbTapGesture *tap = qobject_cast<HbTapGesture*>(event->gesture(Qt::TapGesture))) |
103 |
99 { |
104 mCursorPos = doc->documentLayout()->hitTest(event->pos(), Qt::ExactHit); |
100 //capturing gesture position, and map to local co-ordinates. |
105 |
101 QPointF pos = mapFromScene(tap->scenePosition()); |
106 highlightText(true); |
102 |
107 } |
103 switch (tap->state()) |
108 |
104 { |
109 //--------------------------------------------------------------- |
105 case Qt::GestureStarted: |
110 //UniViewerAddressWidget :: mouseReleaseEvent |
106 { |
111 // @see header file |
107 //highlight find item. |
112 //--------------------------------------------------------------- |
108 QTextDocument* doc = this->document(); |
113 void UniViewerAddressWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) |
109 mCursorPos = doc->documentLayout()->hitTest(pos, Qt::ExactHit); |
114 { |
110 highlightText(true); |
115 HbTextEdit::mouseReleaseEvent(event); |
111 break; |
116 |
112 } |
117 highlightText(false); |
113 |
118 |
114 case Qt::GestureFinished: |
119 QString anchor = this->anchorAt(event->pos()); |
115 { |
120 |
116 if (HbTapGesture::Tap == tap->tapStyleHint()) |
121 if(!anchor.isEmpty() && !this->textCursor().hasSelection()) |
117 { |
122 { |
118 //gesture is finshed dehighlight text. |
123 shortTapAction(anchor); |
119 highlightText(false); |
124 } |
120 |
125 } |
121 QString anchor = this->anchorAt(pos); |
|
122 |
|
123 //do short tap action. |
|
124 if (!anchor.isEmpty() && !this->textCursor().hasSelection()) |
|
125 { |
|
126 shortTapAction(anchor); |
|
127 } |
|
128 } |
|
129 break; |
|
130 } |
|
131 |
|
132 case Qt::GestureCanceled: |
|
133 { |
|
134 //gesture is canceled due to pan or swipe, dehighlight text. |
|
135 if (HbTapGesture::Tap == tap->tapStyleHint()) |
|
136 { |
|
137 highlightText(false); |
|
138 break; |
|
139 } |
|
140 } |
|
141 default: |
|
142 break; |
|
143 } |
|
144 |
|
145 event->accept(); |
|
146 } |
|
147 else |
|
148 { |
|
149 event->ignore(); |
|
150 } |
|
151 |
|
152 //passing gesture event to base class. |
|
153 HbTextEdit::gestureEvent(event); |
|
154 } |
|
155 |
126 |
156 |
127 //---------------------------------------------------------------------------- |
157 //---------------------------------------------------------------------------- |
128 // UniViewerAddressWidget::populate |
158 // UniViewerAddressWidget::populate |
129 // @see header file |
159 // @see header file |
130 //---------------------------------------------------------------------------- |
160 //---------------------------------------------------------------------------- |
370 if(action) |
400 if(action) |
371 { |
401 { |
372 QString phoneNumber = action->data().toString(); |
402 QString phoneNumber = action->data().toString(); |
373 |
403 |
374 //invoke dialer service and pass phoneNumber. |
404 //invoke dialer service and pass phoneNumber. |
375 QString serviceName("com.nokia.services.telephony"); |
405 QString serviceName("com.nokia.symbian.ICallDial"); |
376 QString operation("dial(QString)"); |
406 QString operation("dial(QString)"); |
377 |
407 |
378 XQServiceRequest* serviceRequest = new XQServiceRequest(serviceName,operation,false); |
408 XQServiceRequest* serviceRequest = new XQServiceRequest(serviceName,operation,false); |
379 |
409 |
380 connect(serviceRequest, SIGNAL(requestCompleted(QVariant)), |
410 connect(serviceRequest, SIGNAL(requestCompleted(QVariant)), |