[glom] Make the Calendar portal work again.



commit d57ff116306514fe506089f9e6ed1bbc5bc9966f
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Nov 16 09:23:45 2011 +0100

    Make the Calendar portal work again.
    
    	* glom/mode_data/box_data_calendar_related.[h|cc]: Override
    	create_layout() as a place to call our get_fields_to_show(), like
    	Box_Data_List_Related does. Then fill_from_database() can succeed.

 ChangeLog                                   |    8 ++++++++
 glom/mode_data/box_data_calendar_related.cc |   17 +++++++++++++++++
 glom/mode_data/box_data_calendar_related.h  |    1 +
 3 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3c4081e..252ec42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-11-16  Murray Cumming  <murrayc murrayc com>
+
+	Make the Calendar portal work again.
+
+	* glom/mode_data/box_data_calendar_related.[h|cc]: Override
+	create_layout() as a place to call our get_fields_to_show(), like
+	Box_Data_List_Related does. Then fill_from_database() can succeed.
+
 2011-11-14  Murray Cumming  <murrayc murrayc com>
 
 	Fake connection test: Test for a substring in the generated query.
diff --git a/glom/mode_data/box_data_calendar_related.cc b/glom/mode_data/box_data_calendar_related.cc
index 8d7cc30..37f6248 100644
--- a/glom/mode_data/box_data_calendar_related.cc
+++ b/glom/mode_data/box_data_calendar_related.cc
@@ -119,6 +119,14 @@ bool Box_Data_Calendar_Related::init_db_details(const Glib::ustring& parent_tabl
   return Box_Data::init_db_details(found_set, "" /* layout_platform */); //Calls create_layout() and fill_from_database().
 }
 
+
+void Box_Data_Calendar_Related::create_layout()
+{
+  Box_Data::create_layout();
+
+  m_FieldsShown = get_fields_to_show();
+}
+
 bool Box_Data_Calendar_Related::fill_from_database()
 {
   if(!m_portal)
@@ -311,11 +319,17 @@ Box_Data_Calendar_Related::type_vecConstLayoutFields Box_Data_Calendar_Related::
 
   sharedptr<LayoutItem_CalendarPortal> derived_portal = sharedptr<LayoutItem_CalendarPortal>::cast_dynamic(m_portal);
   if(!derived_portal)
+  {
+    std::cerr << G_STRFUNC << ": The portal is not a LayoutItem_CalendarPortal." << std::endl;
     return layout_fields;
+  }
 
   sharedptr<const Field> date_field = derived_portal->get_date_field();
   if(!date_field)
+  {
+    std::cerr << G_STRFUNC << ": get_date_field() returned no field." << std::endl;
     return layout_fields;
+  }
 
   //Add it to the list to ensure that we request the date (though it will not really be shown in the calendar):
   sharedptr<LayoutItem_Field> layout_item_date_field = sharedptr<LayoutItem_Field>::create();
@@ -393,7 +407,10 @@ Glib::ustring Box_Data_Calendar_Related::on_calendar_details(guint year, guint m
 
   sharedptr<const Field> date_field = derived_portal->get_date_field();
   if(!date_field)
+  {
+    std::cerr << G_STRFUNC << ":  get_date_field() returned no field." << std::endl;
     return Glib::ustring();
+  }
 
   //TODO: month seems to be 143710360 sometimes, which seems to be a GtkCalendar bug:
   //std::cout << "debug: " << G_STRFUNC << ": year=" << year << ", month=" << month << " day=" << day << std::endl;
diff --git a/glom/mode_data/box_data_calendar_related.h b/glom/mode_data/box_data_calendar_related.h
index 369a11a..0cf6b54 100644
--- a/glom/mode_data/box_data_calendar_related.h
+++ b/glom/mode_data/box_data_calendar_related.h
@@ -51,6 +51,7 @@ public:
 private:
   virtual bool fill_from_database(); //Override.
   virtual type_vecConstLayoutFields get_fields_to_show() const; //override
+  virtual void create_layout(); //override
     
     
   //Implementations of pure virtual methods from Base_DB_Table_Data:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]