72 mIsNoEntriesAdded = true; |
73 mIsNoEntriesAdded = true; |
73 mIsGestureHandled = false; |
74 mIsGestureHandled = false; |
74 mNoEntriesLabel = 0; |
75 mNoEntriesLabel = 0; |
75 mHtDiff = 0.0; |
76 mHtDiff = 0.0; |
76 mScrollDuration = 0; |
77 mScrollDuration = 0; |
|
78 mPreviewTextColor = HbColorScheme::color("qtc_cal_day_preview_text"); |
|
79 |
77 setAcceptDrops(true); |
80 setAcceptDrops(true); |
78 setScrollDirections(Qt::Vertical); |
81 setScrollDirections(Qt::Vertical); |
79 setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); |
82 setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff); |
80 |
83 |
81 // Connect the scrollig finished signal |
84 // Connect the scrollig finished signal |
105 { |
108 { |
106 OstTraceFunctionEntry0( CALENPREVIEWPANE_SETNOENTRIESLABEL_ENTRY ); |
109 OstTraceFunctionEntry0( CALENPREVIEWPANE_SETNOENTRIESLABEL_ENTRY ); |
107 |
110 |
108 mNoEntriesLabel = label; |
111 mNoEntriesLabel = label; |
109 |
112 |
|
113 if (mPreviewTextColor.isValid()) { |
|
114 mNoEntriesLabel->setTextColor(mPreviewTextColor); |
|
115 } |
110 OstTraceFunctionExit0( CALENPREVIEWPANE_SETNOENTRIESLABEL_EXIT ); |
116 OstTraceFunctionExit0( CALENPREVIEWPANE_SETNOENTRIESLABEL_EXIT ); |
111 } |
117 } |
112 |
118 |
113 /*! |
119 /*! |
114 Populates the preview with proper data |
120 Populates the preview with proper data |
136 (content->layout()); |
143 (content->layout()); |
137 int instanceCount = mInstanceArray.count(); |
144 int instanceCount = mInstanceArray.count(); |
138 HbFontSpec font(HbFontSpec::Secondary); |
145 HbFontSpec font(HbFontSpec::Secondary); |
139 if (mIsNoEntriesAdded) { |
146 if (mIsNoEntriesAdded) { |
140 if (!instanceCount) { |
147 if (!instanceCount) { |
|
148 if (mPreviewTextColor.isValid()) { |
|
149 mNoEntriesLabel->setTextColor(mPreviewTextColor); |
|
150 } |
141 mNoEntriesLabel->setVisible(true); |
151 mNoEntriesLabel->setVisible(true); |
142 OstTraceFunctionExit0( CALENPREVIEWPANE_POPULATELABEL_EXIT ); |
152 OstTraceFunctionExit0( CALENPREVIEWPANE_POPULATELABEL_EXIT ); |
143 return; |
153 return; |
144 } else { |
154 } else { |
145 // Remove the no entries label |
155 // Remove the no entries label |
160 label = new HbLabel(this); |
170 label = new HbLabel(this); |
161 |
171 |
162 // Set the required font |
172 // Set the required font |
163 label->setFontSpec(font); |
173 label->setFontSpec(font); |
164 |
174 |
165 // Set the text color from the theme |
|
166 QColor previewPaneColor = HbColorScheme::color( |
|
167 "qtc_cal_day_preview_text"); |
|
168 if (previewPaneColor.isValid()) { |
|
169 label->setTextColor(previewPaneColor); |
|
170 } |
|
171 |
|
172 // Set the elide mode to right |
175 // Set the elide mode to right |
173 label->setElideMode(Qt::ElideRight); |
176 label->setElideMode(Qt::ElideRight); |
174 // Add the label to the list |
177 // Add the label to the list |
175 mLabelList.append(label); |
178 mLabelList.append(label); |
176 layout->addItem(label); |
179 layout->addItem(label); |
177 } else { |
180 } else { |
178 // Reuse the same label |
181 // Reuse the same label |
179 label = mLabelList.at(i); |
182 label = mLabelList.at(i); |
180 count--; |
183 count--; |
|
184 } |
|
185 |
|
186 if (mPreviewTextColor.isValid()) { |
|
187 label->setTextColor(mPreviewTextColor); |
181 } |
188 } |
182 QString summary = mInstanceArray[i].summary(); |
189 QString summary = mInstanceArray[i].summary(); |
183 if(!summary.length()) { |
190 if(!summary.length()) { |
184 // No summary display "Unnamed" |
191 // No summary display "Unnamed" |
185 summary.append(hbTrId("txt_calendar_preview_unnamed")); |
192 summary.append(hbTrId("txt_calendar_preview_unnamed")); |
289 if (mIsNoEntriesAdded) { |
299 if (mIsNoEntriesAdded) { |
290 scrollContentsTo(QPointF(0.0,0.0)); |
300 scrollContentsTo(QPointF(0.0,0.0)); |
291 OstTraceFunctionExit0( CALENPREVIEWPANE_STARTAUTOSCROLL_EXIT ); |
301 OstTraceFunctionExit0( CALENPREVIEWPANE_STARTAUTOSCROLL_EXIT ); |
292 return; |
302 return; |
293 } |
303 } |
294 |
304 |
|
305 // Stop the timer |
|
306 mTwoSecTimer->stop(); |
|
307 |
|
308 // Set the proper scroll direction |
|
309 mScrollDirection = up; |
|
310 |
295 // Start the 2 seconds timer |
311 // Start the 2 seconds timer |
296 mTwoSecTimer->setSingleShot(true); |
312 mTwoSecTimer->setSingleShot(true); |
297 connect(mTwoSecTimer, SIGNAL(timeout()), this, SLOT(onTwoSecondsTimeout())); |
313 connect(mTwoSecTimer, SIGNAL(timeout()), this, SLOT(onTwoSecondsTimeout())); |
298 mTwoSecTimer->start(TWO_SECONDS_TIMER); |
314 mTwoSecTimer->start(TWO_SECONDS_TIMER); |
299 |
315 |
321 mScrollDuration = mHtDiff / SCROLLING_SPEED; |
337 mScrollDuration = mHtDiff / SCROLLING_SPEED; |
322 } |
338 } |
323 } |
339 } |
324 |
340 |
325 // Start the scrolling in the proper direction |
341 // Start the scrolling in the proper direction |
326 if (mScrollDirection == up) { |
342 if (mScrollDirection == up && mScrollDuration) { |
327 // Start scrolling upwards |
343 // Start scrolling upwards |
328 mScrollDirection = down; |
344 mScrollDirection = down; |
329 mNumOfScrolls++; |
345 mNumOfScrolls++; |
330 QPointF targetPos(0.0, -mHtDiff); |
346 QPointF targetPos(0.0, -mHtDiff); |
331 scrollContentsTo(-targetPos, mScrollDuration * 1000); |
347 scrollContentsTo(-targetPos, mScrollDuration * 1000); |
332 } else if (mScrollDirection == down) { |
348 } else if (mScrollDirection == down && mScrollDuration) { |
333 mScrollDirection = up; |
349 mScrollDirection = up; |
334 mNumOfScrolls++; |
350 mNumOfScrolls++; |
335 // Start scrolling downwards |
351 // Start scrolling downwards |
336 QPointF targetPos(0.0, 0.0); |
352 QPointF targetPos(0.0, 0.0); |
337 scrollContentsTo(targetPos, mScrollDuration * 1000); |
353 scrollContentsTo(targetPos, mScrollDuration * 1000); |
428 } |
444 } |
429 } else if(QTapGesture *tapGesture = qobject_cast<QTapGesture *>(event->gesture(Qt::TapGesture))) { |
445 } else if(QTapGesture *tapGesture = qobject_cast<QTapGesture *>(event->gesture(Qt::TapGesture))) { |
430 if (tapGesture && tapGesture->state() == Qt::GestureFinished) { |
446 if (tapGesture && tapGesture->state() == Qt::GestureFinished) { |
431 HbInstantFeedback::play(HbFeedback::Basic); |
447 HbInstantFeedback::play(HbFeedback::Basic); |
432 // Preview pane tapped |
448 // Preview pane tapped |
|
449 // Stop the scrolling first |
|
450 stopScrolling(); |
|
451 // Issue command to launch agenda view |
433 mServices.IssueCommandL(ECalenAgendaView); |
452 mServices.IssueCommandL(ECalenAgendaView); |
|
453 mView->disconnectAboutToQuitEvent(); |
434 event->accept(Qt::TapGesture); |
454 event->accept(Qt::TapGesture); |
435 } |
455 } |
436 } |
456 } |
437 |
457 |
438 OstTraceFunctionExit0( DUP2_CALENPREVIEWPANE_GESTUREEVENT_EXIT ); |
458 OstTraceFunctionExit0( DUP3_CALENPREVIEWPANE_GESTUREEVENT_EXIT ); |
439 } |
459 } |
440 |
460 |
441 /*! |
461 /*! |
442 Set monthview pointer |
462 Set monthview pointer |
443 */ |
463 */ |
455 */ |
475 */ |
456 void CalenPreviewPane::stopScrolling() |
476 void CalenPreviewPane::stopScrolling() |
457 { |
477 { |
458 OstTraceFunctionEntry0( CALENPREVIEWPANE_STOPSCROLLING_ENTRY ); |
478 OstTraceFunctionEntry0( CALENPREVIEWPANE_STOPSCROLLING_ENTRY ); |
459 |
479 |
460 if (isScrolling() || mTwoSecTimer->isActive()) { |
480 mTwoSecTimer->stop(); |
|
481 if (isScrolling()) { |
|
482 mNumOfScrolls = 0; // required so that timer will not get started again in |
|
483 // scrollingFinished() slot |
|
484 // Stop the scrolling by sending the foucs out event |
|
485 QFocusEvent* focusEvent = new QFocusEvent(QFocusEvent::FocusOut, Qt::MouseFocusReason); |
|
486 focusOutEvent(focusEvent); |
|
487 |
|
488 // Set the contents position to zero |
461 scrollContentsTo(QPointF(0.0,0.0)); |
489 scrollContentsTo(QPointF(0.0,0.0)); |
462 |
|
463 // Call pan gesture with zero delta just to stop the scfrolling |
|
464 HbScrollArea::panGesture(QPointF(0.0,0.0)); |
|
465 mTwoSecTimer->stop(); |
|
466 } |
490 } |
467 |
491 |
468 OstTraceFunctionExit0( CALENPREVIEWPANE_STOPSCROLLING_EXIT ); |
492 OstTraceFunctionExit0( CALENPREVIEWPANE_STOPSCROLLING_EXIT ); |
469 } |
493 } |
470 |
494 |
497 void CalenPreviewPane::effectFinished() |
521 void CalenPreviewPane::effectFinished() |
498 { |
522 { |
499 mIsGestureHandled = false; |
523 mIsGestureHandled = false; |
500 } |
524 } |
501 |
525 |
|
526 /*! |
|
527 Slot to handle the change in theme |
|
528 */ |
|
529 void CalenPreviewPane::handleThemeChange() |
|
530 { |
|
531 OstTraceFunctionEntry0( CALENPREVIEWPANE_HANDLETHEMECHANGE_ENTRY ); |
|
532 |
|
533 mPreviewTextColor = HbColorScheme::color("qtc_cal_day_preview_text"); |
|
534 |
|
535 OstTraceFunctionExit0( CALENPREVIEWPANE_HANDLETHEMECHANGE_EXIT ); |
|
536 } |
|
537 |
502 // End of file --Don't remove this. |
538 // End of file --Don't remove this. |