[glom] Related Records layout: Field formatting: Choices: Fix related choices.



commit ac1f179f54bdedc1d473c1672b4e74f3c41bd17d
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Dec 3 10:13:32 2009 +0100

    Related Records layout: Field formatting: Choices: Fix related choices.
    
    * glom/mode_design/layout/dialog_layout_details.[h|cc]
    * glom/mode_design/layout/dialog_layout_list_related.[h|cc]:
    Add virtual get_fields_table() and use this in
    on_button_field_formatting() so that the formatting dialog shows
    relationships for the to table instead of the parent table, when
    editing formatting for a field in a related records portal.
    Bug noticed by Michael Hasselmann and Andrew Ruthven.
    * glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.c:
    Removed some debug output.

 ChangeLog                                          |   14 ++++++++++++++
 glom/mode_design/layout/dialog_layout_details.cc   |    8 +++++++-
 glom/mode_design/layout/dialog_layout_details.h    |    7 +++++++
 .../layout/dialog_layout_list_related.cc           |    7 +++++++
 .../layout/dialog_layout_list_related.h            |    3 +++
 .../layout_item_dialogs/dialog_field_layout.cc     |   14 --------------
 6 files changed, 38 insertions(+), 15 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5686b77..f9609bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2009-12-03  Murray Cumming  <murrayc murrayc com>
 
+	Related Records layout: Field formatting: Choices: Fix related choices.
+
+	* glom/mode_design/layout/dialog_layout_details.[h|cc]
+	* glom/mode_design/layout/dialog_layout_list_related.[h|cc]:
+	Add virtual get_fields_table() and use this in 
+	on_button_field_formatting() so that the formatting dialog shows 
+	relationships for the to table instead of the parent table, when 
+	editing formatting for a field in a related records portal.
+	Bug noticed by Michael Hasselmann and Andrew Ruthven.
+	* glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.c:
+	Removed some debug output.
+
+2009-12-03  Murray Cumming  <murrayc murrayc com>
+
 	Allow use of example documents that mention an unsupported backend.
 
 	* glom/application.cc: check_document_hosting_mode_is_supported():
diff --git a/glom/mode_design/layout/dialog_layout_details.cc b/glom/mode_design/layout/dialog_layout_details.cc
index f2813bc..0da1b69 100644
--- a/glom/mode_design/layout/dialog_layout_details.cc
+++ b/glom/mode_design/layout/dialog_layout_details.cc
@@ -944,7 +944,7 @@ void Dialog_Layout_Details::on_button_field_formatting()
       sharedptr<LayoutItem_Field> field = sharedptr<LayoutItem_Field>::cast_dynamic(layout_item);
       if(field)
       {
-        sharedptr<LayoutItem_Field> chosenitem = offer_field_formatting(field, m_table_name, this);
+        sharedptr<LayoutItem_Field> chosenitem = offer_field_formatting(field, get_fields_table(), this);
         if(chosenitem)
         {
           *field = *chosenitem; //TODO_Performance.
@@ -1428,6 +1428,12 @@ void Dialog_Layout_Details::on_treeview_cell_edited_group_columns(const Glib::us
   }
 }
 
+
+Glib::ustring Dialog_Layout_Details::get_fields_table() const
+{
+  return m_table_name;
+}
+
 } //namespace Glom
 
 
diff --git a/glom/mode_design/layout/dialog_layout_details.h b/glom/mode_design/layout/dialog_layout_details.h
index 5c2f076..2515572 100644
--- a/glom/mode_design/layout/dialog_layout_details.h
+++ b/glom/mode_design/layout/dialog_layout_details.h
@@ -58,6 +58,13 @@ protected:
   Gtk::TreeModel::iterator get_selected_group_parent() const;
   sharedptr<LayoutItem_Button> offer_button_script_edit(const sharedptr<const LayoutItem_Button>& button);
 
+  /** Get the table that the fields belong to.
+   * This is usually the regular table name (m_table_name),
+   * but for related records portals (Dialog_Layout_List_Related),
+   * it's the to table of the relationship.
+   */
+  virtual Glib::ustring get_fields_table() const;
+
   //signal handlers:
   void on_button_up();
   void on_button_down();
diff --git a/glom/mode_design/layout/dialog_layout_list_related.cc b/glom/mode_design/layout/dialog_layout_list_related.cc
index 8027ad2..e968cc3 100644
--- a/glom/mode_design/layout/dialog_layout_list_related.cc
+++ b/glom/mode_design/layout/dialog_layout_list_related.cc
@@ -478,6 +478,13 @@ void Dialog_Layout_List_Related::on_button_edit()
   }
 }
 
+Glib::ustring Dialog_Layout_List_Related::get_fields_table() const
+{
+  if(!m_portal)
+    return Glib::ustring();
+
+  return m_portal->get_table_used(m_table_name);
+}
 
 } //namespace Glom
 
diff --git a/glom/mode_design/layout/dialog_layout_list_related.h b/glom/mode_design/layout/dialog_layout_list_related.h
index 50ba563..21c883f 100644
--- a/glom/mode_design/layout/dialog_layout_list_related.h
+++ b/glom/mode_design/layout/dialog_layout_list_related.h
@@ -51,6 +51,9 @@ protected:
 
   virtual void save_to_document();
 
+  ///@inheritdoc
+  virtual Glib::ustring get_fields_table() const;
+
   //signal handlers:
   virtual void on_button_add_field(); //override
   virtual void on_button_edit(); //override
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.cc b/glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.cc
index 353db83..bd2ee16 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.cc
@@ -115,12 +115,6 @@ void Dialog_FieldLayout::set_field(const sharedptr<const LayoutItem_Field>& fiel
 
 sharedptr<LayoutItem_Field> Dialog_FieldLayout::get_field_chosen() const
 {
-    double x = 0;
-    double y = 0;
-    double width, height;
-    m_layout_item->get_print_layout_position(x, y, width, height);
-    std::cout << "DEBUGDialog_FieldLayout::get_field_chosen1(): m_layout_item: x=" << x << std::endl;
-
   m_layout_item->set_editable( m_checkbutton_editable->get_active() );
 
   m_layout_item->set_formatting_use_default( !m_radiobutton_custom_formatting->get_active() );
@@ -132,14 +126,6 @@ sharedptr<LayoutItem_Field> Dialog_FieldLayout::get_field_chosen() const
 
   m_layout_item->set_title_custom(title_custom);
 
-  {
-    double x = 0;
-    double y = 0;
-    double width, height;
-    m_layout_item->get_print_layout_position(x, y, width, height);
-    std::cout << "DEBUGDialog_FieldLayout::get_field_chosen2(): m_layout_item: x=" << x << std::endl;
-  }
-
   return glom_sharedptr_clone(m_layout_item);
 }
 



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