Skip to content
GitLab
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
740dadd8
Commit
740dadd8
authored
Jul 04, 2013
by
Murray Cumming
Browse files
C++11: Replace Glom::sharedptr with std::shared_ptr.
parent
56afb4a4
Changes
242
Expand all
Hide whitespace changes
Inline
Side-by-side
Makefile_tests.am
View file @
740dadd8
...
...
@@ -18,7 +18,6 @@
check_PROGRAMS = \
glom/libglom/test_connectionpool \
glom/libglom/example_document_load \
glom/libglom/test_sharedptr_layoutitem \
tests/test_document_load \
tests/test_document_load_and_change \
tests/test_document_load_and_save \
...
...
glom/appwindow.cc
View file @
740dadd8
...
...
@@ -43,7 +43,7 @@
#include
<gtkmm/main.h>
#include
<cstdio>
#include
<memory>
//For std::
auto
_ptr<>
#include
<memory>
//For std::
shared
_ptr<>
#include
<giomm/file.h>
#include
<glibmm/spawn.h>
#include
<glibmm/convert.h>
...
...
@@ -1246,13 +1246,13 @@ bool AppWindow::on_document_load()
{
Glib
::
ustring
error_message
;
//TODO: Check this and tell the user.
ConnectionPool
*
connection_pool
=
ConnectionPool
::
get_instance
();
sharedptr
<
SharedConnection
>
sharedconnection
=
connection_pool
->
connect
();
std
::
shared
_
ptr
<
SharedConnection
>
sharedconnection
=
connection_pool
->
connect
();
AppPythonUICallbacks
callbacks
;
glom_execute_python_function_implementation
(
script
,
type_map_fields
(),
//only used when there is a current table and record.
pDocument
,
Glib
::
ustring
()
/* table_name */
,
sharedptr
<
Field
>
(),
Gnome
::
Gda
::
Value
(),
// primary key - only used when there is a current table and record.
std
::
shared
_
ptr
<
Field
>
(),
Gnome
::
Gda
::
Value
(),
// primary key - only used when there is a current table and record.
sharedconnection
->
get_gda_connection
(),
callbacks
,
error_message
);
...
...
@@ -1393,7 +1393,7 @@ void AppWindow::update_userlevel_ui()
{
if
(
ConnectionPool
::
get_instance_is_ready
())
{
sharedptr
<
SharedConnection
>
connection
=
ConnectionPool
::
get_and_connect
();
std
::
shared
_
ptr
<
SharedConnection
>
connection
=
ConnectionPool
::
get_and_connect
();
if
(
connection
&&
!
connection
->
get_gda_connection
()
->
supports_feature
(
Gnome
::
Gda
::
CONNECTION_FEATURE_USERS
))
m_action_developer_users
->
set_sensitive
(
false
);
}
...
...
@@ -1426,7 +1426,7 @@ bool AppWindow::offer_new_or_existing()
//Offer to load an existing document, or start a new one.
Dialog_ExistingOrNew
*
dialog_raw
=
0
;
Utils
::
get_glade_widget_derived_with_warning
(
dialog_raw
);
std
::
auto
_ptr
<
Dialog_ExistingOrNew
>
dialog
(
dialog_raw
);
std
::
shared
_ptr
<
Dialog_ExistingOrNew
>
dialog
(
dialog_raw
);
dialog
->
set_transient_for
(
*
this
);
/*
dialog->signal_new().connect(sigc::mem_fun(*this, &AppWindow::on_existing_or_new_new));
...
...
@@ -1637,14 +1637,14 @@ bool AppWindow::recreate_database_from_example(bool& user_cancelled)
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
#else
std
::
auto
_ptr
<
std
::
exception
>
error
;
std
::
shared
_ptr
<
std
::
exception
>
error
;
#endif // GLIBMM_EXCEPTIONS_ENABLED
{
connection_pool
->
set_ready_to_connect
();
//This has succeeded already.
#ifdef GLIBMM_EXCEPTIONS_ENABLED
sharedptr
<
SharedConnection
>
sharedconnection
=
connection_pool
->
connect
();
std
::
shared
_
ptr
<
SharedConnection
>
sharedconnection
=
connection_pool
->
connect
();
#else
sharedptr
<
SharedConnection
>
sharedconnection
=
connection_pool
->
connect
(
error
);
std
::
shared
_
ptr
<
SharedConnection
>
sharedconnection
=
connection_pool
->
connect
(
error
);
if
(
!
error
.
get
())
{
#endif // GLIBMM_EXCEPTIONS_ENABLED
...
...
@@ -1700,7 +1700,7 @@ bool AppWindow::recreate_database_from_example(bool& user_cancelled)
pulse_progress_message
();
BusyCursor
busy_cursor
(
this
);
sharedptr
<
SharedConnection
>
sharedconnection
;
std
::
shared
_
ptr
<
SharedConnection
>
sharedconnection
;
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
#endif // GLIBMM_EXCEPTIONS_ENABLED
...
...
@@ -1741,7 +1741,7 @@ bool AppWindow::recreate_database_from_example(bool& user_cancelled)
Document
::
type_listTableInfo
tables
=
pDocument
->
get_tables
();
for
(
Document
::
type_listTableInfo
::
const_iterator
iter
=
tables
.
begin
();
iter
!=
tables
.
end
();
++
iter
)
{
sharedptr
<
const
TableInfo
>
table_info
=
*
iter
;
std
::
shared
_
ptr
<
const
TableInfo
>
table_info
=
*
iter
;
//Create SQL to describe all fields in this table:
Glib
::
ustring
sql_fields
;
...
...
@@ -1768,7 +1768,7 @@ bool AppWindow::recreate_database_from_example(bool& user_cancelled)
for
(
Document
::
type_listTableInfo
::
const_iterator
iter
=
tables
.
begin
();
iter
!=
tables
.
end
();
++
iter
)
{
sharedptr
<
const
TableInfo
>
table_info
=
*
iter
;
std
::
shared
_
ptr
<
const
TableInfo
>
table_info
=
*
iter
;
//Add any example data to the table:
pulse_progress_message
();
...
...
@@ -1816,14 +1816,14 @@ bool AppWindow::recreate_database_from_backup(const Glib::ustring& backup_uri, b
#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
#else
std
::
auto
_ptr
<
std
::
exception
>
error
;
std
::
shared
_ptr
<
std
::
exception
>
error
;
#endif // GLIBMM_EXCEPTIONS_ENABLED
{
connection_pool
->
set_ready_to_connect
();
//This has succeeded already.
#ifdef GLIBMM_EXCEPTIONS_ENABLED
sharedptr
<
SharedConnection
>
sharedconnection
=
connection_pool
->
connect
();
std
::
shared
_
ptr
<
SharedConnection
>
sharedconnection
=
connection_pool
->
connect
();
#else
sharedptr
<
SharedConnection
>
sharedconnection
=
connection_pool
->
connect
(
error
);
std
::
shared
_
ptr
<
SharedConnection
>
sharedconnection
=
connection_pool
->
connect
(
error
);
if
(
!
error
.
get
())
{
#endif // GLIBMM_EXCEPTIONS_ENABLED
...
...
@@ -2007,7 +2007,7 @@ void AppWindow::fill_menu_tables()
const
Document
::
type_listTableInfo
tables
=
document
->
get_tables
();
for
(
Document
::
type_listTableInfo
::
const_iterator
iter
=
tables
.
begin
();
iter
!=
tables
.
end
();
++
iter
)
{
sharedptr
<
const
TableInfo
>
table_info
=
*
iter
;
std
::
shared
_
ptr
<
const
TableInfo
>
table_info
=
*
iter
;
if
(
!
table_info
->
get_hidden
())
{
const
Glib
::
ustring
action_name
=
"NavTableAction_"
+
table_info
->
get_name
();
...
...
@@ -2073,7 +2073,7 @@ void AppWindow::fill_menu_reports(const Glib::ustring& table_name)
const
std
::
vector
<
Glib
::
ustring
>
reports
=
document
->
get_report_names
(
table_name
);
for
(
std
::
vector
<
Glib
::
ustring
>::
const_iterator
iter
=
reports
.
begin
();
iter
!=
reports
.
end
();
++
iter
)
{
sharedptr
<
Report
>
report
=
document
->
get_report
(
table_name
,
*
iter
);
std
::
shared
_
ptr
<
Report
>
report
=
document
->
get_report
(
table_name
,
*
iter
);
if
(
report
)
{
const
Glib
::
ustring
report_name
=
report
->
get_name
();
...
...
@@ -2155,7 +2155,7 @@ void AppWindow::fill_menu_print_layouts(const Glib::ustring& table_name)
#ifndef GLOM_ENABLE_CLIENT_ONLY
for
(
std
::
vector
<
Glib
::
ustring
>::
const_iterator
iter
=
tables
.
begin
();
iter
!=
tables
.
end
();
++
iter
)
{
sharedptr
<
PrintLayout
>
print_layout
=
document
->
get_print_layout
(
table_name
,
*
iter
);
std
::
shared
_
ptr
<
PrintLayout
>
print_layout
=
document
->
get_print_layout
(
table_name
,
*
iter
);
if
(
print_layout
)
{
const
Glib
::
ustring
name
=
print_layout
->
get_name
();
...
...
@@ -2307,7 +2307,7 @@ Glib::ustring AppWindow::ui_file_select_save(const Glib::ustring& old_file_uri)
//Reimplement this whole function, just so we can use our custom FileChooserDialog class:
AppWindow
&
app
=
*
this
;
std
::
auto
_ptr
<
Gtk
::
FileChooserDialog
>
fileChooser_Save
;
std
::
shared
_ptr
<
Gtk
::
FileChooserDialog
>
fileChooser_Save
;
Glom
::
FileChooserDialog_SaveExtras
*
fileChooser_SaveExtras
=
0
;
//Create the appropriate dialog, depending on how the caller set m_ui_save_extra_showextras:
...
...
@@ -2916,7 +2916,7 @@ Glib::ustring AppWindow::get_current_locale()
return
"C"
;
}
Glib
::
ustring
item_get_title
(
const
sharedptr
<
const
TranslatableItem
>&
item
)
Glib
::
ustring
item_get_title
(
const
std
::
shared
_
ptr
<
const
TranslatableItem
>&
item
)
{
if
(
!
item
)
return
Glib
::
ustring
();
...
...
@@ -2924,7 +2924,7 @@ Glib::ustring item_get_title(const sharedptr<const TranslatableItem>& item)
return
item
->
get_title
(
AppWindow
::
get_current_locale
());
}
Glib
::
ustring
item_get_title_or_name
(
const
sharedptr
<
const
TranslatableItem
>&
item
)
Glib
::
ustring
item_get_title_or_name
(
const
std
::
shared
_
ptr
<
const
TranslatableItem
>&
item
)
{
if
(
!
item
)
return
Glib
::
ustring
();
...
...
glom/appwindow.h
View file @
740dadd8
...
...
@@ -296,9 +296,9 @@ private:
static
Glib
::
ustring
m_current_locale
,
m_original_locale
;
};
Glib
::
ustring
item_get_title
(
const
sharedptr
<
const
TranslatableItem
>&
item
);
Glib
::
ustring
item_get_title
(
const
std
::
shared
_
ptr
<
const
TranslatableItem
>&
item
);
Glib
::
ustring
item_get_title_or_name
(
const
sharedptr
<
const
TranslatableItem
>&
item
);
Glib
::
ustring
item_get_title_or_name
(
const
std
::
shared
_
ptr
<
const
TranslatableItem
>&
item
);
}
//namespace Glom
...
...
glom/base_db.cc
View file @
740dadd8
This diff is collapsed.
Click to expand it.
glom/base_db.h
View file @
740dadd8
...
...
@@ -64,15 +64,15 @@ public:
virtual
AppState
::
userlevels
get_userlevel
()
const
;
virtual
void
set_userlevel
(
AppState
::
userlevels
value
);
static
sharedptr
<
SharedConnection
>
connect_to_server
(
Gtk
::
Window
*
parent_window
=
0
);
static
std
::
shared
_
ptr
<
SharedConnection
>
connect_to_server
(
Gtk
::
Window
*
parent_window
=
0
);
virtual
void
set_document
(
Document
*
pDocument
);
//View override
virtual
void
load_from_document
();
//View override
sharedptr
<
Field
>
change_column
(
const
Glib
::
ustring
&
table_name
,
const
sharedptr
<
const
Field
>&
field_old
,
const
sharedptr
<
const
Field
>&
field
,
Gtk
::
Window
*
parent_window
)
const
;
std
::
shared
_
ptr
<
Field
>
change_column
(
const
Glib
::
ustring
&
table_name
,
const
std
::
shared
_
ptr
<
const
Field
>&
field_old
,
const
std
::
shared
_
ptr
<
const
Field
>&
field
,
Gtk
::
Window
*
parent_window
)
const
;
typedef
std
::
vector
<
sharedptr
<
Field
>
>
type_vec_fields
;
typedef
std
::
vector
<
sharedptr
<
const
Field
>
>
type_vec_const_fields
;
typedef
std
::
vector
<
std
::
shared
_
ptr
<
Field
>
>
type_vec_fields
;
typedef
std
::
vector
<
std
::
shared
_
ptr
<
const
Field
>
>
type_vec_const_fields
;
#ifndef GLOM_ENABLE_CLIENT_ONLY
bool
change_columns
(
const
Glib
::
ustring
&
table_name
,
const
type_vec_const_fields
&
old_fields
,
type_vec_fields
&
fields
,
Gtk
::
Window
*
parent_window
)
const
;
...
...
@@ -82,23 +82,23 @@ public:
/// Get the active layout platform for the document, or get a suitable default.
static
Glib
::
ustring
get_active_layout_platform
(
Document
*
document
);
typedef
std
::
vector
<
sharedptr
<
LayoutItem_Field
>
>
type_vecLayoutFields
;
typedef
std
::
vector
<
sharedptr
<
const
LayoutItem_Field
>
>
type_vecConstLayoutFields
;
typedef
std
::
vector
<
std
::
shared
_
ptr
<
LayoutItem_Field
>
>
type_vecLayoutFields
;
typedef
std
::
vector
<
std
::
shared
_
ptr
<
const
LayoutItem_Field
>
>
type_vecConstLayoutFields
;
protected:
typedef
std
::
list
<
sharedptr
<
LayoutItem_Field
>
>
type_list_field_items
;
typedef
std
::
list
<
sharedptr
<
const
LayoutItem_Field
>
>
type_list_const_field_items
;
typedef
std
::
list
<
std
::
shared
_
ptr
<
LayoutItem_Field
>
>
type_list_field_items
;
typedef
std
::
list
<
std
::
shared
_
ptr
<
const
LayoutItem_Field
>
>
type_list_const_field_items
;
#ifndef GLOM_ENABLE_CLIENT_ONLY
/** Allow the user to select a field from the list of fields for the table.
*/
sharedptr
<
LayoutItem_Field
>
offer_field_list_select_one_field
(
const
Glib
::
ustring
&
table_name
,
Gtk
::
Window
*
transient_for
=
0
);
std
::
shared
_
ptr
<
LayoutItem_Field
>
offer_field_list_select_one_field
(
const
Glib
::
ustring
&
table_name
,
Gtk
::
Window
*
transient_for
=
0
);
/** Allow the user to select a field from the list of fields for the table,
* with @a start_field selected by default.
*/
sharedptr
<
LayoutItem_Field
>
offer_field_list_select_one_field
(
const
sharedptr
<
const
LayoutItem_Field
>&
start_field
,
const
Glib
::
ustring
&
table_name
,
Gtk
::
Window
*
transient_for
=
0
);
std
::
shared
_
ptr
<
LayoutItem_Field
>
offer_field_list_select_one_field
(
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
start_field
,
const
Glib
::
ustring
&
table_name
,
Gtk
::
Window
*
transient_for
=
0
);
/** Allow the user to select fields from the list of fields for the table.
...
...
@@ -106,25 +106,25 @@ protected:
type_list_field_items
offer_field_list
(
const
Glib
::
ustring
&
table_name
,
Gtk
::
Window
*
transient_for
=
0
);
sharedptr
<
LayoutItem_Field
>
offer_field_formatting
(
const
sharedptr
<
const
LayoutItem_Field
>&
start_field
,
const
Glib
::
ustring
&
table_name
,
Gtk
::
Window
*
transient_for
,
bool
show_editable_options
=
true
);
std
::
shared
_
ptr
<
LayoutItem_Field
>
offer_field_formatting
(
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
start_field
,
const
Glib
::
ustring
&
table_name
,
Gtk
::
Window
*
transient_for
,
bool
show_editable_options
=
true
);
/** Offer generic formatting for a @a layout_item, starting with its current options.
* @result true if the user changed some formatting for the items.
*/
bool
offer_non_field_item_formatting
(
const
sharedptr
<
LayoutItem_WithFormatting
>&
layout_item
,
Gtk
::
Window
*
transient_for
=
0
);
bool
offer_non_field_item_formatting
(
const
std
::
shared
_
ptr
<
LayoutItem_WithFormatting
>&
layout_item
,
Gtk
::
Window
*
transient_for
=
0
);
sharedptr
<
LayoutItem_Text
>
offer_textobject
(
const
sharedptr
<
LayoutItem_Text
>&
start_textobject
,
Gtk
::
Window
*
transient_for
=
0
,
bool
show_title
=
true
);
sharedptr
<
LayoutItem_Image
>
offer_imageobject
(
const
sharedptr
<
LayoutItem_Image
>&
start_imageobject
,
Gtk
::
Window
*
transient_for
=
0
,
bool
show_title
=
true
);
sharedptr
<
LayoutItem_Notebook
>
offer_notebook
(
const
sharedptr
<
LayoutItem_Notebook
>&
start_notebook
,
Gtk
::
Window
*
transient_for
=
0
);
std
::
shared
_
ptr
<
LayoutItem_Text
>
offer_textobject
(
const
std
::
shared
_
ptr
<
LayoutItem_Text
>&
start_textobject
,
Gtk
::
Window
*
transient_for
=
0
,
bool
show_title
=
true
);
std
::
shared
_
ptr
<
LayoutItem_Image
>
offer_imageobject
(
const
std
::
shared
_
ptr
<
LayoutItem_Image
>&
start_imageobject
,
Gtk
::
Window
*
transient_for
=
0
,
bool
show_title
=
true
);
std
::
shared
_
ptr
<
LayoutItem_Notebook
>
offer_notebook
(
const
std
::
shared
_
ptr
<
LayoutItem_Notebook
>&
start_notebook
,
Gtk
::
Window
*
transient_for
=
0
);
#endif // !GLOM_ENABLE_CLIENT_ONLY
bool
get_relationship_exists
(
const
Glib
::
ustring
&
table_name
,
const
Glib
::
ustring
&
relationship_name
);
sharedptr
<
Field
>
get_field_primary_key_for_table
(
const
Glib
::
ustring
&
table_name
)
const
;
std
::
shared
_
ptr
<
Field
>
get_field_primary_key_for_table
(
const
Glib
::
ustring
&
table_name
)
const
;
//Methods to be overridden by derived classes:
virtual
void
set_entered_field_data
(
const
sharedptr
<
const
LayoutItem_Field
>&
field
,
const
Gnome
::
Gda
::
Value
&
value
);
virtual
void
set_entered_field_data
(
const
Gtk
::
TreeModel
::
iterator
&
row
,
const
sharedptr
<
const
LayoutItem_Field
>&
field
,
const
Gnome
::
Gda
::
Value
&
value
);
virtual
void
set_entered_field_data
(
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
field
,
const
Gnome
::
Gda
::
Value
&
value
);
virtual
void
set_entered_field_data
(
const
Gtk
::
TreeModel
::
iterator
&
row
,
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
field
,
const
Gnome
::
Gda
::
Value
&
value
);
class
FieldInRecord
...
...
@@ -133,12 +133,12 @@ protected:
FieldInRecord
()
{}
FieldInRecord
(
const
Glib
::
ustring
&
table_name
,
const
sharedptr
<
const
Field
>&
field
,
const
sharedptr
<
const
Field
>&
key
,
const
Gnome
::
Gda
::
Value
&
key_value
)
FieldInRecord
(
const
Glib
::
ustring
&
table_name
,
const
std
::
shared
_
ptr
<
const
Field
>&
field
,
const
std
::
shared
_
ptr
<
const
Field
>&
key
,
const
Gnome
::
Gda
::
Value
&
key_value
)
:
m_table_name
(
table_name
),
m_field
(
field
),
m_key
(
key
),
m_key_value
(
key_value
)
{
}
FieldInRecord
(
const
sharedptr
<
const
LayoutItem_Field
>&
layout_item
,
const
Glib
::
ustring
&
parent_table_name
,
const
sharedptr
<
const
Field
>&
parent_key
,
const
Gnome
::
Gda
::
Value
&
key_value
,
const
Document
&
document
)
FieldInRecord
(
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
layout_item
,
const
Glib
::
ustring
&
parent_table_name
,
const
std
::
shared
_
ptr
<
const
Field
>&
parent_key
,
const
Gnome
::
Gda
::
Value
&
key_value
,
const
Document
&
document
)
:
m_key_value
(
key_value
)
{
m_field
=
layout_item
->
get_full_field_details
();
...
...
@@ -148,12 +148,12 @@ protected:
if
(
layout_item
->
get_has_relationship_name
())
{
//The field is in a related table.
sharedptr
<
const
Relationship
>
rel
=
layout_item
->
get_relationship
();
std
::
shared
_
ptr
<
const
Relationship
>
rel
=
layout_item
->
get_relationship
();
if
(
rel
)
{
if
(
layout_item
->
get_has_related_relationship_name
())
//For doubly-related fields
{
sharedptr
<
const
Relationship
>
rel
=
layout_item
->
get_related_relationship
();
std
::
shared
_
ptr
<
const
Relationship
>
rel
=
layout_item
->
get_related_relationship
();
if
(
rel
)
{
//Actually a foreign key in a doubly-related table:
...
...
@@ -175,10 +175,10 @@ protected:
//Identify the field:
Glib
::
ustring
m_table_name
;
sharedptr
<
const
Field
>
m_field
;
std
::
shared
_
ptr
<
const
Field
>
m_field
;
//Identify the record:
sharedptr
<
const
Field
>
m_key
;
std
::
shared
_
ptr
<
const
Field
>
m_key
;
Gnome
::
Gda
::
Value
m_key_value
;
};
...
...
@@ -189,7 +189,7 @@ protected:
LayoutFieldInRecord
()
{}
LayoutFieldInRecord
(
const
sharedptr
<
const
LayoutItem_Field
>&
layout_item
,
const
Glib
::
ustring
&
parent_table_name
,
const
sharedptr
<
const
Field
>&
parent_key
,
const
Gnome
::
Gda
::
Value
&
key_value
)
LayoutFieldInRecord
(
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
layout_item
,
const
Glib
::
ustring
&
parent_table_name
,
const
std
::
shared
_
ptr
<
const
Field
>&
parent_key
,
const
Gnome
::
Gda
::
Value
&
key_value
)
:
m_key_value
(
key_value
)
{
m_field
=
layout_item
;
...
...
@@ -204,10 +204,10 @@ protected:
//Identify the field:
Glib
::
ustring
m_table_name
;
sharedptr
<
const
LayoutItem_Field
>
m_field
;
std
::
shared
_
ptr
<
const
LayoutItem_Field
>
m_field
;
//Identify the record:
sharedptr
<
const
Field
>
m_key
;
std
::
shared
_
ptr
<
const
Field
>
m_key
;
Gnome
::
Gda
::
Value
m_key_value
;
};
...
...
@@ -224,20 +224,20 @@ protected:
/** Get the fields whose values should be recalculated when @a field_name changes.
*/
type_list_const_field_items
get_calculated_fields
(
const
Glib
::
ustring
&
table_name
,
const
sharedptr
<
const
LayoutItem_Field
>&
field
);
type_list_const_field_items
get_calculated_fields
(
const
Glib
::
ustring
&
table_name
,
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
field
);
/** Get the fields used, if any, in the calculation of this field.
*/
type_list_const_field_items
get_calculation_fields
(
const
Glib
::
ustring
&
table_name
,
const
sharedptr
<
const
LayoutItem_Field
>&
field
);
type_list_const_field_items
get_calculation_fields
(
const
Glib
::
ustring
&
table_name
,
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
field
);
void
calculate_field
(
const
LayoutFieldInRecord
&
field_in_record
);
void
calculate_field_in_all_records
(
const
Glib
::
ustring
&
table_name
,
const
sharedptr
<
const
Field
>&
field
);
void
calculate_field_in_all_records
(
const
Glib
::
ustring
&
table_name
,
const
sharedptr
<
const
Field
>&
field
,
const
sharedptr
<
const
Field
>&
primary_key
);
void
calculate_field_in_all_records
(
const
Glib
::
ustring
&
table_name
,
const
std
::
shared
_
ptr
<
const
Field
>&
field
);
void
calculate_field_in_all_records
(
const
Glib
::
ustring
&
table_name
,
const
std
::
shared
_
ptr
<
const
Field
>&
field
,
const
std
::
shared
_
ptr
<
const
Field
>&
primary_key
);
typedef
std
::
map
<
Glib
::
ustring
,
Gnome
::
Gda
::
Value
>
type_map_fields
;
//TODO: Performance: This is massively inefficient:
type_map_fields
get_record_field_values_for_calculation
(
const
Glib
::
ustring
&
table_name
,
const
sharedptr
<
const
Field
>
primary_key
,
const
Gnome
::
Gda
::
Value
&
primary_key_value
);
type_map_fields
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
);
void
do_lookups
(
const
LayoutFieldInRecord
&
field_in_record
,
const
Gtk
::
TreeModel
::
iterator
&
row
,
const
Gnome
::
Gda
::
Value
&
field_value
);
...
...
@@ -254,12 +254,12 @@ protected:
Gnome
::
Gda
::
Value
get_field_value_in_database
(
const
LayoutFieldInRecord
&
field_in_record
,
Gtk
::
Window
*
parent_window
);
///Get a single field value from the database.
Gnome
::
Gda
::
Value
get_field_value_in_database
(
const
sharedptr
<
Field
>&
field
,
const
FoundSet
&
found_set
,
Gtk
::
Window
*
parent_window
);
Gnome
::
Gda
::
Value
get_field_value_in_database
(
const
std
::
shared
_
ptr
<
Field
>&
field
,
const
FoundSet
&
found_set
,
Gtk
::
Window
*
parent_window
);
bool
get_field_value_is_unique
(
const
Glib
::
ustring
&
table_name
,
const
sharedptr
<
const
LayoutItem_Field
>&
field
,
const
Gnome
::
Gda
::
Value
&
value
);
bool
get_field_value_is_unique
(
const
Glib
::
ustring
&
table_name
,
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
field
,
const
Gnome
::
Gda
::
Value
&
value
);
bool
check_entered_value_for_uniqueness
(
const
Glib
::
ustring
&
table_name
,
const
sharedptr
<
const
LayoutItem_Field
>&
field
,
const
Gnome
::
Gda
::
Value
&
value
,
Gtk
::
Window
*
parent_window
);
bool
check_entered_value_for_uniqueness
(
const
Glib
::
ustring
&
table_name
,
const
Gtk
::
TreeModel
::
iterator
&
/* row */
,
const
sharedptr
<
const
LayoutItem_Field
>&
field
,
const
Gnome
::
Gda
::
Value
&
value
,
Gtk
::
Window
*
parent_window
);
bool
check_entered_value_for_uniqueness
(
const
Glib
::
ustring
&
table_name
,
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
field
,
const
Gnome
::
Gda
::
Value
&
value
,
Gtk
::
Window
*
parent_window
);
bool
check_entered_value_for_uniqueness
(
const
Glib
::
ustring
&
table_name
,
const
Gtk
::
TreeModel
::
iterator
&
/* row */
,
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
field
,
const
Gnome
::
Gda
::
Value
&
value
,
Gtk
::
Window
*
parent_window
);
//TODO: Make this private?
/** Fill the UI with information (data or structure, depending on the widget).
...
...
@@ -270,7 +270,7 @@ protected:
virtual
void
on_userlevel_changed
(
AppState
::
userlevels
userlevel
);
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
;
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
std
::
shared
_
ptr
<
LayoutGroup
>&
group
,
type_vecConstLayoutFields
&
vecFields
)
const
;
bool
get_primary_key_is_in_foundset
(
const
FoundSet
&
found_set
,
const
Gnome
::
Gda
::
Value
&
primary_key_value
);
...
...
@@ -281,7 +281,7 @@ protected:
* @param portal The related records portal whose records should be selected by the SQL query.
* @param foreign_key_value The value of the from field in the parent table.
*/
void
set_found_set_where_clause_for_portal
(
FoundSet
&
found_set
,
const
sharedptr
<
LayoutItem_Portal
>&
portal
,
const
Gnome
::
Gda
::
Value
&
foreign_key_value
);
void
set_found_set_where_clause_for_portal
(
FoundSet
&
found_set
,
const
std
::
shared
_
ptr
<
LayoutItem_Portal
>&
portal
,
const
Gnome
::
Gda
::
Value
&
foreign_key_value
);
static
Glib
::
RefPtr
<
Gnome
::
Gda
::
Connection
>
get_connection
();
...
...
glom/base_db_table_data.cc
View file @
740dadd8
...
...
@@ -41,15 +41,15 @@ Base_DB_Table_Data::~Base_DB_Table_Data()
{
}
Gnome
::
Gda
::
Value
Base_DB_Table_Data
::
get_entered_field_data_field_only
(
const
sharedptr
<
const
Field
>&
field
)
const
Gnome
::
Gda
::
Value
Base_DB_Table_Data
::
get_entered_field_data_field_only
(
const
std
::
shared
_
ptr
<
const
Field
>&
field
)
const
{
sharedptr
<
LayoutItem_Field
>
layout_item
=
sharedptr
<
LayoutItem_Field
>
::
create
(
);
std
::
shared
_
ptr
<
LayoutItem_Field
>
layout_item
=
std
::
shared
_
ptr
<
LayoutItem_Field
>
(
new
LayoutItem_Field
()
);
layout_item
->
set_full_field_details
(
field
);
return
get_entered_field_data
(
layout_item
);
}
Gnome
::
Gda
::
Value
Base_DB_Table_Data
::
get_entered_field_data
(
const
sharedptr
<
const
LayoutItem_Field
>&
/* field */
)
const
Gnome
::
Gda
::
Value
Base_DB_Table_Data
::
get_entered_field_data
(
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
/* field */
)
const
{
//Override this to use Field::set_data() too.
...
...
@@ -71,7 +71,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
Document
*
document
=
get_document
();
sharedptr
<
const
Field
>
fieldPrimaryKey
=
get_field_primary_key
();
std
::
shared
_
ptr
<
const
Field
>
fieldPrimaryKey
=
get_field_primary_key
();
const
Glib
::
ustring
primary_key_name
=
fieldPrimaryKey
->
get_name
();
...
...
@@ -87,7 +87,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
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
(
);
std
::
shared
_
ptr
<
LayoutItem_Field
>
layout_item
=
std
::
shared
_
ptr
<
LayoutItem_Field
>
(
new
LayoutItem_Field
()
);
layout_item
->
set_full_field_details
(
*
iter
);
fieldsToAdd
.
push_back
(
layout_item
);
...
...
@@ -105,7 +105,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
for
(
type_vecConstLayoutFields
::
const_iterator
iter
=
fieldsToAdd
.
begin
();
iter
!=
fieldsToAdd
.
end
();
++
iter
)
{
sharedptr
<
const
LayoutItem_Field
>
layout_item
=
*
iter
;
std
::
shared
_
ptr
<
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.
{
...
...
@@ -114,7 +114,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
{
Gnome
::
Gda
::
Value
value
;
const
sharedptr
<
const
Field
>&
field
=
layout_item
->
get_full_field_details
();
const
std
::
shared
_
ptr
<
const
Field
>&
field
=
layout_item
->
get_full_field_details
();
if
(
!
field
)
continue
;
...
...
@@ -139,7 +139,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
//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?
sharedptr
<
SharedConnection
>
sharedconnection
=
connect_to_server
(
AppWindow
::
get_appwindow
());
std
::
shared
_
ptr
<
SharedConnection
>
sharedconnection
=
connect_to_server
(
AppWindow
::
get_appwindow
());
Glib
::
ustring
error_message
;
//TODO: Check this.
value
=
...
...
@@ -207,7 +207,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
//Update any lookups, related fields, or calculations:
for
(
type_vecConstLayoutFields
::
const_iterator
iter
=
fieldsToAdd
.
begin
();
iter
!=
fieldsToAdd
.
end
();
++
iter
)
{
sharedptr
<
const
LayoutItem_Field
>
layout_item
=
*
iter
;
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
);
...
...
@@ -232,9 +232,9 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
return
false
;
//Failed.
}
bool
Base_DB_Table_Data
::
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
,
bool
Base_DB_Table_Data
::
add_related_record_for_field
(
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
layout_item_parent
,
const
std
::
shared
_
ptr
<
const
Relationship
>&
relationship
,
const
std
::
shared
_
ptr
<
const
Field
>&
primary_key_field
,
const
Gnome
::
Gda
::
Value
&
primary_key_value_provided
,
Gnome
::
Gda
::
Value
&
primary_key_value_used
)
{
...
...
@@ -312,7 +312,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const sharedptr<const Layo
if
(
key_is_auto_increment
)
{
//Set the key in the parent table
sharedptr
<
LayoutItem_Field
>
item_from_key
=
sharedptr
<
LayoutItem_Field
>
::
create
(
);
std
::
shared
_
ptr
<
LayoutItem_Field
>
item_from_key
=
std
::
shared
_
ptr
<
LayoutItem_Field
>
(
new
LayoutItem_Field
()
);
item_from_key
->
set_name
(
relationship
->
get_from_field
());
//Show the new from key in the parent table's layout:
...
...
@@ -320,7 +320,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const sharedptr<const Layo
//Set it in the database too:
Document
*
document
=
get_document
();
sharedptr
<
Field
>
field_from_key
=
DbUtils
::
get_fields_for_table_one_field
(
document
,
std
::
shared
_
ptr
<
Field
>
field_from_key
=
DbUtils
::
get_fields_for_table_one_field
(
document
,
relationship
->
get_from_table
(),
relationship
->
get_from_field
());
//TODO_Performance.
if
(
!
field_from_key
)
{
...
...
@@ -328,7 +328,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const sharedptr<const Layo
return
false
;
}
sharedptr
<
Field
>
parent_primary_key_field
=
get_field_primary_key
();
std
::
shared
_
ptr
<
Field
>
parent_primary_key_field
=
get_field_primary_key
();
if
(
!
parent_primary_key_field
)
{
std
::
cerr
<<
G_STRFUNC
<<
": get_field_primary_key() failed. table = "
<<
get_table_name
()
<<
std
::
endl
;
...
...
@@ -400,7 +400,7 @@ bool Base_DB_Table_Data::confirm_delete_record()
bool
Base_DB_Table_Data
::
record_delete
(
const
Gnome
::
Gda
::
Value
&
primary_key_value
)
{
sharedptr
<
Field
>
field_primary_key
=
get_field_primary_key
();
std
::
shared
_
ptr
<
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
=
...
...
@@ -424,7 +424,7 @@ Base_DB_Table_Data::type_signal_record_changed Base_DB_Table_Data::signal_record
}
bool
Base_DB_Table_Data
::
get_related_record_exists
(
const
sharedptr
<
const
Relationship
>&
relationship
,
const
Gnome
::
Gda
::
Value
&
key_value
)
bool
Base_DB_Table_Data
::
get_related_record_exists
(
const
std
::
shared
_
ptr
<
const
Relationship
>&
relationship
,
const
Gnome
::
Gda
::
Value
&
key_value
)
{
BusyCursor
cursor
(
AppWindow
::
get_appwindow
());
...
...
@@ -465,7 +465,7 @@ 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_vecConstLayoutFields
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
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
field
)
const
{
type_vecConstLayoutFields
result
;
...
...
@@ -475,12 +475,12 @@ Base_DB_Table_Data::type_vecConstLayoutFields Base_DB_Table_Data::get_related_fi
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_vecConstLayoutFields
::
const_iterator
iter
=
m_FieldsShown
.
begin
();
iter
!=
m_FieldsShown
.
end
();
++
iter
)
{
const
sharedptr
<
const
LayoutItem_Field
>
layout_field
=
*
iter
;
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>
layout_field
=
*
iter
;
//Examine each field that looks up its data from a relationship:
if
(
layout_field
->
get_has_relationship_name
())
{
//Get the relationship information:
sharedptr
<
const
Relationship
>
relationship
=
document
->
get_relationship
(
m_table_name
,
layout_field
->
get_relationship_name
());
std
::
shared
_
ptr
<
const
Relationship
>
relationship
=
document
->
get_relationship
(
m_table_name
,
layout_field
->
get_relationship_name
());
if
(
relationship
)
{
//If the relationship uses the specified field:
...
...
@@ -536,7 +536,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
<
const
LayoutItem_Field
>
layout_item
=
*
iterFields
;
std
::
shared
_
ptr
<
const
LayoutItem_Field
>
layout_item
=
*
iterFields
;
if
(
!
layout_item
)
std
::
cerr
<<
G_STRFUNC
<<
": The layout_item was null."
<<
std
::
endl
;
else
...
...
glom/base_db_table_data.h
View file @
740dadd8
...
...
@@ -52,8 +52,8 @@ protected:
*/
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
;
Gnome
::
Gda
::
Value
get_entered_field_data_field_only
(
const
std
::
shared
_
ptr
<
const
Field
>&
field
)
const
;
virtual
Gnome
::
Gda
::
Value
get_entered_field_data
(
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
field
)
const
;
//Gets the row being edited, for derived classes that have rows.
virtual
Gtk
::
TreeModel
::
iterator
get_row_selected
();
...
...
@@ -64,7 +64,7 @@ protected:
/** Get the fields that are in related tables, via a relationship using @a field_name changes.
*/
type_vecConstLayoutFields
get_related_fields
(
const
sharedptr
<
const
LayoutItem_Field
>&
field
)
const
;
type_vecConstLayoutFields
get_related_fields
(
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
field
)
const
;
/** Ask the user if he really wants to delete the record.
*/
...
...
@@ -75,7 +75,7 @@ protected:
*/
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
);
bool
add_related_record_for_field
(
const
std
::
shared
_
ptr
<
const
LayoutItem_Field
>&
layout_item_parent
,
const
std
::
shared
_
ptr
<
const
Relationship
>&
relationship
,
const
std
::
shared
_
ptr
<
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.
...
...
@@ -83,7 +83,7 @@ protected:
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
);
bool
get_related_record_exists
(
const
std
::
shared
_
ptr
<
const
Relationship
>&
relationship
,
const
Gnome
::
Gda
::
Value
&
key_value
);
};
}
//namespace Glom
...
...
glom/base_db_table_data_readonly.h
View file @
740dadd8
...
...
@@ -43,7 +43,7 @@ public:
protected:
//TODO: Move these to Base_DB_Table_Data too?
virtual
sharedptr
<
Field
>
get_field_primary_key
()
const
=
0
;
virtual
std
::
shared
_
ptr
<
Field
>
get_field_primary_key
()
const
=
0
;
//TODO: Document whether these get the primary key in an existing record,
//or the primary key value as it is entered in the UI, even before a record exists,
...