calendarui/views/dayview/src/calendayinfo.cpp
changeset 77 b0711afde476
parent 50 579cc610882e
equal deleted inserted replaced
68:a5a1242fd2e8 77:b0711afde476
    19 //  INCLUDES
    19 //  INCLUDES
    20 #include "calendayinfo.h"
    20 #include "calendayinfo.h"
    21 #include "calenagendautils.h"
    21 #include "calenagendautils.h"
    22 #include "calenconstants.h"
    22 #include "calenconstants.h"
    23 #include "calendateutils.h"
    23 #include "calendateutils.h"
       
    24 #include "calendayutils.h"
    24 
    25 
    25 namespace
    26 namespace
    26 {
    27 {
    27 const int KUntimedDefaultSlot(16);
    28 const int KUntimedDefaultSlot(16);
    28 }
    29 }
    48 {
    49 {
    49     for (int i = 0; i < iRegionList.count(); i++) {
    50     for (int i = 0; i < iRegionList.count(); i++) {
    50         iRegionList[i].Close();
    51         iRegionList[i].Close();
    51     }
    52     }
    52     iRegionList.clear();
    53     iRegionList.clear();
    53     iUntimedEvents.clear();//Close();
    54     iUntimedEvents.clear();
    54     iTodoEvents.clear();//Close();
    55     iTodoEvents.clear();
    55     iAlldayEvents.clear();//Close();
    56     iAlldayEvents.clear();
    56 }
    57 }
    57 
    58 
    58 /*!
    59 /*!
    59  \brief CalenDayInfo::Reset
    60  \brief CalenDayInfo::Reset
    60 */
    61 */
    61 void CalenDayInfo::Reset()
    62 void CalenDayInfo::Reset()
    62 {
    63 {
    63     for (int i = 0; i < iRegionList.count(); i++) {
    64     for (int i = 0; i < iRegionList.count(); i++) {
    64         iRegionList[i].Close();
    65         iRegionList[i].Close();
    65     }
    66     }
    66     iRegionList.clear();//Reset();
    67     iRegionList.clear();
    67     iUntimedEvents.clear();//Reset();
    68     iUntimedEvents.clear();
    68     iTodoEvents.clear();//Reset();
    69     iTodoEvents.clear();
    69     iAlldayEvents.clear();//Reset();
    70     iAlldayEvents.clear();
    70 
    71 
    71     iUntimedSlotCount = 0;
    72     iUntimedSlotCount = 0;
    72     iFirstUntimedSlot = KFSCalStartingHour * iSlotsInHour;
    73     iFirstUntimedSlot = KFSCalStartingHour * iSlotsInHour;
    73 
    74 
    74     iSelectedSlot = KFSCalStartingHour * iSlotsInHour;
    75     iSelectedSlot = KFSCalStartingHour * iSlotsInHour;
    85 void CalenDayInfo::InsertTimedEvent(const SCalenApptInfo& aItemInfo)
    86 void CalenDayInfo::InsertTimedEvent(const SCalenApptInfo& aItemInfo)
    86 {
    87 {
    87 
    88 
    88     int startIndex = SlotIndexForStartTime(aItemInfo.iStartTime);
    89     int startIndex = SlotIndexForStartTime(aItemInfo.iStartTime);
    89     int endIndex = SlotIndexForEndTime(aItemInfo.iEndTime);
    90     int endIndex = SlotIndexForEndTime(aItemInfo.iEndTime);
    90     if (endIndex == startIndex) {
    91     
    91         endIndex++;
    92     // 10.1 update: the minimum height of event is defined by UI spec.,
       
    93     // so number of occupied slots must be verified to hold at least bubble
       
    94     // with minimum possible height
       
    95     qreal slotHeight = CalenDayUtils::instance()->hourElementHeight()
       
    96         / iSlotsInHour;
       
    97     int minSlotsInEvent = qRound((CalenDayUtils::instance()->minEventHeight()
       
    98         / slotHeight) + 0.5);
       
    99     if (endIndex < startIndex + minSlotsInEvent) {
       
   100         endIndex = startIndex + minSlotsInEvent;
    92     }
   101     }
    93     if (iRegionList.count() > 0) {
   102     if (iRegionList.count() > 0) {
    94         // the timed events must be added in order
   103         // the timed events must be added in order
    95         ASSERT( startIndex >= iLastStartSlot );
   104         ASSERT( startIndex >= iLastStartSlot );
    96     }
   105     }