b=298353,298367,298335 need to make calendar views shrinkable, add context menu support to views, fix bug with last day not being queried correctly in views. r=vladimir

This commit is contained in:
vladimir%pobox.com 2005-06-22 19:41:12 +00:00
Родитель 96c2d4a605
Коммит 0191864ef7
4 изменённых файлов: 129 добавлений и 60 удалений

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

@ -47,7 +47,7 @@
<binding id="calendar-month-day-box-item">
<content>
<xul:label anonid="item-label" crop="end" class="calendar-month-day-box-item-label"/>
<xul:label anonid="item-label" crop="end" class="calendar-month-day-box-item-label" xbl:inherits="context"/>
</content>
<implementation>
@ -266,6 +266,7 @@
before = this.mItemData[j].box;
var box = createXULElement("calendar-month-day-box-item");
box.setAttribute("context", this.getAttribute("item-context") || this.getAttribute("context"));
box.setAttribute("class", "calendar-item");
box.setAttribute("item-calendar", itd.item.calendar.uri.spec);
@ -386,6 +387,24 @@
<field name="mShowDaysOutsideMonth">true</field>
<!-- other methods -->
<method name="setAttribute">
<parameter name="aAttr"/>
<parameter name="aVal"/>
<body><![CDATA[
var needsrelayout = false;
if (aAttr == "context" || aAttr == "item-context")
needsrelayout = true;
var ret = XULElement.prototype.setAttribute.call (this, aAttr, aVal);
if (needsrelayout)
this.relayout();
return ret;
]]></body>
</method>
<!-- calICalendarView -->
<property name="supportsDisjointDates" readonly="true"
@ -415,15 +434,26 @@
<property name="endDate" readonly="true">
<getter><![CDATA[
if (!this.mEndDate)
return null;
var realEnd = this.mEndDate.clone();
realEnd.day -= 1;
realEnd.normalize();
return realEnd;
return this.mEndDate;
]]></getter>
</property>
<!-- the end date that should be used for getItems and similar queries -->
<property name="queryEndDate" readonly="true">
<getter><![CDATA[
var end = this.endDate;
if (!end)
return null;
end = end.clone();
end.day += 1;
end.isDate = true;
end.normalize();
return end;
]]></getter>
</property>
<property name="selectedItem">
<getter><![CDATA[
return this.mSelectedItem;
@ -541,15 +571,12 @@
if (!this.mCalendar)
return;
var queryEnd = this.endDate.clone();
queryEnd.day += 1;
queryEnd.normalize();
this.mCalendar.getItems(this.mCalendar.ITEM_FILTER_COMPLETED_ALL |
this.mCalendar.ITEM_FILTER_TYPE_ALL |
this.mCalendar.ITEM_FILTER_CLASS_OCCURRENCES,
0,
this.startDate,
queryEnd,
this.queryEndDate,
this.mOperationListener);
]]></body>
</method>
@ -594,6 +621,9 @@
for each (var date in this.getDateList({})) {
var box = createXULElement("calendar-month-day-box");
box.setAttribute("context", this.getAttribute("context"));
box.setAttribute("item-context", this.getAttribute("item-context") || this.getAttribute("context"));
if (lastMonth != date.month && !first) {
isEven = !isEven;
lastMonth = date.month;
@ -648,7 +678,6 @@
]]></body>
</method>
<method name="findBoxForItem">
<parameter name="aItem"/>
<body><![CDATA[
@ -747,7 +776,7 @@
},
onAddItem: function (aItem) {
var occs = aItem.getOccurrencesBetween(this.calView.startDate,
this.calView.endDate,
this.calView.queryEndDate,
{});
for each (var occ in occs)
this.calView.doAddItem(occ);
@ -755,13 +784,13 @@
onModifyItem: function (aNewItem, aOldItem) {
var occs;
occs = aOldItem.getOccurrencesBetween(this.calView.startDate,
this.calView.endDate,
this.calView.queryEndDate,
{});
for each (var occ in occs)
this.calView.doDeleteItem(occ);
occs = aNewItem.getOccurrencesBetween(this.calView.startDate,
this.calView.endDate,
this.calView.queryEndDate,
{});
for each (var occ in occs)
this.calView.doAddItem(occ);
@ -771,7 +800,7 @@
return;
var occs = aItem.getOccurrencesBetween(this.calView.startDate,
this.calView.endDate,
this.calView.queryEndDate,
{});
for each (var occ in occs) {
this.calView.doDeleteEvent(occ);

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

@ -240,7 +240,7 @@
<content>
<xul:stack anonid="boxstack" flex="1" style="min-width: 1px; min-height: 1px">
<xul:box anonid="bgbox" flex="1" style="min-width: 1px; min-height: 1px"/>
<xul:box anonid="topbox" flex="1" equalsize="always" style="min-width: 1px; min-height: 1px"/>
<xul:box xbl:inherits="context" anonid="topbox" flex="1" equalsize="always" style="min-width: 1px; min-height: 1px"/>
<xul:box anonid="fgbox" flex="1" class="fgdragcontainer" style="min-width: 1px; min-height: 1px">
<xul:box anonid="fgdragspacer" style="display: inherit; overflow: hidden;">
<xul:spacer flex="1"/>
@ -444,6 +444,9 @@
needsrelayout = true;
}
if (aAttr == "context" || aAttr == "item-context")
needsrelayout = true;
// this should be done using lookupMethod(), see bug 286629
var ret = XULElement.prototype.setAttribute.call (this, aAttr, aVal);
@ -629,11 +632,13 @@
if (chunk.event) {
var chunkBox = createXULElement("calendar-event-box");
chunkBox.setAttribute("context", this.getAttribute("item-context") || this.getAttribute("context"));
chunkBox.setAttribute("style", "min-width: 1px; min-height: 1px;");
chunkBox.setAttribute("orient", orient);
// chunkBox.setAttribute("style", "background: #eeeeff; padding: 0px 1px 0px 1px");
// chunkBox.setAttribute("flex", "1");
if (orient == "vertical")
chunkBox.setAttribute("height", duration * this.mPixPerMin);
else
@ -648,6 +653,7 @@
chunk.event.eventbox = chunkBox;
} else {
var chunkBox = createXULElement("spacer");
chunkBox.setAttribute("context", this.getAttribute("context"));
chunkBox.setAttribute("style", "min-width: 1px; min-height: 1px;");
chunkBox.setAttribute("orient", orient);
chunkBox.setAttribute("class", "calendar-empty-space-box");
@ -1186,7 +1192,7 @@
<content>
<xul:box anonid="eventbox" xbl:inherits="orient,width,height" flex="1">
<xul:calendar-event-gripbar anonid="gripbar1" whichside="start" xbl:inherits="parentorient=orient"/>
<xul:vbox class="calendar-event-box-container" xbl:inherits="parentorient=orient" flex="1" align="left">
<xul:vbox class="calendar-event-box-container" xbl:inherits="context,parentorient=orient" flex="1" align="left">
<xul:label anonid="event-name" flex="1" crop="right"/>
<!-- for some reason, textboxes suck ass for reflow. -->
<!-- <xul:textbox class="plain" style="background: transparent !important" anonid="event-name" flex="1" crop="right"/> -->
@ -1330,7 +1336,6 @@
<xul:box anonid="headertimespacer"/>
<xul:box anonid="headerdaybox" flex="1" equalsize="always" />
</xul:box>
<xul:splitter collapse="before"><xul:grippy/></xul:splitter>
<xul:box anonid="childbox" flex="1">
<!-- the orient of the calendar-time-bar needs to be the opposite of the parent -->
<xul:calendar-time-bar xbl:inherits="orient" anonid="timebar"/>
@ -1349,23 +1354,40 @@
this.reorient();
]]></constructor>
<field name="mTimeoutScheduled">false</field>
<field name="mLastSize">0</field>
<method name="onResize">
<parameter name="aRealSelf"/>
<body><![CDATA[
var timebar = document.getAnonymousElementByAttribute(this, "anonid", "timebar");
var daybox = document.getAnonymousElementByAttribute(this, "anonid", "daybox");
var self = this;
if (aRealSelf) {
self = aRealSelf;
self.mTimeoutScheduled = false;
}
var orient = this.orient;
var timebar = document.getAnonymousElementByAttribute(self, "anonid", "timebar");
var daybox = document.getAnonymousElementByAttribute(self, "anonid", "daybox");
var orient = self.orient;
var size;
if (this.orient == "horizontal")
size = daybox.boxObject.width;
if (self.orient == "horizontal")
size = daybox.boxObject.width;
else
size = daybox.boxObject.height;
size = daybox.boxObject.height;
if (self.mLastSize > size) {
self.pixelsPerMinute = 0.01;
self.mLastSize = size;
if (!self.mTimeoutScheduled)
setTimeout(self.onResize, 0, self);
return;
}
self.mLastSize = size;
// ask the
var minutes = timebar.endMinute - timebar.startMinute;
var ppm = size / minutes;
//dump ("new ppm: " + ppm + "\n");
this.pixelsPerMinute = ppm;
self.pixelsPerMinute = ppm;
]]></body>
</method>
@ -1416,7 +1438,7 @@
aItem = aItem.QueryInterface(Components.interfaces.calIEvent);
var occs = aItem.getOccurrencesBetween(this.calView.startDate,
this.calView.endDate,
this.calView.queryEndDate,
{});
//dump ("occs: " + occs.length + "\n");
for each (var occ in occs) {
@ -1433,14 +1455,14 @@
var occs;
occs = aOldItem.getOccurrencesBetween(this.calView.startDate,
this.calView.endDate,
this.calView.queryEndDate,
{});
for each (var occ in occs) {
this.calView.doDeleteEvent(occ);
}
occs = aNewItem.getOccurrencesBetween(this.calView.startDate,
this.calView.endDate,
this.calView.queryEndDate,
{});
for each (var occ in occs) {
this.calView.doAddEvent(occ);
@ -1452,7 +1474,7 @@
return;
var occs = aItem.getOccurrencesBetween(this.calView.startDate,
this.calView.endDate,
this.calView.queryEndDate,
{});
for each (var occ in occs) {
this.calView.doDeleteEvent(occ);
@ -1542,6 +1564,23 @@
]]></getter>
</property>
<!-- the end date that should be used for getItems and similar queries -->
<property name="queryEndDate" readonly="true">
<getter><![CDATA[
var end = this.endDate;
if (!end)
return null;
end = end.clone();
end.day += 1;
end.isDate = true;
end.normalize();
return end;
]]></getter>
</property>
<method name="showDate">
<parameter name="aDate"/>
<body><![CDATA[
@ -1738,17 +1777,20 @@
<parameter name="aAttr"/>
<parameter name="aVal"/>
<body><![CDATA[
var needsrelayout = false;
if (aAttr == "orient") {
if (this.getAttribute("orient") != aVal)
needsrelayout = true;
}
if (aAttr == "context" || aAttr == "item-context")
needsrelayout = true;
// this should be done using lookupMethod(), see bug 286629
var ret = XULElement.prototype.setAttribute.call (this, aAttr, aVal);
if (needsrelayout) {
if (needsrelayout)
this.reorient();
}
return ret;
]]></body>
@ -1791,6 +1833,7 @@
labelbox.removeAttribute("width");
var timebarWidth = 100;
timebar.setAttribute("width", timebarWidth);
timebar.removeAttribute("height");
headertimespacer.setAttribute("width", timebarWidth);
@ -1840,15 +1883,12 @@
// we get all the items, and just filter out the ones we don't
// care about in addItem
var queryEnd = this.endDate.clone();
queryEnd.day += 1;
queryEnd.normalize();
this.mCalendar.getItems(this.mCalendar.ITEM_FILTER_COMPLETED_ALL |
this.mCalendar.ITEM_FILTER_TYPE_EVENT |
this.mCalendar.ITEM_FILTER_CLASS_OCCURRENCES,
0,
this.startDate,
queryEnd,
this.queryEndDate,
this.mOperationListener);
]]></body>
</method>
@ -1901,6 +1941,8 @@
var dayEventsBox = createXULElement("calendar-event-column");
dayEventsBox.setAttribute("flex", "1");
dayEventsBox.setAttribute("class", "calendar-event-column-" + (counter % 2 == 0 ? "even" : "odd"));
dayEventsBox.setAttribute("context", this.getAttribute("context"));
dayEventsBox.setAttribute("item-context", this.getAttribute("item-context") || this.getAttribute("context"));
daybox.appendChild(dayEventsBox);
dayEventsBox.setAttribute("orient", orient);

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

@ -369,9 +369,7 @@ calDateTime::GetStartOfWeek(calIDateTime **aResult)
int day_of_week = icaltime_day_of_week(icalt);
if (day_of_week > 1)
icaltime_adjust(&icalt, - (day_of_week - 1), 0, 0, 0);
icalt.hour = 0;
icalt.minute = 0;
icalt.second = 0;
icalt.is_date = 1;
calDateTime *cdt = new calDateTime(&icalt);
NS_ADDREF(*aResult = cdt);
@ -386,9 +384,7 @@ calDateTime::GetEndOfWeek(calIDateTime **aResult)
int day_of_week = icaltime_day_of_week(icalt);
if (day_of_week < 7)
icaltime_adjust(&icalt, 7 - day_of_week, 0, 0, 0);
icalt.hour = 23;
icalt.minute = 59;
icalt.second = 59;
icalt.is_date = 1;
calDateTime *cdt = new calDateTime(&icalt);
NS_ADDREF(*aResult = cdt);
@ -401,9 +397,8 @@ calDateTime::GetStartOfMonth(calIDateTime **aResult)
struct icaltimetype icalt;
ToIcalTime(&icalt);
icalt.day = 1;
icalt.hour = 0;
icalt.minute = 0;
icalt.second = 0;
icalt.is_date = 1;
calDateTime *cdt = new calDateTime(&icalt);
NS_ADDREF(*aResult = cdt);
return NS_OK;
@ -415,9 +410,8 @@ calDateTime::GetEndOfMonth(calIDateTime **aResult)
struct icaltimetype icalt;
ToIcalTime(&icalt);
icalt.day = icaltime_days_in_month(icalt.month, icalt.year);
icalt.hour = 23;
icalt.minute = 59;
icalt.second = 59;
icalt.is_date = 1;
calDateTime *cdt = new calDateTime(&icalt);
NS_ADDREF(*aResult = cdt);
return NS_OK;
@ -430,9 +424,8 @@ calDateTime::GetStartOfYear(calIDateTime **aResult)
ToIcalTime(&icalt);
icalt.month = 1;
icalt.day = 1;
icalt.hour = 0;
icalt.minute = 0;
icalt.second = 0;
icalt.is_date = 1;
calDateTime *cdt = new calDateTime(&icalt);
NS_ADDREF(*aResult = cdt);
return NS_OK;
@ -445,9 +438,8 @@ calDateTime::GetEndOfYear(calIDateTime **aResult)
ToIcalTime(&icalt);
icalt.month = 12;
icalt.day = 31;
icalt.hour = 23;
icalt.minute = 59;
icalt.second = 59;
icalt.is_date = 1;
calDateTime *cdt = new calDateTime(&icalt);
NS_ADDREF(*aResult = cdt);
return NS_OK;
@ -513,12 +505,19 @@ calDateTime::FromIcalTime(icaltimetype *icalt)
mYear = t.year;
mMonth = t.month - 1;
mDay = t.day;
mHour = t.hour;
mMinute = t.minute;
mSecond = t.second;
mIsDate = t.is_date ? PR_TRUE : PR_FALSE;
if (!mIsDate) {
mHour = t.hour;
mMinute = t.minute;
mSecond = t.second;
} else {
mHour = 0;
mMinute = 0;
mSecond = 0;
}
if (t.is_utc || t.zone == icaltimezone_get_utc_timezone())
mTimezone.AssignLiteral("UTC");
else if (t.zone)

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

@ -145,7 +145,6 @@
.minimonth-day:hover {
cursor: pointer;
font-weight: bold;
border: 1px solid Highlight;
}