22 #include <hbcolorscheme.h> |
22 #include <hbcolorscheme.h> |
23 #include <hbpangesture.h> |
23 #include <hbpangesture.h> |
24 #include <hbswipegesture.h> |
24 #include <hbswipegesture.h> |
25 #include <hbtapgesture.h> |
25 #include <hbtapgesture.h> |
26 #include <hbdeviceprofile.h> |
26 #include <hbdeviceprofile.h> |
|
27 #include <hbinstance.h> |
27 |
28 |
28 // User includes |
29 // User includes |
29 #include "calenmonthgrid.h" |
30 #include "calenmonthgrid.h" |
30 #include "calengriditemprototype.h" |
31 #include "calengriditemprototype.h" |
31 #include "calenmonthdata.h" |
32 #include "calenmonthdata.h" |
273 */ |
273 */ |
274 void CalenMonthGrid::updateMonthGridWithInActiveMonths( |
274 void CalenMonthGrid::updateMonthGridWithInActiveMonths( |
275 QList<CalenMonthData> &monthDataArray) |
275 QList<CalenMonthData> &monthDataArray) |
276 { |
276 { |
277 OstTraceFunctionEntry0( CALENMONTHGRID_UPDATEMONTHGRIDWITHINACTIVEMONTHS_ENTRY ); |
277 OstTraceFunctionEntry0( CALENMONTHGRID_UPDATEMONTHGRIDWITHINACTIVEMONTHS_ENTRY ); |
278 |
|
279 mMonthDataArray = monthDataArray; |
|
280 |
278 |
281 // Prepend the required rows |
279 // Prepend the required rows |
282 handlePrependingRows(monthDataArray); |
280 handlePrependingRows(monthDataArray); |
283 |
281 |
284 // Append the required rows |
282 // Append the required rows |
316 void CalenMonthGrid::updateMonthGridWithEventIndicators( |
314 void CalenMonthGrid::updateMonthGridWithEventIndicators( |
317 QList<CalenMonthData> &monthDataArray) |
315 QList<CalenMonthData> &monthDataArray) |
318 { |
316 { |
319 OstTraceFunctionEntry0( CALENMONTHGRID_UPDATEMONTHGRIDWITHEVENTINDICATORS_ENTRY ); |
317 OstTraceFunctionEntry0( CALENMONTHGRID_UPDATEMONTHGRIDWITHEVENTINDICATORS_ENTRY ); |
320 |
318 |
321 mMonthDataArray = monthDataArray; |
|
322 int count(monthDataArray.count()); |
319 int count(monthDataArray.count()); |
323 for(int i = 0; i < count; i++) { |
320 for(int i = 0; i < count; i++) { |
324 // Check if the day has events |
321 // Check if the day has events |
325 if (monthDataArray[i].HasEvents()) { |
322 if (monthDataArray[i].HasEvents()) { |
326 QModelIndex itemIndex = mModel->index(i,0); |
323 QModelIndex itemIndex = mModel->index(i,0); |
434 // Get to know the direction of the gesture |
431 // Get to know the direction of the gesture |
435 // Use our defined threshold temporarily till scrollarea |
432 // Use our defined threshold temporarily till scrollarea |
436 // frm orbit side is made clever enough not to scroll in other direction |
433 // frm orbit side is made clever enough not to scroll in other direction |
437 // apart frm the registered scroll direction |
434 // apart frm the registered scroll direction |
438 QPointF delta = gesture->delta(); |
435 QPointF delta = gesture->delta(); |
439 if (abs(delta.x()) > MAX_PAN_DIRECTION_THRESHOLD) { |
436 // Check the current orientation of the device and |
|
437 // swap the vertical and horizontal distances in landscape |
|
438 qreal horizontalDiff = 0.0; |
|
439 qreal verticalDiff = 0.0; |
|
440 if (hbInstance->allMainWindows().at(0)->orientation() == Qt::Vertical) { |
|
441 horizontalDiff = delta.x(); |
|
442 verticalDiff = delta.y(); |
|
443 } else { |
|
444 horizontalDiff = delta.y(); |
|
445 verticalDiff = delta.x(); |
|
446 } |
|
447 if (abs(horizontalDiff) > MAX_PAN_DIRECTION_THRESHOLD) { |
440 // Now see if y coord diff has crossed threshold |
448 // Now see if y coord diff has crossed threshold |
441 if (delta.y() > MAX_PAN_DIRECTION_THRESHOLD) { |
449 if (verticalDiff > MAX_PAN_DIRECTION_THRESHOLD) { |
442 mIsPanGesture = true; |
450 mIsPanGesture = true; |
443 mIgnoreItemActivated = true; |
451 mIgnoreItemActivated = true; |
444 mDirection = down; |
452 mDirection = down; |
445 } else if (delta.y() < -MAX_PAN_DIRECTION_THRESHOLD){ |
453 } else if (verticalDiff < -MAX_PAN_DIRECTION_THRESHOLD){ |
446 mIsPanGesture = true; |
454 mIsPanGesture = true; |
447 mIgnoreItemActivated = true; |
455 mIgnoreItemActivated = true; |
448 mDirection = up; |
456 mDirection = up; |
449 } else { |
457 } else { |
450 event->accept(Qt::PanGesture); |
458 event->accept(Qt::PanGesture); |
451 OstTraceFunctionExit0( CALENMONTHGRID_GESTUREEVENT_EXIT ); |
459 OstTraceFunctionExit0( CALENMONTHGRID_GESTUREEVENT_EXIT ); |
452 return; |
460 return; |
453 } |
461 } |
454 } else if (abs(delta.x()) < MAX_PAN_DIRECTION_THRESHOLD) { |
462 } else if (abs(horizontalDiff) < MAX_PAN_DIRECTION_THRESHOLD) { |
455 if (delta.y() > MIN_PAN_DIRECTION_THRESHOLD) { |
463 if (verticalDiff > MIN_PAN_DIRECTION_THRESHOLD) { |
456 mIsPanGesture = true; |
464 mIsPanGesture = true; |
457 mIgnoreItemActivated = true; |
465 mIgnoreItemActivated = true; |
458 mDirection = down; |
466 mDirection = down; |
459 } else if (delta.y() < -MIN_PAN_DIRECTION_THRESHOLD){ |
467 } else if (verticalDiff < -MIN_PAN_DIRECTION_THRESHOLD){ |
460 mIsPanGesture = true; |
468 mIsPanGesture = true; |
461 mIgnoreItemActivated = true; |
469 mIgnoreItemActivated = true; |
462 mDirection = up; |
470 mDirection = up; |
463 }else { |
471 }else { |
464 event->accept(Qt::PanGesture); |
472 event->accept(Qt::PanGesture); |
549 QList<HbAbstractViewItem *> list = visibleItems(); |
557 QList<HbAbstractViewItem *> list = visibleItems(); |
550 HbAbstractViewItem* item = list[0]; |
558 HbAbstractViewItem* item = list[0]; |
551 QModelIndex modelIndex = item->modelIndex(); |
559 QModelIndex modelIndex = item->modelIndex(); |
552 |
560 |
553 // Get the date which is visible at the above row |
561 // Get the date which is visible at the above row |
554 QDateTime date = mMonthDataArray[modelIndex.row()].Day(); |
562 QList<CalenMonthData>& monthDataArray = mView->monthDataList(); |
|
563 QDateTime date = monthDataArray[modelIndex.row()].Day(); |
555 |
564 |
556 // Check if this date belong to current active month or |
565 // Check if this date belong to current active month or |
557 // previous month else future month |
566 // previous month else future month |
558 QDateTime activeMonth = mView->getActiveDay(); |
567 QDateTime activeMonth = mView->getActiveDay(); |
559 QDateTime prevMonth = activeMonth.addMonths(-1); |
568 QDateTime prevMonth = activeMonth.addMonths(-1); |
641 int deleteFromIndex = (rowsInPrevMonthEarlier + KNumOfVisibleRows) * KCalenDaysInWeek; |
650 int deleteFromIndex = (rowsInPrevMonthEarlier + KNumOfVisibleRows) * KCalenDaysInWeek; |
642 int numOfIndices = rowsInFutMonthEarlier * KCalenDaysInWeek; |
651 int numOfIndices = rowsInFutMonthEarlier * KCalenDaysInWeek; |
643 |
652 |
644 // Get the updated dates from the view |
653 // Get the updated dates from the view |
645 mView->updateModelWithPrevMonth(); |
654 mView->updateModelWithPrevMonth(); |
646 QList<CalenMonthData > monthDataList = mView->monthDataList(); |
655 QList<CalenMonthData >& monthDataList = mView->monthDataList(); |
647 mMonthDataArray = monthDataList; |
|
648 |
656 |
649 // Prepend the required rows |
657 // Prepend the required rows |
650 handlePrependingRows(monthDataList); |
658 handlePrependingRows(monthDataList); |
651 |
659 |
652 // Since, we have finished setData, Now unblock the signals |
660 // Since, we have finished setData, Now unblock the signals |
767 // remove the cells in the previous month |
775 // remove the cells in the previous month |
768 int countToBeDeleted = rowsInPrevMonth * KCalenDaysInWeek; |
776 int countToBeDeleted = rowsInPrevMonth * KCalenDaysInWeek; |
769 |
777 |
770 // Get the updated dates from the view |
778 // Get the updated dates from the view |
771 mView->updateModelWithFutureMonth(); |
779 mView->updateModelWithFutureMonth(); |
772 QList<CalenMonthData > monthDataList = mView->monthDataList(); |
780 QList<CalenMonthData >& monthDataList = mView->monthDataList(); |
773 mMonthDataArray = monthDataList; |
|
774 |
781 |
775 // Get the model count before we add any rows into the mode |
782 // Get the model count before we add any rows into the mode |
776 int rowCount = mModel->rowCount(); |
783 int rowCount = mModel->rowCount(); |
777 // Append the required rows |
784 // Append the required rows |
778 handleAppendingRows(monthDataList); |
785 handleAppendingRows(monthDataList); |
911 true); |
918 true); |
912 mModel->itemFromIndex(itemIndex)->setData(list); |
919 mModel->itemFromIndex(itemIndex)->setData(list); |
913 // Check if inactive date is tapped |
920 // Check if inactive date is tapped |
914 QDateTime activeMonth = mView->getActiveDay(); |
921 QDateTime activeMonth = mView->getActiveDay(); |
915 int month = activeMonth.date().month(); |
922 int month = activeMonth.date().month(); |
916 if(month != mMonthDataArray[mCurrentRow].Day().date().month()){ |
923 QList<CalenMonthData >& monthDataList = mView->monthDataList(); |
|
924 if(month != monthDataList[mCurrentRow].Day().date().month()){ |
917 // Set the flag |
925 // Set the flag |
918 mIsNonActiveDayFocused = true; |
926 mIsNonActiveDayFocused = true; |
919 mNonActiveFocusedDay = mMonthDataArray[mCurrentRow].Day(); |
927 mNonActiveFocusedDay = monthDataList[mCurrentRow].Day(); |
920 |
928 |
921 // Add one month to active month |
929 // Add one month to active month |
922 activeMonth = activeMonth.addMonths(1); |
930 activeMonth = activeMonth.addMonths(1); |
923 if (activeMonth.date().month() == |
931 if (activeMonth.date().month() == |
924 mNonActiveFocusedDay.date().month()) { |
932 mNonActiveFocusedDay.date().month()) { |
997 // set active date color only for the dates that fall in current month |
1005 // set active date color only for the dates that fall in current month |
998 // So, in the whole data array, start from where the current month starts |
1006 // So, in the whole data array, start from where the current month starts |
999 // and stop the loop where it the current month ends |
1007 // and stop the loop where it the current month ends |
1000 |
1008 |
1001 int start = 0; |
1009 int start = 0; |
1002 int end = mMonthDataArray.count(); |
1010 QList<CalenMonthData >& monthDataList = mView->monthDataList(); |
|
1011 int end = monthDataList.count(); |
1003 |
1012 |
1004 // Calculate the start and end values |
1013 // Calculate the start and end values |
1005 QDate firstDateInGrid = mView->firstDayOfGrid().date(); |
1014 QDate firstDateInGrid = mView->firstDayOfGrid().date(); |
1006 |
1015 |
1007 // Get the date where active month starts |
1016 // Get the date where active month starts |