Show events that happen at the same time in multiple columns.

bug 278426, r=pavlov
This commit is contained in:
mvl%exedo.nl 2005-06-08 20:46:09 +00:00
Родитель 0b29ee29dc
Коммит 26bb0b648a
3 изменённых файлов: 68 добавлений и 17 удалений

Просмотреть файл

@ -529,11 +529,11 @@ CalendarWindow.prototype.compareNumbers = function calWin_compareNumbers(a, b) {
}
CalendarWindow.prototype.compareDisplayEventStart = function calWin_compareDisplayEventStart(a, b) {
return ( a.displayDate - b.displayDate );
return ( a.start.compare(b.start) );
}
CalendarWindow.prototype.compareDisplayEventEnd = function calWin_compareDisplayEventStart(a, b) {
return ( a.displayEndDate - b.displayEndDate );
return ( a.end.compare(b.end) );
}
CalendarWindow.prototype.onMouseUpCalendarSplitter = function calWinOnMouseUpCalendarSplitter()
@ -797,11 +797,12 @@ CalendarView.prototype.setDrawProperties = function calView_setDrawProperties( d
var done = false;
var i;
for( i = 0; i < dayEventList.length; i++ )
for( i = 0; i < dayEventList.length; i++ ) {
if( !dayEventList[i].event.isAllDay) {
dayEventStartList.push(dayEventList[i]);
dayEventEndList.push(dayEventList[i]);
}
}
if( dayEventStartList.length > 0 ) {
@ -880,7 +881,8 @@ CalendarView.prototype.setDrawProperties = function calView_setDrawProperties( d
if( !(eventStartListIndex in dayEventStartList) || dayEventStartList[eventStartListIndex] == null )
done = true;
else
nextEventIsStarting = ( dayEventStartList[eventStartListIndex].displayDate < dayEventEndList[eventEndListIndex].displayEndDate );
nextEventIsStarting = dayEventStartList[eventStartListIndex].start
.compare(dayEventEndList[eventEndListIndex].end);
}
// set totalSlotCount for the last contiguous group of events
for ( i = groupStartIndex; i < dayEventStartList.length; i++ )

Просмотреть файл

@ -110,6 +110,20 @@ DayView.prototype.refreshEvents = function()
{
// clean up anything that was here before
this.removeElementsByAttribute("eventbox", "dayview");
this.eventList = new Array();
// set view limits for the day
// XXX expand if event outside this window. Or better, always display the
// complete day, but stroll as needed
var sHour = getIntPref(this.calendarWindow.calendarPreferences.calendarPref, "event.defaultstarthour", 8);
var eHour = getIntPref(this.calendarWindow.calendarPreferences.calendarPref, "event.defaultendhour", 17);
var i;
for (i = 0; i < 24; i++) {
if ((i < sHour) || (i > eHour))
document.getElementById("day-tree-item-"+i).setAttribute("hidden", "true");
else
document.getElementById("day-tree-item-"+i).removeAttribute("hidden");
}
// Figure out the start and end days for the week we're currently viewing
var selectedDateTime = this.calendarWindow.getSelectedDate();
@ -124,12 +138,12 @@ DayView.prototype.refreshEvents = function()
var eventController = this;
var getListener = {
onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {
dump("onOperationComplete\n");
eventController.drawEventBoxes();
},
onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
for (var i = 0; i < aCount; ++i) {
eventController.createEventBox(aItems[i],
function(a1, a2, a3) { eventController.createEventBoxInternal(a1, a2, a3); } );
function(a1, a2, a3) { eventController.addToDisplayList(a1, a2, a3); } );
}
}
};
@ -349,12 +363,29 @@ DayView.prototype.createAllDayEventBox = function dayview_createAllDayEventBox(
return eventBox;
}
DayView.prototype.addToDisplayList = function(itemOccurrence, startDate, endDate)
{
this.eventList.push({event:itemOccurrence, start:startDate, end:endDate});
}
DayView.prototype.drawEventBoxes = function()
{
this.setDrawProperties(this.eventList);
var event;
for (event in this.eventList) {
this.createEventBoxInternal(this.eventList[event]);
}
}
/** PRIVATE
*
* This creates an event box for the day view
*/
DayView.prototype.createEventBoxInternal = function(itemOccurrence, startDate, endDate)
DayView.prototype.createEventBoxInternal = function(event)
{
var itemOccurrence = event.event;
var startDate = event.start;
var endDate = event.end;
var calEvent = itemOccurrence.item.QueryInterface(Components.interfaces.calIEvent);
// XXX Centralize this next checks
@ -399,15 +430,15 @@ DayView.prototype.createEventBoxInternal = function(itemOccurrence, startDate, e
var hourHeight = startHourTreeItem.boxObject.height;
var hourWidth = startHourTreeItem.boxObject.width;
var eventSlotWidth = Math.round( ( hourWidth - kDayViewHourLeftStart )
/ 1 /*calendarEventDisplay.totalSlotCount */);
/ event.totalSlotCount);
//calculate event dimensions
var eventTop = startHourTreeItem.boxObject.y -
startHourTreeItem.parentNode.boxObject.y +
Math.round( hourHeight * startMinutes/ 60 ) - 1;
var eventLeft = kDayViewHourLeftStart + ( /* calendarEventDisplay.startDrawSlot */ 0 * eventSlotWidth );
var eventLeft = kDayViewHourLeftStart + ( event.startDrawSlot * eventSlotWidth );
var eventHeight = Math.round( eventDuration * hourHeight ) + 1;
var eventWidth = ( 1 /* calendarEventDisplay.drawSlotCount */ * eventSlotWidth ) - 1;
var eventWidth = ( event.drawSlotCount * eventSlotWidth ) - 1;
// create title label, location label and description description :)
var eventTitleLabel = document.createElement( "label" );

Просмотреть файл

@ -132,6 +132,7 @@ WeekView.prototype.refreshEvents = function()
// clean up anything that was here before
this.removeElementsByAttribute("eventbox", "weekview");
this.eventList = new Array();
// Figure out the start and end days for the week we're currently viewing
@ -145,11 +146,12 @@ WeekView.prototype.refreshEvents = function()
var getListener = {
onOperationComplete: function(aCalendar, aStatus, aOperationType, aId, aDetail) {
debug("onOperationComplete\n");
eventController.drawEventBoxes();
},
onGetResult: function(aCalendar, aStatus, aItemType, aDetail, aCount, aItems) {
for (var i = 0; i < aCount; ++i) {
eventController.createEventBox(aItems[i],
function(a1, a2, a3) { eventController.createEventBoxInternal(a1, a2, a3); } );
function(a1, a2, a3) { eventController.addToDisplayList(a1, a2, a3); } );
}
}
};
@ -324,13 +326,31 @@ WeekView.prototype.refreshEvents = function()
*/
}
WeekView.prototype.addToDisplayList = function(itemOccurrence, startDate, endDate)
{
this.eventList.push({event:itemOccurrence, start:startDate, end:endDate});
}
WeekView.prototype.drawEventBoxes = function()
{
this.setDrawProperties(this.eventList);
var event;
for (event in this.eventList) {
this.createEventBoxInternal(this.eventList[event]);
}
}
/** PRIVATE
*
* This creates an event box for the week view
*/
WeekView.prototype.createEventBoxInternal = function (itemOccurrence, startDate, endDate)
WeekView.prototype.createEventBoxInternal = function (event)
{
var itemOccurrence = event.event;
var startDate = event.start;
var endDate = event.end;
var calEvent = itemOccurrence.item.QueryInterface(Components.interfaces.calIEvent);
// Check if the event is within the bounds of events to be displayed.
@ -352,8 +372,6 @@ WeekView.prototype.createEventBoxInternal = function (itemOccurrence, startDate,
endDate.hour = this.highestEndHour;
endDate.normalize();
}
dump(startDate+" "+endDate+"\n");
dump(this.displayEndDate+"\n");
/*
if (calEvent.isAllDay) {
@ -385,9 +403,9 @@ dump(this.displayEndDate+"\n");
var hourHeightEnd = ElementOfRefEnd.boxObject.height;
var hourWidth = ElementOfRef.boxObject.width;
var eventSlotWidth = Math.round(hourWidth / 1/*calendarEventDisplay.totalSlotCount*/);
var eventSlotWidth = Math.round(hourWidth / event.totalSlotCount);
var Width = ( 1 /*calendarEventDisplay.drawSlotCount*/ * eventSlotWidth ) - 1;
var Width = ( event.drawSlotCount * eventSlotWidth ) - 1;
eventBox.setAttribute( "width", Width );
var top = eval( ElementOfRef.boxObject.y + ( ( startMinutes/60 ) * hourHeight ) );
@ -406,7 +424,7 @@ dump(this.displayEndDate+"\n");
var boxLeft = document.getElementById("week-tree-day-"+index+"-item-"+startHour).boxObject.x -
document.getElementById( "week-view-content-box" ).boxObject.x +
( /*calendarEventDisplay.startDrawSlot*/0 * eventSlotWidth );
( event.startDrawSlot * eventSlotWidth );
//dump(boxLeft + "\n");
eventBox.setAttribute("left", boxLeft);