calendarui/views/dayview/src/calendaycontainer.cpp
changeset 68 a5a1242fd2e8
parent 58 ef813d54df51
child 77 b0711afde476
equal deleted inserted replaced
58:ef813d54df51 68:a5a1242fd2e8
   236     eventStartY = startSlot * mLayoutValues.slotHeight;
   236     eventStartY = startSlot * mLayoutValues.slotHeight;
   237     eventHeight = (endSlot - startSlot) * mLayoutValues.slotHeight;
   237     eventHeight = (endSlot - startSlot) * mLayoutValues.slotHeight;
   238 
   238 
   239     // Event's startX/width
   239     // Event's startX/width
   240     eventWidth /= columns;
   240     eventWidth /= columns;
   241 
   241     
   242     // In case when eventWidth will be smaller then KCalenMinBubbleWidth [un]
   242     // In case when eventWidth will be smaller then KCalenMinEventWidth [un]
   243     // spacings between events should be smaller.
   243     // spacings between events should be smaller.
   244     // Check whether it's possible to shrink them so the bubbles width 
   244     // Check whether it's possible to shrink them so the bubbles width 
   245     // can stay at KCalenMinBubbleWidth [un] (time stripe + frame margins).
   245     // can stay at KCalenMinEventWidth [un] (time stripe + frame margins).
   246     qreal minWidth = KCalenMinBubbleWidth * mLayoutValues.unitInPixels;
   246     qreal minWidth = KCalenMinEventWidth * mLayoutValues.unitInPixels;
   247     if (eventWidth - mLayoutValues.eventMargin < minWidth) {
   247     if (eventWidth - mLayoutValues.eventMargin < minWidth) {
   248 
   248 
   249         // Calculate new margin value
   249         // Calculate new margin value
   250         // from totalMarginSpace we need to subtract 
   250         // from totalMarginSpace we need to subtract mLayoutValues.eventMargin 
   251         // mLayoutValues.eventMargin because first margin is always 1.5un
   251         // because first margin is always KCalenSpaceBeetwenEvents
   252         qreal totalMarginSpace = mLayoutValues.eventAreaWidth - minWidth
   252         qreal totalMarginSpace = mLayoutValues.eventAreaWidth - minWidth
   253             * columns - mLayoutValues.eventMargin;
   253             * columns - mLayoutValues.eventMargin;
   254         qreal newMarginValue = totalMarginSpace / (columns - 1);
   254         qreal newMarginValue = totalMarginSpace / (columns - 1);
   255 
   255 
   256         // Check if we managed to pack all the events into space we have
   256         // Check if we managed to pack all the events into space we have
   257         if (newMarginValue > 0) {
   257         if (newMarginValue > 0) {
   258             eventWidth = minWidth;
   258             eventWidth = minWidth;
   259         }
   259         }
   260         else {
   260         else {
   261             // There's not enough space
   261             // There's not enough space
   262             // New minWidth is KCalenTimeStripWidth [un] (time stripe only)
   262             // New minWidth is KCalenMinTimeStripWidth [un] (time stripe only)
   263             minWidth = KCalenTimeStripWidth * mLayoutValues.unitInPixels;
   263             minWidth = KCalenMinTimeStripWidth * mLayoutValues.unitInPixels;
   264             totalMarginSpace = mLayoutValues.eventAreaWidth - minWidth * columns 
   264             totalMarginSpace = mLayoutValues.eventAreaWidth - minWidth * columns 
   265 				- mLayoutValues.eventMargin;
   265 				- mLayoutValues.eventMargin;
   266             newMarginValue = totalMarginSpace / (columns - 1);
   266             newMarginValue = totalMarginSpace / (columns - 1);
   267             eventWidth = minWidth;
   267             eventWidth = minWidth;
   268         }
   268         }
   269         
   269         
   270         //First column margin should be always 1.5un (mLayoutValues.eventMargin)
   270         // First column margin should be always KCalenSpaceBeetwenEvents 
       
   271         // (mLayoutValues.eventMargin)
   271         eventStartX += columnIdx * (eventWidth + newMarginValue) + mLayoutValues.eventMargin;
   272         eventStartX += columnIdx * (eventWidth + newMarginValue) + mLayoutValues.eventMargin;
   272     }
   273     }
   273     else {
   274     else {
   274         // Add margins between the event
   275         // Add margins between the event
   275         eventStartX += columnIdx * eventWidth + mLayoutValues.eventMargin;
   276         eventStartX += columnIdx * eventWidth + mLayoutValues.eventMargin;
   276         eventWidth -= mLayoutValues.eventMargin;
   277         eventWidth -= mLayoutValues.eventMargin;
   277     }
   278     }
   278 
   279 
   279     QRectF eventGeometry(eventStartX, eventStartY, eventWidth, eventHeight);
   280     QRectF eventGeometry(eventStartX, eventStartY, eventWidth, eventHeight);
       
   281     
       
   282     // Workaround to prevent size hint caching inside effectiveSizeHint
       
   283     item->setMinimumSize(0, 0);
       
   284     item->setMaximumSize(eventWidth, eventHeight);
   280     item->setGeometry(eventGeometry);
   285     item->setGeometry(eventGeometry);
   281 }
   286 }
   282 
   287 
   283 
   288 
   284 /*!
   289 /*!
   339         eventStartX += mLayoutValues.eventMargin;
   344         eventStartX += mLayoutValues.eventMargin;
   340         eventWidth -= mLayoutValues.eventMargin;
   345         eventWidth -= mLayoutValues.eventMargin;
   341     }
   346     }
   342 
   347 
   343     QRectF eventGeometry(eventStartX, eventStartY, eventWidth, eventHeight);
   348     QRectF eventGeometry(eventStartX, eventStartY, eventWidth, eventHeight);
       
   349 	
       
   350     // Workaround to prevent size hint caching inside effectiveSizeHint
       
   351     item->setMinimumSize(0, 0);
       
   352     item->setMaximumSize(eventWidth, eventHeight);
   344     item->setGeometry(eventGeometry);
   353     item->setGeometry(eventGeometry);
   345 }
   354 }
   346 
   355 
   347 
   356 
   348 /*!
   357 /*!
   349  \brief Gets event layout values
   358  \brief Gets event layout values
   350  \a layoutValues structure to be filled with layout data
   359  \a layoutValues structure to be filled with layout data
   351  */
   360  */
   352 void CalenDayContainer::getTimedEventLayoutValues(LayoutValues& layoutValues)
   361 void CalenDayContainer::getTimedEventLayoutValues(LayoutValues& layoutValues)
   353 {
   362 {
   354     // Get the width of content area
   363     // Get the width of entire content area
   355     qreal contentWidth = CalenDayUtils::instance()->contentWidth();
   364     qreal contentWidth = CalenDayUtils::instance()->contentWidth();
   356 
   365 
   357     // 1. Time column width -> eventAreaX[out]
       
   358     HbStyle style;
   366     HbStyle style;
   359     HbDeviceProfile deviceProfile;
   367     HbDeviceProfile deviceProfile;
   360     layoutValues.unitInPixels = deviceProfile.unitValue();
   368     layoutValues.unitInPixels = deviceProfile.unitValue();
   361 
   369 
       
   370     // Empty right column's width
       
   371     qreal emptyRightColumnWidth = KCalenEmptyRightColumnWidth
       
   372         * layoutValues.unitInPixels;
       
   373 
       
   374     // Margins between the overlapping events -> eventMargin[out]
       
   375     layoutValues.eventMargin = KCalenSpaceBeetwenEvents
       
   376         * layoutValues.unitInPixels;
       
   377 
       
   378     // Start position (x) for drawing events -> eventAreaX[out]
   362     if (mInfo && mInfo->AlldayCount()) {
   379     if (mInfo && mInfo->AlldayCount()) {
   363         layoutValues.eventAreaX = KCalenAllDayEventArea * contentWidth;
   380         layoutValues.eventAreaX = KCalenAllDayEventArea * (contentWidth
       
   381             - emptyRightColumnWidth);
   364     }
   382     }
   365     else {
   383     else {
   366         layoutValues.eventAreaX = 0;
   384         layoutValues.eventAreaX = 0;
   367     }
   385     }
   368 
   386 
   369     // 2. event area width -> eventAreaWidth[out]
   387     // Event area width (excluding All Day Events area)-> eventAreaWidth[out]
   370     qreal emptyRightColumnWidth(0.0);
       
   371     emptyRightColumnWidth = KCalenEmptyRightColumnWidth
       
   372         * layoutValues.unitInPixels;
       
   373     layoutValues.eventAreaWidth = contentWidth - emptyRightColumnWidth
   388     layoutValues.eventAreaWidth = contentWidth - emptyRightColumnWidth
   374         - layoutValues.eventAreaX;
   389         - layoutValues.eventAreaX;
   375 
   390 
   376     // 3. margins between the overlapping events -> eventMargin[out]
   391     // Half-hour slot's height -> slotHeight[out]
   377     layoutValues.eventMargin = KCalenSpaceBeetwenEvents
       
   378         * layoutValues.unitInPixels;
       
   379 
       
   380     // 4. half-hour slot'h height -> slotHeight[out]
       
   381     layoutValues.slotHeight = CalenDayUtils::instance()->hourElementHeight()
   392     layoutValues.slotHeight = CalenDayUtils::instance()->hourElementHeight()
   382         / KCalenSlotsInHour;
   393         / KCalenSlotsInHour;
   383 
   394 
   384     // check if we should create absorber over some overlapping region
   395     // Check if touch absorbers should be created over some overlapping regions
   385     layoutValues.maxColumns = layoutValues.eventAreaWidth
   396     layoutValues.maxColumns = layoutValues.eventAreaWidth
   386         / (KCalenMinTouchableEventWidth * layoutValues.unitInPixels);
   397         / ((KCalenMinTouchableEventWidth + KCalenSpaceBeetwenEvents)
       
   398             * layoutValues.unitInPixels);
   387 }
   399 }
   388 
   400 
   389 
   401 
   390 /*!
   402 /*!
   391  \brief Sets day's info structure to the container.
   403  \brief Sets day's info structure to the container.