зеркало из https://github.com/mozilla/gecko-dev.git
Fixed some problems with multi-day event displaydates
This commit is contained in:
Родитель
3cc3973a4a
Коммит
001f4cf1d5
|
@ -633,7 +633,8 @@ oeICalContainerImpl::GetNextNEvents( PRTime datems, PRInt32 maxcount, nsISimpleE
|
|||
while( tmplistptr && count<maxcount ) {
|
||||
if( tmplistptr->event ) {
|
||||
oeIICalEvent* tmpevent = tmplistptr->event;
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate );
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate, nsnull );
|
||||
next.is_date = false;
|
||||
if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) {
|
||||
eventEnum->AddEvent( tmpevent );
|
||||
PRTime nextdateinms = ConvertToPrtime( nextcheckdate );
|
||||
|
|
|
@ -863,7 +863,8 @@ NS_IMETHODIMP oeICalEventImpl::GetNextRecurrence( PRTime begin, PRTime *retval,
|
|||
#endif
|
||||
*isvalid = false;
|
||||
icaltimetype begindate,result;
|
||||
result = GetNextRecurrence( begindate );
|
||||
result = GetNextRecurrence( begindate, nsnull );
|
||||
result.is_date = false;
|
||||
if( icaltime_is_null_time( result ) )
|
||||
return NS_OK;
|
||||
*retval = ConvertToPrtime( result );
|
||||
|
@ -939,7 +940,11 @@ NS_IMETHODIMP oeICalEventImpl::GetPreviousOccurrence( PRTime beforethis, PRTime
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
icaltimetype oeICalEventImpl::GetNextRecurrence( icaltimetype begin ) {
|
||||
icaltimetype oeICalEventImpl::GetNextRecurrence( icaltimetype begin, bool *isbeginning ) {
|
||||
|
||||
if( isbeginning ) {
|
||||
*isbeginning = true;
|
||||
}
|
||||
|
||||
icaltimetype result = icaltime_null_time();
|
||||
|
||||
|
@ -955,8 +960,17 @@ icaltimetype oeICalEventImpl::GetNextRecurrence( icaltimetype begin ) {
|
|||
struct icaltimetype nextday = begin;
|
||||
nextday.hour = 0; nextday.minute = 0; nextday.second = 0;
|
||||
icaltime_adjust( &nextday, 1, 0, 0, 0 );
|
||||
if( icaltime_compare( nextday, m_end->m_datetime ) < 0 )
|
||||
if( icaltime_compare( nextday, m_end->m_datetime ) < 0 ) {
|
||||
struct icaltimetype afternextday = nextday;
|
||||
icaltime_adjust( &afternextday, 1, 0, 0, 0 );
|
||||
if( icaltime_compare( afternextday, m_end->m_datetime ) < 0 ) {
|
||||
nextday.is_date = true;
|
||||
}
|
||||
if( isbeginning ) {
|
||||
*isbeginning = false;
|
||||
}
|
||||
return nextday;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -977,6 +991,7 @@ icaltimetype oeICalEventImpl::GetNextRecurrence( icaltimetype begin ) {
|
|||
struct icalrecurrencetype recur = icalproperty_get_rrule(prop);
|
||||
//printf("#### %s\n",icalrecurrencetype_as_string(&recur));
|
||||
icalrecur_iterator* ritr = icalrecur_iterator_new(recur,m_start->m_datetime);
|
||||
bool nextpropagationisdate = false;
|
||||
for(next = icalrecur_iterator_next(ritr);
|
||||
!icaltime_is_null_time(next);
|
||||
next = icalrecur_iterator_next(ritr)){
|
||||
|
@ -1020,6 +1035,11 @@ icaltimetype oeICalEventImpl::GetNextRecurrence( icaltimetype begin ) {
|
|||
PRTime nextdayinms = ConvertToPrtime( nextday );
|
||||
if( !IsExcepted( nextdayinms ) ) {
|
||||
nextpropagation = nextday;
|
||||
struct icaltimetype afternextday = nextday;
|
||||
icaltime_adjust( &afternextday, 1, 0, 0, 0 );
|
||||
if( icaltime_compare( afternextday, end ) < 0 ) {
|
||||
nextpropagationisdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1029,9 +1049,19 @@ icaltimetype oeICalEventImpl::GetNextRecurrence( icaltimetype begin ) {
|
|||
if( !icaltime_is_null_time( nextpropagation ) ) {
|
||||
if( icaltime_compare( nextpropagation , result ) < 0 ) {
|
||||
result = nextpropagation;
|
||||
result.is_date = nextpropagationisdate;
|
||||
if( isbeginning ) {
|
||||
*isbeginning = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if( !icaltime_is_null_time( nextpropagation ) ) {
|
||||
result = nextpropagation;
|
||||
result.is_date = nextpropagationisdate;
|
||||
if( isbeginning ) {
|
||||
*isbeginning = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
icalcomponent_free( vcalendar );
|
||||
|
@ -1068,7 +1098,8 @@ icaltimetype oeICalEventImpl::GetNextAlarmTime( icaltimetype begin ) {
|
|||
|
||||
icaltimetype checkloop = starting;
|
||||
do {
|
||||
checkloop = GetNextRecurrence( checkloop );
|
||||
checkloop = GetNextRecurrence( checkloop, nsnull );
|
||||
checkloop.is_date = false;
|
||||
result = checkloop;
|
||||
if( icaltime_is_null_time( checkloop ) ) {
|
||||
break;
|
||||
|
|
|
@ -112,7 +112,7 @@ public:
|
|||
icalcomponent *AsIcalComponent();
|
||||
icaltimetype GetNextAlarmTime( icaltimetype begin );
|
||||
bool matchId( const char *id );
|
||||
icaltimetype GetNextRecurrence( icaltimetype begin );
|
||||
icaltimetype GetNextRecurrence( icaltimetype begin, bool *isbeginning );
|
||||
icaltimetype GetPreviousOccurrence( icaltimetype beforethis );
|
||||
NS_IMETHODIMP SetParent( oeIICal *parent );
|
||||
icaltimetype CalculateEventTime( icaltimetype alarmtime );
|
||||
|
|
|
@ -1188,7 +1188,7 @@ oeICalImpl::GetAllEvents(nsISimpleEnumerator **resultList )
|
|||
for ( unsigned int i=0; i<num; i++ ) {
|
||||
oeIICalEvent* tmpevent;
|
||||
eventArray->GetElementAt( i, (nsISupports **)&tmpevent );
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( now );
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( now, nsnull );
|
||||
if( !icaltime_is_null_time( next ) )
|
||||
continue;
|
||||
icaltimetype previous = ((oeICalEventImpl *)tmpevent)->GetPreviousOccurrence( checkdate );
|
||||
|
@ -1203,7 +1203,7 @@ oeICalImpl::GetAllEvents(nsISimpleEnumerator **resultList )
|
|||
for ( unsigned int i=0; i<num; i++ ) {
|
||||
oeIICalEvent* tmpevent;
|
||||
eventArray->GetElementAt( i, (nsISupports **)&tmpevent );
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( now );
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( now, nsnull );
|
||||
if( !icaltime_is_null_time( next ) )
|
||||
continue;
|
||||
icaltimetype previous = ((oeICalEventImpl *)tmpevent)->GetPreviousOccurrence( checkdate );
|
||||
|
@ -1228,7 +1228,8 @@ oeICalImpl::GetAllEvents(nsISimpleEnumerator **resultList )
|
|||
for ( unsigned int i=0; i<num; i++ ) {
|
||||
oeIICalEvent* tmpevent;
|
||||
eventArray->GetElementAt( i, (nsISupports **)&tmpevent );
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate );
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate, nsnull );
|
||||
next.is_date = false;
|
||||
if( !icaltime_is_null_time( next ) && ( icaltime_is_null_time( soonest ) || (icaltime_compare( soonest, next ) > 0) ) ) {
|
||||
soonest = next;
|
||||
}
|
||||
|
@ -1241,7 +1242,8 @@ oeICalImpl::GetAllEvents(nsISimpleEnumerator **resultList )
|
|||
for ( unsigned int i=0; i<num; i++ ) {
|
||||
oeIICalEvent* tmpevent;
|
||||
eventArray->GetElementAt( i, (nsISupports **)&tmpevent );
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate );
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate, nsnull );
|
||||
next.is_date = false;
|
||||
if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) {
|
||||
eventEnum->AddEvent( tmpevent );
|
||||
// PRTime nextdateinms = ConvertToPrtime( nextcheckdate );
|
||||
|
@ -1337,25 +1339,12 @@ oeICalImpl::GetEventsForDay( PRTime datems, nsISimpleEnumerator **datelist, nsIS
|
|||
return GetEventsForRange(checkdateinms ,checkenddateinms ,datelist ,eventlist );
|
||||
}
|
||||
|
||||
void oeICalImpl::ChopAndAddEventToEnum( struct icaltimetype initialdisplaydate,
|
||||
struct icaltimetype checkenddate,
|
||||
nsISimpleEnumerator **eventlist, oeICalEventImpl* event ) {
|
||||
void oeICalImpl::ChopAndAddEventToEnum( struct icaltimetype startdate,
|
||||
nsISimpleEnumerator **eventlist, oeICalEventImpl* event, bool isallday, bool isbeginning ) {
|
||||
|
||||
nsCOMPtr<oeEventEnumerator> eventEnum;
|
||||
eventEnum = (oeEventEnumerator *)*eventlist;
|
||||
|
||||
oeIDateTime *start;
|
||||
oeIDateTime *end;
|
||||
event->GetStart( &start );
|
||||
event->GetEnd( &end );
|
||||
|
||||
struct icaltimetype startdate = initialdisplaydate;
|
||||
struct icaldurationtype eventlength = icaltime_subtract( ((oeDateTimeImpl *)end)->m_datetime, ((oeDateTimeImpl *)start)->m_datetime );
|
||||
struct icaltimetype eventenddate = icaltime_add( startdate, eventlength );
|
||||
|
||||
do {
|
||||
struct icaltimetype endofday = startdate;
|
||||
endofday.hour = 23; endofday.minute = 59; endofday.second = 59;
|
||||
oeIICalEventDisplay* eventDisplay;
|
||||
nsresult rv = NS_NewICalEventDisplay( event, &eventDisplay );
|
||||
if( NS_FAILED( rv ) ) {
|
||||
|
@ -1365,23 +1354,41 @@ void oeICalImpl::ChopAndAddEventToEnum( struct icaltimetype initialdisplaydate,
|
|||
return;
|
||||
}
|
||||
eventEnum->AddEvent( eventDisplay );
|
||||
|
||||
PRTime startdateinms = ConvertToPrtime( startdate );
|
||||
eventDisplay->SetDisplayDate( startdateinms );
|
||||
|
||||
struct icaltimetype endofday = startdate;
|
||||
endofday.hour = 23; endofday.minute = 59; endofday.second = 59;
|
||||
|
||||
PRTime enddateinms;
|
||||
if( isallday ) {
|
||||
enddateinms = ConvertToPrtime( endofday );
|
||||
eventDisplay->SetDisplayEndDate( enddateinms );
|
||||
} else {
|
||||
oeIDateTime *end;
|
||||
event->GetEnd( &end );
|
||||
if( isbeginning ) {
|
||||
oeIDateTime *start;
|
||||
event->GetStart( &start );
|
||||
|
||||
struct icaldurationtype eventlength = icaltime_subtract( ((oeDateTimeImpl *)end)->m_datetime, ((oeDateTimeImpl *)start)->m_datetime );
|
||||
struct icaltimetype eventenddate = icaltime_add( startdate, eventlength );
|
||||
|
||||
if( icaltime_compare( endofday, eventenddate ) < 0 ) {
|
||||
enddateinms = ConvertToPrtime( endofday );
|
||||
eventDisplay->SetDisplayEndDate( enddateinms );
|
||||
startdate = endofday;
|
||||
icaltime_adjust( &startdate, 0, 0, 0, 1 );
|
||||
if( icaltime_compare( startdate, checkenddate ) >= 0 )
|
||||
break;
|
||||
} else {
|
||||
enddateinms = ConvertToPrtime( eventenddate );
|
||||
eventDisplay->SetDisplayEndDate( enddateinms );
|
||||
break;
|
||||
}
|
||||
} while ( 0 );
|
||||
} else {
|
||||
struct icaltimetype eventenddate = endofday;
|
||||
eventenddate.hour = ((oeDateTimeImpl *)end)->m_datetime.hour;
|
||||
eventenddate.minute = ((oeDateTimeImpl *)end)->m_datetime.minute;
|
||||
eventenddate.second = ((oeDateTimeImpl *)end)->m_datetime.second;
|
||||
enddateinms = ConvertToPrtime( eventenddate );
|
||||
}
|
||||
eventDisplay->SetDisplayEndDate( enddateinms );
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1423,9 +1430,12 @@ oeICalImpl::GetEventsForRange( PRTime checkdateinms, PRTime checkenddateinms, ns
|
|||
while( tmplistptr ) {
|
||||
if( tmplistptr->event ) {
|
||||
oeIICalEvent* tmpevent = tmplistptr->event;
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate );
|
||||
bool isbeginning;
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate, &isbeginning );
|
||||
bool isallday = next.is_date;
|
||||
next.is_date = false;
|
||||
if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) {
|
||||
ChopAndAddEventToEnum( nextcheckdate, checkenddate, eventlist, (oeICalEventImpl *)tmpevent );
|
||||
ChopAndAddEventToEnum( nextcheckdate, eventlist, (oeICalEventImpl *)tmpevent, isallday, isbeginning );
|
||||
PRTime nextdateinms = ConvertToPrtime( nextcheckdate );
|
||||
dateEnum->AddDate( nextdateinms );
|
||||
}
|
||||
|
@ -1481,7 +1491,8 @@ oeICalImpl::GetFirstEventsForRange( PRTime checkdateinms, PRTime checkenddateinm
|
|||
for ( unsigned int i=0; i<num; i++ ) {
|
||||
oeIICalEvent* tmpevent;
|
||||
eventArray->GetElementAt( i, (nsISupports **)&tmpevent );
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate );
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate, nsnull );
|
||||
next.is_date = false;
|
||||
if( !icaltime_is_null_time( next ) && ( icaltime_is_null_time( soonest ) || (icaltime_compare( soonest, next ) > 0) ) ) {
|
||||
soonest = next;
|
||||
}
|
||||
|
@ -1497,7 +1508,8 @@ oeICalImpl::GetFirstEventsForRange( PRTime checkdateinms, PRTime checkenddateinm
|
|||
for ( unsigned int i=0; i<num; i++ ) {
|
||||
oeIICalEvent* tmpevent;
|
||||
eventArray->GetElementAt( i, (nsISupports **)&tmpevent );
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate );
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate, nsnull );
|
||||
next.is_date = false;
|
||||
if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) {
|
||||
eventEnum->AddEvent( tmpevent );
|
||||
// PRTime nextdateinms = ConvertToPrtime( nextcheckdate );
|
||||
|
@ -1527,7 +1539,8 @@ icaltimetype oeICalImpl::GetNextEvent( icaltimetype starting ) {
|
|||
while( tmplistptr ) {
|
||||
if( tmplistptr->event ) {
|
||||
oeIICalEvent* tmpevent = tmplistptr->event;
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( starting );
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( starting, nsnull );
|
||||
next.is_date = false;
|
||||
if( !icaltime_is_null_time( next ) && ( icaltime_is_null_time( soonest ) || (icaltime_compare( soonest, next ) > 0) ) ) {
|
||||
soonest = next;
|
||||
}
|
||||
|
@ -1565,7 +1578,8 @@ oeICalImpl::GetNextNEvents( PRTime datems, PRInt32 maxcount, nsISimpleEnumerator
|
|||
while( tmplistptr && count<maxcount ) {
|
||||
if( tmplistptr->event ) {
|
||||
oeIICalEvent* tmpevent = tmplistptr->event;
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate );
|
||||
icaltimetype next = ((oeICalEventImpl *)tmpevent)->GetNextRecurrence( checkdate, nsnull );
|
||||
next.is_date = false;
|
||||
if( !icaltime_is_null_time( next ) && (icaltime_compare( nextcheckdate, next ) == 0) ) {
|
||||
eventEnum->AddEvent( tmpevent );
|
||||
PRTime nextdateinms = ConvertToPrtime( nextcheckdate );
|
||||
|
|
|
@ -251,9 +251,8 @@ private:
|
|||
char serveraddr[200];
|
||||
oeICalFilter *m_filter;
|
||||
bool SatisfiesFilter( oeIICalTodo *comp );
|
||||
void ChopAndAddEventToEnum( struct icaltimetype initialdisplaydate,
|
||||
struct icaltimetype checkenddate,
|
||||
nsISimpleEnumerator **eventlist, oeICalEventImpl* event );
|
||||
void ChopAndAddEventToEnum( struct icaltimetype startdate,
|
||||
nsISimpleEnumerator **eventlist, oeICalEventImpl* event, bool isallday, bool isbeginning );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче