245 // can stay at KCalenMinEventWidth [un] (time stripe + frame margins). |
245 // can stay at KCalenMinEventWidth [un] (time stripe + frame margins). |
246 qreal minWidth = KCalenMinEventWidth * 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 } |
358 \brief Gets event layout values |
358 \brief Gets event layout values |
359 \a layoutValues structure to be filled with layout data |
359 \a layoutValues structure to be filled with layout data |
360 */ |
360 */ |
361 void CalenDayContainer::getTimedEventLayoutValues(LayoutValues& layoutValues) |
361 void CalenDayContainer::getTimedEventLayoutValues(LayoutValues& layoutValues) |
362 { |
362 { |
363 // Get the width of content area |
363 // Get the width of entire content area |
364 qreal contentWidth = CalenDayUtils::instance()->contentWidth(); |
364 qreal contentWidth = CalenDayUtils::instance()->contentWidth(); |
365 |
365 |
366 // 1. Time column width -> eventAreaX[out] |
|
367 HbStyle style; |
366 HbStyle style; |
368 HbDeviceProfile deviceProfile; |
367 HbDeviceProfile deviceProfile; |
369 layoutValues.unitInPixels = deviceProfile.unitValue(); |
368 layoutValues.unitInPixels = deviceProfile.unitValue(); |
370 |
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] |
371 if (mInfo && mInfo->AlldayCount()) { |
379 if (mInfo && mInfo->AlldayCount()) { |
372 layoutValues.eventAreaX = KCalenAllDayEventArea * contentWidth; |
380 layoutValues.eventAreaX = KCalenAllDayEventArea * (contentWidth |
|
381 - emptyRightColumnWidth); |
373 } |
382 } |
374 else { |
383 else { |
375 layoutValues.eventAreaX = 0; |
384 layoutValues.eventAreaX = 0; |
376 } |
385 } |
377 |
386 |
378 // 2. event area width -> eventAreaWidth[out] |
387 // Event area width (excluding All Day Events area)-> eventAreaWidth[out] |
379 qreal emptyRightColumnWidth = KCalenEmptyRightColumnWidth |
|
380 * layoutValues.unitInPixels; |
|
381 layoutValues.eventAreaWidth = contentWidth - emptyRightColumnWidth |
388 layoutValues.eventAreaWidth = contentWidth - emptyRightColumnWidth |
382 - layoutValues.eventAreaX; |
389 - layoutValues.eventAreaX; |
383 |
390 |
384 // 3. margins between the overlapping events -> eventMargin[out] |
391 // Half-hour slot's height -> slotHeight[out] |
385 layoutValues.eventMargin = KCalenSpaceBeetwenEvents |
|
386 * layoutValues.unitInPixels; |
|
387 |
|
388 // 4. half-hour slot'h height -> slotHeight[out] |
|
389 layoutValues.slotHeight = CalenDayUtils::instance()->hourElementHeight() |
392 layoutValues.slotHeight = CalenDayUtils::instance()->hourElementHeight() |
390 / KCalenSlotsInHour; |
393 / KCalenSlotsInHour; |
391 |
394 |
392 // check if we should create absorber over some overlapping region |
395 // Check if touch absorbers should be created over some overlapping regions |
393 layoutValues.maxColumns = layoutValues.eventAreaWidth |
396 layoutValues.maxColumns = layoutValues.eventAreaWidth |
394 / ((KCalenMinTouchableEventWidth + KCalenSpaceBeetwenEvents) |
397 / ((KCalenMinTouchableEventWidth + KCalenSpaceBeetwenEvents) |
395 * layoutValues.unitInPixels); |
398 * layoutValues.unitInPixels); |
396 } |
399 } |
397 |
400 |