calendarui/views/src/calenpreviewpane.cpp
changeset 68 a5a1242fd2e8
parent 58 ef813d54df51
child 77 b0711afde476
--- a/calendarui/views/src/calenpreviewpane.cpp	Wed Aug 18 09:47:38 2010 +0300
+++ b/calendarui/views/src/calenpreviewpane.cpp	Thu Sep 02 20:25:23 2010 +0300
@@ -21,6 +21,7 @@
 #include <qfont.h>
 #include <qicon.h>
 #include <qpainter.h>
+#include <qevent.h>
 #include <hblabel.h>
 #include <hbmainwindow.h>
 #include <hbframeitem.h>
@@ -74,6 +75,8 @@
 	mNoEntriesLabel = 0;
 	mHtDiff = 0.0;
 	mScrollDuration = 0;
+	mPreviewTextColor = HbColorScheme::color("qtc_cal_day_preview_text");
+	
 	setAcceptDrops(true);
 	setScrollDirections(Qt::Vertical);
 	setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
@@ -107,6 +110,9 @@
     
 	mNoEntriesLabel = label;
 	
+	if (mPreviewTextColor.isValid()) {
+		mNoEntriesLabel->setTextColor(mPreviewTextColor);
+	}
 	OstTraceFunctionExit0( CALENPREVIEWPANE_SETNOENTRIESLABEL_EXIT );
 }
 
@@ -122,6 +128,7 @@
 	// Scroll contents to zero position before we display to the user
 	// if it was scrolling already or timer was running
 	mNumOfScrolls = 0;
+	mScrollDuration = 0;
 	stopScrolling();
 	
 	mDate = date;
@@ -138,6 +145,9 @@
 	HbFontSpec font(HbFontSpec::Secondary);
 	if (mIsNoEntriesAdded) {
 		if (!instanceCount) {
+			if (mPreviewTextColor.isValid()) {
+				mNoEntriesLabel->setTextColor(mPreviewTextColor);
+			}
 		    mNoEntriesLabel->setVisible(true);
 		    OstTraceFunctionExit0( CALENPREVIEWPANE_POPULATELABEL_EXIT );
 		    return;
@@ -162,13 +172,6 @@
 				// Set the required font
 				label->setFontSpec(font);
 				
-				// Set the text color from the theme
-				QColor previewPaneColor = HbColorScheme::color(
-												"qtc_cal_day_preview_text");
-				if (previewPaneColor.isValid()) {
-				    label->setTextColor(previewPaneColor);
-				}
-				
 				// Set the elide mode to right
 				label->setElideMode(Qt::ElideRight);
 				// Add the label to the list
@@ -179,6 +182,10 @@
 				label = mLabelList.at(i);
 				count--;
 			}
+			
+			if (mPreviewTextColor.isValid()) {
+				label->setTextColor(mPreviewTextColor);
+			}
 			QString summary = mInstanceArray[i].summary();
 			if(!summary.length()) {
 				// No summary display "Unnamed"
@@ -234,6 +241,9 @@
 		// Clear the list
 		mLabelList.clear();
 		
+		if (mPreviewTextColor.isValid()) {
+			mNoEntriesLabel->setTextColor(mPreviewTextColor);
+		}
 		// Add the no entries text to the preview pane
 		mNoEntriesLabel->setVisible(true);
 		mIsNoEntriesAdded = true;
@@ -291,7 +301,13 @@
 		OstTraceFunctionExit0( CALENPREVIEWPANE_STARTAUTOSCROLL_EXIT );
 		return;
 	}
-
+	
+	// Stop the timer
+	mTwoSecTimer->stop();
+	
+	// Set the proper scroll direction
+	mScrollDirection = up;
+	
 	// Start the 2 seconds timer
 	mTwoSecTimer->setSingleShot(true);
 	connect(mTwoSecTimer, SIGNAL(timeout()), this, SLOT(onTwoSecondsTimeout()));
@@ -323,13 +339,13 @@
 	}
 	
     // Start the scrolling in the proper direction
-	if (mScrollDirection == up) {
+	if (mScrollDirection == up && mScrollDuration) {
 		// Start scrolling upwards
 		mScrollDirection = down;
 		mNumOfScrolls++;
 		QPointF targetPos(0.0, -mHtDiff);
         scrollContentsTo(-targetPos, mScrollDuration * 1000);
-	} else if (mScrollDirection == down) {
+	} else if (mScrollDirection == down && mScrollDuration) {
 		mScrollDirection = up;
 		mNumOfScrolls++;
 		// Start scrolling downwards
@@ -430,12 +446,16 @@
         if (tapGesture && tapGesture->state() == Qt::GestureFinished) {
             	HbInstantFeedback::play(HbFeedback::Basic);
                 // Preview pane tapped
+            	// Stop the scrolling first
+            	stopScrolling();
+            	// Issue command to launch agenda view
                 mServices.IssueCommandL(ECalenAgendaView);
+                mView->disconnectAboutToQuitEvent();
                 event->accept(Qt::TapGesture);
         }
     }
     
-    OstTraceFunctionExit0( DUP2_CALENPREVIEWPANE_GESTUREEVENT_EXIT );
+    OstTraceFunctionExit0( DUP3_CALENPREVIEWPANE_GESTUREEVENT_EXIT );
 }
 
 /*!
@@ -457,12 +477,16 @@
 {
     OstTraceFunctionEntry0( CALENPREVIEWPANE_STOPSCROLLING_ENTRY );
     
-	if (isScrolling() || mTwoSecTimer->isActive()) {
+    mTwoSecTimer->stop();
+	if (isScrolling()) {
+        mNumOfScrolls = 0; // required so that timer will not get started again in 
+        // scrollingFinished() slot
+        // Stop the scrolling by sending the foucs out event
+        QFocusEvent* focusEvent = new QFocusEvent(QFocusEvent::FocusOut, Qt::MouseFocusReason);
+        focusOutEvent(focusEvent); 
+        
+        // Set the contents position to zero
 		scrollContentsTo(QPointF(0.0,0.0));
-		
-		// Call pan gesture with zero delta just to stop the scfrolling 
-		HbScrollArea::panGesture(QPointF(0.0,0.0));
-		mTwoSecTimer->stop();
 	}
 	
 	OstTraceFunctionExit0( CALENPREVIEWPANE_STOPSCROLLING_EXIT );
@@ -499,4 +523,16 @@
     mIsGestureHandled = false;
 }
 
+/*!
+ Slot to handle the change in theme
+ */
+void CalenPreviewPane::handleThemeChange()
+{
+    OstTraceFunctionEntry0( CALENPREVIEWPANE_HANDLETHEMECHANGE_ENTRY );
+    
+    mPreviewTextColor = HbColorScheme::color("qtc_cal_day_preview_text");
+    
+    OstTraceFunctionExit0( CALENPREVIEWPANE_HANDLETHEMECHANGE_EXIT );
+}
+
 // End of file  --Don't remove this.