[glom/glom-1-18] libglom::LayoutItem_Portal: Added get_suitable_table_to_view_details().



commit d79eb9b7bfe7ff33f5de5060ce61d0b20a37bfa5
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Sep 27 12:49:32 2011 +0200

    libglom::LayoutItem_Portal: Added get_suitable_table_to_view_details().
    
    	* glom/base_db.[h|cc]: Move the get_portal_navigation_relationship_automatic()
    	and get_suitable_table_to_view_details() utility functions to:
    	* glom/libglom/data_structure/layout/layoutitem_portal.[h|cc]: Also
    	move other privately-used utility functions here too, from Base_DB.
    	* glom/mode_design/layout/dialog_layout_calendar_related.cc: update_ui():
    	* glom/mode_design/layout/dialog_layout_list_related.cc: update_ui():
    	* glom/mode_data/box_data_portal.cc:
      get_has_suitable_record_to_view_details(),
      get_has_suitable_record_to_view_details(): Adapted.

 ChangeLog                                          |   14 ++
 glom/base_db.cc                                    |  120 -------------
 glom/base_db.h                                     |    8 -
 .../data_structure/layout/layoutitem_portal.cc     |  187 ++++++++++++++++++++
 .../data_structure/layout/layoutitem_portal.h      |   20 ++
 glom/mode_data/box_data_portal.cc                  |   71 ++------
 glom/mode_data/box_data_portal.h                   |    9 +-
 .../layout/dialog_layout_calendar_related.cc       |   13 +-
 .../layout/dialog_layout_list_related.cc           |   13 +-
 9 files changed, 252 insertions(+), 203 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0e5e06e..85f311a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2011-09-27  Murray Cumming  <murrayc murrayc com>>
+
+  libglom::LayoutItem_Portal: Added get_suitable_table_to_view_details().
+
+	* glom/base_db.[h|cc]: Move the get_portal_navigation_relationship_automatic()
+	and get_suitable_table_to_view_details() utility functions to: 
+	* glom/libglom/data_structure/layout/layoutitem_portal.[h|cc]: Also
+	move other privately-used utility functions here too, from Base_DB.
+	* glom/mode_design/layout/dialog_layout_calendar_related.cc: update_ui():
+	* glom/mode_design/layout/dialog_layout_list_related.cc: update_ui():
+	* glom/mode_data/box_data_portal.cc: 
+  get_has_suitable_record_to_view_details(), 
+  get_has_suitable_record_to_view_details(): Adapted.
+
 2011-09-27  Murray Cumming  <murrayc murrayc com>
 
 	libglom::layout_field_should_have_navigation(): Return Relationship not bool.
diff --git a/glom/base_db.cc b/glom/base_db.cc
index cd3231e..d5f5f6f 100644
--- a/glom/base_db.cc
+++ b/glom/base_db.cc
@@ -1715,126 +1715,6 @@ bool Base_DB::get_relationship_exists(const Glib::ustring& table_name, const Gli
   return false;
 }
 
-sharedptr<const LayoutItem_Field> Base_DB::get_field_is_from_non_hidden_related_record(const sharedptr<const LayoutItem_Portal>& portal) const
-{
-  //Find the first field that is from a non-hidden related table.
-  sharedptr<LayoutItem_Field> result;
-
-  if(!portal)
-    return result;
-
-  const Document* document = get_document();
-  if(!document)
-    return result;
-
-  const Glib::ustring parent_table_name = portal->get_table_used(Glib::ustring() /* parent table - not relevant */);
-
-  LayoutItem_Portal::type_list_const_items items = portal->get_items();
-  for(LayoutItem_Portal::type_list_const_items::const_iterator iter = items.begin(); iter != items.end(); ++iter)
-  {
-    sharedptr<const LayoutItem_Field> field = sharedptr<const LayoutItem_Field>::cast_dynamic(*iter);
-    if(field)
-    {
-      if(field->get_has_relationship_name())
-      {
-        const Glib::ustring table_name = field->get_table_used(parent_table_name);
-        if(!(document->get_table_is_hidden(table_name)))
-          return field;
-      }
-
-    }
-  }
-
-  return result;
-}
-
-sharedptr<const LayoutItem_Field> Base_DB::get_field_identifies_non_hidden_related_record(const sharedptr<const LayoutItem_Portal>& portal, sharedptr<const Relationship>& used_in_relationship) const
-{
-  //Find the first field that is from a non-hidden related table.
-  sharedptr<LayoutItem_Field> result;
-
-  const Document* document = get_document();
-  if(!document)
-    return result;
-
-  const Glib::ustring parent_table_name = portal->get_table_used(Glib::ustring() /* parent table - not relevant */);
-
-  LayoutItem_Portal::type_list_const_items items = portal->get_items();
-  for(LayoutItem_Portal::type_list_const_items::const_iterator iter = items.begin(); iter != items.end(); ++iter)
-  {
-    sharedptr<const LayoutItem_Field> field = sharedptr<const LayoutItem_Field>::cast_dynamic(*iter);
-    if(field && !(field->get_has_relationship_name()))
-    {
-      sharedptr<const Relationship> relationship = document->get_field_used_in_relationship_to_one(parent_table_name, field);
-      if(relationship)
-      {
-        const Glib::ustring table_name = relationship->get_to_table();
-        if(!(table_name.empty()))
-        {
-          if(!(document->get_table_is_hidden(table_name)))
-          {
-            used_in_relationship = relationship;
-            return field;
-          }
-        }
-      }
-    }
-  }
-
-  return result;
-}
-
-sharedptr<const UsesRelationship> Base_DB::get_portal_navigation_relationship_automatic(const sharedptr<LayoutItem_Portal>& portal, bool& navigation_main) const
-{
-  //Initialize output parameters:
-  navigation_main = false;
-
-  const Document* document = get_document();
-
-  //If the related table is not hidden then we can just navigate to that:
-  const Glib::ustring direct_related_table_name = portal->get_table_used(Glib::ustring() /* parent table - not relevant */);
-  if(!(document->get_table_is_hidden(direct_related_table_name)))
-  {
-    //Non-hidden tables can just be shown directly. Navigate to it:
-    navigation_main = true;
-    return sharedptr<UsesRelationship>();
-  }
-  else
-  {
-    //If the related table is hidden,
-    //then find a suitable related non-hidden table by finding the first layout field that mentions one:
-    sharedptr<const LayoutItem_Field> field = get_field_is_from_non_hidden_related_record(portal);
-    if(field)
-    {
-      return field; //Returns the relationship part. (A relationship belonging to the portal's related table.)
-      //sharedptr<UsesRelationship> result = sharedptr<UsesRelationship>::create();
-      //result->set_relationship( portal->get_relationship() );
-      //result->set_related_relationship( field->get_relationship() );
-
-      //return result;
-    }
-    else
-    {
-      //Instead, find a key field that's used in a relationship,
-      //and pretend that we are showing the to field as a related field:
-      sharedptr<const Relationship> used_in_relationship;
-      sharedptr<const LayoutItem_Field> field_identifies = get_field_identifies_non_hidden_related_record(portal, used_in_relationship);
-      if(field_identifies)
-      {
-        sharedptr<UsesRelationship> result = sharedptr<UsesRelationship>::create();
-
-        sharedptr<Relationship> rel_nonconst = sharedptr<Relationship>::cast_const(used_in_relationship);
-        result->set_relationship(rel_nonconst);
-
-        return result;
-      }
-    }
-  }
-
-  //There was no suitable related table to show:
-  return sharedptr<UsesRelationship>();
-}
-
 bool Base_DB::get_primary_key_is_in_foundset(const FoundSet& found_set, const Gnome::Gda::Value& primary_key_value)
 {
   //TODO_Performance: This is probably called too often, when we should know that the key is in the found set.
diff --git a/glom/base_db.h b/glom/base_db.h
index 38e54e3..04103b0 100644
--- a/glom/base_db.h
+++ b/glom/base_db.h
@@ -309,14 +309,6 @@ protected:
   type_vecLayoutFields get_table_fields_to_show_for_sequence(const Glib::ustring& table_name, const Document::type_list_layout_groups& mapGroupSequence) const;
   void get_table_fields_to_show_for_sequence_add_group(const Glib::ustring& table_name, const Privileges& table_privs, const type_vec_fields& all_db_fields, const sharedptr<LayoutGroup>& group, type_vecLayoutFields& vecFields) const;
 
-  /** Get the relationship into which the row button should navigate,
-   * or the relationship itself, if the navigation_main output parameter is set to true after calling this method.
-   * (If that should be chosen automatically, by looking at the fields in the portal.)
-   */
-  sharedptr<const UsesRelationship> get_portal_navigation_relationship_automatic(const sharedptr<LayoutItem_Portal>& portal, bool& navigation_main) const;
-  sharedptr<const LayoutItem_Field> get_field_is_from_non_hidden_related_record(const sharedptr<const LayoutItem_Portal>& portal) const;
-  sharedptr<const LayoutItem_Field> get_field_identifies_non_hidden_related_record(const sharedptr<const LayoutItem_Portal>& portal, sharedptr<const Relationship>& used_in_relationship) const;
-
   bool get_primary_key_is_in_foundset(const FoundSet& found_set, const Gnome::Gda::Value& primary_key_value);
 
 
diff --git a/glom/libglom/data_structure/layout/layoutitem_portal.cc b/glom/libglom/data_structure/layout/layoutitem_portal.cc
index e33b1cc..8597b3b 100644
--- a/glom/libglom/data_structure/layout/layoutitem_portal.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_portal.cc
@@ -19,6 +19,8 @@
  */
 
 #include <libglom/data_structure/layout/layoutitem_portal.h>
+#include <libglom/document/document.h> //For the utility functions.
+#include <iostream>
 #include <glibmm/i18n.h>
 
 namespace Glom
@@ -171,4 +173,189 @@ void LayoutItem_Portal::debug(guint level) const
 }
 */
 
+void LayoutItem_Portal::get_suitable_table_to_view_details(Glib::ustring& table_name, sharedptr<const UsesRelationship>& relationship, const Document* document) const
+{
+  //Initialize output parameters:
+  table_name = Glib::ustring();
+
+  sharedptr<const UsesRelationship> navigation_relationship;
+
+  //Check whether a relationship was specified:
+  if(get_navigation_type() == LayoutItem_Portal::NAVIGATION_AUTOMATIC)
+  {
+    //std::cout << "debug: decide automatically." << std::endl;
+    //Decide automatically:
+    navigation_relationship = get_portal_navigation_relationship_automatic(document);
+    //if(navigation_relationship && navigation_relationship->get_relationship())
+    //  std::cout << "  navigation_relationship->get_relationship()=" <<  navigation_relationship->get_relationship()->get_name() << std::endl;
+    //if(navigation_relationship && navigation_relationship->get_related_relationship())
+    //  std::cout << "  navigation_relationship->get_related_relationship()=" <<  navigation_relationship->get_related_relationship()->get_name() << std::endl;
+  }
+  else
+  {
+    navigation_relationship = get_navigation_relationship_specific();
+    //std::cout << "debug: " << G_STRFUNC << ": Using specific nav." << std::endl;
+  }
+
+
+  //Get the navigation table name from the chosen relationship:
+  const Glib::ustring directly_related_table_name = get_table_used(Glib::ustring() /* not relevant */);
+
+  // The navigation_table_name (and therefore, the table_name output parameter,
+  // as well) stays empty if the navrel type was set to none.
+  Glib::ustring navigation_table_name;
+  if(navigation_relationship)
+  {
+    navigation_table_name = navigation_relationship->get_table_used(directly_related_table_name);
+  }
+  else if(get_navigation_type() != LayoutItem_Portal::NAVIGATION_NONE)
+  {
+    //An empty result from get_portal_navigation_relationship_automatic() or 
+    //get_navigation_relationship_specific() means we should use the directly related table:
+    navigation_table_name = directly_related_table_name;
+  }
+
+  if(navigation_table_name.empty())
+  {
+    //std::cerr << G_STRFUNC << ": navigation_table_name is empty." << std::endl;
+    return;
+  }
+  
+  if(!document)
+  {
+    std::cerr << G_STRFUNC << ": document is null" << std::endl;
+    return;
+  }
+  
+  if(document->get_table_is_hidden(navigation_table_name))
+  {
+    std::cerr << G_STRFUNC << ": navigation_table_name indicates a hidden table: " << navigation_table_name << std::endl;
+    return;
+  }
+
+  table_name = navigation_table_name;
+  relationship = navigation_relationship;
+}
+
+sharedptr<const UsesRelationship> LayoutItem_Portal::get_portal_navigation_relationship_automatic(const Document* document) const
+{
+  if(!document)
+  {
+    std::cerr << G_STRFUNC << ": document was null" << std::endl;
+    return sharedptr<const UsesRelationship>();
+  }
+
+  //If the related table is not hidden then we can just navigate to that:
+  const Glib::ustring direct_related_table_name = get_table_used(Glib::ustring() /* parent table - not relevant */);
+  if(!(document->get_table_is_hidden(direct_related_table_name)))
+  {
+    //Non-hidden tables can just be shown directly. Navigate to it:
+    return sharedptr<const UsesRelationship>();
+  }
+  else
+  {
+    //If the related table is hidden,
+    //then find a suitable related non-hidden table by finding the first layout field that mentions one:
+    sharedptr<const LayoutItem_Field> field = get_field_is_from_non_hidden_related_record(document);
+    if(field)
+    {
+      return field; //Returns the UsesRelationship base part. (A relationship belonging to the portal's related table.)
+      //sharedptr<UsesRelationship> result = sharedptr<UsesRelationship>::create();
+      //result->set_relationship( get_relationship() );
+      //result->set_related_relationship( field->get_relationship() );
+
+      //return result;
+    }
+    else
+    {
+      //Instead, find a key field that's used in a relationship,
+      //and pretend that we are showing the to field as a related field:
+      sharedptr<const Relationship> used_in_relationship;
+      sharedptr<const LayoutItem_Field> field_identifies = get_field_identifies_non_hidden_related_record(used_in_relationship, document);
+      if(field_identifies)
+      {
+        sharedptr<UsesRelationship> result = sharedptr<UsesRelationship>::create();
+
+        sharedptr<Relationship> rel_nonconst = sharedptr<Relationship>::cast_const(used_in_relationship);
+        result->set_relationship(rel_nonconst);
+
+        return result;
+      }
+    }
+  }
+
+  //There was no suitable related table to show:
+  return sharedptr<const UsesRelationship>();
+}
+
+sharedptr<const LayoutItem_Field> LayoutItem_Portal::get_field_is_from_non_hidden_related_record(const Document* document) const
+{
+  //Find the first field that is from a non-hidden related table.
+  sharedptr<LayoutItem_Field> result;
+
+  if(!document)
+  {
+    std::cerr << G_STRFUNC << ": document is null" << std::endl;
+    return result;
+  }
+  
+  const Glib::ustring parent_table_name = get_table_used(Glib::ustring() /* parent table - not relevant */);
+
+  LayoutItem_Portal::type_list_const_items items = get_items();
+  for(LayoutItem_Portal::type_list_const_items::const_iterator iter = items.begin(); iter != items.end(); ++iter)
+  {
+    sharedptr<const LayoutItem_Field> field = sharedptr<const LayoutItem_Field>::cast_dynamic(*iter);
+    if(field)
+    {
+      if(field->get_has_relationship_name())
+      {
+        const Glib::ustring table_name = field->get_table_used(parent_table_name);
+        if(!(document->get_table_is_hidden(table_name)))
+          return field;
+      }
+
+    }
+  }
+
+  return result;
+}
+
+sharedptr<const LayoutItem_Field> LayoutItem_Portal::get_field_identifies_non_hidden_related_record(sharedptr<const Relationship>& used_in_relationship, const Document* document) const
+{
+  //Find the first field that is from a non-hidden related table.
+  sharedptr<LayoutItem_Field> result;
+
+  if(!document)
+  {
+    std::cerr << G_STRFUNC << ": document is null" << std::endl;
+    return result;
+  }
+
+  const Glib::ustring parent_table_name = get_table_used(Glib::ustring() /* parent table - not relevant */);
+
+  LayoutItem_Portal::type_list_const_items items = get_items();
+  for(LayoutItem_Portal::type_list_const_items::const_iterator iter = items.begin(); iter != items.end(); ++iter)
+  {
+    sharedptr<const LayoutItem_Field> field = sharedptr<const LayoutItem_Field>::cast_dynamic(*iter);
+    if(field && !(field->get_has_relationship_name()))
+    {
+      sharedptr<const Relationship> relationship = document->get_field_used_in_relationship_to_one(parent_table_name, field);
+      if(relationship)
+      {
+        const Glib::ustring table_name = relationship->get_to_table();
+        if(!(table_name.empty()))
+        {
+          if(!(document->get_table_is_hidden(table_name)))
+          {
+            used_in_relationship = relationship;
+            return field;
+          }
+        }
+      }
+    }
+  }
+
+  return result;
+}
+
 } //namespace Glom
diff --git a/glom/libglom/data_structure/layout/layoutitem_portal.h b/glom/libglom/data_structure/layout/layoutitem_portal.h
index 962a1d8..23b81e4 100644
--- a/glom/libglom/data_structure/layout/layoutitem_portal.h
+++ b/glom/libglom/data_structure/layout/layoutitem_portal.h
@@ -29,6 +29,8 @@
 namespace Glom
 {
 
+class Document; //For the utility functions.
+
 class LayoutItem_Portal
 : public LayoutGroup,
   public UsesRelationship
@@ -91,7 +93,21 @@ public:
    * activates a related record row.
    */
   void set_navigation_type(navigation_type type);
+  
+  /** Discover what table to show when clicking on a related record.
+   * This table will not necessarily just be the directly related table.
+   * The caller should check, in the document, that the returned @a table_name is not hidden.
+   *
+   * @param table_name The table that should be shown.
+   * @param relationship The relationship in the directly related table that should be used to get to that table. If this is empty then we should just show the table directly.
+   */
+  void get_suitable_table_to_view_details(Glib::ustring& table_name, sharedptr<const UsesRelationship>& relationship, const Document* document) const;
 
+  /** Get the relationship (from the related table) into which the row button should navigate,
+   * or none if it should use the portal's directly related table itself.
+   * (If that should be chosen automatically, by looking at the fields in the portal.)
+   */
+  sharedptr<const UsesRelationship> get_portal_navigation_relationship_automatic(const Document* document) const;
 
   /// This is used only for the print layouts.
   double get_print_layout_row_height() const;
@@ -102,6 +118,10 @@ public:
 
 private:
 
+  sharedptr<const LayoutItem_Field> get_field_is_from_non_hidden_related_record(const Document* document) const;
+  sharedptr<const LayoutItem_Field> get_field_identifies_non_hidden_related_record(sharedptr<const Relationship>& used_in_relationship, const Document* document) const;
+
+
   sharedptr<UsesRelationship> m_navigation_relationship_specific;
 
   // This is used only for the print layouts.
diff --git a/glom/mode_data/box_data_portal.cc b/glom/mode_data/box_data_portal.cc
index 12c8cc6..217ad95 100644
--- a/glom/mode_data/box_data_portal.cc
+++ b/glom/mode_data/box_data_portal.cc
@@ -412,81 +412,36 @@ void Box_Data_Portal::on_dialog_layout_hide()
 
 bool Box_Data_Portal::get_has_suitable_record_to_view_details() const
 {
+  if(!m_portal)
+    return false;
+
+  const Document* document = get_document();
+  if(!document)
+    return false;
+    
   Glib::ustring navigation_table_name;
-  sharedptr<const UsesRelationship> navigation_relationship;
-  get_suitable_table_to_view_details(navigation_table_name, navigation_relationship);
+  sharedptr<const UsesRelationship> navigation_relationship; //Ignored.
+  m_portal->get_suitable_table_to_view_details(navigation_table_name, navigation_relationship, document);
 
   return !(navigation_table_name.empty());
 }
 
-void Box_Data_Portal::get_suitable_table_to_view_details(Glib::ustring& table_name, sharedptr<const UsesRelationship>& relationship) const
+void Box_Data_Portal::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();
 
   if(!m_portal)
     return;
 
-
-  sharedptr<const UsesRelationship> navigation_relationship = m_portal->get_navigation_relationship_specific();
-
-  //Check whether a relationship was specified:
-  if(m_portal->get_navigation_type() == LayoutItem_Portal::NAVIGATION_AUTOMATIC)
-  {
-    //std::cout << "debug: decide automatically." << std::endl;
-    //Decide automatically:
-    bool navigation_relationship_main = false; // no longer used
-    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* 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 */);
-
-  // The navigation_table_name (and therefore, the table_name output parameter,
-  // as well) stays empty if the navrel type was set to none.
-  Glib::ustring navigation_table_name;
-  if(m_portal->get_navigation_type() == LayoutItem_Portal::NAVIGATION_AUTOMATIC)
-  {
-    navigation_table_name = directly_related_table_name;
-  }
-  else if(m_portal->get_navigation_type() == LayoutItem_Portal::NAVIGATION_SPECIFIC)
-  {
-    navigation_table_name = navigation_relationship->get_table_used(directly_related_table_name);
-  }
-
-  if(navigation_table_name.empty())
-  {
-    //std::cerr << "Box_Data_Portal::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_Portal::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_Portal::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);
+  m_portal->get_suitable_table_to_view_details(navigation_table_name, navigation_relationship, document);
 
   if(navigation_table_name.empty())
     return;
diff --git a/glom/mode_data/box_data_portal.h b/glom/mode_data/box_data_portal.h
index 13e0421..823dd86 100644
--- a/glom/mode_data/box_data_portal.h
+++ b/glom/mode_data/box_data_portal.h
@@ -77,7 +77,14 @@ public:
   type_signal_portal_record_changed signal_portal_record_changed();
     
   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;
+
+  /** Discover what record to show, in what table, when clicking on a related record.
+   * This record will not necessarily just be the directly related record.
+   *
+   * @param primary_key_value Identifies the related record that has been clicked.
+   * @param table_name The table that should be shown.
+   * @param table_primary_key_value Identifies the record in that table that should be shown.
+   */
   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:
diff --git a/glom/mode_design/layout/dialog_layout_calendar_related.cc b/glom/mode_design/layout/dialog_layout_calendar_related.cc
index c8bd539..bdfbf25 100644
--- a/glom/mode_design/layout/dialog_layout_calendar_related.cc
+++ b/glom/mode_design/layout/dialog_layout_calendar_related.cc
@@ -225,14 +225,11 @@ void Dialog_Layout_Calendar_Related::update_ui(bool including_relationship_list)
 
 
   //Describe the automatic navigation:
-  sharedptr<const UsesRelationship> relationship_navigation_automatic;
-  bool navigation_automatic_main = false;
-  relationship_navigation_automatic = get_portal_navigation_relationship_automatic(m_portal, navigation_automatic_main);
-  Glib::ustring automatic_navigation_description;
-
-  if(navigation_automatic_main)
-    automatic_navigation_description = m_portal->get_relationship_name_used();
-  else if(relationship_navigation_automatic)
+  sharedptr<const UsesRelationship> relationship_navigation_automatic
+    = m_portal->get_portal_navigation_relationship_automatic(document);
+  Glib::ustring automatic_navigation_description = 
+    m_portal->get_relationship_name_used(); //TODO: Use get_relationship_display_name() instead?
+  if(relationship_navigation_automatic) //This is a relationship in the related table.
   {
     automatic_navigation_description = m_portal->get_relationship_name_used();
 
diff --git a/glom/mode_design/layout/dialog_layout_list_related.cc b/glom/mode_design/layout/dialog_layout_list_related.cc
index c30380f..9dab60b 100644
--- a/glom/mode_design/layout/dialog_layout_list_related.cc
+++ b/glom/mode_design/layout/dialog_layout_list_related.cc
@@ -229,14 +229,11 @@ void Dialog_Layout_List_Related::update_ui(bool including_relationship_list)
   }
 
   //Describe the automatic navigation:
-  sharedptr<const UsesRelationship> relationship_navigation_automatic;
-  bool navigation_automatic_main = false;
-  relationship_navigation_automatic = get_portal_navigation_relationship_automatic(m_portal, navigation_automatic_main);
-  Glib::ustring automatic_navigation_description;
-  
-  if(navigation_automatic_main)
-    automatic_navigation_description = m_portal->get_relationship_name_used();
-  else if(relationship_navigation_automatic)
+  sharedptr<const UsesRelationship> relationship_navigation_automatic = 
+    m_portal->get_portal_navigation_relationship_automatic(document);
+  Glib::ustring automatic_navigation_description = 
+    m_portal->get_relationship_name_used(); //TODO: Use get_relationship_display_name() instead?
+  if(relationship_navigation_automatic) //This is a relationship in the related table.
   {
     automatic_navigation_description = m_portal->get_relationship_name_used();
 



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