[glom/glom-1-30] Box_Data_Details/FlowTableWithFields: Allow notebooks at the top-level.



commit 59a1b05d49b47ba9c96840cd22f18ff807f511fa
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Jan 28 22:36:47 2016 +0100

    Box_Data_Details/FlowTableWithFields: Allow notebooks at the top-level.
    
    And portals too. By not just assuming that the top-level groups
    are normal groups. They can be derived groups, such as notebooks.
    
    Bug #759511

 glom/mode_data/box_data_details.cc    |    2 +-
 glom/mode_data/flowtablewithfields.cc |   59 ++++++++++++++++++--------------
 glom/mode_data/flowtablewithfields.h  |   12 +++++-
 3 files changed, 44 insertions(+), 29 deletions(-)
---
diff --git a/glom/mode_data/box_data_details.cc b/glom/mode_data/box_data_details.cc
index 90fc32a..9867d71 100644
--- a/glom/mode_data/box_data_details.cc
+++ b/glom/mode_data/box_data_details.cc
@@ -224,7 +224,7 @@ void Box_Data_Details::create_layout()
 
     for(const auto& item : layout_groups)
     {
-      m_FlowTable.add_layout_group(item, false /* no indent at this top level */);
+      m_FlowTable.add_layout_group_or_derived(item, false /* no indent at this top level */);
     }
 
     m_FlowTable.align_child_group_labels();
diff --git a/glom/mode_data/flowtablewithfields.cc b/glom/mode_data/flowtablewithfields.cc
index 34107b2..8d41f56 100644
--- a/glom/mode_data/flowtablewithfields.cc
+++ b/glom/mode_data/flowtablewithfields.cc
@@ -112,46 +112,53 @@ void FlowTableWithFields::add_layout_item(const std::shared_ptr<LayoutItem>& ite
   }
   else
   {
-    std::shared_ptr<LayoutItem_Portal> portal = std::dynamic_pointer_cast<LayoutItem_Portal>(item);
-    if(portal)
+    auto group = std::dynamic_pointer_cast<LayoutGroup>(item);
+    if(group)
     {
-      add_layout_portal(portal);
+      add_layout_group_or_derived(group);
     }
     else
     {
-      std::shared_ptr<LayoutItem_Notebook> notebook = std::dynamic_pointer_cast<LayoutItem_Notebook>(item);
-      if(notebook)
-      {
-        add_layout_notebook(notebook);
-      }
+      auto layout_button = std::dynamic_pointer_cast<LayoutItem_Button>(item);
+      if(layout_button)
+        add_button(layout_button, m_table_name);
       else
       {
-        std::shared_ptr<LayoutGroup> group = std::dynamic_pointer_cast<LayoutGroup>(item);
-        if(group)
-          add_layout_group(group);
+        auto layout_textobject = std::dynamic_pointer_cast<LayoutItem_Text>(item);
+        if(layout_textobject)
+          add_textobject(layout_textobject, m_table_name);
         else
         {
-          std::shared_ptr<LayoutItem_Button> layout_button = 
std::dynamic_pointer_cast<LayoutItem_Button>(item);
-          if(layout_button)
-            add_button(layout_button, m_table_name);
-          else
-          {
-            std::shared_ptr<LayoutItem_Text> layout_textobject = 
std::dynamic_pointer_cast<LayoutItem_Text>(item);
-            if(layout_textobject)
-              add_textobject(layout_textobject, m_table_name);
-            else
-            {
-              std::shared_ptr<LayoutItem_Image> layout_imageobject = 
std::dynamic_pointer_cast<LayoutItem_Image>(item);
-              if(layout_imageobject)
-                add_imageobject(layout_imageobject, m_table_name);
-            }
-          }
+          auto layout_imageobject = std::dynamic_pointer_cast<LayoutItem_Image>(item);
+          if(layout_imageobject)
+            add_imageobject(layout_imageobject, m_table_name);
         }
       }
     }
   }
 }
 
+void FlowTableWithFields::add_layout_group_or_derived(const std::shared_ptr<LayoutGroup>& group, bool 
with_indent)
+{
+  auto portal = std::dynamic_pointer_cast<LayoutItem_Portal>(group);
+  if(portal)
+  {
+    add_layout_portal(portal);
+  }
+  else
+  {
+    auto notebook = std::dynamic_pointer_cast<LayoutItem_Notebook>(group);
+    if(notebook)
+    {
+      add_layout_notebook(notebook);
+    }
+    else
+    {
+      add_layout_group(group, with_indent);
+    }
+  }
+}
+          
 void FlowTableWithFields::add_layout_group(const std::shared_ptr<LayoutGroup>& group, bool with_indent)
 {
   if(!group)
diff --git a/glom/mode_data/flowtablewithfields.h b/glom/mode_data/flowtablewithfields.h
index ba479a2..e9c5bef 100644
--- a/glom/mode_data/flowtablewithfields.h
+++ b/glom/mode_data/flowtablewithfields.h
@@ -86,10 +86,10 @@ public:
 
   void add_layout_item(const std::shared_ptr<LayoutItem>& item);
 
-  /**
+    /**
    * @param with_indent Pass true for top-level groups, to avoid wasting extra space with an unnecessary 
indent.
    */
-  void add_layout_group(const std::shared_ptr<LayoutGroup>& group, bool with_indent = true);
+  void add_layout_group_or_derived(const std::shared_ptr<LayoutGroup>& group, bool with_indent = true);
 
   void set_field_editable(const std::shared_ptr<const LayoutItem_Field>& field, bool editable = true);
 
@@ -249,6 +249,14 @@ private:
   void add_imageobject(const std::shared_ptr<LayoutItem_Image>& layoutitem_image, const Glib::ustring& 
table_name);
 
   void add_layoutwidgetbase(LayoutWidgetBase* layout_widget);
+
+  /** Add a normal group, not a notebook or portal.
+   * See also add_layout_group_or_derived().
+   *
+   * @param with_indent Pass true for top-level groups, to avoid wasting extra space with an unnecessary 
indent.
+   */
+  void add_layout_group(const std::shared_ptr<LayoutGroup>& group, bool with_indent = true);
+
   void add_layout_notebook(const std::shared_ptr<LayoutItem_Notebook>& notebook);
   void add_layout_portal(const std::shared_ptr<LayoutItem_Portal>& portal);
 


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