[glom/glom-1-18] Document: get_data_layout_groups_default(): Simplify the default structure.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/glom-1-18] Document: get_data_layout_groups_default(): Simplify the default structure.
- Date: Fri, 7 Oct 2011 07:57:39 +0000 (UTC)
commit 76f773de7c1ed797c4517210feae80ad7fb6f98b
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Oct 6 12:46:16 2011 +0200
Document: get_data_layout_groups_default(): Simplify the default structure.
* glom/libglom/document/document.cc: Do not create the useless main
top-level group for details layouts.
ChangeLog | 7 +++++
glom/libglom/document/document.cc | 51 ++++++++++++++++---------------------
2 files changed, 29 insertions(+), 29 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 337f1e2..797749a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-10-06 Murray Cumming <murrayc murrayc com>
+
+ Document: get_data_layout_groups_default(): Simplify the default structure.
+
+ * glom/libglom/document/document.cc: Do not create the useless "main"
+ top-level group for details layouts.
+
2011-10-02 Murray Cumming <murrayc murrayc com>
Find: Get criteria even when a field is on the layout twice.
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 9fcd696..37091ec 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -1436,41 +1436,34 @@ Document::type_list_layout_groups Document::get_data_layout_groups_default(const
type_list_layout_groups result;
//Add one if necessary:
- sharedptr<LayoutGroup> pTopLevel;
- sharedptr<LayoutGroup> pOverview;
- sharedptr<LayoutGroup> pDetails;
-
- sharedptr<LayoutGroup> group = sharedptr<LayoutGroup>::create();
- group->set_name("main");
- group->set_columns_count(1);
- result.push_back(group);
- pTopLevel = group;
+ sharedptr<LayoutGroup> overview;
+ sharedptr<LayoutGroup> details;
if(layout_name == "details") //The Details default layout is a bit more complicated.
{
- sharedptr<LayoutGroup> overview = sharedptr<LayoutGroup>::create();;
+ overview = sharedptr<LayoutGroup>::create();;
overview->set_name("overview");
overview->set_title_original("Overview"); //Don't translate this, but TODO: add standard translations.
overview->set_columns_count(2);
+ result.push_back(overview);
- pTopLevel->add_item(overview);
- pOverview = sharedptr<LayoutGroup>::cast_dynamic(overview);
-
- sharedptr<LayoutGroup> details = sharedptr<LayoutGroup>::create();
+ details = sharedptr<LayoutGroup>::create();
details->set_name("details");
details->set_title_original("Details"); //Don't translate this, but TODO: add standard translations.
details->set_columns_count(2);
-
- pTopLevel->add_item(details);
- pDetails = sharedptr<LayoutGroup>::cast_dynamic(details);
+ result.push_back(details);
+ }
+
+ //If, for some reason, we didn't create the-subgroups, add everything to a top level group:
+ if(!overview && !details)
+ {
+ overview = sharedptr<LayoutGroup>::create();
+ overview->set_name("main");
+ overview->set_columns_count(1);
+ result.push_back(overview);
+
+ details = overview; //Adding anything to details adds it to the overview, which is the only group.
}
-
- //If, for some reason, we didn't create the-subgroups, add everything to the top level group:
- if(!pOverview)
- pOverview = pTopLevel;
-
- if(!pDetails)
- pDetails = pTopLevel;
//Discover new fields, and add them:
@@ -1500,11 +1493,11 @@ Document::type_list_layout_groups Document::get_data_layout_groups_default(const
//layout_item.set_table_name(child_table_name); //TODO: Allow viewing of fields through relationships.
//layout_item.m_sequence = sequence; add_item() will fill this.
- //std::cout << " debug: add_item(): " << layout_item.get_name() << std::endl;
- if(pOverview && layout_item->get_full_field_details()->get_primary_key())
- pOverview->add_item(layout_item);
- else if(pDetails)
- pDetails->add_item(layout_item);
+ //std::cout << "debug: " << G_STRFUNC << ": " << layout_item.get_name() << std::endl;
+ if(overview && layout_item->get_full_field_details()->get_primary_key())
+ overview->add_item(layout_item);
+ else if(details)
+ details->add_item(layout_item);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]