[glom] Box_Data_Details/FlowTableWithFields: Allow notebooks at the top-level.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Box_Data_Details/FlowTableWithFields: Allow notebooks at the top-level.
- Date: Thu, 28 Jan 2016 22:31:56 +0000 (UTC)
commit b416e1f4e1654a69077f7d8fca1365501668f078
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 a273b1d..c8228b0 100644
--- a/glom/mode_data/box_data_details.cc
+++ b/glom/mode_data/box_data_details.cc
@@ -225,7 +225,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 36c9660..e76182b 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
{
- auto 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
{
- auto 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
{
- auto 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
{
- auto layout_button = std::dynamic_pointer_cast<LayoutItem_Button>(item);
- if(layout_button)
- add_button(layout_button, m_table_name);
- else
- {
- auto layout_textobject = std::dynamic_pointer_cast<LayoutItem_Text>(item);
- if(layout_textobject)
- add_textobject(layout_textobject, m_table_name);
- else
- {
- auto 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 bad20f4..70a27f7 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);
@@ -247,6 +247,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]