[glom] Document::fill_layout_field_details(): Handle related choices sort fields.



commit 1d9ac8213803bb225882009ecd75811d48fc5e5d
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Dec 29 21:49:03 2011 +0100

    Document::fill_layout_field_details(): Handle related choices sort fields.
    
    * glom/libglom/document/document.[h|cc]: fill_layout_field_details():
    Also fill the details of the sort fields for related choices, dealing
    with those TODO comments.

 ChangeLog                         |    8 ++++++++
 glom/libglom/document/document.cc |   19 +++++++++++++++++--
 glom/libglom/document/document.h  |    4 ++--
 3 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index fa5d0e6..16aa23d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2011-12-29  Murray Cumming  <murrayc murrayc com>
 
+	Document::fill_layout_field_details(): Handle related choices sort fields.
+
+	* glom/libglom/document/document.[h|cc]: fill_layout_field_details():
+	Also fill the details of the sort fields for related choices, dealing 
+	with those TODO comments.
+
+2011-12-29  Murray Cumming  <murrayc murrayc com>
+
 	Related Choices: Allow the user to specify a sort order.
 
 	* glom/libglom/data_structure/layout/fieldformatting.[h|cc]:
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index d520f29..14c7656 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -1437,6 +1437,21 @@ void Document::set_tables(const type_listTableInfo& tables)
     set_modified();
 }
 
+void Document::fill_sort_field_details(const Glib::ustring& parent_table_name, FieldFormatting::type_list_sort_fields& sort_fields) const
+{
+  for(FieldFormatting::type_list_sort_fields::iterator iter = sort_fields.begin(); iter != sort_fields.end(); ++iter)
+  {
+    sharedptr<const LayoutItem_Field> sort_field = iter->first;
+    if(!sort_field)
+     continue;
+ 
+    //TODO: Avoid this unconst?
+    sharedptr<LayoutItem_Field> unconst_sort_field = sharedptr<LayoutItem_Field>::cast_const(sort_field);
+    sharedptr<Field> field = get_field( sort_field->get_table_used(parent_table_name), sort_field->get_name() );
+    unconst_sort_field->set_full_field_details(field);
+  }
+}
+
 void Document::fill_layout_field_details(const Glib::ustring& parent_table_name, const sharedptr<LayoutGroup>& layout_group) const
 {
   if(!layout_group)
@@ -1465,7 +1480,7 @@ void Document::fill_layout_field_details(const Glib::ustring& parent_table_name,
         choice_layout_first->set_full_field_details( get_field(table_name, choice_layout_first->get_name()) );
       fill_layout_field_details(parent_table_name, choice_extra_layouts); //recurse
 
-      //TODO: Handle choice_sort_fields.
+      fill_sort_field_details(table_name, choice_sort_fields);
     }
 
     sharedptr<LayoutItem_Field> layout_field = sharedptr<LayoutItem_Field>::cast_dynamic(layout_item);
@@ -1488,7 +1503,7 @@ void Document::fill_layout_field_details(const Glib::ustring& parent_table_name,
           choice_layout_first->set_full_field_details( get_field(table_name, choice_layout_first->get_name()) );
         fill_layout_field_details(parent_table_name, choice_extra_layouts); //recurse
 
-        //TODO: Handle choice_sort_fields.
+        fill_sort_field_details(table_name, choice_sort_fields);
       }
     }
     else
diff --git a/glom/libglom/document/document.h b/glom/libglom/document/document.h
index 117f7f1..35d76d8 100644
--- a/glom/libglom/document/document.h
+++ b/glom/libglom/document/document.h
@@ -264,8 +264,6 @@ public:
   void fill_layout_field_details(const Glib::ustring& parent_table_name, const sharedptr<LayoutGroup>& layout_group) const;
   void fill_layout_field_details(const Glib::ustring& parent_table_name, type_list_layout_groups& groups) const;
 
-
-
   ///When a field name is changed, change it in the relationships, layouts, reports, and fields data:
   void change_field_name(const Glib::ustring& table_name, const Glib::ustring& strFieldNameOld, const Glib::ustring& strFieldNameNew);
 
@@ -518,6 +516,8 @@ private:
 
   void fill_translatable_layout_items(const sharedptr<LayoutGroup>& group, type_list_translatables& the_list);
 
+  void fill_sort_field_details(const Glib::ustring& parent_table_name, FieldFormatting::type_list_sort_fields& sort_fields) const;
+
 
   /// If the attribute is not there, then the default will be returned.
   static bool get_node_attribute_value_as_bool(const xmlpp::Element* node, const Glib::ustring& strAttributeName, bool value_default = false);



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