2004-05-07  JP Rosevear  <jpr@ximian.com>

	Fixes #52294

	* gui/e-cal-model.c (set_dtstart): set the tzid properly
	(ecm_is_cell_editable): set check properly

	* gui/e-cal-model-tasks.c (set_due): set the tzid properly
	(ecmt_is_cell_editable): set check properly

	* gui/e-cal-model-calendar.c (set_dtend): set the tzid properly
	(ecmc_is_cell_editable): kill fixme and set check properly

svn path=/trunk/; revision=25825
This commit is contained in:
JP Rosevear
2004-05-07 15:10:46 +00:00
committed by JP Rosevear
parent 7aa2882d38
commit 6b70641a97
4 changed files with 136 additions and 24 deletions

View File

@ -1,3 +1,16 @@
2004-05-07 JP Rosevear <jpr@ximian.com>
Fixes #52294
* gui/e-cal-model.c (set_dtstart): set the tzid properly
(ecm_is_cell_editable): set check properly
* gui/e-cal-model-tasks.c (set_due): set the tzid properly
(ecmt_is_cell_editable): set check properly
* gui/e-cal-model-calendar.c (set_dtend): set the tzid properly
(ecmc_is_cell_editable): kill fixme and set check properly
2004-05-07 JP Rosevear <jpr@ximian.com>
* gui/e-cal-model.c (ecm_is_cell_editable): fix comment and check

View File

@ -205,17 +205,53 @@ ecmc_value_at (ETableModel *etm, int col, int row)
static void
set_dtend (ECalModelComponent *comp_data, const void *value)
{
icalproperty *prop;
ECellDateEditValue *dv = (ECellDateEditValue *) value;
icalproperty *prop;
icalparameter *param;
const char *tzid;
prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DTEND_PROPERTY);
if (prop)
param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER);
else
param = NULL;
/* If we are setting the property to NULL (i.e. removing it), then
we remove it if it exists. */
if (!dv) {
if (prop) {
icalcomponent_remove_property (comp_data->icalcomp, prop);
icalproperty_free (prop);
}
} else
icalcomponent_set_dtend (comp_data->icalcomp, dv->tt);
return;
}
/* If the TZID is set to "UTC", we set the is_utc flag. */
tzid = dv->zone ? icaltimezone_get_tzid (dv->zone) : "UTC";
if (tzid && !strcmp (tzid, "UTC"))
dv->tt.is_utc = 1;
else
dv->tt.is_utc = 0;
if (prop) {
icalproperty_set_dtend (prop, dv->tt);
} else {
prop = icalproperty_new_dtend (dv->tt);
icalcomponent_add_property (comp_data->icalcomp, prop);
}
/* If the TZID is set to "UTC", we don't want to save the TZID. */
if (tzid && strcmp (tzid, "UTC")) {
if (param) {
icalparameter_set_tzid (param, (char *) tzid);
} else {
param = icalparameter_new_tzid ((char *) tzid);
icalproperty_add_parameter (prop, param);
}
} else if (param) {
icalproperty_remove_parameter (prop, ICAL_TZID_PARAMETER);
}
}
static void
@ -323,9 +359,7 @@ ecmc_is_cell_editable (ETableModel *etm, int col, int row)
g_return_val_if_fail (E_IS_CAL_MODEL_CALENDAR (model), FALSE);
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_CALENDAR_FIELD_LAST, FALSE);
/* FIXME: We can't check this as 'click-to-add' passes row 0. */
/* g_return_val_if_fail (row >= 0 && row < e_table_model_get_row_count (etm), FALSE); */
g_return_val_if_fail (row >= -1 || (row >= 0 && row < e_table_model_row_count (etm)), FALSE);
if (col < E_CAL_MODEL_FIELD_LAST)
return E_TABLE_MODEL_CLASS (parent_class)->is_cell_editable (etm, col, row);

View File

@ -540,23 +540,52 @@ set_complete (ECalModelComponent *comp_data, const void *value)
static void
set_due (ECalModelComponent *comp_data, const void *value)
{
icalproperty *prop;
ECellDateEditValue *dv = (ECellDateEditValue *) value;
icalproperty *prop;
icalparameter *param;
const char *tzid;
prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DTEND_PROPERTY);
if (prop)
param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER);
else
param = NULL;
prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DUE_PROPERTY);
/* If we are setting the property to NULL (i.e. removing it), then
we remove it if it exists. */
if (!dv) {
if (prop) {
icalcomponent_remove_property (comp_data->icalcomp, prop);
icalproperty_free (prop);
}
return;
}
/* If the TZID is set to "UTC", we set the is_utc flag. */
tzid = dv->zone ? icaltimezone_get_tzid (dv->zone) : "UTC";
if (tzid && !strcmp (tzid, "UTC"))
dv->tt.is_utc = 1;
else
dv->tt.is_utc = 0;
if (prop) {
icalproperty_set_dtend (prop, dv->tt);
} else {
if (prop)
icalproperty_set_due (prop, dv->tt);
else {
prop = icalproperty_new_due (dv->tt);
icalcomponent_add_property (comp_data->icalcomp, prop);
prop = icalproperty_new_dtend (dv->tt);
icalcomponent_add_property (comp_data->icalcomp, prop);
}
/* If the TZID is set to "UTC", we don't want to save the TZID. */
if (tzid && strcmp (tzid, "UTC")) {
if (param) {
icalparameter_set_tzid (param, (char *) tzid);
} else {
param = icalparameter_new_tzid ((char *) tzid);
icalproperty_add_parameter (prop, param);
}
} else if (param) {
icalproperty_remove_parameter (prop, ICAL_TZID_PARAMETER);
}
}
@ -813,7 +842,7 @@ ecmt_is_cell_editable (ETableModel *etm, int col, int row)
priv = model->priv;
g_return_val_if_fail (col >= 0 && col < E_CAL_MODEL_TASKS_FIELD_LAST, FALSE);
g_return_val_if_fail (row >= -1 && row < e_table_model_get_row_count (etm), FALSE);
g_return_val_if_fail (row >= -1 || (row >= 0 && row < e_table_model_row_count (etm)), FALSE);
if (col < E_CAL_MODEL_FIELD_LAST)
return E_TABLE_MODEL_CLASS (parent_class)->is_cell_editable (etm, col, row);

View File

@ -582,17 +582,53 @@ set_description (ECalModelComponent *comp_data, const char *value)
static void
set_dtstart (ECalModel *model, ECalModelComponent *comp_data, const void *value)
{
icalproperty *prop;
ECellDateEditValue *dv = (ECellDateEditValue *) value;
icalproperty *prop;
icalparameter *param;
const char *tzid;
prop = icalcomponent_get_first_property (comp_data->icalcomp, ICAL_DTSTART_PROPERTY);
if (prop)
param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER);
else
param = NULL;
/* If we are setting the property to NULL (i.e. removing it), then
we remove it if it exists. */
if (!dv) {
if (prop) {
icalcomponent_remove_property (comp_data->icalcomp, prop);
icalproperty_free (prop);
}
} else
icalcomponent_set_dtstart (comp_data->icalcomp, dv->tt);
return;
}
/* If the TZID is set to "UTC", we set the is_utc flag. */
tzid = dv->zone ? icaltimezone_get_tzid (dv->zone) : "UTC";
if (tzid && !strcmp (tzid, "UTC"))
dv->tt.is_utc = 1;
else
dv->tt.is_utc = 0;
if (prop) {
icalproperty_set_dtstart (prop, dv->tt);
} else {
prop = icalproperty_new_dtstart (dv->tt);
icalcomponent_add_property (comp_data->icalcomp, prop);
}
/* If the TZID is set to "UTC", we don't want to save the TZID. */
if (tzid && strcmp (tzid, "UTC")) {
if (param) {
icalparameter_set_tzid (param, (char *) tzid);
} else {
param = icalparameter_new_tzid ((char *) tzid);
icalproperty_add_parameter (prop, param);
}
} else if (param) {
icalproperty_remove_parameter (prop, ICAL_TZID_PARAMETER);
}
}
static void
@ -671,7 +707,7 @@ ecm_is_cell_editable (ETableModel *etm, int col, int row)
priv = model->priv;
g_return_val_if_fail (col >= 0 && col <= E_CAL_MODEL_FIELD_LAST, FALSE);
g_return_val_if_fail (row >= -1 && row < priv->objects->len, FALSE);
g_return_val_if_fail (row >= -1 || (row >= 0 && row < priv->objects->len), FALSE);
switch (col) {
case E_CAL_MODEL_FIELD_CATEGORIES :
@ -1206,7 +1242,7 @@ e_cal_view_objects_added_cb (ECalView *query, GList *objects, gpointer user_data
comp_data = g_new0 (ECalModelComponent, 1);
comp_data->client = g_object_ref (e_cal_view_get_client (query));
comp_data->icalcomp = icalcomponent_new_clone (l->data);
g_ptr_array_add (priv->objects, comp_data);
e_table_model_row_inserted (E_TABLE_MODEL (model), priv->objects->len - 1);
@ -1803,8 +1839,8 @@ e_cal_model_copy_component_data (ECalModelComponent *comp_data)
new_data = g_new0 (ECalModelComponent, 1);
if (comp_data->icalcomp)
new_data->icalcomp = icalcomponent_new_clone (comp_data->icalcomp);
if (comp_data->icalcomp)
new_data->icalcomp = icalcomponent_new_clone (comp_data->icalcomp);
if (comp_data->client)
new_data->client = g_object_ref (comp_data->client);
if (comp_data->dtstart)