Commit 0519800f authored by Murray Cumming's avatar Murray Cumming
Browse files

Const corrections in use of LayoutItem and LayoutItem_Field in vectors.

  This allows DbTreeModel to take a vector of const items.
parent db52f743
2010-09-24 Murray Cumming <murrayc@murrayc.com>
Const corrections in use of LayoutItem and LayoutItem_Field in vectors.
This allows DbTreeModel to take a vector of const items.
2010-09-24 David King <davidk@openismus.com>
Improve use of defines
......
......@@ -709,7 +709,7 @@ sharedptr<Field> Base_DB::get_field_primary_key_for_table(const Glib::ustring& t
return sharedptr<Field>();
}
void Base_DB::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, Base_DB::type_vecLayoutFields& vecFields) const
void Base_DB::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, Base_DB::type_vecConstLayoutFields& vecFields) const
{
//g_warning("Box_Data::get_table_fields_to_show_for_sequence_add_group(): table_name=%s, all_db_fields.size()=%d, group->name=%s", table_name.c_str(), all_db_fields.size(), group->get_name().c_str());
......@@ -787,7 +787,7 @@ void Base_DB::get_table_fields_to_show_for_sequence_add_group(const Glib::ustrin
}
}
Base_DB::type_vecLayoutFields Base_DB::get_table_fields_to_show_for_sequence(const Glib::ustring& table_name, const Document::type_list_layout_groups& mapGroupSequence) const
Base_DB::type_vecConstLayoutFields Base_DB::get_table_fields_to_show_for_sequence(const Glib::ustring& table_name, const Document::type_list_layout_groups& mapGroupSequence) const
{
//Get field definitions from the database, with corrections from the document:
type_vec_fields all_fields = get_fields_for_table(table_name);
......@@ -795,7 +795,7 @@ Base_DB::type_vecLayoutFields Base_DB::get_table_fields_to_show_for_sequence(con
const Privileges table_privs = Privs::get_current_privs(table_name);
//Get fields that the document says we should show:
type_vecLayoutFields result;
type_vecConstLayoutFields result;
const Document* pDoc = dynamic_cast<const Document*>(get_document());
if(pDoc)
{
......
......@@ -302,8 +302,8 @@ protected:
virtual void on_userlevel_changed(AppState::userlevels userlevel);
type_vecLayoutFields 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_vecLayoutFields& vecFields) const;
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;
/** Get the relationship into which the row button should navigate,
* or the relationship itself, if the navigation_main output parameter is set to true after calling this method.
......
......@@ -69,7 +69,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_vecLayoutFields fieldsToAdd = m_FieldsShown;
type_vecConstLayoutFields fieldsToAdd = m_FieldsShown;
if(m_TableFields.empty())
m_TableFields = get_fields_for_table(m_table_name);
......@@ -78,7 +78,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
for(type_vec_fields::const_iterator iter = m_TableFields.begin(); iter != m_TableFields.end(); ++iter)
{
//TODO: Search for the non-related field with the name, not just the field with the name:
type_vecLayoutFields::const_iterator iterFind = std::find_if(fieldsToAdd.begin(), fieldsToAdd.end(), predicate_FieldHasName<LayoutItem_Field>((*iter)->get_name()));
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();
......@@ -91,9 +91,9 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
Document* document = get_document();
//Calculate any necessary field values and enter them:
for(type_vecLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
for(type_vecConstLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
{
sharedptr<LayoutItem_Field> layout_item = *iter;
sharedptr<const LayoutItem_Field> layout_item = *iter;
//If the user did not enter something in this field:
Gnome::Gda::Value value = get_entered_field_data(layout_item);
......@@ -151,9 +151,9 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
type_map_added map_added;
Glib::RefPtr<Gnome::Gda::Set> params = Gnome::Gda::Set::create();
for(type_vecLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
for(type_vecConstLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
{
sharedptr<LayoutItem_Field> layout_item = *iter;
sharedptr<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.
{
......@@ -208,7 +208,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
set_primary_key_value(row, primary_key_value); //Needed by Box_Data_List::on_adddel_user_changed().
//Update any lookups, related fields, or calculations:
for(type_vecLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
for(type_vecConstLayoutFields::const_iterator iter = fieldsToAdd.begin(); iter != fieldsToAdd.end(); ++iter)
{
sharedptr<const LayoutItem_Field> layout_item = *iter;
......@@ -354,8 +354,8 @@ bool Base_DB_Table_Data::add_related_record_for_field(const sharedptr<const Layo
}
else
{
const Glib::ustring target_table = relationship->get_from_table();
Glib::RefPtr<Gnome::Gda::SqlBuilder> builder =
const Glib::ustring 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);
builder->add_field_value_as_value(relationship->get_from_field(), primary_key_value);
......@@ -363,7 +363,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const sharedptr<const Layo
builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
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);
if(!test)
{
......@@ -417,7 +417,7 @@ bool Base_DB_Table_Data::record_delete(const Gnome::Gda::Value& primary_key_valu
sharedptr<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 =
Glib::RefPtr<Gnome::Gda::SqlBuilder> builder =
Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_DELETE);
builder->set_table(m_table_name);
builder->set_where(
......@@ -453,7 +453,7 @@ bool Base_DB_Table_Data::get_related_record_exists(const sharedptr<const Relatio
const Glib::ustring to_field = relationship->get_to_field();
const Glib::ustring 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?
//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 =
Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_SELECT);
builder->select_add_field(to_field, related_table);
......@@ -462,7 +462,7 @@ bool Base_DB_Table_Data::get_related_record_exists(const sharedptr<const Relatio
builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_EQ,
builder->add_field_id(to_field, related_table),
builder->add_expr(key_value)));
Glib::RefPtr<Gnome::Gda::DataModel> records = DbUtils::query_execute_select(builder);
if(!records)
handle_error();
......@@ -479,17 +479,17 @@ 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_vecLayoutFields 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 sharedptr<const LayoutItem_Field>& field) const
{
type_vecLayoutFields result;
type_vecConstLayoutFields result;
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.
for(type_vecLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
for(type_vecConstLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
{
sharedptr<LayoutItem_Field> layout_field = *iter;
const sharedptr<const LayoutItem_Field> layout_field = *iter;
//Examine each field that looks up its data from a relationship:
if(layout_field->get_has_relationship_name())
{
......@@ -521,7 +521,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_vecLayoutFields fieldsToGet = get_related_fields(field_in_record_changed.m_field);
type_vecConstLayoutFields fieldsToGet = get_related_fields(field_in_record_changed.m_field);
if(!fieldsToGet.empty())
{
......@@ -539,7 +539,7 @@ void Base_DB_Table_Data::refresh_related_fields(const LayoutFieldInRecord& field
//Field contents:
if(result->get_n_rows())
{
type_vecLayoutFields::const_iterator iterFields = fieldsToGet.begin();
type_vecConstLayoutFields::const_iterator iterFields = fieldsToGet.begin();
const guint cols_count = result->get_n_columns();
if(cols_count <= 0)
......@@ -550,7 +550,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<LayoutItem_Field> layout_item = *iterFields;
sharedptr<const LayoutItem_Field> layout_item = *iterFields;
if(!layout_item)
std::cerr << G_STRFUNC << ": The layout_item was null." << std::endl;
else
......
......@@ -27,15 +27,15 @@
namespace Glom
{
/** A base class some database functionality
/** A base class some database functionality
* for use with a specific database table, showing data from the table.
*/
class Base_DB_Table_Data : public Base_DB_Table_Data_ReadOnly
{
public:
public:
Base_DB_Table_Data();
virtual ~Base_DB_Table_Data();
/** Tell the parent widget that something has changed in one of the shown records,
* or a record was added or deleted.
* This is only emitted for widgets for which it would be useful.
......@@ -50,38 +50,38 @@ protected:
/** Create a new record with all the entered field values from the currently-active details/row.
* @result true if the record was added to the database.
*/
bool record_new(bool use_entered_data = true, const Gnome::Gda::Value& primary_key_value = Gnome::Gda::Value());
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;
//Gets the row being edited, for derived classes that have rows.
virtual Gtk::TreeModel::iterator get_row_selected();
virtual void set_primary_key_value(const Gtk::TreeModel::iterator& row, const Gnome::Gda::Value& value) = 0;
virtual void refresh_related_fields(const LayoutFieldInRecord& field_in_record_changed, const Gtk::TreeModel::iterator& row, const Gnome::Gda::Value& field_value);
/** Get the fields that are in related tables, via a relationship using @a field_name changes.
*/
type_vecLayoutFields get_related_fields(const sharedptr<const LayoutItem_Field>& field) const;
type_vecConstLayoutFields get_related_fields(const sharedptr<const LayoutItem_Field>& field) const;
/** Ask the user if he really wants to delete the record.
*/
*/
bool confirm_delete_record();
/** Delete a record from the database table.
* @param primary_key_value A primary key to indentify the record to delete.
*/
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);
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.
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);
};
......
......@@ -50,7 +50,7 @@ protected:
FoundSet m_found_set;
type_vec_fields m_TableFields; //A cache, so we don't have to repeatedly get them from the Document.
type_vecLayoutFields m_FieldsShown; //And any extra keys needed by shown fields. //TODO: Move to the non-read-only class?
type_vecConstLayoutFields m_FieldsShown; //And any extra keys needed by shown fields. //TODO: Move to the non-read-only class?
};
} //namespace Glom
......
......@@ -679,7 +679,7 @@ void Frame_Glom::on_menu_file_export()
//TODO: Reduce copy/pasting in these export_data_to_*() methods:
void Frame_Glom::export_data_to_vector(Document::type_example_rows& the_vector, const FoundSet& found_set, const Document::type_list_layout_groups& sequence)
{
type_vecLayoutFields fieldsSequence = get_table_fields_to_show_for_sequence(found_set.m_table_name, sequence);
type_vecConstLayoutFields fieldsSequence = get_table_fields_to_show_for_sequence(found_set.m_table_name, sequence);
if(fieldsSequence.empty())
{
......@@ -708,7 +708,7 @@ void Frame_Glom::export_data_to_vector(Document::type_example_rows& the_vector,
{
const Gnome::Gda::Value value = result->get_value_at(col_index, row_index);
sharedptr<LayoutItem_Field> layout_item = fieldsSequence[col_index];
sharedptr<const LayoutItem_Field> layout_item = fieldsSequence[col_index];
//if(layout_item->m_field.get_glom_type() != Field::TYPE_IMAGE) //This is too much data.
//{
......@@ -729,7 +729,7 @@ void Frame_Glom::export_data_to_vector(Document::type_example_rows& the_vector,
void Frame_Glom::export_data_to_string(Glib::ustring& the_string, const FoundSet& found_set, const Document::type_list_layout_groups& sequence)
{
type_vecLayoutFields fieldsSequence = get_table_fields_to_show_for_sequence(found_set.m_table_name, sequence);
type_vecConstLayoutFields fieldsSequence = get_table_fields_to_show_for_sequence(found_set.m_table_name, sequence);
if(fieldsSequence.empty())
{
......@@ -758,7 +758,7 @@ void Frame_Glom::export_data_to_string(Glib::ustring& the_string, const FoundSet
{
const Gnome::Gda::Value value = result->get_value_at(col_index, row_index);
sharedptr<LayoutItem_Field> layout_item = fieldsSequence[col_index];
sharedptr<const LayoutItem_Field> layout_item = fieldsSequence[col_index];
//if(layout_item->m_field.get_glom_type() != Field::TYPE_IMAGE) //This is too much data.
//{
if(!row_string.empty())
......@@ -781,7 +781,7 @@ void Frame_Glom::export_data_to_string(Glib::ustring& the_string, const FoundSet
void Frame_Glom::export_data_to_stream(std::ostream& the_stream, const FoundSet& found_set, const Document::type_list_layout_groups& sequence)
{
type_vecLayoutFields fieldsSequence = get_table_fields_to_show_for_sequence(found_set.m_table_name, sequence);
type_vecConstLayoutFields fieldsSequence = get_table_fields_to_show_for_sequence(found_set.m_table_name, sequence);
if(fieldsSequence.empty())
{
......@@ -810,7 +810,7 @@ void Frame_Glom::export_data_to_stream(std::ostream& the_stream, const FoundSet&
{
const Gnome::Gda::Value value = result->get_value_at(col_index, row_index);
sharedptr<LayoutItem_Field> layout_item = fieldsSequence[col_index];
sharedptr<const LayoutItem_Field> layout_item = fieldsSequence[col_index];
//if(layout_item->m_field.get_glom_type() != Field::TYPE_IMAGE) //This is too much data.
//{
if(!row_string.empty())
......@@ -2156,13 +2156,13 @@ bool Frame_Glom::connection_request_password_and_choose_new_database_name()
}
// Do startup, such as starting the self-hosting database server
const ConnectionPool::StartupErrors started =
const ConnectionPool::StartupErrors started =
connection_pool->startup( sigc::mem_fun(*this, &Frame_Glom::on_connection_startup_progress) );
if(started != ConnectionPool::Backend::STARTUPERROR_NONE)
{
std::cerr << G_STRFUNC << ": startup() failed." << std::endl;
return false;
}
}
if(m_dialog_progess_connection_startup)
{
......@@ -2324,7 +2324,7 @@ bool Frame_Glom::connection_request_password_and_attempt(bool& database_not_foun
//Start a self-hosted server if necessary:
ConnectionPool* connection_pool = ConnectionPool::get_instance();
connection_pool->setup_from_document(document);
const ConnectionPool::StartupErrors started =
const ConnectionPool::StartupErrors started =
connection_pool->startup( sigc::mem_fun(*this, &Frame_Glom::on_connection_startup_progress) );
if(started != ConnectionPool::Backend::STARTUPERROR_NONE)
{
......
......@@ -93,7 +93,7 @@ Gnome::Gda::SqlExpr Box_Data::get_find_where_clause() const
guint where_cond_id = 0;
//Look at each field entry and build e.g. 'Name = "Bob"'
for(type_vecLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
for(type_vecConstLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
{
const Gnome::Gda::Value data = get_entered_field_data(*iter);
......@@ -236,17 +236,17 @@ void Box_Data::on_dialog_layout_hide()
}
#endif // !GLOM_ENABLE_CLIENT_ONLY
Box_Data::type_vecLayoutFields Box_Data::get_fields_to_show() const
Box_Data::type_vecConstLayoutFields Box_Data::get_fields_to_show() const
{
if(m_table_name.empty())
{
return type_vecLayoutFields();
return type_vecConstLayoutFields();
}
else
return get_table_fields_to_show(m_table_name);
}
Box_Data::type_vecLayoutFields Box_Data::get_table_fields_to_show(const Glib::ustring& table_name) const
Box_Data::type_vecConstLayoutFields Box_Data::get_table_fields_to_show(const Glib::ustring& table_name) const
{
const Document* pDoc = dynamic_cast<const Document*>(get_document());
if(pDoc)
......@@ -255,7 +255,7 @@ Box_Data::type_vecLayoutFields Box_Data::get_table_fields_to_show(const Glib::us
return get_table_fields_to_show_for_sequence(table_name, mapGroupSequence);
}
else
return type_vecLayoutFields();
return type_vecConstLayoutFields();
}
Document::type_list_layout_groups Box_Data::get_data_layout_groups(const Glib::ustring& layout_name, const Glib::ustring& layout_platform)
......
......@@ -97,9 +97,9 @@ protected:
///Fill the existing layout with data from the database.
virtual bool fill_from_database(); //override.
virtual type_vecLayoutFields get_fields_to_show() const;
virtual type_vecConstLayoutFields get_fields_to_show() const;
type_vecLayoutFields get_table_fields_to_show(const Glib::ustring& table_name) const;
type_vecConstLayoutFields get_table_fields_to_show(const Glib::ustring& table_name) const;
/** Get the layout groups, with the Field information filled in.
*/
......
......@@ -310,9 +310,9 @@ void Box_Data_Calendar_Related::on_record_added(const Gnome::Gda::Value& primary
}
}
Box_Data_Calendar_Related::type_vecLayoutFields Box_Data_Calendar_Related::get_fields_to_show() const
Box_Data_Calendar_Related::type_vecConstLayoutFields Box_Data_Calendar_Related::get_fields_to_show() const
{
type_vecLayoutFields layout_fields = Box_Data_Portal::get_fields_to_show();
type_vecConstLayoutFields layout_fields = Box_Data_Portal::get_fields_to_show();
sharedptr<LayoutItem_CalendarPortal> derived_portal = sharedptr<LayoutItem_CalendarPortal>::cast_dynamic(m_portal);
if(!derived_portal)
......
......@@ -50,7 +50,7 @@ public:
private:
virtual bool fill_from_database(); //Override.
virtual type_vecLayoutFields get_fields_to_show() const; //override
virtual type_vecConstLayoutFields get_fields_to_show() const; //override
//Implementations of pure virtual methods from Base_DB_Table_Data:
......
......@@ -291,7 +291,7 @@ bool Box_Data_Details::fill_from_database()
bResult = Box_Data::fill_from_database();
m_FieldsShown = get_fields_to_show();
type_vecLayoutFields fieldsToGet = m_FieldsShown;
type_vecConstLayoutFields fieldsToGet = m_FieldsShown;
if(!fieldsToGet.empty())
{
......@@ -314,7 +314,7 @@ bool Box_Data_Details::fill_from_database()
//TODO_Performance: Do this for create_layout() only, instead of repeating it for each refresh?:
int index_primary_key = -1; //Arbitrary default.
//g_warning("primary_key name = %s", m_field_primary_key->get_name().c_str());
const type_vecLayoutFields::const_iterator iterFind = std::find_if(fieldsToGet.begin(), fieldsToGet.end(), predicate_LayoutItem_Field_IsSameField<LayoutItem_Field>(layout_item));
const type_vecConstLayoutFields::const_iterator iterFind = std::find_if(fieldsToGet.begin(), fieldsToGet.end(), predicate_LayoutItem_Field_IsSameField<LayoutItem_Field>(layout_item));
if(iterFind == fieldsToGet.end())
{
fieldsToGet.push_back(layout_item);
......@@ -379,7 +379,7 @@ bool Box_Data_Details::fill_from_database()
//Get field values to show:
for(int i = 0; i < cols_count; ++i)
{
sharedptr<LayoutItem_Field> layout_item = fieldsToGet[i];
sharedptr<const LayoutItem_Field> layout_item = fieldsToGet[i];
//Field value:
Gnome::Gda::Value value;
......
......@@ -504,9 +504,11 @@ void Box_Data_List::print_layout() //TODO: Is this a duplicate of the one in box
report_temp->set_title(_("List"));
//Add all the fields from the layout:
for(type_vecLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
for(type_vecConstLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
{
report_temp->m_layout_group->add_item(*iter);
sharedptr<const LayoutItem> item = *iter;
sharedptr<LayoutItem> unconst = sharedptr<LayoutItem>::cast_const(item); //TODO: Avoid this?
report_temp->m_layout_group->add_item(unconst);
}
ReportBuilder report_builder;
......
......@@ -35,7 +35,7 @@ Box_Data_ManyRecords::Box_Data_ManyRecords()
: m_has_one_or_more_records(false),
m_read_only(false)
{
//We do not actually use this,
//We do not actually use this,
//so it is a bug if this appears in the .glom file:
m_layout_name = "manyrecords"; //Set by derived classes.
......@@ -57,7 +57,7 @@ void Box_Data_ManyRecords::refresh_data_from_database_blank()
Document::type_list_layout_groups Box_Data_ManyRecords::create_layout_get_layout()
{
//Overriden in Box_Data_ManyRecords_Related:
return get_data_layout_groups(m_layout_name);
return get_data_layout_groups(m_layout_name);
}
*/
......@@ -83,9 +83,11 @@ void Box_Data_ManyRecords::print_layout()
report_temp->set_title(_("List"));
//Add all the fields from the layout:
for(type_vecLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
for(type_vecConstLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
{
report_temp->m_layout_group->add_item(*iter);
sharedptr<const LayoutItem> item = *iter;
sharedptr<LayoutItem> unconst = sharedptr<LayoutItem>::cast_const(item); //TODO: Avoid this?
report_temp->m_layout_group->add_item(unconst);
}
ReportBuilder report_builder;
......@@ -104,4 +106,3 @@ void Box_Data_ManyRecords::set_primary_key_value_selected(const Gnome::Gda::Valu
}
} //namespace Glom
......@@ -365,7 +365,7 @@ void Box_Data_Portal::on_record_added(const Gnome::Gda::Value& /* primary_key_va
signal_portal_record_changed().emit(m_portal->get_relationship_name());
}
Box_Data_Portal::type_vecLayoutFields Box_Data_Portal::get_fields_to_show() const
Box_Data_Portal::type_vecConstLayoutFields Box_Data_Portal::get_fields_to_show() const
{
const Document* document = get_document();
if(document && m_portal)
......@@ -376,24 +376,27 @@ Box_Data_Portal::type_vecLayoutFields Box_Data_Portal::get_fields_to_show() cons
sharedptr<const Relationship> relationship = m_portal->get_relationship();
if(relationship)
{
type_vecLayoutFields result = get_table_fields_to_show_for_sequence(m_portal->get_table_used(Glib::ustring() /* not relevant */), mapGroups);
type_vecConstLayoutFields result = get_table_fields_to_show_for_sequence(m_portal->get_table_used(Glib::ustring() /* not relevant */), mapGroups);
//If the relationship does not allow editing, then mark all these fields as non-editable:
//TODO: Prevent this in some other way:
/*
if(!(m_portal->get_relationship_used_allows_edit()))
{
for(type_vecLayoutFields::iterator iter = result.begin(); iter != result.end(); ++iter)
for(type_vecConstLayoutFields::iterator iter = result.begin(); iter != result.end(); ++iter)
{
sharedptr<LayoutItem_Field> item = *iter;
sharedptr<const LayoutItem_Field> item = *iter;
if(item)
item->set_editable(false);
}
}
*/
return result;
}
}
return type_vecLayoutFields();
return type_vecConstLayoutFields();
}
#ifndef GLOM_ENABLE_CLIENT_ONLY
......
......@@ -81,7 +81,7 @@ public:
void get_suitable_record_to_view_details(const Gnome::Gda::Value& primary_key_value, Glib::ustring& table_name, Gnome::Gda::Value& table_primary_key_value) const;
protected:
virtual type_vecLayoutFields get_fields_to_show() const; //override
virtual type_vecConstLayoutFields get_fields_to_show() const; //override
//Implementations of pure virtual methods from Base_DB_Table_Data:
virtual sharedptr<Field> get_field_primary_key() const;
......
......@@ -702,8 +702,10 @@ Gtk::CellRenderer* DbAddDel::construct_specified_columns_cellrenderer(const shar
return pCellRenderer;
}
typedef std::vector< sharedptr<const LayoutItem> > type_vec_const_layout_items;
typedef std::vector< sharedptr<LayoutItem> > type_vec_layout_items;
static Glib::RefPtr<DbTreeModel> create_model_db(const FoundSet& found_set, const type_vec_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecLayoutFields& fields_shown)
static Glib::RefPtr<DbTreeModel> create_model_db(const FoundSet& found_set, const type_vec_const_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown)
{
Glib::RefPtr<DbTreeModel> result;
......@@ -716,12 +718,12 @@ static Glib::RefPtr<DbTreeModel> create_model_db(const FoundSet& found_set, cons
Gtk::TreeModel::ColumnRecord record;
//Database columns:
DbTreeModel::type_vec_fields fields;
Base_DB::type_vecConstLayoutFields fields;
{
type_vecModelColumns::size_type i = 0;
for(type_vec_layout_items::const_iterator iter = layout_items.begin(); iter != layout_items.end(); ++iter)
for(type_vec_const_layout_items::const_iterator iter = layout_items.begin(); iter != layout_items.end(); ++iter)
{
sharedptr<LayoutItem_Field> item_field = sharedptr<LayoutItem_Field>::cast_dynamic(*iter);
sharedptr<const LayoutItem_Field> item_field = sharedptr<const LayoutItem_Field>::cast_dynamic(*iter);
if(item_field)
{
type_modelcolumn_value* pModelColumn = new type_modelcolumn_value;
......@@ -744,9 +746,9 @@ static Glib::RefPtr<DbTreeModel> create_model_db(const FoundSet& found_set, cons
//Find the primary key:
int column_index_key = 0;
bool key_found = false;
for(DbTreeModel::type_vec_fields::const_iterator iter = fields.begin(); iter != fields.end(); ++iter)
for(Base_DB::type_vecConstLayoutFields::const_iterator iter = fields.begin(); iter != fields.end(); ++iter)
{
sharedptr<LayoutItem_Field> layout_item = *iter;
sharedptr<const LayoutItem_Field> layout_item = *iter;
if( !(layout_item->get_has_relationship_name()) )
{
sharedptr<const Field> field_full = layout_item->get_full_field_details();
......@@ -770,7 +772,7 @@ static Glib::RefPtr<DbTreeModel> create_model_db(const FoundSet& found_set, cons
else
{
g_warning("%s: no primary key field found.", __FUNCTION__);
//for(DbTreeModel::type_vec_fields::const_iterator iter = fields.begin(); iter != fields.end(); ++iter)
//for(DbTreeModel::type_vec_const_fields::const_iterator iter = fields.begin(); iter != fields.end(); ++iter)
//{