glom r1581 - in trunk: . glom/mode_data



Author: murrayc
Date: Mon Apr 21 17:43:53 2008
New Revision: 1581
URL: http://svn.gnome.org/viewvc/glom?rev=1581&view=rev

Log:
2008-04-21  Murray Cumming  <murrayc murrayc com>

* glom/mode_data/box_data_calendar_related.cc
  (Glom.on_calendar_details):
* glom/mode_data/box_data_calendar_related.h
  (Box_Data_Calendar_Related):
* glom/mode_data/box_data_list_related.cc:
* glom/mode_data/box_data_list_related.h:
Removed get_has_suitable_record_to_view_details(),
        get_suitable_table_to_view_details() and 
get_suitable_record_to_view_details() because they are in the base 
Box_Data_Portal) class.

* glom/mode_data/box_data_portal.cc:
* glom/mode_data/box_data_portal.h: Removed unused empty 
create_layout_dialog() and prepare_layout_dialog
* glom/mode_data/flowtablewithfields.h:
* glom/mode_data/flowtablewithfields.cc: get_portals(): Get a list of 
Box_Data_Portal instead of Widget, to make this more self-documenting.
set_field_value(): Do not dynamic_cast to just Box_Data_List_Related, 
so that Box_Data_Calendar_Related is updated too, to show just the 
related records, instead of all.

Modified:
   trunk/ChangeLog
   trunk/glom/mode_data/box_data_calendar_related.cc
   trunk/glom/mode_data/box_data_calendar_related.h
   trunk/glom/mode_data/box_data_list_related.cc
   trunk/glom/mode_data/box_data_list_related.h
   trunk/glom/mode_data/box_data_portal.cc
   trunk/glom/mode_data/box_data_portal.h
   trunk/glom/mode_data/flowtablewithfields.cc
   trunk/glom/mode_data/flowtablewithfields.h

Modified: trunk/glom/mode_data/box_data_calendar_related.cc
==============================================================================
--- trunk/glom/mode_data/box_data_calendar_related.cc	(original)
+++ trunk/glom/mode_data/box_data_calendar_related.cc	Mon Apr 21 17:43:53 2008
@@ -87,77 +87,6 @@
   return Box_Data_List::init_db_details(found_set); //Calls create_layout() and fill_from_database().
 }
 
-bool Box_Data_Calendar_Related::refresh_data_from_database_with_foreign_key(const Gnome::Gda::Value& foreign_key_value)
-{
-  std::cout << "DEBUG: Box_Data_Calendar_Related::refresh_data_from_database_with_foreign_key()" << std::endl;
-  
-  
-  m_key_value = foreign_key_value;
-
-  if(!m_key_field)
-    std::cout << "DEBUG: Box_Data_Calendar_Related::refresh_data_from_database_with_foreign_key(): m_key_field is NULL" << std::endl;
-  
-  if(Conversions::value_is_empty(m_key_value))
-    std::cout << "DEBUG: Box_Data_Calendar_Related::refresh_data_from_database_with_foreign_key(): m_key_value is empty." << std::endl;
-  
-  
-  if(m_key_field)
-  {
-    if(!Conversions::value_is_empty(m_key_value))
-    {
-      sharedptr<Relationship> relationship = m_portal->get_relationship();
-
-      // Notice that, in the case that this is a portal to doubly-related records,
-      // The WHERE clause mentions the first-related table (though by the alias defined in extra_join)
-      // and we add an extra JOIN to mention the second-related table.
-
-      Glib::ustring where_clause_to_table_name = relationship->get_to_table();
-      sharedptr<Field> where_clause_to_key_field = m_key_field;
-
-      m_found_set.m_table_name = m_portal->get_table_used(Glib::ustring() /* parent table - not relevant */);
-      
-      sharedptr<const Relationship> relationship_related = m_portal->get_related_relationship();
-      if(relationship_related)
-      {
-         //Add the extra JOIN:
-         sharedptr<UsesRelationship> uses_rel_temp = sharedptr<UsesRelationship>::create();
-         uses_rel_temp->set_relationship(relationship);
-         //found_set.m_extra_join = uses_rel_temp->get_sql_join_alias_definition();
-         m_found_set.m_extra_join = "LEFT OUTER JOIN \"" + relationship->get_to_table() + "\" AS \"" + uses_rel_temp->get_sql_join_alias_name() + "\" ON (\"" + uses_rel_temp->get_sql_join_alias_name() + "\".\"" + relationship_related->get_from_field() + "\" = \"" + relationship_related->get_to_table() + "\".\"" + relationship_related->get_to_field() + "\")";
-
-         //Add an extra GROUP BY to ensure that we get no repeated records from the doubly-related table:
-         m_found_set.m_extra_group_by = "GROUP BY \"" + m_found_set.m_table_name + "\".\"" + m_key_field->get_name() + "\"";
-
-         //Adjust the WHERE clause appropriately for the extra JOIN:
-         where_clause_to_table_name = uses_rel_temp->get_sql_join_alias_name();
-
-         const Glib::ustring to_field_name = uses_rel_temp->get_to_field_used();
-         where_clause_to_key_field = get_fields_for_table_one_field(relationship->get_to_table(), to_field_name);
-         //std::cout << "extra_join=" << found_set.m_extra_join << std::endl;
- 
-         //std::cout << "extra_join where_clause_to_key_field=" << where_clause_to_key_field->get_name() << std::endl;
-      }
-
-      m_found_set.m_where_clause = "\"" + where_clause_to_table_name + "\".\"" + relationship->get_to_field() + "\" = " + where_clause_to_key_field->sql(m_key_value);
-      return true;
-    }
-    else
-    {
-      //If there is no from key value then no records can be shown:
-      //TODO
-      return true;
-    }
-  }
-  else
-  {
-    //If there is no to field then this relationship specifies all records in the table.
-    m_found_set.m_where_clause = Glib::ustring();
-    return true;
-  }
-  
-  //The actual data is retrieved in the detail_func handler.
-}
-
 bool Box_Data_Calendar_Related::fill_from_database()
 {
   bool result = false;
@@ -320,150 +249,6 @@
 }
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
-
-bool Box_Data_Calendar_Related::get_has_suitable_record_to_view_details() const
-{
-  Glib::ustring navigation_table_name;
-  sharedptr<const UsesRelationship> navigation_relationship;
-  get_suitable_table_to_view_details(navigation_table_name, navigation_relationship);
-
-  return !(navigation_table_name.empty());
-}
-
-void Box_Data_Calendar_Related::get_suitable_table_to_view_details(Glib::ustring& table_name, sharedptr<const UsesRelationship>& relationship) const
-{
- 
-  //Initialize output parameters:
-  table_name = Glib::ustring();
-
-  //Check whether a relationship was specified:
-  bool navigation_relationship_main = false;
-  sharedptr<const UsesRelationship> navigation_relationship = m_portal->get_navigation_relationship_specific(navigation_relationship_main);
-  if(!navigation_relationship_main && !navigation_relationship)
-  {
-    //std::cout << "debug: decide automatically." << std::endl;
-    //Decide automatically:
-    navigation_relationship_main = false;
-    navigation_relationship = get_portal_navigation_relationship_automatic(m_portal, navigation_relationship_main);
-    //std::cout << "debug: auto main=" << navigation_relationship_main << ", navigation_relationship=" << (navigation_relationship ? navigation_relationship->get_name() : navigation_relationship->get_relationship()->get_name()) << std::endl;
-  }
-  //else
-  //  std::cout << "debug: get_suitable_table_to_view_details(): Using specific nav." << std::endl;
-
-  const Document_Glom* document = get_document();
-  if(!document)
-    return;
-
-
-  //Get the navigation table name from the chosen relationship:
-  const Glib::ustring directly_related_table_name = m_portal->get_table_used(Glib::ustring() /* not relevant */);
- 
-  Glib::ustring navigation_table_name;
-  if(navigation_relationship_main)
-  {
-    navigation_table_name = directly_related_table_name;
-  }
-  else if(navigation_relationship)
-  {
-    navigation_table_name = navigation_relationship->get_table_used(directly_related_table_name);
-  }
-
-  if(navigation_table_name.empty())
-  {
-    std::cerr << "Box_Data_Calendar_Related::get_suitable_table_to_view_details(): navigation_table_name is empty." << std::endl;
-    return;
-  }
-
-  if(document->get_table_is_hidden(navigation_table_name))
-  {
-    std::cerr << "Box_Data_Calendar_Related::get_suitable_table_to_view_details(): navigation_table_name indicates a hidden table: " << navigation_table_name << std::endl;
-    return;
-  }
-
-  table_name = navigation_table_name;
-  relationship = navigation_relationship;
-}
-
-void Box_Data_Calendar_Related::get_suitable_record_to_view_details(const Gnome::Gda::Value& primary_key_value, Glib::ustring& table_name, Gnome::Gda::Value& table_primary_key_value) const
-{
-  //Initialize output parameters:
-  table_name = Glib::ustring();
-  table_primary_key_value = Gnome::Gda::Value();
-
-  Glib::ustring navigation_table_name;
-  sharedptr<const UsesRelationship> navigation_relationship;
-  get_suitable_table_to_view_details(navigation_table_name, navigation_relationship);
- 
-  if(navigation_table_name.empty())
-    return;
-
-  //Get the primary key of that table:
-  sharedptr<Field> navigation_table_primary_key = get_field_primary_key_for_table(navigation_table_name);
-
-  //Build a layout item to get the field's value:
-  sharedptr<LayoutItem_Field> layout_item = sharedptr<LayoutItem_Field>::create();
-  layout_item->set_full_field_details(navigation_table_primary_key);
-
-  if(navigation_relationship)
-  {
-    layout_item->set_relationship( navigation_relationship->get_relationship() );
-    //std::cout << "debug: navigation_relationship->get_relationship()= " << navigation_relationship->get_relationship()->get_name() << std::endl;
-    layout_item->set_related_relationship( navigation_relationship->get_related_relationship() );
-  }
-
-  //Get the value of the navigation related primary key:
-  type_vecLayoutFields fieldsToGet;
-  fieldsToGet.push_back(layout_item);
-
-  const Glib::ustring query; //TODO: = Utils::build_sql_select_with_key(m_portal->get_table_used(Glib::ustring() /* not relevant */), fieldsToGet, m_calendar.get_key_field(), primary_key_value);
-  Glib::RefPtr<Gnome::Gda::DataModel> data_model = query_execute(query);
-
-
-  bool value_found = true;
-  if(data_model && data_model->get_n_rows() && data_model->get_n_columns())
-  {
-    //Set the output parameters:
-    table_name = navigation_table_name;
-    table_primary_key_value = data_model->get_value_at(0, 0);
-
-    //std::cout << "Box_Data_Calendar_Related::get_suitable_record_to_view_details(): table_primary_key_value=" << table_primary_key_value.to_string() << std::endl;
-
-    //The value is empty when there there is no record to match the key in the related table:
-    //For instance, if an invoice lines record mentions a product id, but the product does not exist in the products table.
-    if(Conversions::value_is_empty(table_primary_key_value))
-    {
-      value_found = false;
-      std::cout << "debug: Box_Data_Calendar_Related::get_suitable_record_to_view_details(): SQL query returned empty primary key." << std::endl;
-    }
-  }
-  else
-  {
-    value_found = false;
-    std::cout << "debug: Box_Data_Calendar_Related::get_suitable_record_to_view_details(): SQL query returned no suitable primary key." << std::endl;
-  }
-
-  if(!value_found)
-  {
-    //Clear the output parameters:
-    table_name = Glib::ustring();
-    table_primary_key_value = Gnome::Gda::Value();
-
-    Gtk::Window* window = const_cast<Gtk::Window*>(get_app_window());
-    if(window)
-      Frame_Glom::show_ok_dialog(_("No Corresponding Record Exists"), _("No record with this value exists. Therefore navigation to the related record is not possible."), *window, Gtk::MESSAGE_WARNING); //TODO: Make it more clear to the user exactly what record, what field, and what value, we are talking about.
-  }
-}
-
-Document_Glom::type_list_layout_groups Box_Data_Calendar_Related::create_layout_get_layout()
-{
-  Document_Glom::type_list_layout_groups result;
-
-  if(m_portal)
-    result.push_back(m_portal);
-  
-  return result;
-}
-
 Dialog_Layout* Box_Data_Calendar_Related::create_layout_dialog() const
 {
 #ifndef GLOM_ENABLE_CLIENT_ONLY
@@ -524,6 +309,7 @@
   else
     where_clause = "( " + m_found_set.m_where_clause + " ) AND ( " + extra_where_clause + " )";
   
+  //TODO: Do one SQL query for the whole month and just read the cached values here, responding to month_changed to update the cache.
   const Glib::ustring sql_query = Utils::build_sql_select_with_where_clause(m_found_set.m_table_name, m_FieldsShown, where_clause, m_found_set.m_extra_join, m_found_set.m_sort_clause, m_found_set.m_extra_group_by);
   //std::cout << "DEBUG: sql_query=" << sql_query << std::endl;
   Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute(sql_query, get_app_window());
@@ -552,7 +338,7 @@
       {
         const Gnome::Gda::Value value = datamodel->get_value_at(row_index, column_index);
         text = Conversions::get_text_for_gda_value(layout_item_field->get_glom_type(), value, layout_item_field->get_formatting_used().m_numeric_format);
-        std::cout << "  DEBUG: text=" << text << std::endl;
+        //std::cout << "  DEBUG: text=" << text << std::endl;
         ++column_index;
       }
     }

Modified: trunk/glom/mode_data/box_data_calendar_related.h
==============================================================================
--- trunk/glom/mode_data/box_data_calendar_related.h	(original)
+++ trunk/glom/mode_data/box_data_calendar_related.h	Mon Apr 21 17:43:53 2008
@@ -41,17 +41,7 @@
   /**
    * @param portal: The full portal details
    */
-    virtual bool init_db_details(const sharedptr<const LayoutItem_CalendarPortal>& portal, bool show_title = true);
-
-  /**
-   * @param foreign_key_value: The value that should be found in this table.
-   * @param from_table_primary_key_value The primary key of the parent record's table, used to associate new related records.
-   */
-  virtual bool refresh_data_from_database_with_foreign_key(const Gnome::Gda::Value& foreign_key_value);
-
-  bool get_has_suitable_record_to_view_details() const;
-  void get_suitable_table_to_view_details(Glib::ustring& table_name, sharedptr<const UsesRelationship>& relationship) const;
-  void get_suitable_record_to_view_details(const Gnome::Gda::Value& primary_key_value, Glib::ustring& table_name, Gnome::Gda::Value& table_primary_key_value) const;
+  virtual bool init_db_details(const sharedptr<const LayoutItem_CalendarPortal>& portal, bool show_title = true);
 
 protected:
   virtual bool fill_from_database(); //Override.
@@ -85,8 +75,6 @@
   #endif
     
 protected:
-  virtual Document_Glom::type_list_layout_groups create_layout_get_layout(); //override.
-
   GlomGtk::Calendar m_calendar;
     
   //TODO: Avoid repeating these in so many widgets:

Modified: trunk/glom/mode_data/box_data_list_related.cc
==============================================================================
--- trunk/glom/mode_data/box_data_list_related.cc	(original)
+++ trunk/glom/mode_data/box_data_list_related.cc	Mon Apr 21 17:43:53 2008
@@ -79,70 +79,6 @@
   return Box_Data_List::init_db_details(found_set); //Calls create_layout() and fill_from_database().
 }
 
-bool Box_Data_List_Related::refresh_data_from_database_with_foreign_key(const Gnome::Gda::Value& foreign_key_value)
-{
-  m_key_value = foreign_key_value;
-
-  if(m_key_field)
-  {
-    if(!Conversions::value_is_empty(m_key_value))
-    {
-      sharedptr<Relationship> relationship = m_portal->get_relationship();
-
-      // Notice that, in the case that this is a portal to doubly-related records,
-      // The WHERE clause mentions the first-related table (though by the alias defined in extra_join)
-      // and we add an extra JOIN to mention the second-related table.
-
-      Glib::ustring where_clause_to_table_name = relationship->get_to_table();
-      sharedptr<Field> where_clause_to_key_field = m_key_field;
-
-      FoundSet found_set = m_found_set;
-      found_set.m_table_name = m_portal->get_table_used(Glib::ustring() /* parent table - not relevant */);
-      
-      sharedptr<const Relationship> relationship_related = m_portal->get_related_relationship();
-      if(relationship_related)
-      {
-         //Add the extra JOIN:
-         sharedptr<UsesRelationship> uses_rel_temp = sharedptr<UsesRelationship>::create();
-         uses_rel_temp->set_relationship(relationship);
-         //found_set.m_extra_join = uses_rel_temp->get_sql_join_alias_definition();
-         found_set.m_extra_join = "LEFT OUTER JOIN \"" + relationship->get_to_table() + "\" AS \"" + uses_rel_temp->get_sql_join_alias_name() + "\" ON (\"" + uses_rel_temp->get_sql_join_alias_name() + "\".\"" + relationship_related->get_from_field() + "\" = \"" + relationship_related->get_to_table() + "\".\"" + relationship_related->get_to_field() + "\")";
-
-         //Add an extra GROUP BY to ensure that we get no repeated records from the doubly-related table:
-         found_set.m_extra_group_by = "GROUP BY \"" + found_set.m_table_name + "\".\"" + m_key_field->get_name() + "\"";
-
-         //Adjust the WHERE clause appropriately for the extra JOIN:
-         where_clause_to_table_name = uses_rel_temp->get_sql_join_alias_name();
-
-         Glib::ustring to_field_name = uses_rel_temp->get_to_field_used();
-         where_clause_to_key_field = get_fields_for_table_one_field(relationship->get_to_table(), to_field_name);
-         //std::cout << "extra_join=" << found_set.m_extra_join << std::endl;
- 
-         //std::cout << "extra_join where_clause_to_key_field=" << where_clause_to_key_field->get_name() << std::endl;
-      }
-
-      found_set.m_where_clause = "\"" + where_clause_to_table_name + "\".\"" + relationship->get_to_field() + "\" = " + where_clause_to_key_field->sql(m_key_value);
-
-
-      //g_warning("refresh_data_from_database(): where_clause=%s", where_clause.c_str());
-      return Box_Data_List::refresh_data_from_database_with_where_clause(found_set);
-    }
-    else
-    {
-      //If there is no from key value then no records can be shown:
-      refresh_data_from_database_blank();
-      return true;
-    }
-  }
-  else
-  {
-    //If there is no to field then this relationship specifies all records in the table.
-    FoundSet found_set = m_found_set;
-    found_set.m_where_clause = Glib::ustring();
-    return Box_Data_List::refresh_data_from_database_with_where_clause(found_set);
-  }
-}
-
 bool Box_Data_List_Related::fill_from_database()
 {
   bool result = false;
@@ -363,152 +299,6 @@
     Box_Data_List::on_adddel_user_requested_add();
 }
 
-
-
-
-bool Box_Data_List_Related::get_has_suitable_record_to_view_details() const
-{
-  Glib::ustring navigation_table_name;
-  sharedptr<const UsesRelationship> navigation_relationship;
-  get_suitable_table_to_view_details(navigation_table_name, navigation_relationship);
-
-  return !(navigation_table_name.empty());
-}
-
-void Box_Data_List_Related::get_suitable_table_to_view_details(Glib::ustring& table_name, sharedptr<const UsesRelationship>& relationship) const
-{
- 
-  //Initialize output parameters:
-  table_name = Glib::ustring();
-
-  //Check whether a relationship was specified:
-  bool navigation_relationship_main = false;
-  sharedptr<const UsesRelationship> navigation_relationship = m_portal->get_navigation_relationship_specific(navigation_relationship_main);
-  if(!navigation_relationship_main && !navigation_relationship)
-  {
-    //std::cout << "debug: decide automatically." << std::endl;
-    //Decide automatically:
-    navigation_relationship_main = false;
-    navigation_relationship = get_portal_navigation_relationship_automatic(m_portal, navigation_relationship_main);
-    //std::cout << "debug: auto main=" << navigation_relationship_main << ", navigation_relationship=" << (navigation_relationship ? navigation_relationship->get_name() : navigation_relationship->get_relationship()->get_name()) << std::endl;
-  }
-  //else
-  //  std::cout << "debug: get_suitable_table_to_view_details(): Using specific nav." << std::endl;
-
-  const Document_Glom* document = get_document();
-  if(!document)
-    return;
-
-
-  //Get the navigation table name from the chosen relationship:
-  const Glib::ustring directly_related_table_name = m_portal->get_table_used(Glib::ustring() /* not relevant */);
- 
-  Glib::ustring navigation_table_name;
-  if(navigation_relationship_main)
-  {
-    navigation_table_name = directly_related_table_name;
-  }
-  else if(navigation_relationship)
-  {
-    navigation_table_name = navigation_relationship->get_table_used(directly_related_table_name);
-  }
-
-  if(navigation_table_name.empty())
-  {
-    std::cerr << "Box_Data_List_Related::get_suitable_table_to_view_details(): navigation_table_name is empty." << std::endl;
-    return;
-  }
-
-  if(document->get_table_is_hidden(navigation_table_name))
-  {
-    std::cerr << "Box_Data_List_Related::get_suitable_table_to_view_details(): navigation_table_name indicates a hidden table: " << navigation_table_name << std::endl;
-    return;
-  }
-
-  table_name = navigation_table_name;
-  relationship = navigation_relationship;
-}
-
-void Box_Data_List_Related::get_suitable_record_to_view_details(const Gnome::Gda::Value& primary_key_value, Glib::ustring& table_name, Gnome::Gda::Value& table_primary_key_value) const
-{
-  //Initialize output parameters:
-  table_name = Glib::ustring();
-  table_primary_key_value = Gnome::Gda::Value();
-
-  Glib::ustring navigation_table_name;
-  sharedptr<const UsesRelationship> navigation_relationship;
-  get_suitable_table_to_view_details(navigation_table_name, navigation_relationship);
- 
-  if(navigation_table_name.empty())
-    return;
-
-  //Get the primary key of that table:
-  sharedptr<Field> navigation_table_primary_key = get_field_primary_key_for_table(navigation_table_name);
-
-  //Build a layout item to get the field's value:
-  sharedptr<LayoutItem_Field> layout_item = sharedptr<LayoutItem_Field>::create();
-  layout_item->set_full_field_details(navigation_table_primary_key);
-
-  if(navigation_relationship)
-  {
-    layout_item->set_relationship( navigation_relationship->get_relationship() );
-    //std::cout << "debug: navigation_relationship->get_relationship()= " << navigation_relationship->get_relationship()->get_name() << std::endl;
-    layout_item->set_related_relationship( navigation_relationship->get_related_relationship() );
-  }
-
-  //Get the value of the navigation related primary key:
-  type_vecLayoutFields fieldsToGet;
-  fieldsToGet.push_back(layout_item);
-
-  const Glib::ustring query = Utils::build_sql_select_with_key(m_portal->get_table_used(Glib::ustring() /* not relevant */), fieldsToGet, m_AddDel.get_key_field(), primary_key_value);
-  Glib::RefPtr<Gnome::Gda::DataModel> data_model = query_execute(query);
-
-
-  bool value_found = true;
-  if(data_model && data_model->get_n_rows() && data_model->get_n_columns())
-  {
-    //Set the output parameters:
-    table_name = navigation_table_name;
-    table_primary_key_value = data_model->get_value_at(0, 0);
-
-    //std::cout << "Box_Data_List_Related::get_suitable_record_to_view_details(): table_primary_key_value=" << table_primary_key_value.to_string() << std::endl;
-
-    //The value is empty when there there is no record to match the key in the related table:
-    //For instance, if an invoice lines record mentions a product id, but the product does not exist in the products table.
-    if(Conversions::value_is_empty(table_primary_key_value))
-    {
-      value_found = false;
-      std::cout << "debug: Box_Data_List_Related::get_suitable_record_to_view_details(): SQL query returned empty primary key." << std::endl;
-    }
-  }
-  else
-  {
-    value_found = false;
-    std::cout << "debug: Box_Data_List_Related::get_suitable_record_to_view_details(): SQL query returned no suitable primary key." << std::endl;
-  }
-
-  if(!value_found)
-  {
-    //Clear the output parameters:
-    table_name = Glib::ustring();
-    table_primary_key_value = Gnome::Gda::Value();
-
-    Gtk::Window* window = const_cast<Gtk::Window*>(get_app_window());
-    if(window)
-      Frame_Glom::show_ok_dialog(_("No Corresponding Record Exists"), _("No record with this value exists. Therefore navigation to the related record is not possible."), *window, Gtk::MESSAGE_WARNING); //TODO: Make it more clear to the user exactly what record, what field, and what value, we are talking about.
-  }
-}
-
-Document_Glom::type_list_layout_groups Box_Data_List_Related::create_layout_get_layout()
-{
-  Document_Glom::type_list_layout_groups result;
-
-  if(m_portal)
-    result.push_back(m_portal);
-  
-  return result;
-}
-
 #ifndef GLOM_ENABLE_CLIENT_ONLY
 Dialog_Layout* Box_Data_List_Related::create_layout_dialog() const
 {

Modified: trunk/glom/mode_data/box_data_list_related.h
==============================================================================
--- trunk/glom/mode_data/box_data_list_related.h	(original)
+++ trunk/glom/mode_data/box_data_list_related.h	Mon Apr 21 17:43:53 2008
@@ -40,17 +40,6 @@
    */
   virtual bool init_db_details(const sharedptr<const LayoutItem_Portal>& portal, bool show_title = true);
 
-  /**
-   * @param foreign_key_value: The value that should be found in this table.
-   * @param from_table_primary_key_value The primary key of the parent record's table, used to associate new related records.
-   */
-  virtual bool refresh_data_from_database_with_foreign_key(const Gnome::Gda::Value& foreign_key_value);
-
-  bool get_has_suitable_record_to_view_details() const;
-  void get_suitable_table_to_view_details(Glib::ustring& table_name, sharedptr<const UsesRelationship>& relationship) const;
-  void get_suitable_record_to_view_details(const Gnome::Gda::Value& primary_key_value, Glib::ustring& table_name, Gnome::Gda::Value& table_primary_key_value) const;
-
-
 protected:
   virtual bool fill_from_database(); //Override.
   virtual type_vecLayoutFields get_fields_to_show() const; //override
@@ -71,9 +60,6 @@
   virtual Dialog_Layout* create_layout_dialog() const; // override.
   virtual void prepare_layout_dialog(Dialog_Layout* dialog); // override.
 #endif // !GLOM_ENABLE_CLIENT_ONLY
-
-protected:
-  virtual Document_Glom::type_list_layout_groups create_layout_get_layout(); //override.
 };
 
 } //namespace Glom

Modified: trunk/glom/mode_data/box_data_portal.cc
==============================================================================
--- trunk/glom/mode_data/box_data_portal.cc	(original)
+++ trunk/glom/mode_data/box_data_portal.cc	Mon Apr 21 17:43:53 2008
@@ -352,17 +352,4 @@
   return result;
 }
 
-#ifndef GLOM_ENABLE_CLIENT_ONLY
-Dialog_Layout* Box_Data_Portal::create_layout_dialog() const
-{
-  //Overridden inderived classes.
-  return 0;
-}
-
-void Box_Data_Portal::prepare_layout_dialog(Dialog_Layout* dialog)
-{
-  //Overridden inderived classes.
-}
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-
 } //namespace Glom

Modified: trunk/glom/mode_data/box_data_portal.h
==============================================================================
--- trunk/glom/mode_data/box_data_portal.h	(original)
+++ trunk/glom/mode_data/box_data_portal.h	Mon Apr 21 17:43:53 2008
@@ -29,7 +29,7 @@
 namespace Glom
 {
 
-/** This is a base class for data widgets that should show multiple related records. 
+/** This is a base class for data widgets that should show multiple related records.
  */
 class Box_Data_Portal : 
   public Box_Data_List,
@@ -43,11 +43,12 @@
    */
   virtual bool init_db_details(const sharedptr<const LayoutItem_Portal>& portal, bool show_title = true);
 
-  /**
+  /** Update a portal if a relevant value in its parent table has changed.
+   *
    * @param foreign_key_value: The value that should be found in this table.
    * @param from_table_primary_key_value The primary key of the parent record's table, used to associate new related records.
    */
-  virtual bool refresh_data_from_database_with_foreign_key(const Gnome::Gda::Value& foreign_key_value);
+  bool refresh_data_from_database_with_foreign_key(const Gnome::Gda::Value& foreign_key_value);
 
   virtual sharedptr<LayoutItem_Portal> get_portal() const;
   virtual sharedptr<const Field> get_key_field() const;
@@ -73,11 +74,6 @@
   virtual void on_dialog_layout_hide(); //override.
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
-#ifndef GLOM_ENABLE_CLIENT_ONLY
-  virtual Dialog_Layout* create_layout_dialog() const; // override.
-  virtual void prepare_layout_dialog(Dialog_Layout* dialog); // override.
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-
 protected:
   virtual Document_Glom::type_list_layout_groups create_layout_get_layout(); //override.
 

Modified: trunk/glom/mode_data/flowtablewithfields.cc
==============================================================================
--- trunk/glom/mode_data/flowtablewithfields.cc	(original)
+++ trunk/glom/mode_data/flowtablewithfields.cc	Mon Apr 21 17:43:53 2008
@@ -120,11 +120,7 @@
     sharedptr<LayoutItem_Portal> portal = sharedptr<LayoutItem_Portal>::cast_dynamic(item);
     if(portal)
     {
-      sharedptr<LayoutItem_CalendarPortal> calendar_portal = sharedptr<LayoutItem_CalendarPortal>::cast_dynamic(portal);
-      if(calendar_portal)
-        add_layout_related_calendar_at_position(calendar_portal, add_before);
-      else
-        add_layout_related_at_position(portal, add_before);
+      add_layout_portal_at_position(portal, add_before);     
     }
     else
     {
@@ -309,19 +305,15 @@
   return 0;
 }
 
-void FlowTableWithFields::add_layout_related_at_position(const sharedptr<LayoutItem_Portal>& portal, const type_list_layoutwidgets::iterator& add_before)
-{
-  Box_Data_List_Related* portal_box = create_related(portal);
-  if(portal_box)
-  {
-    add(*portal_box, true /* expand */);
-    add_layoutwidgetbase(portal_box, add_before);
-  }
-}
-
-void FlowTableWithFields::add_layout_related_calendar_at_position(const sharedptr<LayoutItem_CalendarPortal>& portal, const type_list_layoutwidgets::iterator& add_before)
+void FlowTableWithFields::add_layout_portal_at_position(const sharedptr<LayoutItem_Portal>& portal, const type_list_layoutwidgets::iterator& add_before)
 {
-  Box_Data_Calendar_Related* portal_box = create_related_calendar(portal);
+  Box_Data_Portal* portal_box = 0;
+  sharedptr<LayoutItem_CalendarPortal> calendar_portal = sharedptr<LayoutItem_CalendarPortal>::cast_dynamic(portal);
+  if(calendar_portal)
+    portal_box = create_related_calendar(calendar_portal);
+  else
+    portal_box = create_related(portal);
+  
   if(portal_box)
   {
     add(*portal_box, true /* expand */);
@@ -741,10 +733,10 @@
   }
 
   //Refresh widgets which should show the related records for relationships that use this field:
-  type_list_widgets list_portals = get_portals(field /* from_key field name */);
-  for(type_list_widgets::iterator iter = list_portals.begin(); iter != list_portals.end(); ++iter)
+  type_portals list_portals = get_portals(field /* from_key field name */);
+  for(type_portals::iterator iter = list_portals.begin(); iter != list_portals.end(); ++iter)
   {
-    Box_Data_List_Related* portal = dynamic_cast<Box_Data_List_Related*>(*iter);
+    Box_Data_Portal* portal = *iter;
     if(portal)
     {
       //g_warning("FlowTableWithFields::set_field_value: foreign_key_value=%s", value.to_string().c_str());
@@ -782,9 +774,9 @@
 }
 
 
-FlowTableWithFields::type_list_widgets FlowTableWithFields::get_portals(const sharedptr<const LayoutItem_Field>& from_key)
+FlowTableWithFields::type_portals FlowTableWithFields::get_portals(const sharedptr<const LayoutItem_Field>& from_key)
 {
-  type_list_widgets result;
+  type_portals result;
 
   const Glib::ustring from_key_name = from_key->get_name();
 
@@ -815,7 +807,7 @@
     FlowTableWithFields* subtable = *iter;
     if(subtable)
     {
-      type_list_widgets sub_list = subtable->get_portals(from_key);
+      type_portals sub_list = subtable->get_portals(from_key);
       if(!sub_list.empty())
       {
         //Add to the main result:

Modified: trunk/glom/mode_data/flowtablewithfields.h
==============================================================================
--- trunk/glom/mode_data/flowtablewithfields.h	(original)
+++ trunk/glom/mode_data/flowtablewithfields.h	Mon Apr 21 17:43:53 2008
@@ -138,11 +138,13 @@
   
 protected:
 
-  virtual type_list_widgets get_field(const sharedptr<const LayoutItem_Field>& field);
-  virtual type_list_const_widgets get_field(const sharedptr<const LayoutItem_Field>& field) const;
+  type_list_widgets get_field(const sharedptr<const LayoutItem_Field>& field);
+  type_list_const_widgets get_field(const sharedptr<const LayoutItem_Field>& field) const;
 
-  ///Get portals whose relationships have @a from_key as the from_key.
-  virtual type_list_widgets get_portals(const sharedptr<const LayoutItem_Field>& from_key);
+  typedef std::list< Box_Data_Portal* > type_portals;
+    
+  /// Get portals whose relationships have @a from_key as the from_key.
+  type_portals get_portals(const sharedptr<const LayoutItem_Field>& from_key);
 
   //int get_suitable_width(Field::glom_field_type field_type);
 
@@ -186,7 +188,6 @@
   typedef std::list< FlowTableWithFields* > type_sub_flow_tables;
   type_sub_flow_tables m_sub_flow_tables;
 
-  typedef std::list< Box_Data_Portal* > type_portals;
   type_portals m_portals;
 
   //Remember the sequence of LayoutWidgetBase widgets, so we can iterate over them later:
@@ -204,8 +205,7 @@
   void add_layout_item_at_position(const sharedptr<LayoutItem>& item, const type_list_layoutwidgets::iterator& add_before);
   void add_layout_group_at_position(const sharedptr<LayoutGroup>& group, const type_list_layoutwidgets::iterator& add_before);
   void add_layout_notebook_at_position(const sharedptr<LayoutItem_Notebook>& notebook, const type_list_layoutwidgets::iterator& add_before);
-  void add_layout_related_at_position(const sharedptr<LayoutItem_Portal>& portal, const type_list_layoutwidgets::iterator& add_before);
-  void add_layout_related_calendar_at_position(const sharedptr<LayoutItem_CalendarPortal>& portal, const type_list_layoutwidgets::iterator& add_before);
+  void add_layout_portal_at_position(const sharedptr<LayoutItem_Portal>& portal, const type_list_layoutwidgets::iterator& add_before);
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   virtual void on_dnd_add_placeholder(LayoutWidgetBase* above);



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