3 * Evolution calendar - Data model for ETable
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 * Rodrigo Moya <rodrigo@ximian.com>
21 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
28 #include <libecal/libecal.h>
30 #include <e-util/e-util.h>
31 #include <shell/e-shell.h>
32 #include <calendar/gui/e-cal-data-model.h>
34 #include "e-cell-date-edit-text.h"
36 /* Standard GObject macros */
37 #define E_TYPE_CAL_MODEL \
38 (e_cal_model_get_type ())
39 #define E_CAL_MODEL(obj) \
40 (G_TYPE_CHECK_INSTANCE_CAST \
41 ((obj), E_TYPE_CAL_MODEL, ECalModel))
42 #define E_CAL_MODEL_CLASS(cls) \
43 (G_TYPE_CHECK_CLASS_CAST \
44 ((cls), E_TYPE_CAL_MODEL, ECalModelClass))
45 #define E_IS_CAL_MODEL(obj) \
46 (G_TYPE_CHECK_INSTANCE_TYPE \
47 ((obj), E_TYPE_CAL_MODEL))
48 #define E_IS_CAL_MODEL_CLASS(cls) \
49 (G_TYPE_CHECK_CLASS_TYPE \
50 ((cls), E_TYPE_CAL_MODEL))
51 #define E_CAL_MODEL_GET_CLASS(obj) \
52 (G_TYPE_INSTANCE_GET_CLASS \
53 ((obj), E_TYPE_CAL_MODEL, ECalModelClass))
55 /* Standard GObject macros */
56 #define E_TYPE_CAL_MODEL_COMPONENT \
57 (e_cal_model_component_get_type ())
58 #define E_CAL_MODEL_COMPONENT(obj) \
59 (G_TYPE_CHECK_INSTANCE_CAST \
60 ((obj), E_TYPE_CAL_MODEL_COMPONENT, ECalModelComponent))
61 #define E_CAL_MODEL_COMPONENT_CLASS(cls) \
62 (G_TYPE_CHECK_CLASS_CAST \
63 ((cls), E_TYPE_CAL_MODEL_COMPONENT, ECalModelComponentClass))
64 #define E_IS_CAL_MODEL_COMPONENT(obj) \
65 (G_TYPE_CHECK_INSTANCE_TYPE \
66 ((obj), E_TYPE_CAL_MODEL_COMPONENT))
67 #define E_IS_CAL_MODEL_COMPONENT_CLASS(cls) \
68 (G_TYPE_CHECK_CLASS_TYPE \
69 ((cls), E_TYPE_CAL_MODEL_COMPONENT))
70 #define E_CAL_MODEL_COMPONENT_GET_CLASS(obj) \
71 (G_TYPE_INSTANCE_GET_CLASS \
72 ((obj), E_TYPE_CAL_MODEL_COMPONENT, ECalModelComponentClass))
77 /* If you add new items here or reorder them, you have to update the
78 * .etspec files for the tables using this model */
79 E_CAL_MODEL_FIELD_CATEGORIES
,
80 E_CAL_MODEL_FIELD_CLASSIFICATION
,
81 E_CAL_MODEL_FIELD_COLOR
, /* not a real field */
82 E_CAL_MODEL_FIELD_COMPONENT
, /* not a real field */
83 E_CAL_MODEL_FIELD_DESCRIPTION
,
84 E_CAL_MODEL_FIELD_DTSTART
,
85 E_CAL_MODEL_FIELD_HAS_ALARMS
, /* not a real field */
86 E_CAL_MODEL_FIELD_ICON
, /* not a real field */
87 E_CAL_MODEL_FIELD_SUMMARY
,
88 E_CAL_MODEL_FIELD_UID
,
89 E_CAL_MODEL_FIELD_CREATED
,
90 E_CAL_MODEL_FIELD_LASTMODIFIED
,
91 E_CAL_MODEL_FIELD_SOURCE
, /* not a real field */
92 E_CAL_MODEL_FIELD_LAST
95 typedef struct _ECalModel ECalModel
;
96 typedef struct _ECalModelClass ECalModelClass
;
97 typedef struct _ECalModelPrivate ECalModelPrivate
;
99 typedef struct _ECalModelComponent ECalModelComponent
;
100 typedef struct _ECalModelComponentClass ECalModelComponentClass
;
101 typedef struct _ECalModelComponentPrivate ECalModelComponentPrivate
;
103 struct _ECalModelComponent
{
107 icalcomponent
*icalcomp
;
108 time_t instance_start
;
110 gboolean is_new_component
;
112 /* Private data used by ECalModelCalendar and ECalModelTasks */
113 /* keep these public to avoid many accessor functions */
114 ECellDateEditValue
*dtstart
;
115 ECellDateEditValue
*dtend
;
116 ECellDateEditValue
*due
;
117 ECellDateEditValue
*completed
;
118 ECellDateEditValue
*created
;
119 ECellDateEditValue
*lastmodified
;
122 ECalModelComponentPrivate
*priv
;
125 struct _ECalModelComponentClass
{
126 GObjectClass parent_class
;
130 ECalModelComponent
*comp_data
;
132 } ECalModelGenerateInstancesData
;
136 ECalModelPrivate
*priv
;
139 struct _ECalModelClass
{
140 GObjectClass parent_class
;
142 /* virtual methods */
143 const gchar
* (*get_color_for_component
)
145 ECalModelComponent
*comp_data
);
146 void (*store_values_from_model
)
148 ETableModel
*source_model
,
150 GHashTable
*values
); /* column ID ~> value */
151 void (*fill_component_from_values
)
153 ECalModelComponent
*comp_data
,
154 GHashTable
*values
); /* column ID ~> value, populated by store_values_from_model() */
157 void (*time_range_changed
) (ECalModel
*model
,
158 gint64 start
, /* time_t */
159 gint64 end
); /* time_t */
160 void (*row_appended
) (ECalModel
*model
);
161 void (*comps_deleted
) (ECalModel
*model
,
163 void (*timezone_changed
) (ECalModel
*model
,
164 icaltimezone
*old_zone
,
165 icaltimezone
*new_zone
);
166 void (*object_created
) (ECalModel
*model
,
170 typedef time_t (*ECalModelDefaultTimeFunc
) (ECalModel
*model
, gpointer user_data
);
172 GType
e_cal_model_get_type (void);
173 GType
e_cal_model_component_get_type (void);
174 ECalDataModel
* e_cal_model_get_data_model (ECalModel
*model
);
176 e_cal_model_get_registry (ECalModel
*model
);
177 EShell
* e_cal_model_get_shell (ECalModel
*model
);
178 EClientCache
* e_cal_model_get_client_cache (ECalModel
*model
);
180 e_cal_model_get_component_kind (ECalModel
*model
);
181 void e_cal_model_set_component_kind (ECalModel
*model
,
182 icalcomponent_kind kind
);
183 gboolean
e_cal_model_get_confirm_delete (ECalModel
*model
);
184 void e_cal_model_set_confirm_delete (ECalModel
*model
,
185 gboolean confirm_delete
);
186 icaltimezone
* e_cal_model_get_timezone (ECalModel
*model
);
187 void e_cal_model_set_timezone (ECalModel
*model
,
189 gboolean e_cal_model_get_compress_weekend
191 void e_cal_model_set_compress_weekend
193 gboolean compress_weekend
);
194 void e_cal_model_set_default_category
196 const gchar
*default_cat
);
197 gint e_cal_model_get_default_reminder_interval
199 void e_cal_model_set_default_reminder_interval
201 gint def_reminder_interval
);
202 EDurationType e_cal_model_get_default_reminder_units
204 void e_cal_model_set_default_reminder_units
206 EDurationType def_reminder_units
);
207 gboolean e_cal_model_get_use_24_hour_format
209 void e_cal_model_set_use_24_hour_format
212 gboolean e_cal_model_get_use_default_reminder
214 void e_cal_model_set_use_default_reminder
216 gboolean use_def_reminder
);
217 GDateWeekday
e_cal_model_get_week_start_day (ECalModel
*model
);
218 void e_cal_model_set_week_start_day (ECalModel
*model
,
219 GDateWeekday week_start_day
);
220 gboolean
e_cal_model_get_work_day (ECalModel
*model
,
221 GDateWeekday weekday
);
222 void e_cal_model_set_work_day (ECalModel
*model
,
223 GDateWeekday weekday
,
225 GDateWeekday
e_cal_model_get_work_day_first (ECalModel
*model
);
226 GDateWeekday
e_cal_model_get_work_day_last (ECalModel
*model
);
227 gint e_cal_model_get_work_day_end_hour
229 void e_cal_model_set_work_day_end_hour
231 gint work_day_end_hour
);
232 gint e_cal_model_get_work_day_end_minute
234 void e_cal_model_set_work_day_end_minute
236 gint work_day_end_minute
);
237 gint e_cal_model_get_work_day_start_hour
239 void e_cal_model_set_work_day_start_hour
241 gint work_day_start_hour
);
242 gint e_cal_model_get_work_day_start_minute
244 void e_cal_model_set_work_day_start_minute
246 gint work_day_start_minute
);
247 gint e_cal_model_get_work_day_start_mon
249 void e_cal_model_set_work_day_start_mon
251 gint work_day_start
);
252 gint e_cal_model_get_work_day_end_mon
254 void e_cal_model_set_work_day_end_mon
257 gint e_cal_model_get_work_day_start_tue
259 void e_cal_model_set_work_day_start_tue
261 gint work_day_start
);
262 gint e_cal_model_get_work_day_end_tue
264 void e_cal_model_set_work_day_end_tue
267 gint e_cal_model_get_work_day_start_wed
269 void e_cal_model_set_work_day_start_wed
271 gint work_day_start
);
272 gint e_cal_model_get_work_day_end_wed
274 void e_cal_model_set_work_day_end_wed
277 gint e_cal_model_get_work_day_start_thu
279 void e_cal_model_set_work_day_start_thu
281 gint work_day_start
);
282 gint e_cal_model_get_work_day_end_thu
284 void e_cal_model_set_work_day_end_thu
287 gint e_cal_model_get_work_day_start_fri
289 void e_cal_model_set_work_day_start_fri
291 gint work_day_start
);
292 gint e_cal_model_get_work_day_end_fri
294 void e_cal_model_set_work_day_end_fri
297 gint e_cal_model_get_work_day_start_sat
299 void e_cal_model_set_work_day_start_sat
301 gint work_day_start
);
302 gint e_cal_model_get_work_day_end_sat
304 void e_cal_model_set_work_day_end_sat
307 gint e_cal_model_get_work_day_start_sun
309 void e_cal_model_set_work_day_start_sun
311 gint work_day_start
);
312 gint e_cal_model_get_work_day_end_sun
314 void e_cal_model_set_work_day_end_sun
317 void e_cal_model_get_work_day_range_for
319 GDateWeekday weekday
,
324 const gchar
* e_cal_model_get_default_source_uid
326 void e_cal_model_set_default_source_uid
328 const gchar
*source_uid
);
329 void e_cal_model_remove_all_objects (ECalModel
*model
);
330 void e_cal_model_get_time_range (ECalModel
*model
,
333 void e_cal_model_set_time_range (ECalModel
*model
,
336 icalcomponent
* e_cal_model_create_component_with_defaults_sync
340 GCancellable
*cancellable
,
342 gchar
* e_cal_model_get_attendees_status_info
345 ECalClient
*cal_client
);
346 const gchar
* e_cal_model_get_color_for_component
348 ECalModelComponent
*comp_data
);
349 gboolean e_cal_model_get_rgba_for_component
351 ECalModelComponent
*comp_data
,
353 gboolean e_cal_model_get_rgb_color_for_component
355 ECalModelComponent
*comp_data
,
360 e_cal_model_get_component_at (ECalModel
*model
,
363 e_cal_model_get_component_for_client_and_uid
366 const ECalComponentId
*id
);
367 gchar
* e_cal_model_date_value_to_string (ECalModel
*model
,
368 gconstpointer value
);
369 void e_cal_model_generate_instances_sync
373 ECalRecurInstanceFn cb
,
375 GPtrArray
* e_cal_model_get_object_array (ECalModel
*model
);
376 void e_cal_model_set_instance_times (ECalModelComponent
*comp_data
,
377 const icaltimezone
*zone
);
378 gboolean
e_cal_model_test_row_editable (ECalModel
*model
,
380 void e_cal_model_set_default_time_func
382 ECalModelDefaultTimeFunc func
,
385 void e_cal_model_update_comp_time (ECalModel
*model
,
386 ECalModelComponent
*comp_data
,
387 gconstpointer time_value
,
388 icalproperty_kind kind
,
389 void (*set_func
) (icalproperty
*prop
,
390 struct icaltimetype v
),
391 icalproperty
* (*new_func
) (struct icaltimetype v
));
393 void e_cal_model_emit_object_created (ECalModel
*model
,
396 void e_cal_model_modify_component (ECalModel
*model
,
397 ECalModelComponent
*comp_data
,
400 void e_cal_model_util_set_value (GHashTable
*values
,
401 ETableModel
*table_model
,
404 gpointer
e_cal_model_util_get_value (GHashTable
*values
,
408 e_cal_model_copy_cell_date_value
409 (const ECellDateEditValue
*value
);
413 #endif /* E_CAL_MODEL_H */