--- a/calendarui/views/src/calenpreviewpane.cpp Tue Jul 06 14:14:56 2010 +0300
+++ b/calendarui/views/src/calenpreviewpane.cpp Wed Aug 18 09:47:38 2010 +0300
@@ -29,6 +29,8 @@
#include <hbcolorscheme.h>
#include <hbtapgesture.h>
#include <hbpangesture.h>
+#include <hbinstance.h>
+#include <hbinstantfeedback.h>
#include <agendautil.h>
#include <agendaentry.h>
@@ -41,12 +43,17 @@
#include "calencommon.h"
#include "calenpreviewpane.h"
#include "calenmonthview.h"
+#include "OstTraceDefinitions.h"
+#ifdef OST_TRACE_COMPILER_IN_USE
+#include "calenpreviewpaneTraces.h"
+#endif
+
// Macros
#define TWO_SECONDS_TIMER 2000 // millseconds
#define SCROLLING_SPEED 10
#define MAX_PAN_DIRECTION_THRESHOLD 50
-#define MIN_PAN_DIRECTION_THRESHOLD 20
+#define MIN_PAN_DIRECTION_THRESHOLD 10
static const QString EMPTYSTRING(" ");
@@ -57,6 +64,8 @@
QGraphicsItem* parent)
: HbScrollArea(parent),mServices(services)
{
+ OstTraceFunctionEntry0( CALENPREVIEWPANE_CALENPREVIEWPANE_ENTRY );
+
// Create the timer
mTwoSecTimer = new QTimer(this);
mScrollDirection = invalid;
@@ -72,6 +81,11 @@
// Connect the scrollig finished signal
connect(this, SIGNAL(scrollingEnded()), this,
SLOT(scrollingFinished()));
+
+ grabGesture(Qt::TapGesture);
+ grabGesture(Qt::PanGesture);
+
+ OstTraceFunctionExit0( CALENPREVIEWPANE_CALENPREVIEWPANE_EXIT );
}
/*!
@@ -79,6 +93,9 @@
*/
CalenPreviewPane::~CalenPreviewPane()
{
+ OstTraceFunctionEntry0( DUP1_CALENPREVIEWPANE_CALENPREVIEWPANE_ENTRY );
+
+ OstTraceFunctionExit0( DUP1_CALENPREVIEWPANE_CALENPREVIEWPANE_EXIT );
}
/*!
@@ -86,7 +103,11 @@
*/
void CalenPreviewPane::setNoEntriesLabel(HbLabel* label)
{
+ OstTraceFunctionEntry0( CALENPREVIEWPANE_SETNOENTRIESLABEL_ENTRY );
+
mNoEntriesLabel = label;
+
+ OstTraceFunctionExit0( CALENPREVIEWPANE_SETNOENTRIESLABEL_EXIT );
}
/*!
@@ -94,6 +115,8 @@
*/
void CalenPreviewPane::populateLabel(QDateTime date)
{
+ OstTraceFunctionEntry0( CALENPREVIEWPANE_POPULATELABEL_ENTRY );
+
mScrollDirection = up;
// Scroll contents to zero position before we display to the user
@@ -116,6 +139,7 @@
if (mIsNoEntriesAdded) {
if (!instanceCount) {
mNoEntriesLabel->setVisible(true);
+ OstTraceFunctionExit0( CALENPREVIEWPANE_POPULATELABEL_EXIT );
return;
} else {
// Remove the no entries label
@@ -157,14 +181,18 @@
}
QString summary = mInstanceArray[i].summary();
if(!summary.length()) {
- // No summary display "No subject"
- summary.append(hbTrId("txt_calendar_dblist_unnamed"));
+ // No summary display "Unnamed"
+ summary.append(hbTrId("txt_calendar_preview_unnamed"));
}
- // Chcek the entry type, based on the type display time field in
+ // Check the entry type, based on the type display time field in
// preview pane.
QString start;
- if(mInstanceArray[i].type() != AgendaEntry::TypeTodo ) {
+ if(mInstanceArray[i].type() != AgendaEntry::TypeTodo &&
+ mInstanceArray[i].type() != AgendaEntry::TypeAnniversary &&
+ !CalenAgendaUtils::isAlldayEvent(mInstanceArray[i])) {
QDateTime startTime = mInstanceArray[i].startTime();
+ // Check if event starts in past
+ checkStartTimeOfEvent(startTime);
HbExtendedLocale systemLocale =HbExtendedLocale::system();
start = systemLocale.format(startTime.time(),
r_qtn_time_usual_with_zero);
@@ -211,6 +239,8 @@
mIsNoEntriesAdded = true;
}
layout->activate();
+
+ OstTraceFunctionExit0( DUP1_CALENPREVIEWPANE_POPULATELABEL_EXIT );
}
/*!
@@ -218,6 +248,8 @@
*/
void CalenPreviewPane::GetInstanceListL()
{
+ OstTraceFunctionEntry0( CALENPREVIEWPANE_GETINSTANCELISTL_ENTRY );
+
mInstanceArray.clear();
// Find Meetings, Remainders, Anniversaries and Day Notes
@@ -232,6 +264,8 @@
AgendaUtil::IncludeReminders);
mInstanceArray = mServices.agendaInterface()->
createEntryIdListForDay(dayStart, filter);
+
+ OstTraceFunctionExit0( CALENPREVIEWPANE_GETINSTANCELISTL_EXIT );
}
/*!
@@ -239,6 +273,9 @@
*/
QDateTime CalenPreviewPane::Date()
{
+ OstTraceFunctionEntry0( CALENPREVIEWPANE_DATE_ENTRY );
+
+ OstTraceFunctionExit0( CALENPREVIEWPANE_DATE_EXIT );
return mDate;
}
@@ -247,8 +284,11 @@
*/
void CalenPreviewPane::startAutoScroll()
{
+ OstTraceFunctionEntry0( CALENPREVIEWPANE_STARTAUTOSCROLL_ENTRY );
+
if (mIsNoEntriesAdded) {
scrollContentsTo(QPointF(0.0,0.0));
+ OstTraceFunctionExit0( CALENPREVIEWPANE_STARTAUTOSCROLL_EXIT );
return;
}
@@ -256,6 +296,8 @@
mTwoSecTimer->setSingleShot(true);
connect(mTwoSecTimer, SIGNAL(timeout()), this, SLOT(onTwoSecondsTimeout()));
mTwoSecTimer->start(TWO_SECONDS_TIMER);
+
+ OstTraceFunctionExit0( DUP1_CALENPREVIEWPANE_STARTAUTOSCROLL_EXIT );
}
/*!
@@ -264,6 +306,8 @@
*/
void CalenPreviewPane::onTwoSecondsTimeout()
{
+ OstTraceFunctionEntry0( CALENPREVIEWPANE_ONTWOSECONDSTIMEOUT_ENTRY );
+
mTwoSecTimer->stop();
disconnect(mTwoSecTimer, SIGNAL(timeout()),
this, SLOT(onTwoSecondsTimeout()));
@@ -292,6 +336,8 @@
QPointF targetPos(0.0, 0.0);
scrollContentsTo(targetPos, mScrollDuration * 1000);
}
+
+ OstTraceFunctionExit0( CALENPREVIEWPANE_ONTWOSECONDSTIMEOUT_EXIT );
}
/*!
@@ -300,14 +346,19 @@
*/
void CalenPreviewPane::scrollingFinished()
{
+ OstTraceFunctionEntry0( CALENPREVIEWPANE_SCROLLINGFINISHED_ENTRY );
+
// If we are here because of calling scrollContentsTo()
if (!mNumOfScrolls) {
+ OstTraceFunctionExit0( CALENPREVIEWPANE_SCROLLINGFINISHED_EXIT );
return;
}
// Now start the two seconds timer again
mTwoSecTimer->setSingleShot(true);
connect(mTwoSecTimer, SIGNAL(timeout()), this, SLOT(onTwoSecondsTimeout()));
mTwoSecTimer->start(TWO_SECONDS_TIMER);
+
+ OstTraceFunctionExit0( DUP1_CALENPREVIEWPANE_SCROLLINGFINISHED_EXIT );
}
/*!
@@ -315,55 +366,76 @@
*/
void CalenPreviewPane::gestureEvent(QGestureEvent *event)
{
+ OstTraceFunctionEntry0( CALENPREVIEWPANE_GESTUREEVENT_ENTRY );
+
if(HbPanGesture *gesture = qobject_cast<HbPanGesture *>(event->gesture(Qt::PanGesture))) {
- if (gesture->state() == Qt::GestureStarted) {
- // TODO: This work aroung till framework provides an api
+ if (gesture->state() == Qt::GestureUpdated) {
+ // Check if effect is not yet completed, ignore the current gesture if it is
+ if (mIsGestureHandled) {
+ OstTraceFunctionExit0( CALENPREVIEWPANE_GESTUREEVENT_EXIT );
+ return;
+ }
+ // TODO: This work around till framework provides an api
// to know the direciton of the pan, until then we need
// calculate the direction explicitly
// Get to know the direction of the gesture
QPointF delta = gesture->delta();
- if (abs(delta.y()) > MAX_PAN_DIRECTION_THRESHOLD) {
- // Now see if y coord diff has crossed threshold
- if (delta.x() > MAX_PAN_DIRECTION_THRESHOLD) {
+ // Check the current orientation of the device and
+ // swap the vertical and horizontal distances in landscape
+ qreal horizontalDiff = 0.0;
+ qreal verticalDiff = 0.0;
+ if (hbInstance->allMainWindows().at(0)->orientation() == Qt::Vertical) {
+ horizontalDiff = delta.x();
+ verticalDiff = delta.y();
+ } else {
+ horizontalDiff = delta.y();
+ verticalDiff = delta.x();
+ }
+ if (abs(verticalDiff) > MAX_PAN_DIRECTION_THRESHOLD) {
+ // Now see if x coord diff has crossed threshold
+ if (horizontalDiff > MAX_PAN_DIRECTION_THRESHOLD) {
mIsGestureHandled = true;
// right gesture
mView->handlePreviewPaneGesture(true);
event->accept(Qt::PanGesture);
- } else if (delta.x() < -MAX_PAN_DIRECTION_THRESHOLD){
+ } else if (horizontalDiff < -MAX_PAN_DIRECTION_THRESHOLD){
mIsGestureHandled = true;
// left gesture
mView->handlePreviewPaneGesture(false);
event->accept(Qt::PanGesture);
} else {
event->accept(Qt::PanGesture);
+ OstTraceFunctionExit0( DUP1_CALENPREVIEWPANE_GESTUREEVENT_EXIT );
return;
}
- } else if (abs(delta.y()) < MAX_PAN_DIRECTION_THRESHOLD) {
- if (delta.x() > MIN_PAN_DIRECTION_THRESHOLD) {
+ } else if (abs(verticalDiff) < MAX_PAN_DIRECTION_THRESHOLD) {
+ if (horizontalDiff > MIN_PAN_DIRECTION_THRESHOLD) {
mIsGestureHandled = true;
// right gesture
mView->handlePreviewPaneGesture(true);
event->accept(Qt::PanGesture);
- } else if (delta.x() < -MIN_PAN_DIRECTION_THRESHOLD){
+ } else if (horizontalDiff < -MIN_PAN_DIRECTION_THRESHOLD){
mIsGestureHandled = true;
// left gesture
mView->handlePreviewPaneGesture(false);
event->accept(Qt::PanGesture);
}else {
event->accept(Qt::PanGesture);
+ OstTraceFunctionExit0( DUP2_CALENPREVIEWPANE_GESTUREEVENT_EXIT );
return;
}
}
}
- } else if(HbTapGesture *gesture = qobject_cast<HbTapGesture *>(event->gesture(Qt::TapGesture))) {
- if (gesture->state() == Qt::GestureFinished) {
- if (gesture->tapStyleHint() == HbTapGesture::Tap) {
+ } else if(QTapGesture *tapGesture = qobject_cast<QTapGesture *>(event->gesture(Qt::TapGesture))) {
+ if (tapGesture && tapGesture->state() == Qt::GestureFinished) {
+ HbInstantFeedback::play(HbFeedback::Basic);
// Preview pane tapped
mServices.IssueCommandL(ECalenAgendaView);
event->accept(Qt::TapGesture);
- }
}
}
+
+ OstTraceFunctionExit0( DUP2_CALENPREVIEWPANE_GESTUREEVENT_EXIT );
}
/*!
@@ -371,7 +443,11 @@
*/
void CalenPreviewPane::setView(CalenMonthView* view)
{
+ OstTraceFunctionEntry0( CALENPREVIEWPANE_SETVIEW_ENTRY );
+
mView = view;
+
+ OstTraceFunctionExit0( CALENPREVIEWPANE_SETVIEW_EXIT );
}
/*!
@@ -379,6 +455,8 @@
*/
void CalenPreviewPane::stopScrolling()
{
+ OstTraceFunctionEntry0( CALENPREVIEWPANE_STOPSCROLLING_ENTRY );
+
if (isScrolling() || mTwoSecTimer->isActive()) {
scrollContentsTo(QPointF(0.0,0.0));
@@ -386,6 +464,39 @@
HbScrollArea::panGesture(QPointF(0.0,0.0));
mTwoSecTimer->stop();
}
+
+ OstTraceFunctionExit0( CALENPREVIEWPANE_STOPSCROLLING_EXIT );
+}
+
+/*!
+ Checks if the start time of the event falls on the date for which preview
+ pane is being shown. If start time is in past, then time will be 12:00AM
+ */
+void CalenPreviewPane::checkStartTimeOfEvent(QDateTime &dateTime)
+{
+ // If event start time is in past
+ if (dateTime.date() < mDate.date()) {
+ // Set the time to 12:00AM of mDate
+ dateTime.setDate(mDate.date());
+ QTime time(0,0,0,0); // 0 means 12:00 AM
+ dateTime.setTime(time);
+ }
+}
+
+/*!
+ Sets the effect beign handled flag to true
+ */
+void CalenPreviewPane::effectStarted()
+{
+ mIsGestureHandled = true;
+}
+
+/*!
+ Resets the effect beign handled flag to true
+ */
+void CalenPreviewPane::effectFinished()
+{
+ mIsGestureHandled = false;
}
// End of file --Don't remove this.