[glom] LayoutItem_GroupBy: Add get and set methods for members.



commit 6aa8bb2b65f3ff562541d09df7311c09bc417e7e
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Mar 12 11:37:39 2012 +0100

    LayoutItem_GroupBy: Add get and set methods for members.
    
    * glom/libglom/data_structure/layout/report_parts/layoutitem_groupby.[h|cc]:
    Make the members private, adding getters. With smartpointers, the direct
    access is not necessary for performance.
    * glom/libglom/document/document.cc:
    * glom/libglom/report_builder.cc:
    * glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc: Adapted.

 ChangeLog                                          |   11 +++++++++
 .../layout/report_parts/layoutitem_groupby.cc      |   24 ++++++++++++++++++-
 .../layout/report_parts/layoutitem_groupby.h       |   16 +++++++++----
 glom/libglom/document/document.cc                  |   10 ++++----
 glom/libglom/report_builder.cc                     |    4 +-
 .../layout/layout_item_dialogs/dialog_group_by.cc  |    8 +++---
 6 files changed, 55 insertions(+), 18 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9448dd5..1a7e2ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2012-03-12  Murray Cumming  <murrayc murrayc com>
 
+	LayoutItem_GroupBy: Add get and set methods for members.
+
+	* glom/libglom/data_structure/layout/report_parts/layoutitem_groupby.[h|cc]: 
+	Make the members private, adding getters. With smartpointers, the direct 
+	access is not necessary for performance.
+	* glom/libglom/document/document.cc:
+	* glom/libglom/report_builder.cc:
+	* glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc: Adapted.
+
+2012-03-12  Murray Cumming  <murrayc murrayc com>
+
 	libglom: LayoutGroup: Remove deprecated remove_field() and has_field().
 
 	* glom/libglom/data_structure/layout/layoutgroup.[h|cc]: Remove 
diff --git a/glom/libglom/data_structure/layout/report_parts/layoutitem_groupby.cc b/glom/libglom/data_structure/layout/report_parts/layoutitem_groupby.cc
index 7511cf7..aaa6297 100644
--- a/glom/libglom/data_structure/layout/report_parts/layoutitem_groupby.cc
+++ b/glom/libglom/data_structure/layout/report_parts/layoutitem_groupby.cc
@@ -32,9 +32,9 @@ LayoutItem_GroupBy::LayoutItem_GroupBy()
 
 LayoutItem_GroupBy::LayoutItem_GroupBy(const LayoutItem_GroupBy& src)
 : LayoutGroup(src),
+  m_field_group_by(src.m_field_group_by),
   m_group_secondary_fields(src.m_group_secondary_fields),
-  m_fields_sort_by(src.m_fields_sort_by),
-  m_field_group_by(src.m_field_group_by)
+  m_fields_sort_by(src.m_fields_sort_by)
 {
 }
 
@@ -147,5 +147,25 @@ Glib::ustring LayoutItem_GroupBy::get_report_part_id() const
   return "group_by";
 }
 
+sharedptr<LayoutGroup> LayoutItem_GroupBy::get_secondary_fields()
+{
+  return m_group_secondary_fields;
+}
+
+sharedptr<const LayoutGroup> LayoutItem_GroupBy::get_secondary_fields() const
+{
+  return m_group_secondary_fields;
+}
+
+LayoutItem_GroupBy::type_list_sort_fields LayoutItem_GroupBy::get_sort_by() const
+{
+  return m_fields_sort_by;
+}
+
+void LayoutItem_GroupBy::set_sort_by(const type_list_sort_fields& sort_by)
+{
+  m_fields_sort_by = sort_by;
+}
+
 } //namespace Glom
 
diff --git a/glom/libglom/data_structure/layout/report_parts/layoutitem_groupby.h b/glom/libglom/data_structure/layout/report_parts/layoutitem_groupby.h
index 80b1a22..40a4128 100644
--- a/glom/libglom/data_structure/layout/report_parts/layoutitem_groupby.h
+++ b/glom/libglom/data_structure/layout/report_parts/layoutitem_groupby.h
@@ -31,7 +31,8 @@ namespace Glom
 class LayoutItem_Field;
 
 /** The child items are fields to be shown for each record in the group.
- * field_group_by is the field by which the records are grouped.
+ * The records are grouped by a specified field and there may be.
+ * secondary fields that are also shown for each group.
  */
 class LayoutItem_GroupBy : public LayoutGroup
 {
@@ -67,13 +68,18 @@ public:
   virtual Glib::ustring get_part_type_name() const;
   virtual Glib::ustring get_report_part_id() const;
 
-  //TODO: Add get/set methods for this:
-  sharedptr<LayoutGroup> m_group_secondary_fields; //For instance, show a contact name as well as the contact ID that we group by.
-
-  type_list_sort_fields m_fields_sort_by;
+  sharedptr<LayoutGroup> get_secondary_fields();
+  sharedptr<const LayoutGroup> get_secondary_fields() const;
 
+  //TODO: Is this used by anything?
+  type_list_sort_fields get_sort_by() const;
+  void set_sort_by(const type_list_sort_fields& sort_by);
+  
 private:
+
   sharedptr<LayoutItem_Field> m_field_group_by;
+  sharedptr<LayoutGroup> m_group_secondary_fields; //For instance, show a contact name as well as the contact ID that we group by.
+  type_list_sort_fields m_fields_sort_by;
 };
 
 } //namespace Glom
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index efd4977..1064069 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -2508,8 +2508,8 @@ void Document::load_after_layout_group(const xmlpp::Element* node, const Glib::u
           xmlpp::Element* elementGroup = get_node_child_named(elementSecondary, GLOM_NODE_DATA_LAYOUT_GROUP);
           if(elementGroup)
           {
-            load_after_layout_group(elementGroup, table_name, child_group->m_group_secondary_fields, with_print_layout_positions);
-            fill_layout_field_details(table_name, child_group->m_group_secondary_fields); //Get full field details from the field names.
+            load_after_layout_group(elementGroup, table_name, child_group->get_secondary_fields(), with_print_layout_positions);
+            fill_layout_field_details(table_name, child_group->get_secondary_fields()); //Get full field details from the field names.
           }
         }
 
@@ -3385,10 +3385,10 @@ void Document::save_before_layout_group(xmlpp::Element* node, const sharedptr<co
     }
 
     //Secondary fields:
-    if(!group_by->m_group_secondary_fields->m_list_items.empty())
+    if(!group_by->get_secondary_fields()->m_list_items.empty())
     {
       xmlpp::Element* secondary_fields = child->add_child(GLOM_NODE_DATA_LAYOUT_GROUP_SECONDARYFIELDS);
-      save_before_layout_group(secondary_fields, group_by->m_group_secondary_fields, with_print_layout_positions);
+      save_before_layout_group(secondary_fields, group_by->get_secondary_fields(), with_print_layout_positions);
     }
   }
   else
@@ -4612,7 +4612,7 @@ void Document::fill_translatable_layout_items(const sharedptr<LayoutGroup>& grou
         sharedptr<LayoutItem_Field> field = group_by->get_field_group_by();
         fill_translatable_layout_items(field, the_list, hint);
 
-        fill_translatable_layout_items(group_by->m_group_secondary_fields, the_list, this_hint);
+        fill_translatable_layout_items(group_by->get_secondary_fields(), the_list, this_hint);
       }
 
       //recurse:
diff --git a/glom/libglom/report_builder.cc b/glom/libglom/report_builder.cc
index 76fcc27..b57ebb4 100644
--- a/glom/libglom/report_builder.cc
+++ b/glom/libglom/report_builder.cc
@@ -276,12 +276,12 @@ bool ReportBuilder::report_build_groupby(const FoundSet& found_set_parent, xmlpp
         found_set_records.m_where_clause = where_clause;
 
         //Secondary fields. For instance, the Contact Name, in addition to the Contact ID that we group by.
-        if(!(group_by->m_group_secondary_fields->m_list_items.empty()))
+        if(!(group_by->get_secondary_fields()->m_list_items.empty()))
         {
           xmlpp::Element* nodeSecondaryFields = nodeGroupBy->add_child("secondary_fields");
 
           type_vecLayoutItems itemsToGet;
-          for(LayoutGroup::type_list_items::iterator iterChildren = group_by->m_group_secondary_fields->m_list_items.begin(); iterChildren != group_by->m_group_secondary_fields->m_list_items.end(); ++iterChildren)
+          for(LayoutGroup::type_list_items::iterator iterChildren = group_by->get_secondary_fields()->m_list_items.begin(); iterChildren != group_by->get_secondary_fields()->m_list_items.end(); ++iterChildren)
           {
             sharedptr<LayoutItem> item = *iterChildren;
             itemsToGet.push_back( glom_sharedptr_clone(item) );
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc b/glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc
index 01bc1da..40c497d 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc
@@ -163,14 +163,14 @@ void Dialog_GroupBy::on_button_secondary_fields()
 
   if(m_dialog_choose_secondary_fields)
   {
-    m_dialog_choose_secondary_fields->set_fields(m_table_name, m_layout_item->m_group_secondary_fields->m_list_items);
+    m_dialog_choose_secondary_fields->set_fields(m_table_name, m_layout_item->get_secondary_fields()->m_list_items);
 
     const int response = Glom::Utils::dialog_run_with_help(m_dialog_choose_secondary_fields);
     m_dialog_choose_secondary_fields->hide();
     if(response == Gtk::RESPONSE_OK && m_dialog_choose_secondary_fields->get_modified())
     {
-      m_layout_item->m_group_secondary_fields->remove_all_items(); //Free the existing member items.
-      m_layout_item->m_group_secondary_fields->m_list_items = m_dialog_choose_secondary_fields->get_fields();
+      m_layout_item->get_secondary_fields()->remove_all_items(); //Free the existing member items.
+      m_layout_item->get_secondary_fields()->m_list_items = m_dialog_choose_secondary_fields->get_fields();
     }
   }
 
@@ -196,7 +196,7 @@ void Dialog_GroupBy::update_labels()
 
   //Secondary Fields:
   const Glib::ustring text_secondary_fields =
-    Utils::get_list_of_layout_items_for_display(m_layout_item->m_group_secondary_fields);
+    Utils::get_list_of_layout_items_for_display(m_layout_item->get_secondary_fields());
   m_label_secondary_fields->set_text(text_secondary_fields);
 }
 



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