Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
glom
Commits
448fc7b2
Commit
448fc7b2
authored
Feb 08, 2016
by
Murray Cumming
Browse files
C++11: More range-based for loops.
With help from clang-modernize-3.7.
parent
c987d018
Changes
9
Hide whitespace changes
Inline
Side-by-side
glom/application.cc
View file @
448fc7b2
...
...
@@ -117,9 +117,8 @@ void Application::on_open(const Gio::Application::type_vec_files& files,
// The application has been asked to open some files,
// so let's open a new window for each one.
//std::cout << "debug: files.size()=" << files.size() << std::endl;
for
(
guint
i
=
0
;
i
<
files
.
size
();
i
++
)
for
(
const
auto
&
file
:
files
)
{
auto
file
=
files
[
i
];
if
(
!
file
)
{
std
::
cerr
<<
G_STRFUNC
<<
": file is null."
<<
std
::
endl
;
...
...
glom/base_db.cc
View file @
448fc7b2
...
...
@@ -202,9 +202,10 @@ Base_DB::type_vec_strings Base_DB::util_vecStrings_from_Fields(const type_vec_fi
//Get vector of field names, suitable for a combo box:
type_vec_strings
vecNames
;
for
(
type_vec_fields
::
size_type
i
=
0
;
i
<
fields
.
size
();
++
i
)
for
(
const
auto
&
field
:
fields
)
{
vecNames
.
emplace_back
(
fields
[
i
]
->
get_name
());
if
(
field
)
vecNames
.
emplace_back
(
field
->
get_name
());
}
return
vecNames
;
...
...
glom/import_csv/dialog_import_csv.cc
View file @
448fc7b2
...
...
@@ -643,11 +643,11 @@ void Dialog_Import_CSV::on_field_edited(const Glib::ustring& path, const Glib::u
// Lookup field indicated by new_text
const
auto
children
=
m_field_model
->
children
();
for
(
auto
field_iter
=
children
.
begin
();
field_iter
!=
children
.
end
();
++
field_iter
)
for
(
const
auto
&
elem
:
children
)
{
if
(
(
*
field_iter
)[
m_field_columns
.
m_col_field_name
]
==
new_text
)
if
(
(
elem
)[
m_field_columns
.
m_col_field_name
]
==
new_text
)
{
std
::
shared_ptr
<
Field
>
field
=
(
*
field_iter
)[
m_field_columns
.
m_col_field
];
std
::
shared_ptr
<
Field
>
field
=
(
elem
)[
m_field_columns
.
m_col_field
];
// Check whether another column is already using that field
auto
vec_field_iter
=
Utils
::
find
(
m_fields
,
field
);
// Reset the old column since two different columns cannot be imported into the same field
...
...
glom/mode_data/db_adddel/db_adddel.cc
View file @
448fc7b2
...
...
@@ -516,14 +516,14 @@ guint DbAddDel::get_fixed_cell_height()
m_fixed_cell_height
=
height_default
;
//Look at each column:
for
(
auto
ite
r
=
m_column_items
.
begin
();
iter
!=
m_column_items
.
end
();
++
iter
)
for
(
const
auto
&
ite
m
:
m_column_items
)
{
Glib
::
ustring
font_name
;
auto
item_withformatting
=
std
::
dynamic_pointer_cast
<
const
LayoutItem_WithFormatting
>
(
*
ite
r
);
const
auto
item_withformatting
=
std
::
dynamic_pointer_cast
<
const
LayoutItem_WithFormatting
>
(
ite
m
);
if
(
item_withformatting
)
{
const
auto
formatting
=
item_withformatting
->
get_formatting_used
();
const
auto
&
formatting
=
item_withformatting
->
get_formatting_used
();
font_name
=
formatting
.
get_text_format_font
();
}
...
...
@@ -691,9 +691,8 @@ void DbAddDel::construct_specified_columns()
const
auto
has_expandable_column
=
get_column_to_expand
(
column_to_expand
);
//std::cout << "DEBUG: column_to_expand=" << column_to_expand << ", has=" << has_expandable_column << std::endl;
for
(
auto
iter
=
m_column_items
.
begin
();
iter
!=
m_column_items
.
end
();
++
iter
)
for
(
const
auto
&
layout_item
:
m_column_items
)
{
const
auto
layout_item
=
m_column_items
[
model_column_index
];
//TODO: Inefficient.
if
(
layout_item
)
//column_info.m_visible)
{
no_columns_used
=
false
;
...
...
@@ -1609,18 +1608,14 @@ void DbAddDel::on_treeview_columns_changed()
//Get the new column order, and save it in m_vecColumnIDs:
m_vecColumnIDs
.
clear
();
typedef
std
::
vector
<
Gtk
::
TreeViewColumn
*>
type_vecViewColumns
;
type_vecViewColumns
vecViewColumns
=
m_TreeView
.
get_columns
();
for
(
auto
iter
=
vecViewColumns
.
begin
();
iter
!=
vecViewColumns
.
end
();
++
iter
)
for
(
const
auto
&
vecViewColumn
:
m_TreeView
.
get_columns
())
{
auto
pViewColumn
=
dynamic_cast
<
DbTreeViewColumnGlom
*>
(
*
iter
);
if
(
pViewColumn
)
{
const
auto
column_id
=
pViewColumn
->
get_column_id
();
m_vecColumnIDs
.
emplace_back
(
column_id
);
const
auto
view_column
=
dynamic_cast
<
DbTreeViewColumnGlom
*>
(
vecViewColumn
);
if
(
!
view_column
)
continue
;
}
const
auto
column_id
=
view_column
->
get_column_id
();
m_vecColumnIDs
.
emplace_back
(
column_id
);
}
//Tell other code that something has changed, so the new column order can be serialized.
...
...
glom/mode_data/flowtablewithfields.cc
View file @
448fc7b2
...
...
@@ -716,11 +716,10 @@ 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
{
type_list_const_widgets
list_widgets
=
get_field
(
field
,
true
);
for
(
auto
iter
=
list_widgets
.
begin
();
iter
!=
list_widgets
.
end
();
++
iter
)
const
type_list_const_widgets
list_widgets
=
get_field
(
field
,
true
);
for
(
const
auto
&
list_widget
:
list_widgets
)
{
const
auto
datawidget
=
dynamic_cast
<
const
DataWidget
*>
(
*
iter
);
const
auto
datawidget
=
dynamic_cast
<
const
DataWidget
*>
(
list_widget
);
if
(
!
datawidget
)
continue
;
...
...
glom/mode_design/fields/box_db_table_definition.cc
View file @
448fc7b2
...
...
@@ -74,11 +74,11 @@ void Box_DB_Table_Definition::init()
//Set Type choices:
Field
::
type_map_type_names
mapFieldTypes
=
Field
::
get_usable_type_names
();
const
auto
mapFieldTypes
=
Field
::
get_usable_type_names
();
AddDel
::
type_vec_strings
vecTypes
;
for
(
auto
iter
=
mapFieldType
s
.
begin
();
iter
!=
mapFieldTypes
.
end
();
++
iter
)
for
(
const
auto
&
mapFieldType
:
mapFieldTypes
)
{
const
Glib
::
ustring
&
name
=
(
*
iter
).
second
;
const
auto
&
name
=
(
mapFieldType
).
second
;
vecTypes
.
emplace_back
(
name
);
}
...
...
glom/mode_design/print_layouts/window_print_layout_edit.cc
View file @
448fc7b2
...
...
@@ -1393,8 +1393,6 @@ void Window_PrintLayout_Edit::get_dimensions_of_multiple_selected_items(double&
void
Window_PrintLayout_Edit
::
on_canvas_selection_changed
()
{
Canvas_PrintLayout
::
type_vec_items
items
=
m_canvas
.
get_selected_items
();
//Forget about any previously selected items:
m_layout_items_selected
.
clear
();
for
(
auto
item
:
m_connections_items_selected_moved
)
...
...
@@ -1403,11 +1401,10 @@ void Window_PrintLayout_Edit::on_canvas_selection_changed()
}
m_connections_items_selected_moved
.
clear
();
for
(
auto
iter
=
items
.
begin
();
iter
!=
items
.
end
();
++
iter
)
const
auto
items
=
m_canvas
.
get_selected_items
();
for
(
const
auto
&
base_item
:
items
)
{
auto
item
=
Glib
::
RefPtr
<
CanvasLayoutItem
>::
cast_dynamic
(
*
ite
r
);
auto
item
=
Glib
::
RefPtr
<
CanvasLayoutItem
>::
cast_dynamic
(
base_
ite
m
);
if
(
!
item
)
continue
;
...
...
glom/print_layout/canvas_print_layout.cc
View file @
448fc7b2
...
...
@@ -94,18 +94,16 @@ void Canvas_PrintLayout::set_print_layout(const Glib::ustring& table_name, const
//Add the rule lines:
remove_rules
();
const
PrintLayout
::
type_vec_doubles
h_rules
=
print_layout
->
get_horizontal_rules
();
for
(
auto
iter
=
h_rules
.
begin
();
iter
!=
h_rules
.
end
();
++
iter
)
const
auto
h_rules
=
print_layout
->
get_horizontal_rules
();
for
(
const
auto
&
h_rule
:
h_rules
)
{
add_horizontal_rule
(
*
iter
);
add_horizontal_rule
(
h_rule
);
}
const
PrintLayout
::
type_vec_doubles
v_rules
=
print_layout
->
get_vertical_rules
();
for
(
auto
iter
=
v_rules
.
begin
();
iter
!=
v_rules
.
end
();
++
iter
)
const
auto
v_rules
=
print_layout
->
get_vertical_rules
();
for
(
const
auto
&
v_rule
:
v_rules
)
{
add_vertical_rule
(
*
iter
);
add_vertical_rule
(
v_rule
);
}
//TODO: This needs a number, but that is decided in WindowPrintLayoutEdit: set_grid_gap( print_layout->get_show_grid() );
...
...
glom/utils_ui.cc
View file @
448fc7b2
...
...
@@ -583,27 +583,22 @@ void UiUtils::treeview_delete_all_columns(Gtk::TreeView* treeview)
//Deleting them explicitly is safer and clearer. murrayc.
//Remove all View columns:
typedef
std
::
vector
<
Gtk
::
TreeView
::
Column
*>
type_vec_columns
;
type_vec_columns
vecViewColumns
(
treeview
->
get_columns
());
for
(
type_vec_columns
::
iterator
iter
(
vecViewColumns
.
begin
()),
columns_end
(
vecViewColumns
.
end
());
iter
!=
columns_end
;
++
iter
)
auto
vecViewColumns
=
treeview
->
get_columns
();
for
(
auto
&
view_column
:
vecViewColumns
)
{
Gtk
::
TreeView
::
Column
*
pViewColumn
(
*
iter
);
if
(
!
pViewColumn
)
if
(
!
view_column
)
continue
;
GtkTreeViewColumn
*
weak_ptr
=
nullptr
;
g_object_add_weak_pointer
(
G_OBJECT
(
pV
iew
C
olumn
->
gobj
()),
(
gpointer
*
)
&
weak_ptr
);
g_object_add_weak_pointer
(
G_OBJECT
(
v
iew
_c
olumn
->
gobj
()),
(
gpointer
*
)
&
weak_ptr
);
//Keep the object alive, instead of letting gtk_tree_view_remove_column() delete it by reducing its reference to 0,
//so we can explicitly delete it.
//This feels safer, considering some strange crashes I've seen when using Gtk::TreeView::remove_all_columns(),
//though that might have been just because we didn't reset m_treeviewcolumn_button. murrayc.
pV
iew
C
olumn
->
reference
();
treeview
->
remove_column
(
*
pV
iew
C
olumn
);
delete
pV
iew
C
olumn
;
//This should cause it to be removed.
v
iew
_c
olumn
->
reference
();
treeview
->
remove_column
(
*
v
iew
_c
olumn
);
delete
v
iew
_c
olumn
;
//This should cause it to be removed.
if
(
weak_ptr
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment