Commit 804110db authored by Murray Cumming's avatar Murray Cumming
Browse files

C++: Use auto

parent 4823dba0
......@@ -67,7 +67,7 @@ void Application::create_window(const Glib::RefPtr<Gio::File>& file)
input_uri = file->get_uri();
}
const bool test = window->init_with_document(input_uri, m_remote_option_group.m_arg_restore); //Sets it up and shows it.
const auto test = window->init_with_document(input_uri, m_remote_option_group.m_arg_restore); //Sets it up and shows it.
if(!test) //The user could cancel the offer of a new or existing database.
{
window->hide(); //This will cause it to be deleted by on_window_hide.
......@@ -172,7 +172,7 @@ int Application::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>
return EXIT_FAILURE;
bool stop = false;
const bool date_check_ok = local_group.get_debug_date_check_result(stop);
const auto date_check_ok = local_group.get_debug_date_check_result(stop);
if(stop)
{
//This command-line option is documented as stopping afterwards.
......@@ -206,7 +206,7 @@ int Application::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine>
return EXIT_FAILURE;
}
const Gio::FileType file_type = file->query_file_type();
const auto file_type = file->query_file_type();
if(file_type == Gio::FILE_TYPE_DIRECTORY)
{
std::cerr << _("Glom: The file path is a directory instead of a file.") << std::endl;
......
This diff is collapsed.
......@@ -71,7 +71,7 @@ void AppWindow_WithDoc::on_menu_file_close()
bool AppWindow_WithDoc::open_document_from_data(const guchar* data, std::size_t length)
{
int failure_code = 0;
const bool bTest = m_pDocument->load_from_data(data, length, failure_code);
const auto bTest = m_pDocument->load_from_data(data, length, failure_code);
bool bOpenFailed = false;
if(!bTest) //if open failed.
......@@ -79,7 +79,7 @@ bool AppWindow_WithDoc::open_document_from_data(const guchar* data, std::size_t
else
{
//if open succeeded then let the App respond:
const bool test = on_document_load();
const auto test = on_document_load();
if(!test)
bOpenFailed = true; //The application didn't like something about the just-loaded document.
else
......@@ -111,12 +111,12 @@ bool AppWindow_WithDoc::open_document(const Glib::ustring& file_uri)
return true;
}
AppWindow_WithDoc* pApp = this; //Replace the default new document in this instance.
auto pApp = this; //Replace the default new document in this instance.
//Open it.
pApp->m_pDocument->set_file_uri(file_uri);
int failure_code = 0;
const bool bTest = pApp->m_pDocument->load(failure_code);
const auto bTest = pApp->m_pDocument->load(failure_code);
bool bOpenFailed = false;
bool bShowError = false;
......@@ -128,7 +128,7 @@ bool AppWindow_WithDoc::open_document(const Glib::ustring& file_uri)
else
{
//if open succeeded then let the App respond:
const bool test = pApp->on_document_load();
const auto test = pApp->on_document_load();
if(!test)
bOpenFailed = true; //The application didn't like something about the just-loaded document.
else
......@@ -172,7 +172,7 @@ void AppWindow_WithDoc::on_menu_file_open()
ui_bring_to_front();
//Ask user to choose file to open:
Glib::ustring file_uri = ui_file_select_open();
auto file_uri = ui_file_select_open();
if(!file_uri.empty())
open_document(file_uri);
}
......@@ -191,7 +191,7 @@ bool AppWindow_WithDoc::file_exists(const Glib::ustring& uri)
//Check whether file exists already:
{
// Try to examine the input file.
Glib::RefPtr<Gio::File> file = Gio::File::create_for_uri(uri);
auto file = Gio::File::create_for_uri(uri);
try
{
......@@ -213,16 +213,16 @@ void AppWindow_WithDoc::on_menu_file_saveas()
ui_bring_to_front();
//Show the save dialog:
const Glib::ustring& file_uriOld = m_pDocument->get_file_uri();
const auto file_uriOld = m_pDocument->get_file_uri();
Glib::ustring file_uri = ui_file_select_save(file_uriOld); //Also asks for overwrite confirmation.
auto file_uri = ui_file_select_save(file_uriOld); //Also asks for overwrite confirmation.
if(!file_uri.empty())
{
//Enforce the file extension:
file_uri = m_pDocument->get_file_uri_with_extension(file_uri);
m_pDocument->set_file_uri(file_uri, true); //true = enforce file extension
const bool bTest = m_pDocument->save();
const auto bTest = m_pDocument->save();
if(!bTest)
{
......@@ -256,7 +256,7 @@ void AppWindow_WithDoc::on_menu_file_save()
//If there is already a filepath, then save to that location:
if(!(m_pDocument->get_file_uri().empty()))
{
bool bTest = m_pDocument->save();
auto bTest = m_pDocument->save();
if(bTest)
{
......@@ -337,7 +337,7 @@ void AppWindow_WithDoc::offer_to_save_changes()
//The document has unsaved changes,
//so ask the user whether the document should be saved:
enumSaveChanges buttonClicked = ui_offer_to_save_changes();
auto buttonClicked = ui_offer_to_save_changes();
//Respond to button that was clicked:
switch(buttonClicked)
......@@ -384,7 +384,7 @@ bool AppWindow_WithDoc::on_document_load()
//Show document contents:
if(m_pDocument)
{
GlomBakery::ViewBase* pView = m_pDocument->get_view();
auto pView = m_pDocument->get_view();
if(pView)
pView->load_from_document();
......@@ -430,21 +430,21 @@ void AppWindow_WithDoc::set_document_modified(bool bModified /* = true */)
void AppWindow_WithDoc::on_menu_edit_copy()
{
GlomBakery::ViewBase* pView = m_pDocument->get_view();
auto pView = m_pDocument->get_view();
if(pView)
pView->clipboard_copy();
}
void AppWindow_WithDoc::on_menu_edit_paste()
{
GlomBakery::ViewBase* pView = m_pDocument->get_view();
auto pView = m_pDocument->get_view();
if(pView)
pView->clipboard_paste();
}
void AppWindow_WithDoc::on_menu_edit_clear()
{
GlomBakery::ViewBase* pView = m_pDocument->get_view();
auto pView = m_pDocument->get_view();
if(pView)
pView->clipboard_clear();
}
......
......@@ -33,7 +33,7 @@ void BusyCursor::init()
if(!m_refWindow)
return;
type_map_cursors::iterator iter = m_map_cursors.find(m_pWindow);
auto iter = m_map_cursors.find(m_pWindow);
if(iter != m_map_cursors.end())
{
m_old_cursor = iter->second; //Remember the existing cursor.
......@@ -62,7 +62,7 @@ BusyCursor::~BusyCursor()
if(m_refWindow)
m_refWindow->set_cursor();
type_map_cursors::iterator iter = m_map_cursors.find(m_pWindow);
auto iter = m_map_cursors.find(m_pWindow);
if(iter != m_map_cursors.end())
m_map_cursors.erase(iter);
}
......
......@@ -359,7 +359,7 @@ std::shared_ptr<LayoutItem_Field> Base_DB::offer_field_list_select_one_field(con
dialog->set_transient_for(*transient_for);
dialog->set_document(get_document(), table_name, start_field);
const int response = dialog->run();
const auto response = dialog->run();
if(response == Gtk::RESPONSE_OK)
{
//Get the chosen field:
......@@ -389,7 +389,7 @@ Base_DB::type_list_field_items Base_DB::offer_field_list(const Glib::ustring& ta
dialog->set_transient_for(*transient_for);
dialog->set_document(get_document(), table_name);
const int response = dialog->run();
const auto response = dialog->run();
if(response == Gtk::RESPONSE_OK)
{
//Get the chosen field:
......@@ -414,7 +414,7 @@ bool Base_DB::offer_non_field_item_formatting(const std::shared_ptr<LayoutItem_W
dialog.set_item(layout_item, false);
const int response = dialog.run();
const auto response = dialog.run();
if(response == Gtk::RESPONSE_OK)
{
//Get the chosen formatting:
......@@ -444,7 +444,7 @@ std::shared_ptr<LayoutItem_Field> Base_DB::offer_field_formatting(const std::sha
dialog->set_field(start_field, table_name, show_editable_options);
const int response = dialog->run();
const auto response = dialog->run();
if(response == Gtk::RESPONSE_OK)
{
//Get the chosen field:
......@@ -472,7 +472,7 @@ std::shared_ptr<LayoutItem_Text> Base_DB::offer_textobject(const std::shared_ptr
dialog->set_transient_for(*transient_for);
dialog->set_textobject(start_textobject, Glib::ustring(), show_title);
const int response = Glom::UiUtils::dialog_run_with_help(dialog);
const auto response = Glom::UiUtils::dialog_run_with_help(dialog);
dialog->hide();
if(response == Gtk::RESPONSE_OK)
{
......@@ -498,7 +498,7 @@ std::shared_ptr<LayoutItem_Image> Base_DB::offer_imageobject(const std::shared_p
dialog->set_transient_for(*transient_for);
dialog->set_imageobject(start_imageobject, Glib::ustring(), show_title);
const int response = Glom::UiUtils::dialog_run_with_help(dialog);
const auto response = Glom::UiUtils::dialog_run_with_help(dialog);
dialog->hide();
if(response == Gtk::RESPONSE_OK)
{
......@@ -525,7 +525,7 @@ std::shared_ptr<LayoutItem_Notebook> Base_DB::offer_notebook(const std::shared_p
dialog->set_notebook(start_notebook);
//dialog->set_transient_for(*this);
const int response = Glom::UiUtils::dialog_run_with_help(dialog);
const auto response = Glom::UiUtils::dialog_run_with_help(dialog);
dialog->hide();
if(response == Gtk::RESPONSE_OK)
{
......@@ -591,7 +591,7 @@ bool Base_DB::get_field_primary_key_index_for_fields(const type_vecLayoutFields&
std::shared_ptr<Field> Base_DB::get_field_primary_key_for_table(const Glib::ustring& table_name) const
{
const Document* document = get_document();
const auto document = get_document();
if(document)
{
//TODO_Performance: Cache this result?
......@@ -628,7 +628,7 @@ void Base_DB::get_table_fields_to_show_for_sequence_add_group(const Glib::ustrin
if(item_field)
{
//Get the field info:
const Glib::ustring field_name = item->get_name();
const auto field_name = item->get_name();
if(item_field->get_has_relationship_name()) //If it's a field in a related table.
{
......@@ -641,7 +641,7 @@ void Base_DB::get_table_fields_to_show_for_sequence_add_group(const Glib::ustrin
//TODO_Performance: We do this once for each related field, even if there are 2 from the same table:
const Privileges privs_related = Privs::get_current_privs(item_field->get_table_used(table_name));
const auto privs_related = Privs::get_current_privs(item_field->get_table_used(table_name));
layout_item->m_priv_view = privs_related.m_view;
layout_item->m_priv_edit = privs_related.m_edit;
......@@ -700,7 +700,7 @@ Base_DB::type_vecConstLayoutFields Base_DB::get_table_fields_to_show_for_sequenc
//Get field definitions from the database, with corrections from the document:
type_vec_fields all_fields = DbUtils::get_fields_for_table(pDoc, table_name);
const Privileges table_privs = Privs::get_current_privs(table_name);
const auto table_privs = Privs::get_current_privs(table_name);
//Get fields that the document says we should show:
type_vecConstLayoutFields result;
......@@ -807,10 +807,10 @@ void Base_DB::calculate_field_in_all_records(const Glib::ustring& table_name, co
field_in_record.m_key = primary_key;
//Calculate the value for the field in every record:
const int rows_count = data_model->get_n_rows();
const auto rows_count = data_model->get_n_rows();
for(int row = 0; row < rows_count; ++row)
{
const Gnome::Gda::Value primary_key_value = data_model->get_value_at(0, row);
const auto primary_key_value = data_model->get_value_at(0, row);
if(!Conversions::value_is_empty(primary_key_value))
{
......@@ -824,7 +824,7 @@ void Base_DB::calculate_field_in_all_records(const Glib::ustring& table_name, co
void Base_DB::calculate_field(const LayoutFieldInRecord& field_in_record)
{
const Glib::ustring field_name = field_in_record.m_field->get_name();
const auto field_name = field_in_record.m_field->get_name();
//std::cerr << G_STRFUNC << ": field_name=" << field_name << std::endl;
//Do we already have this in our list?
......@@ -864,7 +864,7 @@ void Base_DB::calculate_field(const LayoutFieldInRecord& field_in_record)
//Calculate dependencies first:
//TODO: Prevent unncessary recalculations?
const type_list_const_field_items fields_needed = get_calculation_fields(field_in_record.m_table_name, field_in_record.m_field);
const auto fields_needed = get_calculation_fields(field_in_record.m_table_name, field_in_record.m_field);
for(type_list_const_field_items::const_iterator iterNeeded = fields_needed.begin(); iterNeeded != fields_needed.end(); ++iterNeeded)
{
std::shared_ptr<const LayoutItem_Field> field_item_needed = *iterNeeded;
......@@ -908,7 +908,7 @@ void Base_DB::calculate_field(const LayoutFieldInRecord& field_in_record)
{
//recalculate:
//TODO_Performance: We don't know what fields the python calculation will use, so we give it all of them:
const type_map_fields field_values = get_record_field_values_for_calculation(field_in_record.m_table_name, field_in_record.m_key, field_in_record.m_key_value);
const auto field_values = get_record_field_values_for_calculation(field_in_record.m_table_name, field_in_record.m_key, field_in_record.m_key_value);
if(!field_values.empty())
{
std::shared_ptr<const Field> field = refCalcProgress.m_field;
......@@ -958,7 +958,7 @@ void Base_DB::calculate_field(const LayoutFieldInRecord& field_in_record)
Base_DB::type_map_fields Base_DB::get_record_field_values_for_calculation(const Glib::ustring& table_name, const std::shared_ptr<const Field>& primary_key, const Gnome::Gda::Value& primary_key_value)
{
const Document* document = get_document();
const auto document = get_document();
return DbUtils::get_record_field_values(document, table_name, primary_key, primary_key_value);
}
......@@ -983,7 +983,7 @@ bool Base_DB::set_field_value_in_database(const LayoutFieldInRecord& layoutfield
Document* document = get_document();
g_assert(document);
const FieldInRecord field_in_record = layoutfield_in_record.get_fieldinrecord(*document);
const auto field_in_record = layoutfield_in_record.get_fieldinrecord(*document);
//row is invalid, and ignored, for Box_Data_Details.
if(!(field_in_record.m_field))
......@@ -998,7 +998,7 @@ bool Base_DB::set_field_value_in_database(const LayoutFieldInRecord& layoutfield
return false;
}
const Glib::ustring field_name = field_in_record.m_field->get_name();
const auto field_name = field_in_record.m_field->get_name();
if(!field_name.empty()) //This should not happen.
{
const Gnome::Gda::SqlExpr where_clause =
......@@ -1010,7 +1010,7 @@ bool Base_DB::set_field_value_in_database(const LayoutFieldInRecord& layoutfield
try //TODO: The exceptions are probably already handled by query_execute(
{
const bool test = DbUtils::query_execute(builder); //TODO: Respond to failure.
const auto test = DbUtils::query_execute(builder); //TODO: Respond to failure.
if(!test)
{
std::cerr << G_STRFUNC << ": UPDATE failed." << std::endl;
......@@ -1189,7 +1189,7 @@ Base_DB::type_list_const_field_items Base_DB::get_calculated_fields(const Glib::
//Look at each field in the table, and get lists of what fields trigger their calculations,
//so we can see if our field is in any of those lists:
const type_vec_fields fields = document->get_table_fields(table_name); //TODO_Performance: Cache this?
const auto fields = document->get_table_fields(table_name); //TODO_Performance: Cache this?
//Examine all fields, not just the the shown fields.
//TODO: How do we trigger relcalculation of related fields if necessary?
for(type_vec_fields::const_iterator iter = fields.begin(); iter != fields.end(); ++iter)
......@@ -1201,7 +1201,7 @@ Base_DB::type_list_const_field_items Base_DB::get_calculated_fields(const Glib::
//std::cout << " debug: examining field=" << field_to_examine->get_name() << std::endl;
//Does this field's calculation use the field?
const type_list_const_field_items fields_triggered = get_calculation_fields(table_name, layoutitem_field_to_examine);
const auto fields_triggered = get_calculation_fields(table_name, layoutitem_field_to_examine);
//std::cout << " debug: field_triggered.size()=" << fields_triggered.size() << std::endl;
type_list_const_field_items::const_iterator iterFind = std::find_if(fields_triggered.begin(), fields_triggered.end(), predicate_LayoutItemIsEqual<LayoutItem_Field>(field));
if(iterFind != fields_triggered.end())
......@@ -1231,7 +1231,7 @@ Base_DB::type_list_const_field_items Base_DB::get_calculation_fields(const Glib:
return result;
Glib::ustring::size_type index = 0;
const Glib::ustring calculation = field->get_calculation();
const auto calculation = field->get_calculation();
if(calculation.empty())
return result;
......@@ -1239,9 +1239,9 @@ Base_DB::type_list_const_field_items Base_DB::get_calculation_fields(const Glib:
if(!document)
return result;
const Glib::ustring::size_type count = calculation.size();
const auto count = calculation.size();
const Glib::ustring prefix = "record[\"";
const Glib::ustring::size_type prefix_size = prefix.size();
const auto prefix_size = prefix.size();
while(index < count)
{
......@@ -1252,7 +1252,7 @@ Base_DB::type_list_const_field_items Base_DB::get_calculation_fields(const Glib:
if(pos_find_end != Glib::ustring::npos)
{
Glib::ustring::size_type pos_start = pos_find + prefix_size;
const Glib::ustring field_name = calculation.substr(pos_start, pos_find_end - pos_start);
const auto field_name = calculation.substr(pos_start, pos_find_end - pos_start);
std::shared_ptr<Field> field_found = document->get_field(table_name, field_name);
if(field)
......@@ -1271,14 +1271,14 @@ Base_DB::type_list_const_field_items Base_DB::get_calculation_fields(const Glib:
}
//Check the use of related records too:
const Field::type_list_strings relationships_used = field->get_calculation_relationships();
const auto relationships_used = field->get_calculation_relationships();
for(Field::type_list_strings::const_iterator iter = relationships_used.begin(); iter != relationships_used.end(); ++iter)
{
std::shared_ptr<Relationship> relationship = document->get_relationship(table_name, *iter);
if(relationship)
{
//If the field uses this relationship then it should be triggered by a change in the key that specifies which record the relationship points to:
const Glib::ustring field_from_name = relationship->get_from_field();
const auto field_from_name = relationship->get_from_field();
std::shared_ptr<Field> field_from = document->get_field(table_name, field_from_name);
if(field_from)
{
......@@ -1302,8 +1302,8 @@ void Base_DB::do_lookups(const LayoutFieldInRecord& field_in_record, const Gtk::
//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.m_field->get_name();
const Document::type_list_lookups lookups = document->get_lookup_fields(field_in_record.m_table_name, strFieldName);
const auto strFieldName = field_in_record.m_field->get_name();
const auto lookups = document->get_lookup_fields(field_in_record.m_table_name, strFieldName);
//std::cout << "debug: " << G_STRFUNC << ": lookups size=" << lookups.size() << std::endl;
for(Document::type_list_lookups::const_iterator iter = lookups.begin(); iter != lookups.end(); ++iter)
{
......@@ -1318,9 +1318,9 @@ void Base_DB::do_lookups(const LayoutFieldInRecord& field_in_record, const Gtk::
std::shared_ptr<const Field> field_source = DbUtils::get_fields_for_table_one_field(document, relationship->get_to_table(), field_lookup->get_lookup_field());
if(field_source)
{
const Gnome::Gda::Value value = DbUtils::get_lookup_value(document, field_in_record.m_table_name, iter->second /* relationship */, field_source /* the field to look in to get the value */, field_value /* Value of to and from fields */);
const auto value = DbUtils::get_lookup_value(document, field_in_record.m_table_name, iter->second /* relationship */, field_source /* the field to look in to get the value */, field_value /* Value of to and from fields */);
const Gnome::Gda::Value value_converted = Conversions::convert_value(value, layout_item->get_glom_type());
const auto value_converted = Conversions::convert_value(value, layout_item->get_glom_type());
LayoutFieldInRecord field_in_record_to_set(layout_item, field_in_record.m_table_name /* parent table */, field_in_record.m_key, field_in_record.m_key_value);
......@@ -1346,7 +1346,7 @@ bool Base_DB::get_field_value_is_unique(const Glib::ustring& table_name, const s
{
bool result = true; //Arbitrarily default to saying it's unique if we can't get any result.
const Glib::ustring table_name_used = field->get_table_used(table_name);
const auto table_name_used = field->get_table_used(table_name);
Glib::RefPtr<Gnome::Gda::SqlBuilder> builder =
Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_SELECT);
......@@ -1433,7 +1433,7 @@ bool Base_DB::get_primary_key_is_in_foundset(const FoundSet& found_set, const Gn
Glib::RefPtr<Gnome::Gda::SqlBuilder> builder = Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_SELECT);
builder->select_add_target(found_set.m_table_name);
const guint eq_id = builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
const auto eq_id = builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
builder->add_field_id(primary_key->get_name(), found_set.m_table_name),
builder->add_expr_as_value(primary_key_value));
guint cond_id = 0;
......@@ -1502,7 +1502,7 @@ void Base_DB::set_found_set_where_clause_for_portal(FoundSet& found_set, const s
//Adjust the WHERE clause appropriately for the extra JOIN:
where_clause_to_table_name = uses_rel_temp->get_sql_join_alias_name();
const Glib::ustring to_field_name = uses_rel_temp->get_to_field_used();
const auto to_field_name = uses_rel_temp->get_to_field_used();
where_clause_to_key_field = DbUtils::get_fields_for_table_one_field(document, relationship->get_to_table(), to_field_name);
//std::cout << "extra_join=" << found_set.m_extra_join << std::endl;
......@@ -1522,12 +1522,12 @@ bool Base_DB::set_database_owner_user(const Glib::ustring& user)
return false;
ConnectionPool* connectionpool = ConnectionPool::get_instance();
const Glib::ustring database_name = connectionpool->get_database();
const auto database_name = connectionpool->get_database();
if(database_name.empty())
return false;
const Glib::ustring strQuery = "ALTER DATABASE " + DbUtils::escape_sql_id(database_name) + " OWNER TO " + DbUtils::escape_sql_id(user);
const bool test = DbUtils::query_execute_string(strQuery);
const auto test = DbUtils::query_execute_string(strQuery);
if(!test)
{
std::cerr << G_STRFUNC << ": ALTER DATABASE failed." << std::endl;
......@@ -1551,7 +1551,7 @@ bool Base_DB::disable_user(const Glib::ustring& user)
}
const Glib::ustring strQuery = "ALTER ROLE " + DbUtils::escape_sql_id(user) + " NOLOGIN NOSUPERUSER NOCREATEDB NOCREATEROLE";
const bool test = DbUtils::query_execute_string(strQuery);
const auto test = DbUtils::query_execute_string(strQuery);
if(!test)
{
std::cerr << G_STRFUNC << ": DROP USER failed" << std::endl;
......
......@@ -133,8 +133,8 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
//If the default value should be calculated, then calculate it:
if(field->get_has_calculation())
{
const Glib::ustring calculation = field->get_calculation();
const type_map_fields field_values = get_record_field_values_for_calculation(m_table_name, fieldPrimaryKey, primary_key_value);
const auto calculation = field->get_calculation();
const auto field_values = get_record_field_values_for_calculation(m_table_name, fieldPrimaryKey, primary_key_value);
//We need the connection when we run the script, so that the script may use it.
// TODO: Is this function supposed to throw an exception?
......@@ -195,7 +195,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
//Put it all together to create the record with these field values:
if(!map_added.empty())
{
const bool test = DbUtils::query_execute(builder);
const auto test = DbUtils::query_execute(builder);
if(!test)
std::cerr << G_STRFUNC << ": INSERT failed." << std::endl;
else
......@@ -209,7 +209,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
std::shared_ptr<const LayoutItem_Field> layout_item = *iter;
//TODO_Performance: We just set this with set_entered_field_data() above. Maybe we could just remember it.
const Gnome::Gda::Value field_value = get_entered_field_data(layout_item);
const auto field_value = get_entered_field_data(layout_item);
const LayoutFieldInRecord field_in_record(layout_item, m_table_name, fieldPrimaryKey, primary_key_value);
......@@ -239,7 +239,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const std::shared_ptr<cons
{
Gnome::Gda::Value primary_key_value = primary_key_value_provided;
const bool related_record_exists = get_related_record_exists(relationship, primary_key_value);
const auto related_record_exists = get_related_record_exists(relationship, primary_key_value);
if(related_record_exists)
{
//No problem, the SQL command below will update this value in the related table.
......@@ -266,7 +266,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const std::shared_ptr<cons
}
else
{
const bool key_is_auto_increment = primary_key_field->get_auto_increment();
const auto key_is_auto_increment = primary_key_field->get_auto_increment();
//If we would have to set an otherwise auto-increment key to add the record.
if( key_is_auto_increment && !Conversions::value_is_empty(primary_key_value) )
......@@ -301,7 +301,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const std::shared_ptr<cons
Glib::RefPtr<Gnome::Gda::SqlBuilder> builder = Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_INSERT);
builder->set_table(relationship->get_to_table());
builder->add_field_value(primary_key_field->get_name(), primary_key_value);
const bool test = DbUtils::query_execute(builder);
const auto test = DbUtils::query_execute(builder);
if(!test)
{
std::cerr << G_STRFUNC << ": INSERT failed." << std::endl;
......@@ -335,7 +335,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const std::shared_ptr<cons
}
else
{
const Gnome::Gda::Value parent_primary_key_value = get_primary_key_value_selected();
const auto parent_primary_key_value = get_primary_key_value_selected();
if(parent_primary_key_value.is_null())
{
std::cerr << G_STRFUNC << ": get_primary_key_value_selected() failed. table = " << get_table_name() << std::endl;
......@@ -343,7 +343,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const std::shared_ptr<cons
}
else
{
const Glib::ustring target_table = relationship->get_from_table();
const auto 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);
......@@ -353,7 +353,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const std::shared_ptr<cons
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);
const auto test = DbUtils::query_execute(builder);
if(!test)
{
std::cerr << G_STRFUNC << ": UPDATE failed." << std::endl;
......@@ -435,8 +435,8 @@ bool Base_DB_Table_Data::get_related_record_exists(const std::shared_ptr<const R
//TODO_Performance: It's very possible that this is slow.
//We don't care how many records there are, only whether there are more than zero.
const Glib::ustring to_field = relationship->get_to_field();
const Glib::ustring related_table = relationship->get_to_table();
const auto to_field = relationship->get_to_field();
const auto 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?
Glib::RefPtr<Gnome::Gda::SqlBuilder> builder =
......@@ -471,7 +471,7 @@ Base_DB_Table_Data::type_vecConstLayoutFields Base_DB_Table_Data::get_related_fi
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.
const auto field_name = field->get_name(); //At the moment, relationships can not be based on related fields on the from side.
for(type_vecConstLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
{
const std::shared_ptr<const LayoutItem_Field> layout_field = *iter;
......@@ -534,7 +534,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 */);
const auto value = result->get_value_at(uiCol, 0 /* row */);
std::shared_ptr<const LayoutItem_Field> layout_item = *iterFields;
if(!layout_item)
std::cerr << G_STRFUNC << ": The layout_item was null." << std::endl;
......
......@@ -64,7 +64,7 @@ void Box_Reports::fill_row(const Gtk::TreeModel::iterator& iter, const std::shar
{
if(iter)
{
const Glib::ustring report_name = report->get_name();
const auto report_name = report->get_name();
m_AddDel.set_value_key(iter, report_name);
m_AddDel.set_value(iter, m_colReportName, report_name);
m_AddDel.set_value(iter, m_colTitle, item_get_title(report));
......@@ -129,7 +129,7 @@ void Box_Reports::on_adddel_Add(const Gtk::TreeModel::iterator& row)
{
std::shared_ptr<Report> report = std::make_shared<Report>();
const Glib::ustring report_name = m_AddDel.get_value(row, m_colReportName);
const auto report_name = m_AddDel.get_value(row, m_colReportName);
if(!report_name.empty())
{
report->set_name(report_name);
......@@ -151,7 +151,7 @@ void Box_Reports::on_adddel_Add(const Gtk::TreeModel::iterator& row)
void Box_Reports::on_adddel_Delete(const Gtk::TreeModel::iterator& rowStart, const Gtk::TreeModel::