Commit 5bd11d84 authored by Murray Cumming's avatar Murray Cumming Committed by Murray Cumming
Browse files

glom/mode_data/box_data_calendar_related.h Update the calendar details

2008-04-22  Murray Cumming  <murrayc@murrayc.com>

* glom/mode_data/box_data_calendar_related.h
* glom/mode_data/box_data_calendar_related.cc
 on_calendar_month_changed(): Update the calendar details when the user 
navigates to a different month.

svn path=/trunk/; revision=1583
parent 6eec00bb
2008-04-22 Murray Cumming <murrayc@murrayc.com>
* glom/mode_data/box_data_calendar_related.h
* glom/mode_data/box_data_calendar_related.cc
on_calendar_month_changed(): Update the calendar details when the user
navigates to a different month.
2008-04-22 Murray Cumming <murrayc@murrayc.com>
* examples/example_lesson_planner.glom:
* examples/Makefile.am: Added a new example, which uses a calendar.
* glom/mode_data/box_data_calendar_related.h
* glom/mode_data/box_data_calendar_related.cc:
fill_from_database(): Do one SQL query for the whole month and store
the values.
on_calendar_details(): Show the stored values.
* glom/mode_data/box_data_list_related.cc:
* glom/mode_data/box_data_list_related.h: Removed get_fields_to_show()
because it is in the base class.
2008-04-21 Murray Cumming <murrayc@murrayc.com>
* glom/mode_data/box_data_calendar_related.cc
......
#Install the examples:
glomdatadir = $(pkgdatadir)/doc/examples
glomdata_DATA = example_smallbusiness.glom example_film_manager.glom example_project_manager.glom example_music_collection.glom
glomdata_DATA = example_smallbusiness.glom example_film_manager.glom example_project_manager.glom example_music_collection.glom example_lesson_planner.glom
EXTRA_DIST = README \
$(glomdata_DATA)
......
This diff is collapsed.
......@@ -46,6 +46,8 @@ Box_Data_Calendar_Related::Box_Data_Calendar_Related()
//Tell the calendar how to get the record details to show:
m_calendar.set_detail_func( sigc::mem_fun(*this, &Box_Data_Calendar_Related::on_calendar_details) );
m_calendar.signal_month_changed().connect( sigc::mem_fun(*this, &Box_Data_Calendar_Related::on_calendar_month_changed) );
setup_menu();
//m_calendar.add_events(Gdk::BUTTON_PRESS_MASK); //Allow us to catch button_press_event and button_release_event
m_calendar.signal_button_press_event().connect_notify( sigc::mem_fun(*this, &Box_Data_Calendar_Related::on_calendar_button_press_event) );
......@@ -345,6 +347,12 @@ void Box_Data_Calendar_Related::prepare_layout_dialog(Dialog_Layout* dialog)
related_dialog->set_document(m_layout_name, get_document(), derived_portal);
}
void Box_Data_Calendar_Related::on_calendar_month_changed()
{
//Update the cached values for the new month:
fill_from_database();
}
Glib::ustring Box_Data_Calendar_Related::on_calendar_details(guint year, guint month, guint day)
{
sharedptr<LayoutItem_CalendarPortal> derived_portal = sharedptr<LayoutItem_CalendarPortal>::cast_dynamic(m_portal);
......@@ -358,7 +366,14 @@ Glib::ustring Box_Data_Calendar_Related::on_calendar_details(guint year, guint m
if(!date_field)
return Glib::ustring();
Glib::Date date(day, Glib::Date::Month(month+1), year);
//TODO: month seems to be 143710360 sometimes, which seems to be a GtkCalendar bug:
//std::cout << "Box_Data_Calendar_Related::on_calendar_details(): year=" << year << ", month=" << month << " day=" << day << std::endl;
//Glib::Date is 1-indexed:
Glib::Date::Month datemonth = (Glib::Date::Month)(month +1);
if(datemonth > Glib::Date::DECEMBER)
datemonth = Glib::Date::JANUARY;
Glib::Date date(day, datemonth, year);
//Examine the cached data:
type_map_values::const_iterator iter_find = m_map_values.find(date);
......
......@@ -63,6 +63,7 @@ protected:
#endif // !GLOM_ENABLE_CLIENT_ONLY
Glib::ustring on_calendar_details(guint year, guint month, guint day);
void on_calendar_month_changed();
void setup_menu();
void on_calendar_button_press_event(GdkEventButton *event);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment