calendarui/views/dayview/src/calendaycontainer.cpp
changeset 63 a3cb48f6c889
parent 57 bb2d3e476f29
child 64 1881ad52dc45
equal deleted inserted replaced
57:bb2d3e476f29 63:a3cb48f6c889
   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 
   251         // mLayoutValues.eventMargin because first margin is always 1.5un
   251         // mLayoutValues.eventMargin because first margin is always 1.5un
   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 /*!
   365     else {
   374     else {
   366         layoutValues.eventAreaX = 0;
   375         layoutValues.eventAreaX = 0;
   367     }
   376     }
   368 
   377 
   369     // 2. event area width -> eventAreaWidth[out]
   378     // 2. event area width -> eventAreaWidth[out]
   370     qreal emptyRightColumnWidth(0.0);
   379     qreal emptyRightColumnWidth = KCalenEmptyRightColumnWidth
   371     emptyRightColumnWidth = KCalenEmptyRightColumnWidth
       
   372         * layoutValues.unitInPixels;
   380         * layoutValues.unitInPixels;
   373     layoutValues.eventAreaWidth = contentWidth - emptyRightColumnWidth
   381     layoutValues.eventAreaWidth = contentWidth - emptyRightColumnWidth
   374         - layoutValues.eventAreaX;
   382         - layoutValues.eventAreaX;
   375 
   383 
   376     // 3. margins between the overlapping events -> eventMargin[out]
   384     // 3. margins between the overlapping events -> eventMargin[out]
   381     layoutValues.slotHeight = CalenDayUtils::instance()->hourElementHeight()
   389     layoutValues.slotHeight = CalenDayUtils::instance()->hourElementHeight()
   382         / KCalenSlotsInHour;
   390         / KCalenSlotsInHour;
   383 
   391 
   384     // check if we should create absorber over some overlapping region
   392     // check if we should create absorber over some overlapping region
   385     layoutValues.maxColumns = layoutValues.eventAreaWidth
   393     layoutValues.maxColumns = layoutValues.eventAreaWidth
   386         / (KCalenMinTouchableEventWidth * layoutValues.unitInPixels);
   394         / ((KCalenMinTouchableEventWidth + KCalenSpaceBeetwenEvents)
       
   395             * layoutValues.unitInPixels);
   387 }
   396 }
   388 
   397 
   389 
   398 
   390 /*!
   399 /*!
   391  \brief Sets day's info structure to the container.
   400  \brief Sets day's info structure to the container.