calendarui/views/src/calenpreviewpane.cpp
changeset 23 fd30d51f876b
parent 18 c198609911f9
child 32 ea672fcb0ea0
child 45 b6db4fd4947b
equal deleted inserted replaced
18:c198609911f9 23:fd30d51f876b
    55 {
    55 {
    56 	// Create the timer
    56 	// Create the timer
    57 	mTwoSecTimer = new QTimer(this);
    57 	mTwoSecTimer = new QTimer(this);
    58 	mScrollDirection = invalid;
    58 	mScrollDirection = invalid;
    59 	mIsNoEntriesAdded = true;
    59 	mIsNoEntriesAdded = true;
       
    60 	mIsGestureHandled = false;
    60 	mNoEntriesLabel = 0;
    61 	mNoEntriesLabel = 0;
    61 	setAcceptDrops(true);
    62 	setAcceptDrops(true);
    62 	setScrollDirections(Qt::Vertical);
    63 	setScrollDirections(Qt::Vertical);
    63 	setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
    64 	setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAlwaysOff);
    64 	// Set the frame to the preview pane
       
    65 	HbFrameItem* frame = new HbFrameItem(this);
       
    66 	frame->frameDrawer().setFrameType(HbFrameDrawer::NinePieces);
       
    67 
       
    68 	frame->frameDrawer().setFrameGraphicsName("qtg_fr_cal_preview_bg");
       
    69 	setBackgroundItem(frame->graphicsItem(), -5);
       
    70 	
    65 	
    71 	// Connect the scrollig finished signal
    66 	// Connect the scrollig finished signal
    72 	connect(this, SIGNAL(scrollingEnded()), this,
    67 	connect(this, SIGNAL(scrollingEnded()), this,
    73 				SLOT(scrollingFinished()));
    68 				SLOT(scrollingFinished()));
    74 }
    69 }
   108 	// Get the content of the scroll area
   103 	// Get the content of the scroll area
   109 	QGraphicsWidget* content = this->contentWidget();
   104 	QGraphicsWidget* content = this->contentWidget();
   110 	// Adjust the layout
   105 	// Adjust the layout
   111 	QGraphicsLinearLayout* layout = static_cast<QGraphicsLinearLayout *>
   106 	QGraphicsLinearLayout* layout = static_cast<QGraphicsLinearLayout *>
   112 															(content->layout());
   107 															(content->layout());
   113 	
       
   114 	layout->setPreferredWidth(preferredWidth());
       
   115 	layout->setMinimumWidth(minimumWidth());
       
   116 	layout->setMaximumWidth(maximumWidth());
       
   117 	
       
   118 	int instanceCount = mInstanceArray.count();
   108 	int instanceCount = mInstanceArray.count();
   119 	HbFontSpec font(HbFontSpec::Secondary);
   109 	HbFontSpec font(HbFontSpec::Secondary);
   120 	if (mIsNoEntriesAdded) {
   110 	if (mIsNoEntriesAdded) {
   121 		if (!instanceCount) {
   111 		if (!instanceCount) {
   122 			return;
   112 		    mNoEntriesLabel->setVisible(true);
       
   113 		    return;
   123 		} else {
   114 		} else {
   124 			// Remove the no entries label
   115 			// Remove the no entries label
   125 			layout->removeAt(0);
       
   126 			mNoEntriesLabel->setVisible(false);
   116 			mNoEntriesLabel->setVisible(false);
   127 		}
   117 		}
   128 	}
   118 	}
   129 	int count = layout->count();
   119 	int count = layout->count();
   130 	int labelCount = mLabelList.count();
   120 	int labelCount = mLabelList.count();
   205 		// Clear the list
   195 		// Clear the list
   206 		mLabelList.clear();
   196 		mLabelList.clear();
   207 		
   197 		
   208 		// Add the no entries text to the preview pane
   198 		// Add the no entries text to the preview pane
   209 		mNoEntriesLabel->setVisible(true);
   199 		mNoEntriesLabel->setVisible(true);
   210 		layout->addItem(mNoEntriesLabel);
       
   211 		layout->setStretchFactor(mNoEntriesLabel,1);
       
   212 		mIsNoEntriesAdded = true;
   200 		mIsNoEntriesAdded = true;
   213 	}
   201 	}
   214 	layout->activate();
   202 	layout->activate();
   215 }
   203 }
   216 
   204 
   304 /*!
   292 /*!
   305  Function to listen mouse press events
   293  Function to listen mouse press events
   306  */
   294  */
   307 void CalenPreviewPane::mousePressEvent(QGraphicsSceneMouseEvent* event)
   295 void CalenPreviewPane::mousePressEvent(QGraphicsSceneMouseEvent* event)
   308 {
   296 {
       
   297 	mIsGestureHandled = false;
   309 	mPressedPos = event->pos();
   298 	mPressedPos = event->pos();
       
   299 	event->accept();
   310 }
   300 }
   311 
   301 
   312 /*!
   302 /*!
   313  Function to listen mouse release events
   303  Function to listen mouse release events
   314  */
   304  */
   315 void CalenPreviewPane::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
   305 void CalenPreviewPane::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
   316 {
   306 {
   317 	qreal posDiff = mPressedPos.x()-event->pos().x();
   307 	qreal posDiff = mPressedPos.x()-event->pos().x();
   318 	if (abs(posDiff) < 50) {
   308 	if (abs(posDiff) < 50 && !mIsGestureHandled) {
   319 		// Preview pane tapped
   309 		// Preview pane tapped
   320 		mServices.IssueCommandL(ECalenDayView);
   310 		mServices.IssueCommandL(ECalenDayView);
   321 	} else if (posDiff < -50) {
   311 	}
       
   312 	event->accept();
       
   313 }
       
   314 
       
   315 /*!
       
   316  Function to listen mouse move events
       
   317  */
       
   318 void CalenPreviewPane::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
       
   319 {
       
   320 	qreal posDiff = mPressedPos.x()-event->pos().x();
       
   321 	if (posDiff < -50) {
       
   322 		mIsGestureHandled = true;
   322 		// right gesture
   323 		// right gesture
   323 		mView->handlePreviewPaneGesture(true);
   324 		mView->handlePreviewPaneGesture(true);
   324 	} else if (posDiff > 50) {
   325 	} else if (posDiff > 50) {
       
   326 		mIsGestureHandled = true;
   325 		// left gesture
   327 		// left gesture
   326 		mView->handlePreviewPaneGesture(false);
   328 		mView->handlePreviewPaneGesture(false);
   327 	}
   329 	}
       
   330 	event->accept();
   328 }
   331 }
   329 
   332 
   330 /*!
   333 /*!
   331  Set monthview pointer
   334  Set monthview pointer
   332  */
   335  */