calendarui/views/dayview/src/calendaycontainer.cpp
changeset 68 a5a1242fd2e8
parent 58 ef813d54df51
child 77 b0711afde476
--- a/calendarui/views/dayview/src/calendaycontainer.cpp	Wed Aug 18 09:47:38 2010 +0300
+++ b/calendarui/views/dayview/src/calendaycontainer.cpp	Thu Sep 02 20:25:23 2010 +0300
@@ -238,17 +238,17 @@
 
     // Event's startX/width
     eventWidth /= columns;
-
-    // In case when eventWidth will be smaller then KCalenMinBubbleWidth [un]
+    
+    // In case when eventWidth will be smaller then KCalenMinEventWidth [un]
     // spacings between events should be smaller.
     // Check whether it's possible to shrink them so the bubbles width 
-    // can stay at KCalenMinBubbleWidth [un] (time stripe + frame margins).
-    qreal minWidth = KCalenMinBubbleWidth * mLayoutValues.unitInPixels;
+    // can stay at KCalenMinEventWidth [un] (time stripe + frame margins).
+    qreal minWidth = KCalenMinEventWidth * mLayoutValues.unitInPixels;
     if (eventWidth - mLayoutValues.eventMargin < minWidth) {
 
         // Calculate new margin value
-        // from totalMarginSpace we need to subtract 
-        // mLayoutValues.eventMargin because first margin is always 1.5un
+        // from totalMarginSpace we need to subtract mLayoutValues.eventMargin 
+        // because first margin is always KCalenSpaceBeetwenEvents
         qreal totalMarginSpace = mLayoutValues.eventAreaWidth - minWidth
             * columns - mLayoutValues.eventMargin;
         qreal newMarginValue = totalMarginSpace / (columns - 1);
@@ -259,15 +259,16 @@
         }
         else {
             // There's not enough space
-            // New minWidth is KCalenTimeStripWidth [un] (time stripe only)
-            minWidth = KCalenTimeStripWidth * mLayoutValues.unitInPixels;
+            // New minWidth is KCalenMinTimeStripWidth [un] (time stripe only)
+            minWidth = KCalenMinTimeStripWidth * mLayoutValues.unitInPixels;
             totalMarginSpace = mLayoutValues.eventAreaWidth - minWidth * columns 
 				- mLayoutValues.eventMargin;
             newMarginValue = totalMarginSpace / (columns - 1);
             eventWidth = minWidth;
         }
         
-        //First column margin should be always 1.5un (mLayoutValues.eventMargin)
+        // First column margin should be always KCalenSpaceBeetwenEvents 
+        // (mLayoutValues.eventMargin)
         eventStartX += columnIdx * (eventWidth + newMarginValue) + mLayoutValues.eventMargin;
     }
     else {
@@ -277,6 +278,10 @@
     }
 
     QRectF eventGeometry(eventStartX, eventStartY, eventWidth, eventHeight);
+    
+    // Workaround to prevent size hint caching inside effectiveSizeHint
+    item->setMinimumSize(0, 0);
+    item->setMaximumSize(eventWidth, eventHeight);
     item->setGeometry(eventGeometry);
 }
 
@@ -341,6 +346,10 @@
     }
 
     QRectF eventGeometry(eventStartX, eventStartY, eventWidth, eventHeight);
+	
+    // Workaround to prevent size hint caching inside effectiveSizeHint
+    item->setMinimumSize(0, 0);
+    item->setMaximumSize(eventWidth, eventHeight);
     item->setGeometry(eventGeometry);
 }
 
@@ -351,39 +360,42 @@
  */
 void CalenDayContainer::getTimedEventLayoutValues(LayoutValues& layoutValues)
 {
-    // Get the width of content area
+    // Get the width of entire content area
     qreal contentWidth = CalenDayUtils::instance()->contentWidth();
 
-    // 1. Time column width -> eventAreaX[out]
     HbStyle style;
     HbDeviceProfile deviceProfile;
     layoutValues.unitInPixels = deviceProfile.unitValue();
 
+    // Empty right column's width
+    qreal emptyRightColumnWidth = KCalenEmptyRightColumnWidth
+        * layoutValues.unitInPixels;
+
+    // Margins between the overlapping events -> eventMargin[out]
+    layoutValues.eventMargin = KCalenSpaceBeetwenEvents
+        * layoutValues.unitInPixels;
+
+    // Start position (x) for drawing events -> eventAreaX[out]
     if (mInfo && mInfo->AlldayCount()) {
-        layoutValues.eventAreaX = KCalenAllDayEventArea * contentWidth;
+        layoutValues.eventAreaX = KCalenAllDayEventArea * (contentWidth
+            - emptyRightColumnWidth);
     }
     else {
         layoutValues.eventAreaX = 0;
     }
 
-    // 2. event area width -> eventAreaWidth[out]
-    qreal emptyRightColumnWidth(0.0);
-    emptyRightColumnWidth = KCalenEmptyRightColumnWidth
-        * layoutValues.unitInPixels;
+    // Event area width (excluding All Day Events area)-> eventAreaWidth[out]
     layoutValues.eventAreaWidth = contentWidth - emptyRightColumnWidth
         - layoutValues.eventAreaX;
 
-    // 3. margins between the overlapping events -> eventMargin[out]
-    layoutValues.eventMargin = KCalenSpaceBeetwenEvents
-        * layoutValues.unitInPixels;
-
-    // 4. half-hour slot'h height -> slotHeight[out]
+    // Half-hour slot's height -> slotHeight[out]
     layoutValues.slotHeight = CalenDayUtils::instance()->hourElementHeight()
         / KCalenSlotsInHour;
 
-    // check if we should create absorber over some overlapping region
+    // Check if touch absorbers should be created over some overlapping regions
     layoutValues.maxColumns = layoutValues.eventAreaWidth
-        / (KCalenMinTouchableEventWidth * layoutValues.unitInPixels);
+        / ((KCalenMinTouchableEventWidth + KCalenSpaceBeetwenEvents)
+            * layoutValues.unitInPixels);
 }