[glom] Use auto for DataModel, though we lose some constness.



commit c616684650a9e81a0d82f8b73a1698601bb6562a
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Mar 7 16:48:14 2016 +0100

    Use auto for DataModel, though we lose some constness.

 glom/base_db.cc                             |    8 ++++----
 glom/base_db_table_data.cc                  |    2 +-
 glom/frame_glom.cc                          |    2 +-
 glom/libglom/db_utils.cc                    |    2 +-
 glom/mode_data/box_data_calendar_related.cc |    2 +-
 glom/mode_data/box_data_portal.cc           |    2 +-
 glom/mode_data/datawidget/treemodel_db.cc   |    2 +-
 glom/print_layout/canvas_print_layout.cc    |    2 +-
 8 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/glom/base_db.cc b/glom/base_db.cc
index d51e7ae..1c66390 100644
--- a/glom/base_db.cc
+++ b/glom/base_db.cc
@@ -1032,7 +1032,7 @@ Gnome::Gda::Value Base_DB::get_field_value_in_database(const LayoutFieldInRecord
   auto sql_query = Utils::build_sql_select_with_key(field_in_record.m_table_name,
     list_fields, field_in_record.m_key, field_in_record.m_key_value, type_sort_clause(), 1);
 
-  Glib::RefPtr<const Gnome::Gda::DataModel> data_model = DbUtils::query_execute_select(sql_query);
+  auto data_model = DbUtils::query_execute_select(sql_query);
   if(data_model)
   {
     if(data_model->get_n_rows())
@@ -1075,7 +1075,7 @@ Gnome::Gda::Value Base_DB::get_field_value_in_database(const std::shared_ptr<Fie
     std::shared_ptr<const Relationship>() /* extra_join */, type_sort_clause(),
     1 /* limit */);
 
-  Glib::RefPtr<const Gnome::Gda::DataModel> data_model = DbUtils::query_execute_select(sql_query);
+  auto data_model = DbUtils::query_execute_select(sql_query);
   if(data_model)
   {
     if(data_model->get_n_rows())
@@ -1298,7 +1298,7 @@ bool Base_DB::get_field_value_is_unique(const Glib::ustring& table_name, const s
       builder->add_field_id(field->get_name(), table_name_used),
       builder->add_expr(value)));
 
-  Glib::RefPtr<const Gnome::Gda::DataModel> data_model = DbUtils::query_execute_select(builder);
+  auto data_model = DbUtils::query_execute_select(builder);
   if(data_model)
   {
     //std::cout << "debug: " << G_STRFUNC << ": table_name=" << table_name << ", field name=" << 
field->get_name() << ", value=" << value.to_string() << ", rows count=" << data_model->get_n_rows() << 
std::endl;
@@ -1395,7 +1395,7 @@ bool Base_DB::get_primary_key_is_in_foundset(const FoundSet& found_set, const Gn
   auto query =
     Utils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsToGet,
       builder->export_expression(cond_id));
-  Glib::RefPtr<const Gnome::Gda::DataModel> data_model = DbUtils::query_execute_select(query);
+  auto data_model = DbUtils::query_execute_select(query);
 
   if(data_model && data_model->get_n_rows())
   {
diff --git a/glom/base_db_table_data.cc b/glom/base_db_table_data.cc
index 892f86b..a4b5b73 100644
--- a/glom/base_db_table_data.cc
+++ b/glom/base_db_table_data.cc
@@ -495,7 +495,7 @@ void Base_DB_Table_Data::refresh_related_fields(const LayoutFieldInRecord& field
     auto query = Utils::build_sql_select_with_key(field_in_record_changed.m_table_name, fieldsToGet, 
field_in_record_changed.m_key, field_in_record_changed.m_key_value);
     //std::cout << "debug: " << G_STRFUNC << ": query=" << query << std::endl;
 
-    Glib::RefPtr<const Gnome::Gda::DataModel> result = DbUtils::query_execute_select(query);
+    auto result = DbUtils::query_execute_select(query);
     if(!result)
     {
       std::cerr << G_STRFUNC << ": no result.\n";
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index 8de6b5c..d8eb2ec 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -648,7 +648,7 @@ void Frame_Glom::export_data_to_stream(std::ostream& the_stream, const FoundSet&
   auto query = Utils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsSequence, 
found_set.m_where_clause, found_set.m_extra_join, found_set.m_sort_clause);
 
   //TODO: Lock the database (prevent changes) during export.
-  Glib::RefPtr<const Gnome::Gda::DataModel> result = DbUtils::query_execute_select(query);
+  auto result = DbUtils::query_execute_select(query);
 
   guint rows_count = 0;
   if(result)
diff --git a/glom/libglom/db_utils.cc b/glom/libglom/db_utils.cc
index 493b7db..c0586e7 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -1445,7 +1445,7 @@ Gnome::Gda::Value auto_increment_insert_first_if_necessary(const Glib::ustring&
   builder->select_add_target(GLOM_STANDARD_TABLE_AUTOINCREMENTS_TABLE_NAME);
   builder_set_where_autoincrement(builder, table_name, field_name);
 
-  const Glib::RefPtr<const Gnome::Gda::DataModel> datamodel = query_execute_select(builder);
+  const auto datamodel = query_execute_select(builder);
   if(!datamodel || (datamodel->get_n_rows() == 0))
   {
     //Start with zero:
diff --git a/glom/mode_data/box_data_calendar_related.cc b/glom/mode_data/box_data_calendar_related.cc
index 15e13b3..0ad1a93 100644
--- a/glom/mode_data/box_data_calendar_related.cc
+++ b/glom/mode_data/box_data_calendar_related.cc
@@ -212,7 +212,7 @@ bool Box_Data_Calendar_Related::fill_from_database()
 
     auto sql_query = Utils::build_sql_select_with_where_clause(m_found_set.m_table_name, m_FieldsShown, 
where_clause, m_found_set.m_extra_join, m_found_set.m_sort_clause);
     //std::cout << "DEBUG: sql_query=" << sql_query << std::endl;
-    Glib::RefPtr<const Gnome::Gda::DataModel> datamodel = DbUtils::query_execute_select(sql_query);
+    auto datamodel = DbUtils::query_execute_select(sql_query);
     if(!(datamodel))
       return true;
 
diff --git a/glom/mode_data/box_data_portal.cc b/glom/mode_data/box_data_portal.cc
index 9e10526..3b96f44 100644
--- a/glom/mode_data/box_data_portal.cc
+++ b/glom/mode_data/box_data_portal.cc
@@ -287,7 +287,7 @@ void Box_Data_Portal::get_suitable_record_to_view_details(const Gnome::Gda::Valu
   //std::cout << "DEBUG: related table=" << related_table << ", whose primary_key=" << key_field->get_name() 
<< ", with value=" << primary_key_value.to_string() << "getting value for: " << 
layout_item->get_layout_display_name() << std::endl;
 
   auto query = Utils::build_sql_select_with_key(related_table, fieldsToGet, key_field, primary_key_value);
-  Glib::RefPtr<const Gnome::Gda::DataModel> data_model = DbUtils::query_execute_select(query);
+  auto data_model = DbUtils::query_execute_select(query);
 
 
   bool value_found = true;
diff --git a/glom/mode_data/datawidget/treemodel_db.cc b/glom/mode_data/datawidget/treemodel_db.cc
index c690781..1d4b5bf 100644
--- a/glom/mode_data/datawidget/treemodel_db.cc
+++ b/glom/mode_data/datawidget/treemodel_db.cc
@@ -115,7 +115,7 @@ void DbTreeModelRow::fill_values_if_necessary(DbTreeModel& model, int row)
 
       //Create default values, if necessary, of the correct types:
       //Examine the columns in the returned DataModel:
-      const Glib::RefPtr<const Gnome::Gda::DataModel> datamodel = model.m_gda_datamodel;
+      const auto datamodel = model.m_gda_datamodel;
       for(guint col = 0; col < model.m_data_model_columns_count; ++col)
       {
         if(m_db_values.find(col) == m_db_values.end()) //If there is not already a value in the map for this 
column.
diff --git a/glom/print_layout/canvas_print_layout.cc b/glom/print_layout/canvas_print_layout.cc
index a88c5ba..547892f 100644
--- a/glom/print_layout/canvas_print_layout.cc
+++ b/glom/print_layout/canvas_print_layout.cc
@@ -906,7 +906,7 @@ void Canvas_PrintLayout::fill_with_data_portal(const Glib::RefPtr<CanvasLayoutIt
 
   const Glib::RefPtr<Gnome::Gda::SqlBuilder> sql_query = 
Utils::build_sql_select_with_where_clause(found_set.m_table_name, fields_shown, found_set.m_where_clause, 
found_set.m_extra_join, found_set.m_sort_clause);
   //std::cout << "DEBUG: sql_query=" << sql_query << std::endl;
-  const Glib::RefPtr<const Gnome::Gda::DataModel> datamodel = DbUtils::query_execute_select(sql_query);
+  const auto datamodel = DbUtils::query_execute_select(sql_query);
   if(!(datamodel))
     return;
 


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