Commit e244477d authored by Murray Cumming's avatar Murray Cumming
Browse files

C++11: More use of auto.

parent e27a28f3
......@@ -2039,7 +2039,7 @@ void AppWindow::on_menu_file_save_as_example()
{
const auto table_name = item->get_name();
//const type_vec_fields vec_fields = document->get_table_fields(table_name);
//const auto vec_fields = document->get_table_fields(table_name);
//export_data_to_*() needs a type_list_layout_groups;
Document::type_list_layout_groups sequence = document->get_data_layout_groups_default("list", table_name, "" /* layout_platform */);
......
......@@ -1277,7 +1277,7 @@ bool Base_DB::disable_user(const Glib::ustring& user)
if(user.empty())
return false;
type_vec_strings vecGroups = Privs::get_groups_of_user(user);
const auto vecGroups = Privs::get_groups_of_user(user);
for(const auto& group : vecGroups)
{
DbUtils::remove_user_from_group(user, group);
......
......@@ -64,7 +64,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_vecConstLayoutFields fieldsToAdd = m_FieldsShown;
auto fieldsToAdd = m_FieldsShown;
if(m_TableFields.empty())
m_TableFields = DbUtils::get_fields_for_table(document, m_table_name);
......@@ -490,7 +490,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_vecConstLayoutFields fieldsToGet = get_related_fields(field_in_record_changed.m_field);
const auto fieldsToGet = get_related_fields(field_in_record_changed.m_field);
if(!fieldsToGet.empty())
{
......
......@@ -1305,7 +1305,7 @@ void Frame_Glom::update_table_in_document_from_database()
//Get the fields information from the document.
//and add to, or update Document's list of fields:
type_vec_fields fieldsDocument = pDoc->get_table_fields(m_table_name);
auto fieldsDocument = pDoc->get_table_fields(m_table_name);
for(const auto& field_database : fieldsDatabase)
{
......
......@@ -762,7 +762,7 @@ Field::type_map_type_names Field::get_usable_type_names()
{
init_map();
type_map_type_names result = m_map_type_names_ui;
auto result = m_map_type_names_ui;
//Remove INVALID, because it's not something that a user can use for a field type.
auto iter = result.find(glom_field_type::INVALID);
......
......@@ -984,7 +984,7 @@ type_vec_fields get_fields_for_table(const std::shared_ptr<const Document>& docu
return type_vec_fields(); //This should never happen.
}
type_vec_fields result = document->get_table_fields(table_name);
const auto result = document->get_table_fields(table_name);
//Look at each field in the database:
/*
......@@ -1042,7 +1042,7 @@ std::shared_ptr<Field> get_fields_for_table_one_field(const std::shared_ptr<cons
if(field_name.empty() || table_name.empty())
return result;
type_vec_fields fields = get_fields_for_table(document, table_name); //TODO_Performance
const auto fields = get_fields_for_table(document, table_name); //TODO_Performance
auto iter = find_if_same_name(fields, field_name);
if(iter != fields.end()) //TODO: Handle error?
{
......@@ -2194,7 +2194,7 @@ bool add_group(const std::shared_ptr<const Document>& document, const Glib::ustr
priv.m_view = true;
priv.m_edit = true;
const type_vec_strings table_list =
const auto table_list =
get_table_names_from_database(true /* plus system prefs */);
for(const auto& table : table_list)
{
......
......@@ -939,7 +939,7 @@ void Document::change_field_name(const Glib::ustring& table_name, const Glib::us
if(info)
{
//Fields:
type_vec_fields& vecFields = info->m_fields;
auto& vecFields = info->m_fields;
auto iterFind = find_if_same_name(vecFields, strFieldNameOld);
if(iterFind != vecFields.end()) //If it was found:
{
......@@ -1082,7 +1082,7 @@ void Document::change_relationship_name(const Glib::ustring& table_name, const G
const auto doctableinfo = get_table_info(table_name);
if(doctableinfo)
{
type_vec_relationships relationships = doctableinfo->m_relationships;
const auto relationships = doctableinfo->m_relationships;
//Change the relationship name:
auto iterRelFind = find_if_same_name(relationships, name);
......@@ -4399,7 +4399,7 @@ Document::type_list_translatables Document::get_translatable_items()
}
//The table's relationships:
type_vec_relationships relationships = get_relationships(table_name);
const auto relationships = get_relationships(table_name);
translatable_items_append_with_hint(result, relationships, hint);
//The table's report titles:
......@@ -4413,7 +4413,7 @@ Document::type_list_translatables Document::get_translatable_items()
//Translatable report items:
const auto this_hint = hint + ", Parent Report: " + report->get_name();
type_list_translatables list_layout_items = get_translatable_report_items(table_name, report_name, this_hint);
const auto list_layout_items = get_translatable_report_items(table_name, report_name, this_hint);
add_to_translatable_list(result, list_layout_items);
}
......@@ -4428,12 +4428,12 @@ Document::type_list_translatables Document::get_translatable_items()
//Translatable print layout items:
const auto this_hint = hint + ", Print Layout: " + print_layout->get_name();
type_list_translatables list_layout_items = get_translatable_print_layout_items(table_name, print_layout_name, this_hint);
const auto list_layout_items = get_translatable_print_layout_items(table_name, print_layout_name, this_hint);
add_to_translatable_list(result, list_layout_items);
}
//The table's translatable layout items:
type_list_translatables list_layout_items = get_translatable_layout_items(table_name, hint);
const auto list_layout_items = get_translatable_layout_items(table_name, hint);
add_to_translatable_list(result, list_layout_items);
} //for
......
......@@ -156,7 +156,7 @@ Privs::type_vec_strings Privs::get_database_users(const Glib::ustring& group_nam
if(!value_group.is_null())
group_list = value_group.get_string();
type_vec_strings vecUserIds = pg_list_separate(group_list);
const auto vecUserIds = pg_list_separate(group_list);
for(const auto& userId: vecUserIds)
{
//TODO_Performance: Can we do this in one SQL SELECT?
......@@ -397,7 +397,7 @@ Privs::type_vec_strings Privs::get_groups_of_user(const Glib::ustring& user)
type_vec_strings result;
//Look at each group:
type_vec_strings groups = get_database_groups();
const auto groups = get_database_groups();
for(const auto& group : groups)
{
//See whether the user is in this group:
......@@ -475,7 +475,7 @@ Privileges Privs::get_current_privs(const Glib::ustring& table_name)
if(sharedconnection && sharedconnection->get_gda_connection()->supports_feature(Gnome::Gda::CONNECTION_FEATURE_USERS))
{
//Get the "true" rights for any groups that the user is in:
const type_vec_strings groups = get_groups_of_user(current_user);
const auto groups = get_groups_of_user(current_user);
for(const auto& group : groups)
{
const auto privs = get_table_privileges(group, table_name);
......
......@@ -274,7 +274,7 @@ bool ReportBuilder::report_build_groupby(const FoundSet& found_set_parent, xmlpp
{
auto nodeSecondaryFields = nodeGroupBy->add_child_element("secondary_fields");
type_vecLayoutItems itemsToGet =
const auto itemsToGet =
copy_with_cloned_items(group_by->get_secondary_fields()->m_list_items);
if(!itemsToGet.empty())
......
......@@ -254,7 +254,7 @@ void Box_Data_Calendar_Related::clear_cached_database_values()
{
for(const auto& the_pair : m_map_values)
{
type_list_vectors vec = the_pair.second;
const auto& vec = the_pair.second;
for(const auto& pValues : vec)
{
delete pValues;
......@@ -330,7 +330,7 @@ void Box_Data_Calendar_Related::on_record_added(const Gnome::Gda::Value& primary
Box_Data_Calendar_Related::type_vecConstLayoutFields Box_Data_Calendar_Related::get_fields_to_show() const
{
type_vecConstLayoutFields layout_fields = Box_Data_Portal::get_fields_to_show();
auto layout_fields = Box_Data_Portal::get_fields_to_show();
const auto portal = get_portal();
const auto derived_portal = std::dynamic_pointer_cast<const LayoutItem_CalendarPortal>(portal);
......@@ -447,7 +447,7 @@ Glib::ustring Box_Data_Calendar_Related::on_calendar_details(guint year, guint m
Glib::ustring result;
//Look at each row for this date:
const type_list_vectors& rows = iter_find->second;
const auto& rows = iter_find->second;
for(const auto& pRow : rows)
{
if(!pRow)
......
......@@ -286,7 +286,7 @@ bool Box_Data_Details::fill_from_database()
bResult = Box_Data::fill_from_database();
m_FieldsShown = get_fields_to_show();
type_vecConstLayoutFields fieldsToGet = m_FieldsShown;
auto fieldsToGet = m_FieldsShown;
if(!fieldsToGet.empty())
{
......
......@@ -97,7 +97,6 @@ bool Box_Data_List_Related::init_db_details(const Glib::ustring& parent_table, b
if(show_title)
{
Glib::ustring title;
const auto portal = get_portal();
if(portal)
title = item_get_title(portal);
......
......@@ -109,7 +109,7 @@ void ComboChoicesWithTreeModel::set_choices_with_second(const type_list_values_w
type_list_values_with_second::const_iterator iter= list_values.begin();
if(iter != list_values.end())
{
const type_list_values& second = iter->second;
const auto& second = iter->second;
columns_count += second.size();
}
}
......@@ -147,7 +147,7 @@ void ComboChoicesWithTreeModel::set_choices_with_second(const type_list_values_w
Conversions::get_text_for_gda_value(layout_choice_first->get_glom_type(), the_pair->first, layout_choice_first->get_formatting_used().m_numeric_format);
row.set_value(0, text);
const type_list_values extra_values = the_pair->second;
const auto& extra_values = the_pair->second;
if(layout_choice_extra && !extra_values.empty())
{
guint model_index = 1; //0 is for the main field.
......
......@@ -436,14 +436,14 @@ void DbTreeModel::get_value_vfunc(const TreeModel::iterator& iter, int column, G
//Glib::Value< DbValue > value_specific;
//value_specific.init( Glib::Value< DbValue >::value_type() ); //TODO: Is there any way to avoid this step?
type_datamodel_row_index datamodel_row = get_datamodel_row_index_from_tree_row_iter(iter);
const auto datamodel_row = get_datamodel_row_index_from_tree_row_iter(iter);
//g_warning("DbTreeModel::get_value_vfunc(): datamodel_row=%d, get_internal_rows_count=%d", datamodel_row, get_internal_rows_count());
const unsigned int internal_rows_count = get_internal_rows_count();
if( datamodel_row < internal_rows_count) //!= m_rows.end())
{
//std::cout << " debug: DbTreeModel::get_value_vfunc() 1.2\n";
//const typeRow& dataRow = *datamodel_row;
//const auto& dataRow = *datamodel_row;
//g_warning("DbTreeModel::get_value_vfunc 1: column=%d, row=%d", column, datamodel_row);
......@@ -515,7 +515,7 @@ bool DbTreeModel::iter_next_vfunc(const iterator& iter, iterator& iter_next) con
if( check_treeiter_validity(iter) )
{
//Get the current row:
type_datamodel_row_index datamodel_row = get_datamodel_row_index_from_tree_row_iter(iter);
auto datamodel_row = get_datamodel_row_index_from_tree_row_iter(iter);
//std::cout << "debug: " << G_STRFUNC << ":" << datamodel_row << std::endl;
//Make the iter_next GtkTreeIter represent the next row:
......@@ -623,7 +623,7 @@ bool DbTreeModel::iter_parent_vfunc(const iterator& child, iterator& iter) const
Gtk::TreeModel::Path DbTreeModel::get_path_vfunc(const iterator& iter) const
{
type_datamodel_row_index datamodel_row = get_datamodel_row_index_from_tree_row_iter(iter);
const auto datamodel_row = get_datamodel_row_index_from_tree_row_iter(iter);
//TODO_Performance:
//Get the number of non-removed items before this iter, because the path index doesn't care about removed internal stuff.
......@@ -730,7 +730,7 @@ DbTreeModel::iterator DbTreeModel::append()
//m_rows.resize(existing_size + 1);
//Get aniterator to the last element:
type_datamodel_row_index datamodel_row = get_internal_rows_count();
const auto datamodel_row = get_internal_rows_count();
//std::cerr << G_STRFUNC << ": new row number=" << datamodel_row << std::endl;
++m_count_extra_rows; //So that create_iterator() can succeed.
......@@ -766,7 +766,7 @@ void DbTreeModel::set_value_impl(const iterator& row, int column, const Glib::Va
if(iter_is_valid(row))
{
//Get the index from the user_data:
type_datamodel_row_index datamodel_row = get_datamodel_row_index_from_tree_row_iter(row);
const auto datamodel_row = get_datamodel_row_index_from_tree_row_iter(row);
//TODO: Check column against get_n_columns() too, though it could hurt performance.
......@@ -806,7 +806,7 @@ DbTreeModel::iterator DbTreeModel::erase(const iterator& iter)
if(iter_is_valid(iter))
{
//Get the index from the user_data:
type_datamodel_row_index datamodel_row = get_datamodel_row_index_from_tree_row_iter(iter);
auto datamodel_row = get_datamodel_row_index_from_tree_row_iter(iter);
//Remove the row.
Gtk::TreeModel::Path path_deleted = get_path(iter);
......@@ -836,7 +836,7 @@ void DbTreeModel::set_key_value(const TreeModel::iterator& iter, const DbValue&
//g_warning("DbTreeModel::set_is_placeholder(): val=%d", val);
if(check_treeiter_validity(iter))
{
type_datamodel_row_index datamodel_row = get_datamodel_row_index_from_tree_row_iter(iter);
const auto datamodel_row = get_datamodel_row_index_from_tree_row_iter(iter);
m_map_rows[datamodel_row].m_key = value;
}
}
......@@ -845,7 +845,7 @@ DbTreeModel::DbValue DbTreeModel::get_key_value(const TreeModel::iterator& iter)
{
if(check_treeiter_validity(iter))
{
type_datamodel_row_index datamodel_row = get_datamodel_row_index_from_tree_row_iter(iter);
const auto datamodel_row = get_datamodel_row_index_from_tree_row_iter(iter);
auto iterFind = m_map_rows.find(datamodel_row);
if(iterFind != m_map_rows.end())
return iterFind->second.m_key;
......@@ -865,7 +865,7 @@ bool DbTreeModel::get_is_placeholder(const TreeModel::iterator& iter) const
//g_warning("DbTreeModel::g et_is_placeholder()");
if(check_treeiter_validity(iter))
{
type_datamodel_row_index datamodel_row = get_datamodel_row_index_from_tree_row_iter(iter);
const auto datamodel_row = get_datamodel_row_index_from_tree_row_iter(iter);
return (datamodel_row == ((type_datamodel_row_index)get_internal_rows_count() -1));
}
......@@ -905,7 +905,7 @@ Gtk::TreeModel::iterator DbTreeModel::get_last_row()
const int rows_count = get_internal_rows_count();
if(rows_count)
{
type_datamodel_row_index row = rows_count - 1;
auto row = rows_count - 1;
if(row > 0) //This should always be true, because there is always a placeholder.
--row; //Ignore the placeholder.
......@@ -934,7 +934,7 @@ Gtk::TreeModel::iterator DbTreeModel::get_placeholder_row()
const int rows_count = get_internal_rows_count();
if(rows_count)
{
type_datamodel_row_index row = rows_count - 1;
auto row = rows_count - 1;
//Step backwards until we find one that is not removed:
while((m_map_rows.find(row) != m_map_rows.end()) && m_map_rows[row].m_removed)
......
......@@ -336,7 +336,7 @@ Gnome::Gda::Value DbAddDel::get_value(const Gtk::TreeModel::iterator& iter, cons
if(treerow)
{
type_list_indexes list_indexes = get_data_model_column_index(layout_item);
const auto list_indexes = get_data_model_column_index(layout_item);
if(!list_indexes.empty())
{
const auto iter_begin = list_indexes.begin(); //Just get the first displayed instance of this field->
......@@ -441,7 +441,7 @@ bool DbAddDel::select_item(const Gtk::TreeModel::iterator& iter, const std::shar
{
//Get the model column:
guint treemodel_col = 0;
type_list_indexes list_indexes = get_column_index(layout_item);
const auto list_indexes = get_column_index(layout_item);
if(list_indexes.empty())
return false;
else
......
......@@ -717,7 +717,7 @@ void FlowTableWithFields::set_other_field_value(const std::shared_ptr<const Layo
Gnome::Gda::Value FlowTableWithFields::get_field_value(const std::shared_ptr<const LayoutItem_Field>& field) const
{
const type_list_const_widgets list_widgets = get_field(field, true);
const auto list_widgets = get_field(field, true);
for(const auto& list_widget : list_widgets)
{
const auto datawidget = dynamic_cast<const DataWidget*>(list_widget);
......@@ -803,7 +803,7 @@ FlowTableWithFields::type_portals FlowTableWithFields::get_portals(const std::sh
{
if(subtable)
{
type_portals sub_list = subtable->get_portals(from_key);
const auto sub_list = subtable->get_portals(from_key);
if(!sub_list.empty())
{
//Add to the main result:
......@@ -927,7 +927,7 @@ FlowTableWithFields::type_list_widgets FlowTableWithFields::get_field(const std:
{
if(subtable)
{
type_list_widgets sub_list = subtable->get_field(layout_item, include_item);
const auto sub_list = subtable->get_field(layout_item, include_item);
if(!sub_list.empty())
{
//Add to the main result:
......
......@@ -93,7 +93,7 @@ bool Box_DB_Table_Relationships::fill_from_database()
m_AddDel.set_column_choices(m_colFromField, util_vecStrings_from_Fields(
DbUtils::get_fields_for_table(document, m_table_name)));
type_vec_strings vecTableNames = document->get_table_names(false /* ignore_system_tables */);
const auto vecTableNames = document->get_table_names(false /* ignore_system_tables */);
type_vec_strings vecTableNames_ustring(vecTableNames.begin(), vecTableNames.end());
m_AddDel.set_column_choices(m_colToTable, vecTableNames_ustring);
......@@ -246,7 +246,7 @@ void Box_DB_Table_Relationships::on_adddel_user_activated(const Gtk::TreeModel::
auto connection = sharedconnection->get_gda_connection();
auto document = get_document();
type_vec_strings vecFields = util_vecStrings_from_Fields(DbUtils::get_fields_for_table(document, table_name));
const auto vecFields = util_vecStrings_from_Fields(DbUtils::get_fields_for_table(document, table_name));
//This would cause a lot of tedious re-filling:
//m_AddDel.set_column_choices(m_colToField, vecFields);
......
......@@ -198,7 +198,7 @@ std::shared_ptr<LayoutItem_Field> Dialog_ChooseField::get_field_chosen() const
{
std::shared_ptr<LayoutItem_Field> field;
type_list_field_items list_fields = get_fields_chosen();
const auto list_fields = get_fields_chosen();
if(!(list_fields.empty()))
{
field = *(list_fields.begin());
......
......@@ -521,7 +521,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);
const auto fields_list = offer_field_list(m_table_name, this);
for(const auto& layout_item : fields_list)
{
if(!layout_item)
......
......@@ -250,7 +250,7 @@ void Dialog_Layout_Export::on_treeview_fields_selection_changed()
void Dialog_Layout_Export::on_button_add_field()
{
//Get the chosen fields:
type_list_field_items fields_list = offer_field_list(m_table_name, this);
const auto fields_list = offer_field_list(m_table_name, this);
for(const auto& field : fields_list)
{
if(!field)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment