[glom/maemo5] Maemo: Really fall back to the standard layout if there is no maemo layout.



commit 34252a4d5f41328bb493f2e051e3ec3a4fcbfe50
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Oct 2 18:24:00 2009 +0200

    Maemo: Really fall back to the standard layout if there is no maemo layout.
    
    * glom/libglom/document/document.cc: get_data_layout_groups_plus_new_fields():
    Really fall back to the standard layout if there is no maemo layout.
    When creating a default layout, restrict the column count to 1.

 ChangeLog                         |    8 ++++++++
 glom/libglom/document/document.cc |   20 ++++++++++++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7f7680b..e6a5bc7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2009-10-02  Murray Cumming  <murrayc murrayc com>
 
+	Maemo: Really fall back to the standard layout if there is no maemo layout.
+	
+	* glom/libglom/document/document.cc: get_data_layout_groups_plus_new_fields():
+	Really fall back to the standard layout if there is no maemo layout. 
+	When creating a default layout, restrict the column count to 1. 
+
+2009-10-02  Murray Cumming  <murrayc murrayc com>
+
 	Maemo: Avoid multi-column details layouts.
 	 
 	* glom/libglom/document/document.[h|cc]:
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 2a8a24b..75aab76 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -1417,8 +1417,6 @@ void Document::fill_layout_field_details(const Glib::ustring& parent_table_name,
 
 Document::type_list_layout_groups Document::get_data_layout_groups_default(const Glib::ustring& layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& /* layout_platform */) const
 {
-  //std::cout << "debug: Document::get_data_layout_groups_default(): table_name = " << parent_table_name << std::endl;
-
   type_list_layout_groups result;
 
   //Add one if necessary:
@@ -1504,14 +1502,30 @@ Document::type_list_layout_groups Document::get_data_layout_groups_plus_new_fiel
 
   //If there are no fields in the layout, then add a default:
   bool create_default = false;
+  if(result.empty() && !layout_name.empty())
+  {
+    //Fall back to a general layout instead of one for a specific platform:
+    result = get_data_layout_groups(layout_name, parent_table_name, Glib::ustring());
+  }
+  
   if(result.empty())
+  {
     create_default = true;
+  }
   //TODO: Also set create_default if all groups have no fields.
 
   if(create_default)
   {
+    std::cout << "DEBUG: Document::get_data_layout_groups_plus_new_fields(): Creating a default layout." << std::endl;
     result = get_data_layout_groups_default(layout_name, parent_table_name, layout_platform);
     
+    //Make the default layout suitable for the special platform:
+    if(layout_platform == "maemo")
+    {
+      for(type_list_layout_groups::iterator iter = result.begin(); iter != result.end(); ++iter)
+      maemo_restrict_layouts_to_single_column_group(*iter);
+    }
+    
     //Store this so we don't have to recreate it next time:
     Document* nonconst_this = const_cast<Document*>(this); //TODO: This is not ideal.
     nonconst_this->set_data_layout_groups(layout_name, parent_table_name, layout_platform, result);
@@ -4107,8 +4121,6 @@ void Document::maemo_restrict_layouts_to_single_column_group(const sharedptr<Lay
 {
   if(!layout_group)
     return;
-    
-  std::cout << "debug: group columns=" << layout_group->get_columns_count() << std::endl;
 
   //Change it to a single column group:
   if(layout_group->get_columns_count() > 1)



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