[glom] Const corrections in use of LayoutItem and LayoutItem_Field in vectors.



commit 0519800fb14366d7e3aa14a083da8d54484a0f57
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Sep 24 15:01:20 2010 +0200

    Const corrections in use of LayoutItem and LayoutItem_Field in vectors.
    
      This allows DbTreeModel to take a vector of const items.

 ChangeLog                                          |    6 ++
 glom/base_db.cc                                    |    6 +-
 glom/base_db.h                                     |    4 +-
 glom/base_db_table_data.cc                         |   40 +++++-----
 glom/base_db_table_data.h                          |   22 +++---
 glom/base_db_table_data_readonly.h                 |    2 +-
 glom/frame_glom.cc                                 |   18 ++--
 glom/mode_data/box_data.cc                         |   10 +-
 glom/mode_data/box_data.h                          |    4 +-
 glom/mode_data/box_data_calendar_related.cc        |    4 +-
 glom/mode_data/box_data_calendar_related.h         |    2 +-
 glom/mode_data/box_data_details.cc                 |    6 +-
 glom/mode_data/box_data_list.cc                    |    6 +-
 glom/mode_data/box_data_manyrecords.cc             |   11 ++-
 glom/mode_data/box_data_portal.cc                  |   13 ++-
 glom/mode_data/box_data_portal.h                   |    2 +-
 glom/mode_data/db_adddel/db_adddel.cc              |   49 ++++++++++--
 glom/mode_data/db_adddel/treemodel_db.cc           |    6 +-
 glom/mode_data/db_adddel/treemodel_db.h            |    9 +-
 glom/mode_design/layout/dialog_layout.cc           |    4 +-
 glom/mode_design/layout/dialog_layout.h            |    4 +-
 .../layout/dialog_layout_calendar_related.cc       |   33 ++++----
 glom/mode_design/layout/dialog_layout_details.cc   |   25 ++----
 glom/mode_design/layout/dialog_layout_details.h    |    6 +-
 .../layout/dialog_layout_list_related.cc           |   39 +++++-----
 glom/print_layout/canvas_print_layout.cc           |   82 ++++++++++----------
 glom/print_layout/canvas_print_layout.h            |    2 +-
 27 files changed, 225 insertions(+), 190 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5d4f76c..48b6c1f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-09-24  Murray Cumming  <murrayc murrayc com>
+
+	Const corrections in use of LayoutItem and LayoutItem_Field in vectors.
+
+  This allows DbTreeModel to take a vector of const items.
+
 2010-09-24  David King  <davidk openismus com>
 
 	Improve use of defines
diff --git a/glom/base_db.cc b/glom/base_db.cc
index c89b726..b2bcf43 100644
--- a/glom/base_db.cc
+++ b/glom/base_db.cc
@@ -709,7 +709,7 @@ sharedptr<Field> Base_DB::get_field_primary_key_for_table(const Glib::ustring& t
   return sharedptr<Field>();
 }
 
-void Base_DB::get_table_fields_to_show_for_sequence_add_group(const Glib::ustring& table_name, const Privileges& table_privs, const type_vec_fields& all_db_fields, const sharedptr<LayoutGroup>& group, Base_DB::type_vecLayoutFields& vecFields) const
+void Base_DB::get_table_fields_to_show_for_sequence_add_group(const Glib::ustring& table_name, const Privileges& table_privs, const type_vec_fields& all_db_fields, const sharedptr<LayoutGroup>& group, Base_DB::type_vecConstLayoutFields& vecFields) const
 {
   //g_warning("Box_Data::get_table_fields_to_show_for_sequence_add_group(): table_name=%s, all_db_fields.size()=%d, group->name=%s", table_name.c_str(), all_db_fields.size(), group->get_name().c_str());
 
@@ -787,7 +787,7 @@ void Base_DB::get_table_fields_to_show_for_sequence_add_group(const Glib::ustrin
   }
 }
 
-Base_DB::type_vecLayoutFields Base_DB::get_table_fields_to_show_for_sequence(const Glib::ustring& table_name, const Document::type_list_layout_groups& mapGroupSequence) const
+Base_DB::type_vecConstLayoutFields Base_DB::get_table_fields_to_show_for_sequence(const Glib::ustring& table_name, const Document::type_list_layout_groups& mapGroupSequence) const
 {
   //Get field definitions from the database, with corrections from the document:
   type_vec_fields all_fields = get_fields_for_table(table_name);
@@ -795,7 +795,7 @@ Base_DB::type_vecLayoutFields Base_DB::get_table_fields_to_show_for_sequence(con
   const Privileges table_privs = Privs::get_current_privs(table_name);
 
   //Get fields that the document says we should show:
-  type_vecLayoutFields result;
+  type_vecConstLayoutFields result;
   const Document* pDoc = dynamic_cast<const Document*>(get_document());
   if(pDoc)
   {
diff --git a/glom/base_db.h b/glom/base_db.h
index d755308..1780499 100644
--- a/glom/base_db.h
+++ b/glom/base_db.h
@@ -302,8 +302,8 @@ protected:
 
   virtual void on_userlevel_changed(AppState::userlevels userlevel);
 
-  type_vecLayoutFields get_table_fields_to_show_for_sequence(const Glib::ustring& table_name, const Document::type_list_layout_groups& mapGroupSequence) const;
-  void get_table_fields_to_show_for_sequence_add_group(const Glib::ustring& table_name, const Privileges& table_privs, const type_vec_fields& all_db_fields, const sharedptr<LayoutGroup>& group, type_vecLayoutFields& vecFields) const;
+  type_vecConstLayoutFields get_table_fields_to_show_for_sequence(const Glib::ustring& table_name, const Document::type_list_layout_groups& mapGroupSequence) const;
+  void get_table_fields_to_show_for_sequence_add_group(const Glib::ustring& table_name, const Privileges& table_privs, const type_vec_fields& all_db_fields, const sharedptr<LayoutGroup>& group, type_vecConstLayoutFields& vecFields) const;
 
   /** Get the relationship into which the row button should navigate,
    * or the relationship itself, if the navigation_main output parameter is set to true after calling this method.
diff --git a/glom/base_db_table_data.cc b/glom/base_db_table_data.cc
index 33efffe..de1dc89 100644
--- a/glom/base_db_table_data.cc
+++ b/glom/base_db_table_data.cc
@@ -69,7 +69,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
 
   const Glib::ustring primary_key_name = fieldPrimaryKey->get_name();
 
-  type_vecLayoutFields fieldsToAdd = m_FieldsShown;
+  type_vecConstLayoutFields fieldsToAdd = m_FieldsShown;
   if(m_TableFields.empty())
     m_TableFields = get_fields_for_table(m_table_name);
 
@@ -78,7 +78,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
   for(type_vec_fields::const_iterator iter = m_TableFields.begin(); iter != m_TableFields.end(); ++iter)
   {
     //TODO: Search for the non-related field with the name, not just the field with the name:
-    type_vecLayoutFields::const_iterator iterFind = std::find_if(fieldsToAdd.begin(), fieldsToAdd.end(), predicate_FieldHasName<LayoutItem_Field>((*iter)->get_name()));
+    type_vecConstLayoutFields::const_iterator iterFind = std::find_if(fieldsToAdd.begin(), fieldsToAdd.end(), predicate_FieldHasName<LayoutItem_Field>((*iter)->get_name()));
     if(iterFind == fieldsToAdd.end())
     {
       sharedptr<LayoutItem_Field> layout_item = sharedptr<LayoutItem_Field>::create();
@@ -91,9 +91,9 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
   Document* document = get_document();
 
   //Calculate any necessary field values and enter them:
-  for(type_vecLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
+  for(type_vecConstLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
   {
-    sharedptr<LayoutItem_Field> layout_item = *iter;
+    sharedptr<const LayoutItem_Field> layout_item = *iter;
 
     //If the user did not enter something in this field:
     Gnome::Gda::Value value = get_entered_field_data(layout_item);
@@ -151,9 +151,9 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
   type_map_added map_added;
   Glib::RefPtr<Gnome::Gda::Set> params = Gnome::Gda::Set::create();
 
-  for(type_vecLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
+  for(type_vecConstLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
   {
-    sharedptr<LayoutItem_Field> layout_item = *iter;
+    sharedptr<const LayoutItem_Field> layout_item = *iter;
     const Glib::ustring field_name = layout_item->get_name();
     if(!layout_item->get_has_relationship_name()) //TODO: Allow people to add a related record also by entering new data in a related field of the related record.
     {
@@ -208,7 +208,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
       set_primary_key_value(row, primary_key_value); //Needed by Box_Data_List::on_adddel_user_changed().
 
       //Update any lookups, related fields, or calculations:
-      for(type_vecLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
+      for(type_vecConstLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
       {
         sharedptr<const LayoutItem_Field> layout_item = *iter;
 
@@ -354,8 +354,8 @@ bool Base_DB_Table_Data::add_related_record_for_field(const sharedptr<const Layo
           }
           else
           {
-            const Glib::ustring target_table = relationship->get_from_table();             
-            Glib::RefPtr<Gnome::Gda::SqlBuilder> builder = 
+            const Glib::ustring target_table = relationship->get_from_table();
+            Glib::RefPtr<Gnome::Gda::SqlBuilder> builder =
               Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_UPDATE);
             builder->set_table(target_table);
             builder->add_field_value_as_value(relationship->get_from_field(), primary_key_value);
@@ -363,7 +363,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const sharedptr<const Layo
               builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
                 builder->add_field_id(parent_primary_key_field->get_name(), target_table),
                 builder->add_expr(parent_primary_key_value)) );
-          
+
             const bool test = DbUtils::query_execute(builder);
             if(!test)
             {
@@ -417,7 +417,7 @@ bool Base_DB_Table_Data::record_delete(const Gnome::Gda::Value& primary_key_valu
   sharedptr<Field> field_primary_key = get_field_primary_key();
   if(field_primary_key && !Conversions::value_is_empty(primary_key_value))
   {
-    Glib::RefPtr<Gnome::Gda::SqlBuilder> builder = 
+    Glib::RefPtr<Gnome::Gda::SqlBuilder> builder =
       Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_DELETE);
     builder->set_table(m_table_name);
     builder->set_where(
@@ -453,7 +453,7 @@ bool Base_DB_Table_Data::get_related_record_exists(const sharedptr<const Relatio
   const Glib::ustring to_field = relationship->get_to_field();
   const Glib::ustring related_table = relationship->get_to_table();
 
-  //TODO_Performance: Is this the best way to just find out whether there is one record that meets this criteria? 
+  //TODO_Performance: Is this the best way to just find out whether there is one record that meets this criteria?
   Glib::RefPtr<Gnome::Gda::SqlBuilder> builder =
       Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_SELECT);
   builder->select_add_field(to_field, related_table);
@@ -462,7 +462,7 @@ bool Base_DB_Table_Data::get_related_record_exists(const sharedptr<const Relatio
     builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
       builder->add_field_id(to_field, related_table),
       builder->add_expr(key_value)));
-                                               
+
   Glib::RefPtr<Gnome::Gda::DataModel> records = DbUtils::query_execute_select(builder);
   if(!records)
     handle_error();
@@ -479,17 +479,17 @@ bool Base_DB_Table_Data::get_related_record_exists(const sharedptr<const Relatio
 
 /** Get the shown fields that are in related tables, via a relationship using @a field_name changes.
  */
-Base_DB_Table_Data::type_vecLayoutFields Base_DB_Table_Data::get_related_fields(const sharedptr<const LayoutItem_Field>& field) const
+Base_DB_Table_Data::type_vecConstLayoutFields Base_DB_Table_Data::get_related_fields(const sharedptr<const LayoutItem_Field>& field) const
 {
-  type_vecLayoutFields result;
+  type_vecConstLayoutFields result;
 
   const Document* document = dynamic_cast<const Document*>(get_document());
   if(document)
   {
     const Glib::ustring field_name = field->get_name(); //At the moment, relationships can not be based on related fields on the from side.
-    for(type_vecLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end();  ++iter)
+    for(type_vecConstLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end();  ++iter)
     {
-      sharedptr<LayoutItem_Field> layout_field = *iter;
+      const sharedptr<const LayoutItem_Field> layout_field = *iter;
       //Examine each field that looks up its data from a relationship:
       if(layout_field->get_has_relationship_name())
       {
@@ -521,7 +521,7 @@ void Base_DB_Table_Data::refresh_related_fields(const LayoutFieldInRecord& field
   //Get values for lookup fields, if this field triggers those relationships:
   //TODO_performance: There is a LOT of iterating and copying here.
   //const Glib::ustring strFieldName = field_in_record_changed.m_field->get_name();
-  type_vecLayoutFields fieldsToGet = get_related_fields(field_in_record_changed.m_field);
+  type_vecConstLayoutFields fieldsToGet = get_related_fields(field_in_record_changed.m_field);
 
   if(!fieldsToGet.empty())
   {
@@ -539,7 +539,7 @@ void Base_DB_Table_Data::refresh_related_fields(const LayoutFieldInRecord& field
       //Field contents:
       if(result->get_n_rows())
       {
-        type_vecLayoutFields::const_iterator iterFields = fieldsToGet.begin();
+        type_vecConstLayoutFields::const_iterator iterFields = fieldsToGet.begin();
 
         const guint cols_count = result->get_n_columns();
         if(cols_count <= 0)
@@ -550,7 +550,7 @@ void Base_DB_Table_Data::refresh_related_fields(const LayoutFieldInRecord& field
         for(guint uiCol = 0; uiCol < cols_count; ++uiCol)
         {
           const Gnome::Gda::Value value = result->get_value_at(uiCol, 0 /* row */);
-          sharedptr<LayoutItem_Field> layout_item = *iterFields;
+          sharedptr<const LayoutItem_Field> layout_item = *iterFields;
           if(!layout_item)
             std::cerr << G_STRFUNC << ": The layout_item was null." << std::endl;
           else
diff --git a/glom/base_db_table_data.h b/glom/base_db_table_data.h
index 8dc330a..9acd36c 100644
--- a/glom/base_db_table_data.h
+++ b/glom/base_db_table_data.h
@@ -27,15 +27,15 @@
 namespace Glom
 {
 
-/** A base class some database functionality 
+/** A base class some database functionality
  * for use with a specific database table, showing data from the table.
  */
 class Base_DB_Table_Data : public Base_DB_Table_Data_ReadOnly
 {
-public: 
+public:
   Base_DB_Table_Data();
   virtual ~Base_DB_Table_Data();
-    
+
   /** Tell the parent widget that something has changed in one of the shown records,
    * or a record was added or deleted.
    * This is only emitted for widgets for which it would be useful.
@@ -50,38 +50,38 @@ protected:
   /** Create a new record with all the entered field values from the currently-active details/row.
    * @result true if the record was added to the database.
    */
-  bool record_new(bool use_entered_data = true, const Gnome::Gda::Value& primary_key_value = Gnome::Gda::Value()); 
+  bool record_new(bool use_entered_data = true, const Gnome::Gda::Value& primary_key_value = Gnome::Gda::Value());
 
   Gnome::Gda::Value get_entered_field_data_field_only(const sharedptr<const Field>& field) const;
   virtual Gnome::Gda::Value get_entered_field_data(const sharedptr<const LayoutItem_Field>& field) const;
 
   //Gets the row being edited, for derived classes that have rows.
   virtual Gtk::TreeModel::iterator get_row_selected();
-  
+
   virtual void set_primary_key_value(const Gtk::TreeModel::iterator& row, const Gnome::Gda::Value& value) = 0;
 
   virtual void refresh_related_fields(const LayoutFieldInRecord& field_in_record_changed, const Gtk::TreeModel::iterator& row, const Gnome::Gda::Value& field_value);
 
   /** Get the fields that are in related tables, via a relationship using @a field_name changes.
    */
-  type_vecLayoutFields get_related_fields(const sharedptr<const LayoutItem_Field>& field) const;
-  
+  type_vecConstLayoutFields get_related_fields(const sharedptr<const LayoutItem_Field>& field) const;
+
   /** Ask the user if he really wants to delete the record.
-   */  
+   */
   bool confirm_delete_record();
-    
+
   /** Delete a record from the database table.
    * @param primary_key_value A primary key to indentify the record to delete.
    */
   bool record_delete(const Gnome::Gda::Value& primary_key_value);
-    
+
   bool add_related_record_for_field(const sharedptr<const LayoutItem_Field>& layout_item_parent, const sharedptr<const Relationship>& relationship, const sharedptr<const Field>& primary_key_field, const Gnome::Gda::Value& primary_key_value_provided, Gnome::Gda::Value& primary_key_value_used);
 
   virtual void on_record_added(const Gnome::Gda::Value& primary_key_value, const Gtk::TreeModel::iterator& row); //Overridden by derived classes.
   virtual void on_record_deleted(const Gnome::Gda::Value& primary_key_value); //Overridden by derived classes.
 
   type_signal_record_changed m_signal_record_changed;
-  
+
 private:
   bool get_related_record_exists(const sharedptr<const Relationship>& relationship, const Gnome::Gda::Value& key_value);
 };
diff --git a/glom/base_db_table_data_readonly.h b/glom/base_db_table_data_readonly.h
index e19cb3f..d1cbb9a 100644
--- a/glom/base_db_table_data_readonly.h
+++ b/glom/base_db_table_data_readonly.h
@@ -50,7 +50,7 @@ protected:
   FoundSet m_found_set;
 
   type_vec_fields m_TableFields; //A cache, so we don't have to repeatedly get them from the Document.
-  type_vecLayoutFields m_FieldsShown; //And any extra keys needed by shown fields. //TODO: Move to the non-read-only class?
+  type_vecConstLayoutFields m_FieldsShown; //And any extra keys needed by shown fields. //TODO: Move to the non-read-only class?
 };
 
 } //namespace Glom
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index 5223cf3..0110ffe 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -679,7 +679,7 @@ void Frame_Glom::on_menu_file_export()
 //TODO: Reduce copy/pasting in these export_data_to_*() methods:
 void Frame_Glom::export_data_to_vector(Document::type_example_rows& the_vector, const FoundSet& found_set, const Document::type_list_layout_groups& sequence)
 {
-  type_vecLayoutFields fieldsSequence = get_table_fields_to_show_for_sequence(found_set.m_table_name, sequence);
+  type_vecConstLayoutFields fieldsSequence = get_table_fields_to_show_for_sequence(found_set.m_table_name, sequence);
 
   if(fieldsSequence.empty())
   {
@@ -708,7 +708,7 @@ void Frame_Glom::export_data_to_vector(Document::type_example_rows& the_vector,
         {
           const Gnome::Gda::Value value = result->get_value_at(col_index, row_index);
 
-          sharedptr<LayoutItem_Field> layout_item = fieldsSequence[col_index];
+          sharedptr<const LayoutItem_Field> layout_item = fieldsSequence[col_index];
           //if(layout_item->m_field.get_glom_type() != Field::TYPE_IMAGE) //This is too much data.
           //{
 
@@ -729,7 +729,7 @@ void Frame_Glom::export_data_to_vector(Document::type_example_rows& the_vector,
 
 void Frame_Glom::export_data_to_string(Glib::ustring& the_string, const FoundSet& found_set, const Document::type_list_layout_groups& sequence)
 {
-  type_vecLayoutFields fieldsSequence = get_table_fields_to_show_for_sequence(found_set.m_table_name, sequence);
+  type_vecConstLayoutFields fieldsSequence = get_table_fields_to_show_for_sequence(found_set.m_table_name, sequence);
 
   if(fieldsSequence.empty())
   {
@@ -758,7 +758,7 @@ void Frame_Glom::export_data_to_string(Glib::ustring& the_string, const FoundSet
         {
           const Gnome::Gda::Value value = result->get_value_at(col_index, row_index);
 
-          sharedptr<LayoutItem_Field> layout_item = fieldsSequence[col_index];
+          sharedptr<const LayoutItem_Field> layout_item = fieldsSequence[col_index];
           //if(layout_item->m_field.get_glom_type() != Field::TYPE_IMAGE) //This is too much data.
           //{
             if(!row_string.empty())
@@ -781,7 +781,7 @@ void Frame_Glom::export_data_to_string(Glib::ustring& the_string, const FoundSet
 
 void Frame_Glom::export_data_to_stream(std::ostream& the_stream, const FoundSet& found_set, const Document::type_list_layout_groups& sequence)
 {
-  type_vecLayoutFields fieldsSequence = get_table_fields_to_show_for_sequence(found_set.m_table_name, sequence);
+  type_vecConstLayoutFields fieldsSequence = get_table_fields_to_show_for_sequence(found_set.m_table_name, sequence);
 
   if(fieldsSequence.empty())
   {
@@ -810,7 +810,7 @@ void Frame_Glom::export_data_to_stream(std::ostream& the_stream, const FoundSet&
         {
           const Gnome::Gda::Value value = result->get_value_at(col_index, row_index);
 
-          sharedptr<LayoutItem_Field> layout_item = fieldsSequence[col_index];
+          sharedptr<const LayoutItem_Field> layout_item = fieldsSequence[col_index];
           //if(layout_item->m_field.get_glom_type() != Field::TYPE_IMAGE) //This is too much data.
           //{
             if(!row_string.empty())
@@ -2156,13 +2156,13 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
   }
 
   // Do startup, such as starting the self-hosting database server
-  const ConnectionPool::StartupErrors started = 
+  const ConnectionPool::StartupErrors started =
     connection_pool->startup( sigc::mem_fun(*this, &Frame_Glom::on_connection_startup_progress) );
   if(started != ConnectionPool::Backend::STARTUPERROR_NONE)
   {
     std::cerr << G_STRFUNC << ": startup() failed." << std::endl;
     return false;
-  }  
+  }
 
   if(m_dialog_progess_connection_startup)
   {
@@ -2324,7 +2324,7 @@ bool Frame_Glom::connection_request_password_and_attempt(bool& database_not_foun
   //Start a self-hosted server if necessary:
   ConnectionPool* connection_pool = ConnectionPool::get_instance();
   connection_pool->setup_from_document(document);
-  const ConnectionPool::StartupErrors started = 
+  const ConnectionPool::StartupErrors started =
     connection_pool->startup( sigc::mem_fun(*this, &Frame_Glom::on_connection_startup_progress) );
   if(started != ConnectionPool::Backend::STARTUPERROR_NONE)
   {
diff --git a/glom/mode_data/box_data.cc b/glom/mode_data/box_data.cc
index be240a6..e6f2cde 100644
--- a/glom/mode_data/box_data.cc
+++ b/glom/mode_data/box_data.cc
@@ -93,7 +93,7 @@ Gnome::Gda::SqlExpr Box_Data::get_find_where_clause() const
   guint where_cond_id = 0;
 
   //Look at each field entry and build e.g. 'Name = "Bob"'
-  for(type_vecLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
+  for(type_vecConstLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
   {
     const Gnome::Gda::Value data = get_entered_field_data(*iter);
 
@@ -236,17 +236,17 @@ void Box_Data::on_dialog_layout_hide()
 }
 #endif // !GLOM_ENABLE_CLIENT_ONLY
 
-Box_Data::type_vecLayoutFields Box_Data::get_fields_to_show() const
+Box_Data::type_vecConstLayoutFields Box_Data::get_fields_to_show() const
 {
   if(m_table_name.empty())
   {
-    return type_vecLayoutFields();
+    return type_vecConstLayoutFields();
   }
   else
     return get_table_fields_to_show(m_table_name);
 }
 
-Box_Data::type_vecLayoutFields Box_Data::get_table_fields_to_show(const Glib::ustring& table_name) const
+Box_Data::type_vecConstLayoutFields Box_Data::get_table_fields_to_show(const Glib::ustring& table_name) const
 {
   const Document* pDoc = dynamic_cast<const Document*>(get_document());
   if(pDoc)
@@ -255,7 +255,7 @@ Box_Data::type_vecLayoutFields Box_Data::get_table_fields_to_show(const Glib::us
     return get_table_fields_to_show_for_sequence(table_name, mapGroupSequence);
   }
   else
-    return type_vecLayoutFields();
+    return type_vecConstLayoutFields();
 }
 
 Document::type_list_layout_groups Box_Data::get_data_layout_groups(const Glib::ustring& layout_name, const Glib::ustring& layout_platform)
diff --git a/glom/mode_data/box_data.h b/glom/mode_data/box_data.h
index 694f58a..aae9f7e 100644
--- a/glom/mode_data/box_data.h
+++ b/glom/mode_data/box_data.h
@@ -97,9 +97,9 @@ protected:
   ///Fill the existing layout with data from the database.
   virtual bool fill_from_database(); //override.
 
-  virtual type_vecLayoutFields get_fields_to_show() const;
+  virtual type_vecConstLayoutFields get_fields_to_show() const;
 
-  type_vecLayoutFields get_table_fields_to_show(const Glib::ustring& table_name) const;
+  type_vecConstLayoutFields get_table_fields_to_show(const Glib::ustring& table_name) const;
 
   /** Get the layout groups, with the Field information filled in.
    */
diff --git a/glom/mode_data/box_data_calendar_related.cc b/glom/mode_data/box_data_calendar_related.cc
index 13e92be..09fc4ec 100644
--- a/glom/mode_data/box_data_calendar_related.cc
+++ b/glom/mode_data/box_data_calendar_related.cc
@@ -310,9 +310,9 @@ void Box_Data_Calendar_Related::on_record_added(const Gnome::Gda::Value& primary
   }
 }
 
-Box_Data_Calendar_Related::type_vecLayoutFields Box_Data_Calendar_Related::get_fields_to_show() const
+Box_Data_Calendar_Related::type_vecConstLayoutFields Box_Data_Calendar_Related::get_fields_to_show() const
 {
-  type_vecLayoutFields layout_fields = Box_Data_Portal::get_fields_to_show();
+  type_vecConstLayoutFields layout_fields = Box_Data_Portal::get_fields_to_show();
 
   sharedptr<LayoutItem_CalendarPortal> derived_portal = sharedptr<LayoutItem_CalendarPortal>::cast_dynamic(m_portal);
   if(!derived_portal)
diff --git a/glom/mode_data/box_data_calendar_related.h b/glom/mode_data/box_data_calendar_related.h
index 55aaf7b..369a11a 100644
--- a/glom/mode_data/box_data_calendar_related.h
+++ b/glom/mode_data/box_data_calendar_related.h
@@ -50,7 +50,7 @@ public:
 
 private:
   virtual bool fill_from_database(); //Override.
-  virtual type_vecLayoutFields get_fields_to_show() const; //override
+  virtual type_vecConstLayoutFields get_fields_to_show() const; //override
     
     
   //Implementations of pure virtual methods from Base_DB_Table_Data:
diff --git a/glom/mode_data/box_data_details.cc b/glom/mode_data/box_data_details.cc
index 3df98ac..c688f66 100644
--- a/glom/mode_data/box_data_details.cc
+++ b/glom/mode_data/box_data_details.cc
@@ -291,7 +291,7 @@ bool Box_Data_Details::fill_from_database()
     bResult = Box_Data::fill_from_database();
 
     m_FieldsShown = get_fields_to_show();
-    type_vecLayoutFields fieldsToGet = m_FieldsShown;
+    type_vecConstLayoutFields fieldsToGet = m_FieldsShown;
 
     if(!fieldsToGet.empty())
     {
@@ -314,7 +314,7 @@ bool Box_Data_Details::fill_from_database()
         //TODO_Performance: Do this for create_layout() only, instead of repeating it for each refresh?:
         int index_primary_key = -1; //Arbitrary default.
         //g_warning("primary_key name = %s", m_field_primary_key->get_name().c_str());
-        const type_vecLayoutFields::const_iterator iterFind = std::find_if(fieldsToGet.begin(), fieldsToGet.end(), predicate_LayoutItem_Field_IsSameField<LayoutItem_Field>(layout_item));
+        const type_vecConstLayoutFields::const_iterator iterFind = std::find_if(fieldsToGet.begin(), fieldsToGet.end(), predicate_LayoutItem_Field_IsSameField<LayoutItem_Field>(layout_item));
         if(iterFind == fieldsToGet.end())
         {
           fieldsToGet.push_back(layout_item);
@@ -379,7 +379,7 @@ bool Box_Data_Details::fill_from_database()
             //Get field values to show:
             for(int i = 0; i < cols_count; ++i)
             {
-              sharedptr<LayoutItem_Field> layout_item = fieldsToGet[i];
+              sharedptr<const LayoutItem_Field> layout_item = fieldsToGet[i];
 
               //Field value:
               Gnome::Gda::Value value;
diff --git a/glom/mode_data/box_data_list.cc b/glom/mode_data/box_data_list.cc
index 2b5babc..4b66b7b 100644
--- a/glom/mode_data/box_data_list.cc
+++ b/glom/mode_data/box_data_list.cc
@@ -504,9 +504,11 @@ void Box_Data_List::print_layout() //TODO: Is this a duplicate of the one in box
     report_temp->set_title(_("List"));
 
     //Add all the fields from the layout:
-    for(type_vecLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
+    for(type_vecConstLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
     {
-      report_temp->m_layout_group->add_item(*iter);
+      sharedptr<const LayoutItem> item = *iter;
+      sharedptr<LayoutItem> unconst = sharedptr<LayoutItem>::cast_const(item); //TODO: Avoid this?
+      report_temp->m_layout_group->add_item(unconst);
     }
 
     ReportBuilder report_builder;
diff --git a/glom/mode_data/box_data_manyrecords.cc b/glom/mode_data/box_data_manyrecords.cc
index 9d8ded6..723da78 100644
--- a/glom/mode_data/box_data_manyrecords.cc
+++ b/glom/mode_data/box_data_manyrecords.cc
@@ -35,7 +35,7 @@ Box_Data_ManyRecords::Box_Data_ManyRecords()
 : m_has_one_or_more_records(false),
   m_read_only(false)
 {
-  //We do not actually use this, 
+  //We do not actually use this,
   //so it is a bug if this appears in the .glom file:
   m_layout_name = "manyrecords"; //Set by derived classes.
 
@@ -57,7 +57,7 @@ void Box_Data_ManyRecords::refresh_data_from_database_blank()
 Document::type_list_layout_groups Box_Data_ManyRecords::create_layout_get_layout()
 {
   //Overriden in Box_Data_ManyRecords_Related:
-  return get_data_layout_groups(m_layout_name); 
+  return get_data_layout_groups(m_layout_name);
 }
 */
 
@@ -83,9 +83,11 @@ void Box_Data_ManyRecords::print_layout()
     report_temp->set_title(_("List"));
 
     //Add all the fields from the layout:
-    for(type_vecLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
+    for(type_vecConstLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
     {
-      report_temp->m_layout_group->add_item(*iter);
+      sharedptr<const LayoutItem> item = *iter;
+      sharedptr<LayoutItem> unconst = sharedptr<LayoutItem>::cast_const(item); //TODO: Avoid this?
+      report_temp->m_layout_group->add_item(unconst);
     }
 
     ReportBuilder report_builder;
@@ -104,4 +106,3 @@ void Box_Data_ManyRecords::set_primary_key_value_selected(const Gnome::Gda::Valu
 }
 
 } //namespace Glom
-
diff --git a/glom/mode_data/box_data_portal.cc b/glom/mode_data/box_data_portal.cc
index 31d2cb8..08e4a41 100644
--- a/glom/mode_data/box_data_portal.cc
+++ b/glom/mode_data/box_data_portal.cc
@@ -365,7 +365,7 @@ void Box_Data_Portal::on_record_added(const Gnome::Gda::Value& /* primary_key_va
   signal_portal_record_changed().emit(m_portal->get_relationship_name());
 }
 
-Box_Data_Portal::type_vecLayoutFields Box_Data_Portal::get_fields_to_show() const
+Box_Data_Portal::type_vecConstLayoutFields Box_Data_Portal::get_fields_to_show() const
 {
   const Document* document = get_document();
   if(document && m_portal)
@@ -376,24 +376,27 @@ Box_Data_Portal::type_vecLayoutFields Box_Data_Portal::get_fields_to_show() cons
     sharedptr<const Relationship> relationship = m_portal->get_relationship();
     if(relationship)
     {
-      type_vecLayoutFields result = get_table_fields_to_show_for_sequence(m_portal->get_table_used(Glib::ustring() /* not relevant */), mapGroups);
+      type_vecConstLayoutFields result = get_table_fields_to_show_for_sequence(m_portal->get_table_used(Glib::ustring() /* not relevant */), mapGroups);
 
       //If the relationship does not allow editing, then mark all these fields as non-editable:
+      //TODO: Prevent this in some other way:
+      /*
       if(!(m_portal->get_relationship_used_allows_edit()))
       {
-        for(type_vecLayoutFields::iterator iter = result.begin(); iter != result.end(); ++iter)
+        for(type_vecConstLayoutFields::iterator iter = result.begin(); iter != result.end(); ++iter)
         {
-          sharedptr<LayoutItem_Field> item = *iter;
+          sharedptr<const LayoutItem_Field> item = *iter;
           if(item)
             item->set_editable(false);
         }
       }
+      */
 
       return result;
     }
   }
 
-  return type_vecLayoutFields();
+  return type_vecConstLayoutFields();
 }
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
diff --git a/glom/mode_data/box_data_portal.h b/glom/mode_data/box_data_portal.h
index 101ae7b..71c9a0e 100644
--- a/glom/mode_data/box_data_portal.h
+++ b/glom/mode_data/box_data_portal.h
@@ -81,7 +81,7 @@ public:
   void get_suitable_record_to_view_details(const Gnome::Gda::Value& primary_key_value, Glib::ustring& table_name, Gnome::Gda::Value& table_primary_key_value) const;
 
 protected:
-  virtual type_vecLayoutFields get_fields_to_show() const; //override
+  virtual type_vecConstLayoutFields get_fields_to_show() const; //override
     
   //Implementations of pure virtual methods from Base_DB_Table_Data:
   virtual sharedptr<Field> get_field_primary_key() const;
diff --git a/glom/mode_data/db_adddel/db_adddel.cc b/glom/mode_data/db_adddel/db_adddel.cc
index b0f9c82..678fe7c 100644
--- a/glom/mode_data/db_adddel/db_adddel.cc
+++ b/glom/mode_data/db_adddel/db_adddel.cc
@@ -702,8 +702,10 @@ Gtk::CellRenderer* DbAddDel::construct_specified_columns_cellrenderer(const shar
   return pCellRenderer;
 }
 
+typedef std::vector< sharedptr<const LayoutItem> > type_vec_const_layout_items;
 typedef std::vector< sharedptr<LayoutItem> > type_vec_layout_items;
-static Glib::RefPtr<DbTreeModel> create_model_db(const FoundSet& found_set, const type_vec_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecLayoutFields& fields_shown)
+
+static Glib::RefPtr<DbTreeModel> create_model_db(const FoundSet& found_set, const type_vec_const_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown)
 {
   Glib::RefPtr<DbTreeModel> result;
 
@@ -716,12 +718,12 @@ static Glib::RefPtr<DbTreeModel> create_model_db(const FoundSet& found_set, cons
   Gtk::TreeModel::ColumnRecord record;
 
   //Database columns:
-  DbTreeModel::type_vec_fields fields;
+  Base_DB::type_vecConstLayoutFields fields;
   {
     type_vecModelColumns::size_type i = 0;
-    for(type_vec_layout_items::const_iterator iter = layout_items.begin(); iter != layout_items.end(); ++iter)
+    for(type_vec_const_layout_items::const_iterator iter = layout_items.begin(); iter != layout_items.end(); ++iter)
     {
-      sharedptr<LayoutItem_Field> item_field = sharedptr<LayoutItem_Field>::cast_dynamic(*iter);
+      sharedptr<const LayoutItem_Field> item_field = sharedptr<const LayoutItem_Field>::cast_dynamic(*iter);
       if(item_field)
       {
         type_modelcolumn_value* pModelColumn = new type_modelcolumn_value;
@@ -744,9 +746,9 @@ static Glib::RefPtr<DbTreeModel> create_model_db(const FoundSet& found_set, cons
     //Find the primary key:
     int column_index_key = 0;
     bool key_found = false;
-    for(DbTreeModel::type_vec_fields::const_iterator iter = fields.begin(); iter != fields.end(); ++iter)
+    for(Base_DB::type_vecConstLayoutFields::const_iterator iter = fields.begin(); iter != fields.end(); ++iter)
     {
-      sharedptr<LayoutItem_Field> layout_item = *iter;
+      sharedptr<const LayoutItem_Field> layout_item = *iter;
       if( !(layout_item->get_has_relationship_name()) )
       {
         sharedptr<const Field> field_full = layout_item->get_full_field_details();
@@ -770,7 +772,7 @@ static Glib::RefPtr<DbTreeModel> create_model_db(const FoundSet& found_set, cons
     else
     {
       g_warning("%s: no primary key field found.", __FUNCTION__);
-      //for(DbTreeModel::type_vec_fields::const_iterator iter = fields.begin(); iter != fields.end(); ++iter)
+      //for(DbTreeModel::type_vec_const_fields::const_iterator iter = fields.begin(); iter != fields.end(); ++iter)
       //{
       //  g_warning("  field: %s", (iter->get_name().c_str());
       //}
@@ -788,6 +790,39 @@ static Glib::RefPtr<DbTreeModel> create_model_db(const FoundSet& found_set, cons
   return result;
 }
 
+/*
+static Glib::RefPtr<DbTreeModel> create_model_db(const FoundSet& found_set, const type_vec_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecLayoutFields& fields_shown)
+{
+  //Create a const version of the input, because C++ can't convert it automatically:
+  type_vec_const_layout_items const_items;
+  const_items.insert(const_items.end(), layout_items.begin(), layout_items.end());
+
+  Base_DB::type_vecConstLayoutFields fields_shown_const;
+  Glib::RefPtr<DbTreeModel> result = create_model_db(found_set, const_items, get_records, find_mode, fields_shown_const);
+
+  //Create a non-const version of the output parameter,
+  //because we know it just contains copies of layout_items elements, which were non-const:
+  fields_shown.clear();
+  for(Base_DB::type_vecConstLayoutFields::const_iterator iter = fields_shown_const.begin(); iter != fields_shown_const.end(); ++iter)
+  {
+     sharedptr<const LayoutItem_Field> field = *iter;
+     sharedptr<LayoutItem_Field> unconst = sharedptr<LayoutItem_Field>::cast_const(field);
+     fields_shown.push_back(unconst);
+  }
+
+  return result;
+}
+*/
+
+static Glib::RefPtr<DbTreeModel> create_model_db(const FoundSet& found_set, const type_vec_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown)
+{
+  //Create a const version of the input, because C++ can't convert it automatically:
+  type_vec_const_layout_items const_items;
+  const_items.insert(const_items.end(), layout_items.begin(), layout_items.end());
+
+  return create_model_db(found_set, const_items, get_records, find_mode, fields_shown);
+}
+
 void DbAddDel::construct_specified_columns()
 {
   InnerIgnore innerIgnore(this);
diff --git a/glom/mode_data/db_adddel/treemodel_db.cc b/glom/mode_data/db_adddel/treemodel_db.cc
index 1901fad..e834657 100644
--- a/glom/mode_data/db_adddel/treemodel_db.cc
+++ b/glom/mode_data/db_adddel/treemodel_db.cc
@@ -166,7 +166,7 @@ DbTreeModelRow::DbValue DbTreeModelRow::get_value(DbTreeModel& model, int column
 //Intialize static variable:
 bool DbTreeModel::m_iface_initialized = false;
 
-DbTreeModel::DbTreeModel(const Gtk::TreeModelColumnRecord& columns, const FoundSet& found_set, const type_vec_fields& column_fields, int column_index_key, bool get_records, bool find_mode)
+DbTreeModel::DbTreeModel(const Gtk::TreeModelColumnRecord& columns, const FoundSet& found_set, const type_vec_const_fields& column_fields, int column_index_key, bool get_records, bool find_mode)
 : Glib::ObjectBase( typeid(DbTreeModel) ), //register a custom GType.
   Glib::Object(), //The custom GType is actually registered here.
   m_columns_count(0),
@@ -204,7 +204,7 @@ DbTreeModel::~DbTreeModel()
 }
 
 //static:
-Glib::RefPtr<DbTreeModel> DbTreeModel::create(const Gtk::TreeModelColumnRecord& columns, const FoundSet& found_set, const type_vec_fields& column_fields, int column_index_key, bool get_records, bool find_mode)
+Glib::RefPtr<DbTreeModel> DbTreeModel::create(const Gtk::TreeModelColumnRecord& columns, const FoundSet& found_set, const type_vec_const_fields& column_fields, int column_index_key, bool get_records, bool find_mode)
 {
   return Glib::RefPtr<DbTreeModel>( new DbTreeModel(columns, found_set, column_fields, column_index_key, get_records, find_mode) );
 }
@@ -230,7 +230,7 @@ bool DbTreeModel::refresh_from_database(const FoundSet& found_set)
     m_gda_datamodel = model_array;
 
     int col = 0;
-    for(type_vec_fields::const_iterator iter = m_column_fields.begin(); iter != m_column_fields.end(); ++iter)
+    for(type_vec_const_fields::const_iterator iter = m_column_fields.begin(); iter != m_column_fields.end(); ++iter)
     {
       sharedptr<const LayoutItem_Field> layout_item = *iter;
       if(layout_item)
diff --git a/glom/mode_data/db_adddel/treemodel_db.h b/glom/mode_data/db_adddel/treemodel_db.h
index 034f6e9..f048ce9 100644
--- a/glom/mode_data/db_adddel/treemodel_db.h
+++ b/glom/mode_data/db_adddel/treemodel_db.h
@@ -68,18 +68,17 @@ class DbTreeModel
 public:
   typedef unsigned int size_type;
 
-  //typedef std::vector<LayoutItem_Field> type_vec_fields;
-  typedef Base_DB::type_vecLayoutFields type_vec_fields; //TODO: Use const items instead?
+  typedef Base_DB::type_vecConstLayoutFields type_vec_const_fields;
 
   friend class DbTreeModelRow;
 
 private:
   //Create a TreeModel with @a columns_count number of columns, each of type Glib::ustring.
-  DbTreeModel(const Gtk::TreeModelColumnRecord& columns, const FoundSet& found_set, const type_vec_fields& column_fields, int column_index_key, bool get_records = true, bool find_mode = false);
+  DbTreeModel(const Gtk::TreeModelColumnRecord& columns, const FoundSet& found_set, const type_vec_const_fields& column_fields, int column_index_key, bool get_records = true, bool find_mode = false);
   virtual ~DbTreeModel();
 
 public:
-  static Glib::RefPtr<DbTreeModel> create(const Gtk::TreeModelColumnRecord& columns, const FoundSet& found_set, const type_vec_fields& column_fields, int column_index_key, bool get_records = true, bool find_mode = false);
+  static Glib::RefPtr<DbTreeModel> create(const Gtk::TreeModelColumnRecord& columns, const FoundSet& found_set, const type_vec_const_fields& column_fields, int column_index_key, bool get_records = true, bool find_mode = false);
 
   typedef DbTreeModelRow::DbValue DbValue;
 
@@ -161,7 +160,7 @@ private:
    //Structure:
    unsigned int m_columns_count;
    FoundSet m_found_set;
-   type_vec_fields m_column_fields;
+   type_vec_const_fields m_column_fields;
    int m_column_index_key;
 
    //Data:
diff --git a/glom/mode_design/layout/dialog_layout.cc b/glom/mode_design/layout/dialog_layout.cc
index ff9baca..1479b2c 100644
--- a/glom/mode_design/layout/dialog_layout.cc
+++ b/glom/mode_design/layout/dialog_layout.cc
@@ -50,7 +50,7 @@ Dialog_Layout::~Dialog_Layout()
 {
 }
 
-void Dialog_Layout::set_document(const Glib::ustring& layout_name, const Glib::ustring& layout_platform, Document* /* document */, const Glib::ustring& table_name, const type_vecLayoutFields& /* table_fields */)
+void Dialog_Layout::set_document(const Glib::ustring& layout_name, const Glib::ustring& layout_platform, Document* /* document */, const Glib::ustring& table_name, const type_vecConstLayoutFields& /* table_fields */)
 {
   m_modified = false;
 
@@ -194,7 +194,7 @@ bool Dialog_Layout::get_modified() const
 
 void Dialog_Layout::make_sensitivity_depend_on_toggle_button(Gtk::ToggleButton& toggle_button, Gtk::Widget& widget)
 {
-  toggle_button.signal_toggled().connect( 
+  toggle_button.signal_toggled().connect(
     sigc::bind( sigc::mem_fun(*this, &Dialog_Layout::on_sensitivity_toggle_button), &toggle_button, &widget) );
 
   //Call the handler once, so that the initial state is set:
diff --git a/glom/mode_design/layout/dialog_layout.h b/glom/mode_design/layout/dialog_layout.h
index 44b148f..0cb538d 100644
--- a/glom/mode_design/layout/dialog_layout.h
+++ b/glom/mode_design/layout/dialog_layout.h
@@ -44,7 +44,7 @@ public:
    * @param table_name The table name.
    * @param table_fields: The actual fields in the table, in case the document does not yet know about them all.
    */
-  virtual void set_document(const Glib::ustring& layout_name, const Glib::ustring& layout_platform, Document* document, const Glib::ustring& table_name, const type_vecLayoutFields& table_fields);
+  virtual void set_document(const Glib::ustring& layout_name, const Glib::ustring& layout_platform, Document* document, const Glib::ustring& table_name, const type_vecConstLayoutFields& table_fields);
 
   virtual bool get_modified() const;
 
@@ -71,7 +71,7 @@ protected:
 
   Glib::ustring m_table_name;
   Glib::ustring m_layout_name, m_layout_platform; //As in the document.
- 
+
   bool m_modified;
 };
 
diff --git a/glom/mode_design/layout/dialog_layout_calendar_related.cc b/glom/mode_design/layout/dialog_layout_calendar_related.cc
index 93762e5..e104cd7 100644
--- a/glom/mode_design/layout/dialog_layout_calendar_related.cc
+++ b/glom/mode_design/layout/dialog_layout_calendar_related.cc
@@ -54,7 +54,7 @@ Dialog_Layout_Calendar_Related::Dialog_Layout_Calendar_Related(BaseObjectType* c
   builder->get_widget("checkbutton_show_child_relationships", m_checkbutton_show_child_relationships);
   m_checkbutton_show_child_relationships->signal_toggled().connect(sigc::mem_fun(*this, &Dialog_Layout_Calendar_Related::on_checkbutton_show_child_relationships));
 
-  
+
 
   builder->get_widget("radiobutton_navigation_automatic", m_radio_navigation_automatic);
   builder->get_widget("label_navigation_automatic", m_label_navigation_automatic);
@@ -68,7 +68,7 @@ Dialog_Layout_Calendar_Related::Dialog_Layout_Calendar_Related(BaseObjectType* c
   builder->get_widget_derived("combobox_date_field", m_combobox_date_field);
   m_combobox_date_field->signal_changed().connect(sigc::mem_fun(*this, &Dialog_Layout_Calendar_Related::on_combo_date_field_changed));
 
-  
+
   m_modified = false;
 
   //show_all_children();
@@ -76,9 +76,9 @@ Dialog_Layout_Calendar_Related::Dialog_Layout_Calendar_Related(BaseObjectType* c
   //The base class hid this, but we do want it here:
   //(We share one glade definition for several dialogs.)
   Gtk::Frame* box_calendar = 0;
-  builder->get_widget("frame_calendar", box_calendar); 
+  builder->get_widget("frame_calendar", box_calendar);
   box_calendar->show();
-  
+
   //This entry must be in the Glade file, because it's used by the base class,
   //but we don't want it here, because it is confusing when dealing with relationships:
   if(m_entry_table_title)
@@ -96,7 +96,7 @@ Dialog_Layout_Calendar_Related::~Dialog_Layout_Calendar_Related()
 void Dialog_Layout_Calendar_Related::set_document(const Glib::ustring& layout, const Glib::ustring& layout_platform, Document* document, const sharedptr<const LayoutItem_CalendarPortal>& portal)
 {
   m_portal = glom_sharedptr_clone(portal);
-  
+
   Glib::ustring from_table;
   if(portal)
     from_table = portal->get_from_table();
@@ -111,9 +111,9 @@ void Dialog_Layout_Calendar_Related::set_document(const Glib::ustring& layout_na
     m_portal = sharedptr<LayoutItem_CalendarPortal>::create(); //The rest of the class assumes that this is not null.
   }
 
-  type_vecLayoutFields empty_fields; //Just to satisfy the base class.
+  type_vecConstLayoutFields empty_fields; //Just to satisfy the base class.
+
 
-  
   Dialog_Layout::set_document(layout_name, layout_platform, document, from_table, empty_fields);
   //m_table_name is now actually the parent_table_name.
 
@@ -134,7 +134,7 @@ void Dialog_Layout_Calendar_Related::update_ui(bool including_relationship_list)
     if(including_relationship_list)
     {
       bool show_child_relationships = m_checkbutton_show_child_relationships->get_active();
-        
+
       //For the showing of child relationships if necessary:
       if(!show_child_relationships && m_portal && m_portal->get_related_relationship())
       {
@@ -157,7 +157,7 @@ void Dialog_Layout_Calendar_Related::update_ui(bool including_relationship_list)
 
     //Set the table name and title:
     //sharedptr<LayoutItem_CalendarPortal> portal_temp = m_portal;
-    m_combo_relationship->set_selected_relationship(m_portal->get_relationship(), m_portal->get_related_relationship()); 
+    m_combo_relationship->set_selected_relationship(m_portal->get_relationship(), m_portal->get_related_relationship());
 
     Document::type_list_layout_groups mapGroups;
     if(m_portal)
@@ -218,8 +218,8 @@ void Dialog_Layout_Calendar_Related::update_ui(bool including_relationship_list)
 
   //Set the appropriate radio button:
   //std::cout << "debug: navigation_is_automatic=" << navigation_is_automatic << std::endl;
-  m_radio_navigation_automatic->set_active(navigation_is_automatic); 
-  m_radio_navigation_specify->set_active(!navigation_is_automatic); 
+  m_radio_navigation_automatic->set_active(navigation_is_automatic);
+  m_radio_navigation_specify->set_active(!navigation_is_automatic);
 
 
   //Describe the automatic navigation:
@@ -253,10 +253,10 @@ void Dialog_Layout_Calendar_Related::update_ui(bool including_relationship_list)
     std::cout << "debug: " << G_STRFUNC << ": date field is NULL" << std::endl;
   else
     std::cout << "debug: " << G_STRFUNC << ": date field:" << debugfield->get_name() << std::endl;
-  
+
   m_combobox_date_field->set_fields(document, related_table_name, Field::TYPE_DATE);
   m_combobox_date_field->set_selected_field(m_portal->get_date_field());
-    
+
   m_modified = false;
 }
 
@@ -309,9 +309,9 @@ void Dialog_Layout_Calendar_Related::save_to_document()
       sharedptr<UsesRelationship> none;
       m_portal->set_navigation_relationship_specific(none);
     }
-    
+
     m_portal->set_date_field( m_combobox_date_field->get_selected_field() );
-    
+
     sharedptr<Field> debugfield = m_portal->get_date_field();
     if(!debugfield)
       std::cout << "debug: " << G_STRFUNC << ": date field is NULL" << std::endl;
@@ -379,7 +379,7 @@ void Dialog_Layout_Calendar_Related::on_button_add_field()
   //std::cout << "debug table used =" << m_portal->get_table_used(m_table_name) << std::endl;
 
   type_list_field_items fields_list = offer_field_list(m_table_name, this);
-  for(type_list_field_items::iterator iter_chosen = fields_list.begin(); iter_chosen != fields_list.end(); ++iter_chosen) 
+  for(type_list_field_items::iterator iter_chosen = fields_list.begin(); iter_chosen != fields_list.end(); ++iter_chosen)
   {
     sharedptr<LayoutItem_Field> field = *iter_chosen;
     if(!field)
@@ -445,4 +445,3 @@ sharedptr<LayoutItem_CalendarPortal> Dialog_Layout_Calendar_Related::get_portal_
 
 
 } //namespace Glom
-
diff --git a/glom/mode_design/layout/dialog_layout_details.cc b/glom/mode_design/layout/dialog_layout_details.cc
index 1c1e6c6..ea32d6d 100644
--- a/glom/mode_design/layout/dialog_layout_details.cc
+++ b/glom/mode_design/layout/dialog_layout_details.cc
@@ -65,11 +65,11 @@ Dialog_Layout_Details::Dialog_Layout_Details(BaseObjectType* cobject, const Glib
   m_box_table_widgets->show();
   builder->get_widget("hbox_related_table_widgets", m_box_related_table_widgets);
   m_box_related_table_widgets->hide();
-  builder->get_widget("frame_related_table_navigation", m_box_related_navigation); 
+  builder->get_widget("frame_related_table_navigation", m_box_related_navigation);
   m_box_related_navigation->hide();
 
   Gtk::Frame* box_calendar = 0;
-  builder->get_widget("frame_calendar", box_calendar); 
+  builder->get_widget("frame_calendar", box_calendar);
   box_calendar->hide();
 
   builder->get_widget("label_table_name", m_label_table_name);
@@ -319,7 +319,7 @@ void Dialog_Layout_Details::add_group(const Gtk::TreeModel::iterator& parent, co
   }
 }
 
-void Dialog_Layout_Details::set_document(const Glib::ustring& layout_name, const Glib::ustring& layout_platform, Document* document, const Glib::ustring& table_name, const type_vecLayoutFields& table_fields)
+void Dialog_Layout_Details::set_document(const Glib::ustring& layout_name, const Glib::ustring& layout_platform, Document* document, const Glib::ustring& table_name, const type_vecConstLayoutFields& table_fields)
 {
   m_modified = false;
 
@@ -344,7 +344,7 @@ void Dialog_Layout_Details::set_document(const Glib::ustring& layout_name, const
       group->set_columns_count(1);
 
       list_groups.push_back(group);
-    }      
+    }
 
     //Show the field layout
     //typedef std::list< Glib::ustring > type_listStrings;
@@ -519,7 +519,7 @@ void Dialog_Layout_Details::on_button_down()
 void Dialog_Layout_Details::on_button_add_field()
 {
   type_list_field_items fields_list = offer_field_list(m_table_name, this);
-  for(type_list_field_items::iterator iter_chosen = fields_list.begin(); iter_chosen != fields_list.end(); ++iter_chosen) 
+  for(type_list_field_items::iterator iter_chosen = fields_list.begin(); iter_chosen != fields_list.end(); ++iter_chosen)
   {
     sharedptr<LayoutItem_Field> layout_item = *iter_chosen;
     if(!layout_item)
@@ -933,7 +933,7 @@ void Dialog_Layout_Details::on_button_edit()
         if(relationship)
         {
           layout_portal->set_relationship(relationship);
- 
+
           //This is unnecessary and seems to cause a crash.
           //row[m_model_items->m_columns.m_col_layout_item] = layout_portal;
 
@@ -1221,11 +1221,11 @@ void Dialog_Layout_Details::on_cell_data_column_width(Gtk::CellRenderer* rendere
         sharedptr<LayoutItem_Field> layout_field = sharedptr<LayoutItem_Field>::cast_dynamic(layout_item);
         const bool editable = (layout_field || layout_button || layout_text); //Only these have column widths that can be edited.
         renderer_text->property_editable() = editable;
-      
+
         column_width = layout_item->get_display_width();
       }
 
-      Glib::ustring text; 
+      Glib::ustring text;
       if(column_width) //Show nothing if no width has been specified, meaning that it's automatic.
         text = Utils::string_from_decimal(column_width);
 
@@ -1389,12 +1389,3 @@ Glib::ustring Dialog_Layout_Details::get_fields_table() const
 }
 
 } //namespace Glom
-
-
-
-
-
-
-
-
-
diff --git a/glom/mode_design/layout/dialog_layout_details.h b/glom/mode_design/layout/dialog_layout_details.h
index 3059d46..92c0f9d 100644
--- a/glom/mode_design/layout/dialog_layout_details.h
+++ b/glom/mode_design/layout/dialog_layout_details.h
@@ -32,7 +32,7 @@ class Dialog_Layout_Details : public Dialog_Layout
 public:
   static const char* glade_id;
   static const bool glade_developer;
-  
+
   Dialog_Layout_Details(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder);
   virtual ~Dialog_Layout_Details();
 
@@ -43,7 +43,7 @@ public:
    * @param table_name The table name.
    * @param table_fields: The actual fields in the table, in case the document does not yet know about them all.
    */
-  virtual void set_document(const Glib::ustring& layout_name, const Glib::ustring& layout_platform, Document* document, const Glib::ustring& table_name, const type_vecLayoutFields& table_fields);
+  virtual void set_document(const Glib::ustring& layout_name, const Glib::ustring& layout_platform, Document* document, const Glib::ustring& table_name, const type_vecConstLayoutFields& table_fields);
 
 protected:
 
@@ -72,7 +72,7 @@ protected:
   void on_button_up();
   void on_button_down();
   void on_button_field_delete();
-  virtual void on_button_add_field(); //overridden in derived class. 
+  virtual void on_button_add_field(); //overridden in derived class.
   void on_button_add_group();
   void on_button_add_notebook();
   void on_button_add_related();
diff --git a/glom/mode_design/layout/dialog_layout_list_related.cc b/glom/mode_design/layout/dialog_layout_list_related.cc
index 400b7e8..d7acad9 100644
--- a/glom/mode_design/layout/dialog_layout_list_related.cc
+++ b/glom/mode_design/layout/dialog_layout_list_related.cc
@@ -55,7 +55,7 @@ Dialog_Layout_List_Related::Dialog_Layout_List_Related(BaseObjectType* cobject,
   builder->get_widget("checkbutton_show_child_relationships", m_checkbutton_show_child_relationships);
   m_checkbutton_show_child_relationships->signal_toggled().connect(sigc::mem_fun(*this, &Dialog_Layout_List_Related::on_checkbutton_show_child_relationships));
 
-  
+
 
   builder->get_widget("radiobutton_navigation_automatic", m_radio_navigation_automatic);
   builder->get_widget("label_navigation_automatic", m_label_navigation_automatic);
@@ -68,7 +68,7 @@ Dialog_Layout_List_Related::Dialog_Layout_List_Related(BaseObjectType* cobject,
   make_sensitivity_depend_on_toggle_button(*m_radio_navigation_specify, *m_combo_navigation_specify);
   m_combo_navigation_specify->signal_changed().connect(sigc::mem_fun(*this, &Dialog_Layout_List_Related::on_combo_navigation_specific_changed));
 
- 
+
   m_modified = false;
 
   //show_all_children();
@@ -97,7 +97,7 @@ void Dialog_Layout_List_Related::set_document(const Glib::ustring& layout_name,
     if(portal_from_table.empty())
       actual_from_table = portal_from_table;
   }
-  
+
   if(actual_from_table.empty())
     actual_from_table = from_table;
 
@@ -105,8 +105,8 @@ void Dialog_Layout_List_Related::set_document(const Glib::ustring& layout_name,
     m_portal = glom_sharedptr_clone(portal);
   else
     m_portal = sharedptr<LayoutItem_Portal>::create(); //The rest of the class assumes that this is not null.
-  
-  type_vecLayoutFields empty_fields; //Just to satisfy the base class.
+
+  type_vecConstLayoutFields empty_fields; //Just to satisfy the base class.
   Dialog_Layout::set_document(layout_name, layout_platform, document, actual_from_table, empty_fields);
   //m_table_name is now actually the parent_table_name.
 
@@ -130,7 +130,7 @@ void Dialog_Layout_List_Related::update_ui(bool including_relationship_list)
     if(including_relationship_list)
     {
       bool show_child_relationships = m_checkbutton_show_child_relationships->get_active();
-        
+
       //For the showing of child relationships if necessary:
       if(!show_child_relationships && m_portal->get_related_relationship())
       {
@@ -156,7 +156,7 @@ void Dialog_Layout_List_Related::update_ui(bool including_relationship_list)
     Document::type_list_layout_groups mapGroups;
     if(m_portal)
     {
-      m_combo_relationship->set_selected_relationship(m_portal->get_relationship(), m_portal->get_related_relationship()); 
+      m_combo_relationship->set_selected_relationship(m_portal->get_relationship(), m_portal->get_related_relationship());
 
       mapGroups.push_back(m_portal);
       document->fill_layout_field_details(related_table_name, mapGroups); //Update with full field information.
@@ -231,7 +231,7 @@ void Dialog_Layout_List_Related::update_ui(bool including_relationship_list)
   bool navigation_automatic_main = false;
   relationship_navigation_automatic = get_portal_navigation_relationship_automatic(m_portal, navigation_automatic_main);
   Glib::ustring automatic_navigation_description;
-  
+
   if(navigation_automatic_main)
     automatic_navigation_description = m_portal->get_relationship_name_used();
   else if(relationship_navigation_automatic)
@@ -336,45 +336,45 @@ void Dialog_Layout_List_Related::on_combo_relationship_changed()
   sharedptr<Relationship> relationship = m_combo_relationship->get_selected_relationship(relationship_related);
   if(!relationship)
     return;
-    
+
   //Check that the relationship is appropriate for use in a related records portal.
-  //The relationship's to field may not be a unique field, because that would 
+  //The relationship's to field may not be a unique field, because that would
   //prevent the portal from having multiple records.
-  sharedptr<Field> to_key_field = 
-    get_fields_for_table_one_field(relationship->get_to_table(), 
+  sharedptr<Field> to_key_field =
+    get_fields_for_table_one_field(relationship->get_to_table(),
       relationship->get_to_field());
   bool relationship_invalid = false;
   if(!to_key_field)
   {
-    Utils::show_ok_dialog(_("Invalid Relationship"), 
+    Utils::show_ok_dialog(_("Invalid Relationship"),
       _("The relationship may not be used to show related records because the relationship does not specify a field in the related table."),
      *this, Gtk::MESSAGE_ERROR);
     relationship_invalid = true;
   }
   else if(to_key_field->get_primary_key())
   {
-    Utils::show_ok_dialog(_("Relationship Uses a Related Primary Key"), 
+    Utils::show_ok_dialog(_("Relationship Uses a Related Primary Key"),
       _("The relationship may not be used to show related records because the relationship uses a primary key field in the related table, which must contain unique values. This would prevent the relationship from specifying multiple related records."),
      *this, Gtk::MESSAGE_ERROR);
     relationship_invalid = true;
   }
   else if(to_key_field->get_unique_key())
   {
-    Utils::show_ok_dialog(_("Relationship Uses a Related Unique Field"), 
+    Utils::show_ok_dialog(_("Relationship Uses a Related Unique Field"),
       _("The relationship may not be used to show related records because the relationship uses a unique-values field in the related table. This would prevent the relationship from specifying multiple related records."),
      *this, Gtk::MESSAGE_ERROR);
     relationship_invalid = true;
   }
-  
+
   //Reset the previous value if the choice was bad:
   if(relationship_invalid)
   {
     m_combo_relationship->set_selected_relationship(
-       m_portal->get_relationship(), m_portal->get_related_relationship()); 
+       m_portal->get_relationship(), m_portal->get_related_relationship());
     return;
   }
 
-  //Clear the list of fields if the relationship has changed, 
+  //Clear the list of fields if the relationship has changed,
   //because the fields could not possible be correct for the new table:
   bool relationship_changed = false;
   const Glib::ustring old_relationship_name = glom_get_sharedptr_name(m_portal->get_relationship());
@@ -422,7 +422,7 @@ void Dialog_Layout_List_Related::on_button_add_field()
   //std::cout << "debug table used =" << m_portal->get_table_used(m_table_name) << std::endl;
 
   type_list_field_items fields_list = offer_field_list(m_portal->get_table_used(m_table_name), this);
-  for(type_list_field_items::iterator iter_chosen = fields_list.begin(); iter_chosen != fields_list.end(); ++iter_chosen) 
+  for(type_list_field_items::iterator iter_chosen = fields_list.begin(); iter_chosen != fields_list.end(); ++iter_chosen)
   {
     sharedptr<LayoutItem_Field> field = *iter_chosen;
     if(!field)
@@ -490,4 +490,3 @@ Glib::ustring Dialog_Layout_List_Related::get_fields_table() const
 }
 
 } //namespace Glom
-
diff --git a/glom/print_layout/canvas_print_layout.cc b/glom/print_layout/canvas_print_layout.cc
index 100dcea..384459f 100644
--- a/glom/print_layout/canvas_print_layout.cc
+++ b/glom/print_layout/canvas_print_layout.cc
@@ -86,10 +86,10 @@ void Canvas_PrintLayout::set_print_layout(const Glib::ustring& table_name, const
   if(!key_file_text.empty())
   {
     Glib::KeyFile key_file;
-    
+
     //TODO: Catch an exception
     key_file.load_from_data(key_file_text);
-    
+
     //TODO: Use this when gtkmm and GTK+ have been fixed: page_setup = Gtk::PageSetup::create(key_file);
     page_setup = Glib::wrap(gtk_page_setup_new_from_key_file(key_file.gobj(), 0, 0));
   }
@@ -107,11 +107,11 @@ sharedptr<PrintLayout> Canvas_PrintLayout::get_print_layout()
   //Page Setup:
   Glib::KeyFile key_file;
   m_page_setup->save_to_key_file(key_file);
- 
+
   Glib::ustring data;
   //TODO: Catch an exception
   data = key_file.to_data();
-  
+
   result->set_page_setup(data);
 
   return result;
@@ -162,10 +162,10 @@ void Canvas_PrintLayout::add_canvas_layout_item(const Glib::RefPtr<CanvasLayoutI
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   //Connect signals handlers:
-  //TODO: Avoid the bind of a RefPtr. It has been known to cause memory/ref-counting problems: 
+  //TODO: Avoid the bind of a RefPtr. It has been known to cause memory/ref-counting problems:
   item->signal_show_context().connect(
     sigc::bind(
-      sigc::mem_fun(*this, &Canvas_PrintLayout::on_item_show_context_menu), 
+      sigc::mem_fun(*this, &Canvas_PrintLayout::on_item_show_context_menu),
       item) );
 #endif //GLOM_ENABLE_CLIENT_ONLY
 
@@ -256,7 +256,7 @@ void Canvas_PrintLayout::setup_context_menu()
 
   try
   {
-    Glib::ustring ui_info = 
+    Glib::ustring ui_info =
       "<ui>"
       "  <popup name='ContextMenu'>"
       "    <menuitem action='ContextMenuEdit' />"
@@ -273,7 +273,7 @@ void Canvas_PrintLayout::setup_context_menu()
   }
 
   //Get the menu:
-  m_context_menu = dynamic_cast<Gtk::Menu*>( m_context_menu_uimanager->get_widget("/ContextMenu") ); 
+  m_context_menu = dynamic_cast<Gtk::Menu*>( m_context_menu_uimanager->get_widget("/ContextMenu") );
 }
 
 
@@ -362,7 +362,7 @@ void Canvas_PrintLayout::on_context_menu_formatting()
 {
   if(!m_context_item)
     return;
-  
+
   sharedptr<LayoutItem> layout_item = m_context_item->get_layout_item();
   update_layout_position_from_canvas(layout_item, m_context_item);
 
@@ -441,12 +441,12 @@ void Canvas_PrintLayout::update_layout_position_from_canvas(const sharedptr<Layo
   double width = 0;
   double height = 0;
   canvas_item->get_width_height(width, height);
-  layout_item->set_print_layout_position(x, y, width, height); 
+  layout_item->set_print_layout_position(x, y, width, height);
 }
 
 Glib::RefPtr<Goocanvas::Polyline> Canvas_PrintLayout::create_margin_line(double x1, double y1, double x2, double y2)
 {
-  Glib::RefPtr<Goocanvas::Polyline> line = 
+  Glib::RefPtr<Goocanvas::Polyline> line =
     Goocanvas::Polyline::create(x1, y1, x2, y2);
   line->property_line_width() = 0.5;
   line->property_stroke_color() = "light gray";
@@ -497,18 +497,18 @@ void Canvas_PrintLayout::set_page_setup(const Glib::RefPtr<Gtk::PageSetup>& page
   Glib::RefPtr<Goocanvas::Item> root = get_root_item();
   m_bounds_group = Goocanvas::Group::create();
   root->add_child(m_bounds_group);
-  
- 
+
+
   m_bounds_rect = Goocanvas::Rect::create(bounds.get_x1(), bounds.get_y1(), bounds.get_x2(), bounds.get_y2());
   m_bounds_rect->property_fill_color() = "white";
   m_bounds_rect->property_line_width() = 0;
   m_bounds_group->add_child(m_bounds_rect);
 
-  //Make sure that the bounds rect is at the bottom, 
+  //Make sure that the bounds rect is at the bottom,
   //and that the grid and margins are just above it:
   if(m_grid)
     m_grid->lower();
-  
+
   m_margin_left = create_margin_line(page_setup->get_left_margin(units), bounds.get_y1(), page_setup->get_left_margin(units), bounds.get_y2());
   m_margin_right = create_margin_line(bounds.get_x2() - page_setup->get_right_margin(units), bounds.get_y1(), bounds.get_x2() - page_setup->get_right_margin(units), bounds.get_y2());
   m_margin_top = create_margin_line(bounds.get_x1(), page_setup->get_top_margin(units), bounds.get_x2(), page_setup->get_top_margin(units));
@@ -535,7 +535,7 @@ void Canvas_PrintLayout::fill_with_data(const Glib::RefPtr<Goocanvas::Group>& ca
 
   typedef std::list< sharedptr<LayoutItem_Portal> > type_list_portals;
   type_list_portals list_portals;
-  
+
   //Get list of fields to get from the database.
   Utils::type_vecLayoutFields fieldsToGet;
   const int count = canvas_group->get_n_children();
@@ -546,17 +546,17 @@ void Canvas_PrintLayout::fill_with_data(const Glib::RefPtr<Goocanvas::Group>& ca
     Glib::RefPtr<CanvasLayoutItem> canvas_item = Glib::RefPtr<CanvasLayoutItem>::cast_dynamic(base_canvas_item);
     if(!canvas_item)
       continue;
-      
+
     sharedptr<LayoutItem> layout_item = canvas_item->get_layout_item();
     if(!layout_item)
       continue;
-      
+
     sharedptr<LayoutItem_Field> layoutitem_field = sharedptr<LayoutItem_Field>::cast_dynamic(layout_item);
     if(layoutitem_field && !(layoutitem_field->get_name().empty()))
     {
       fieldsToGet.push_back(layoutitem_field);
-      
-      //Remember the index so we can use it later, 
+
+      //Remember the index so we can use it later,
       //to get the data for this column from the query results:
       map_fields_index[ layoutitem_field->get_layout_display_name() ] = field_i;
       ++field_i;
@@ -585,7 +585,7 @@ void Canvas_PrintLayout::fill_with_data(const Glib::RefPtr<Goocanvas::Group>& ca
     fieldsToGet,
     found_set.m_where_clause, sharedptr<const Relationship>() /* extra_join */, found_set.m_sort_clause,
     1);
-  
+
   bool records_found = false;
   Glib::RefPtr<Gnome::Gda::DataModel> datamodel;
   try
@@ -607,7 +607,7 @@ void Canvas_PrintLayout::fill_with_data(const Glib::RefPtr<Goocanvas::Group>& ca
     if(rows_count > 0)
       records_found = true;
   }
-  
+
   if(!records_found)
     return;
 
@@ -619,14 +619,14 @@ void Canvas_PrintLayout::fill_with_data(const Glib::RefPtr<Goocanvas::Group>& ca
     Glib::RefPtr<CanvasLayoutItem> canvas_item = Glib::RefPtr<CanvasLayoutItem>::cast_dynamic(base_canvas_item);
     if(!canvas_item)
       continue;
-      
+
     sharedptr<LayoutItem> layout_item = canvas_item->get_layout_item();
     if(!layout_item)
       continue;
-      
+
     sharedptr<LayoutItem_Field> layoutitem_field = sharedptr<LayoutItem_Field>::cast_dynamic(layout_item);
     if(layoutitem_field)
-    { 
+    {
       type_map_layout_fields_index::const_iterator iterFind = map_fields_index.find( layoutitem_field->get_layout_display_name() );
       if(iterFind != map_fields_index.end())
       {
@@ -670,9 +670,9 @@ void Canvas_PrintLayout::fill_with_data_portal(const Glib::RefPtr<CanvasLayoutIt
   //TODO: Move the child stuff into group in goocanvas.
 
   LayoutGroup::type_list_items child_layout_items = portal->get_items();
-  
+
   //Build and run the SQL query for this portal:
-  type_vecLayoutFields fields_shown = get_portal_fields_to_show(portal);
+  type_vecConstLayoutFields fields_shown = get_portal_fields_to_show(portal);
 
   FoundSet found_set;
   found_set.m_table_name = portal->get_table_used(Glib::ustring() /* parent table_name, not used. */);
@@ -683,11 +683,11 @@ void Canvas_PrintLayout::fill_with_data_portal(const Glib::RefPtr<CanvasLayoutIt
   Glib::RefPtr<Gnome::Gda::DataModel> datamodel = DbUtils::query_execute_select(sql_query);
   if(!(datamodel))
     return;
-    
+
   const int db_rows_count = datamodel->get_n_rows();
   if(!(db_rows_count > 0))
     return;
-    
+
   const int db_columns_count = datamodel->get_n_columns();
   if(!db_columns_count)
     return;
@@ -710,7 +710,7 @@ void Canvas_PrintLayout::fill_with_data_portal(const Glib::RefPtr<CanvasLayoutIt
 
       if(iter_child_layout_items == child_layout_items.end())
         continue;
-      
+
       sharedptr<LayoutItem> child_layout_item = *iter_child_layout_items;
       sharedptr<LayoutItem_Field> field = sharedptr<LayoutItem_Field>::cast_dynamic(child_layout_item);
       if(field)
@@ -721,7 +721,7 @@ void Canvas_PrintLayout::fill_with_data_portal(const Glib::RefPtr<CanvasLayoutIt
           //TODO: Actually catch exception.
           db_value = datamodel->get_value_at(db_col, row);
         }
-          
+
         set_canvas_item_field_value(canvas_child, field, db_value);
         ++db_col;
       }
@@ -757,7 +757,7 @@ void Canvas_PrintLayout::set_canvas_item_field_value(const Glib::RefPtr<Goocanva
 
     //FieldFormatting& formatting = field->m_formatting;
     //apply_formatting(canvas_item, formatting);
-    const Glib::ustring text = 
+    const Glib::ustring text =
       Conversions::get_text_for_gda_value(field->get_glom_type(), value, field->m_formatting.m_numeric_format);
     canvas_text->set_text(text);
   }
@@ -789,7 +789,7 @@ void Canvas_PrintLayout::set_grid_gap(double gap)
 {
   CanvasEditable::set_grid_gap(gap);
 
-  //Make sure that the bounds rect is at the bottom, 
+  //Make sure that the bounds rect is at the bottom,
   //and that the grid and margins are just above it:
   if(m_grid)
     m_grid->lower();
@@ -816,7 +816,7 @@ Glib::RefPtr<Goocanvas::Item> Canvas_PrintLayout::get_canvas_table_cell_child(co
     table->get_child_property(child, "column", column_value);
     int row_value = 0;
     table->get_child_property(child, "row", row_value);
-       
+
     //This assumes that all items occupy only one cell:
     if( (column_value == col) &&
         (row_value == row) )
@@ -830,7 +830,7 @@ Glib::RefPtr<Goocanvas::Item> Canvas_PrintLayout::get_canvas_table_cell_child(co
 
 
 
-Base_DB::type_vecLayoutFields Canvas_PrintLayout::get_portal_fields_to_show(const sharedptr<LayoutItem_Portal>& portal)
+Base_DB::type_vecConstLayoutFields Canvas_PrintLayout::get_portal_fields_to_show(const sharedptr<LayoutItem_Portal>& portal)
 {
   const Document* document = get_document();
   if(!document)
@@ -844,27 +844,27 @@ Base_DB::type_vecLayoutFields Canvas_PrintLayout::get_portal_fields_to_show(cons
     sharedptr<const Relationship> relationship = portal->get_relationship();
     if(relationship)
     {
-      type_vecLayoutFields result = get_table_fields_to_show_for_sequence(portal->get_table_used(Glib::ustring() /* not relevant */), mapGroups);
+      type_vecConstLayoutFields result = get_table_fields_to_show_for_sequence(portal->get_table_used(Glib::ustring() /* not relevant */), mapGroups);
 
       //If the relationship does not allow editing, then mark all these fields as non-editable:
+      /* TODO: Find a better way to do this.
       if(!(portal->get_relationship_used_allows_edit()))
       {
-        for(type_vecLayoutFields::iterator iter = result.begin(); iter != result.end(); ++iter)
+        for(type_vecConstLayoutFields::iterator iter = result.begin(); iter != result.end(); ++iter)
         {
-          sharedptr<LayoutItem_Field> item = *iter;
+          sharedptr<const LayoutItem_Field> item = *iter;
           if(item)
             item->set_editable(false);
         }
       }
+      */
 
       return result;
     }
   }
 
-  return type_vecLayoutFields();
+  return type_vecConstLayoutFields();
 }
 
 
 } //namespace Glom
-
-
diff --git a/glom/print_layout/canvas_print_layout.h b/glom/print_layout/canvas_print_layout.h
index 28c0d51..ec8e326 100644
--- a/glom/print_layout/canvas_print_layout.h
+++ b/glom/print_layout/canvas_print_layout.h
@@ -81,7 +81,7 @@ private:
 
   static Glib::RefPtr<Goocanvas::Item> get_canvas_table_cell_child(const Glib::RefPtr<Goocanvas::Table>& table, int row, int col); //TODO: Add this to Goocanvas::Table.
   
-  type_vecLayoutFields get_portal_fields_to_show(const sharedptr<LayoutItem_Portal>& portal);
+  type_vecConstLayoutFields get_portal_fields_to_show(const sharedptr<LayoutItem_Portal>& portal);
 
 #ifndef GLOM_ENABLE_CLIENT_ONLY
   sharedptr<LayoutItem_Portal> offer_related_records(const sharedptr<LayoutItem_Portal>& portal, Gtk::Window* parent);



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