glom r1882 - in branches/glom-1-8: . glom glom/mode_data
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: glom r1882 - in branches/glom-1-8: . glom glom/mode_data
- Date: Fri, 6 Feb 2009 12:31:39 +0000 (UTC)
Author: murrayc
Date: Fri Feb 6 12:31:39 2009
New Revision: 1882
URL: http://svn.gnome.org/viewvc/glom?rev=1882&view=rev
Log:
2009-02-06 Murray Cumming <murrayc murrayc com>
* glom/base_db.cc: get_table_names_from_database(): Comment out the
checks for internal tables, because that is now fixed in libgda.
* glom/mode_data/box_data.[h|cc]:
* glom/base_db_table_data.[h|cc]: Move refresh_related_fields()
(which is virtual) and get_related_fields() down the hierarchy so that
the override is also used by DbAddDel, so related fields are updated
in the view on list views and related records.
This really fixes bug #569722 (Johannes Schmid)
Modified:
branches/glom-1-8/ChangeLog
branches/glom-1-8/glom/base_db.cc
branches/glom-1-8/glom/base_db_table_data.cc
branches/glom-1-8/glom/base_db_table_data.h
branches/glom-1-8/glom/mode_data/box_data.cc
branches/glom-1-8/glom/mode_data/box_data.h
Modified: branches/glom-1-8/glom/base_db.cc
==============================================================================
--- branches/glom-1-8/glom/base_db.cc (original)
+++ branches/glom-1-8/glom/base_db.cc Fri Feb 6 12:31:39 2009
@@ -331,12 +331,14 @@
continue;
//Ignore the pg_* tables that something (Postgres? libgda?) adds:
- if(table_name.substr(0, 14) == "pg_catalog.pg_")
- continue;
+ //Not needed now that this was fixed again in libgda-4.0.
+ //if(table_name.substr(0, 14) == "pg_catalog.pg_")
+ // continue;
//Ignore the information_schema tables that something (libgda?) adds:
- if(table_name.substr(0, 23) == "information_schema.sql_")
- continue;
+ //Not needed now that this was fixed again in libgda-4.0.
+ //if(table_name.substr(0, 23) == "information_schema.sql_")
+ // continue;
result.push_back(table_name);
}
Modified: branches/glom-1-8/glom/base_db_table_data.cc
==============================================================================
--- branches/glom-1-8/glom/base_db_table_data.cc (original)
+++ branches/glom-1-8/glom/base_db_table_data.cc Fri Feb 6 12:31:39 2009
@@ -239,7 +239,7 @@
}
else
{
- std::cerr << "Box_Data::record_new(): INSERT returned null DataModel." << std::endl;
+ std::cerr << "Base_DB_Table_Data::record_new(): INSERT returned null DataModel." << std::endl;
}
}
@@ -455,6 +455,90 @@
return m_signal_record_changed;
}
+
+void Base_DB_Table_Data::refresh_related_fields(const LayoutFieldInRecord& field_in_record_changed, const Gtk::TreeModel::iterator& row, const Gnome::Gda::Value& /* field_value */)
+{
+ if(field_in_record_changed.m_table_name != m_table_name)
+ return; //TODO: Handle these too?
+
+ //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);
+
+ if(!fieldsToGet.empty())
+ {
+ const Glib::ustring query = Utils::build_sql_select_with_key(field_in_record_changed.m_table_name, fieldsToGet, field_in_record_changed.m_key, field_in_record_changed.m_key_value);
+
+ Glib::RefPtr<Gnome::Gda::DataModel> result = query_execute(query, 0);
+ if(!result)
+ {
+ g_warning("Box_Data_List::refresh_related_fields(): no result.");
+ handle_error();
+ }
+ else
+ {
+ //Field contents:
+ if(result->get_n_rows())
+ {
+ type_vecLayoutFields::const_iterator iterFields = fieldsToGet.begin();
+
+ guint cols_count = result->get_n_columns();
+ 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;
+
+ //g_warning("list fill: field_name=%s", iterFields->get_name().c_str());
+ //g_warning(" value_as_string=%s", value.to_string().c_str());
+
+ //m_AddDel.set_value(row, layout_item, value);
+ set_entered_field_data(row, layout_item, value);
+ //g_warning("addedel size=%d", m_AddDel.get_count());
+
+ ++iterFields;
+ }
+ }
+ else
+ g_warning("Box_Data_List::refresh_related_fields(): no records found.");
+ }
+ }
+}
+
+/** 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
+{
+ type_vecLayoutFields result;
+
+ const Document_Glom* document = dynamic_cast<const Document_Glom*>(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)
+ {
+ sharedptr<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());
+ if(relationship)
+ {
+ //If the relationship uses the specified field:
+ if(relationship->get_from_field() == field_name)
+ {
+ //Add it:
+ result.push_back(layout_field);
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+}
+
} //namespace Glom
Modified: branches/glom-1-8/glom/base_db_table_data.h
==============================================================================
--- branches/glom-1-8/glom/base_db_table_data.h (original)
+++ branches/glom-1-8/glom/base_db_table_data.h Fri Feb 6 12:31:39 2009
@@ -62,6 +62,12 @@
virtual Gnome::Gda::Value get_primary_key_value_selected() const = 0;
virtual void set_primary_key_value(const Gtk::TreeModel::iterator& row, const Gnome::Gda::Value& value) = 0;
virtual Gnome::Gda::Value get_primary_key_value(const Gtk::TreeModel::iterator& row) const = 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;
/** Ask the user if he really wants to delete the record.
*/
Modified: branches/glom-1-8/glom/mode_data/box_data.cc
==============================================================================
--- branches/glom-1-8/glom/mode_data/box_data.cc (original)
+++ branches/glom-1-8/glom/mode_data/box_data.cc Fri Feb 6 12:31:39 2009
@@ -245,89 +245,6 @@
return type_vecLayoutFields();
}
-/** Get the shown fields that are in related tables, via a relationship using @a field_name changes.
- */
-Box_Data::type_vecLayoutFields Box_Data::get_related_fields(const sharedptr<const LayoutItem_Field>& field) const
-{
- type_vecLayoutFields result;
-
- const Document_Glom* document = dynamic_cast<const Document_Glom*>(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)
- {
- sharedptr<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());
- if(relationship)
- {
- //If the relationship uses the specified field:
- if(relationship->get_from_field() == field_name)
- {
- //Add it:
- result.push_back(layout_field);
- }
- }
- }
- }
- }
-
- return result;
-}
-
-void Box_Data::refresh_related_fields(const LayoutFieldInRecord& field_in_record_changed, const Gtk::TreeModel::iterator& row, const Gnome::Gda::Value& /* field_value */)
-{
- if(field_in_record_changed.m_table_name != m_table_name)
- return; //TODO: Handle these too?
-
- //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);
-
- if(!fieldsToGet.empty())
- {
- const Glib::ustring query = Utils::build_sql_select_with_key(field_in_record_changed.m_table_name, fieldsToGet, field_in_record_changed.m_key, field_in_record_changed.m_key_value);
-
- Glib::RefPtr<Gnome::Gda::DataModel> result = query_execute(query, get_app_window());
- if(!result)
- {
- g_warning("Box_Data_List::refresh_related_fields(): no result.");
- handle_error();
- }
- else
- {
- //Field contents:
- if(result->get_n_rows())
- {
- type_vecLayoutFields::const_iterator iterFields = fieldsToGet.begin();
-
- guint cols_count = result->get_n_columns();
- 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;
-
- //g_warning("list fill: field_name=%s", iterFields->get_name().c_str());
- //g_warning(" value_as_string=%s", value.to_string().c_str());
-
- //m_AddDel.set_value(row, layout_item, value);
- set_entered_field_data(row, layout_item, value);
- //g_warning("addedel size=%d", m_AddDel.get_count());
-
- ++iterFields;
- }
- }
- else
- g_warning("Box_Data_List::refresh_related_fields(): no records found.");
- }
- }
-}
-
Document_Glom::type_list_layout_groups Box_Data::get_data_layout_groups(const Glib::ustring& layout)
{
Document_Glom::type_list_layout_groups layout_groups;
Modified: branches/glom-1-8/glom/mode_data/box_data.h
==============================================================================
--- branches/glom-1-8/glom/mode_data/box_data.h (original)
+++ branches/glom-1-8/glom/mode_data/box_data.h Fri Feb 6 12:31:39 2009
@@ -96,8 +96,6 @@
///Fill the existing layout with data from the database.
virtual bool fill_from_database(); //override.
- virtual void refresh_related_fields(const LayoutFieldInRecord& field_in_record_changed, const Gtk::TreeModel::iterator& row, const Gnome::Gda::Value& field_value);
-
virtual type_vecLayoutFields get_fields_to_show() const;
type_vecLayoutFields get_table_fields_to_show(const Glib::ustring& table_name) const;
@@ -107,11 +105,6 @@
Document_Glom::type_list_layout_groups get_data_layout_groups(const Glib::ustring& layout_name);
void fill_layout_group_field_info(const sharedptr<LayoutGroup>& group, const Privileges& table_privs);
-
- /** 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;
-
void execute_button_script(const sharedptr<const LayoutItem_Button>& layout_item, const Gnome::Gda::Value& primary_key_value);
//Signal handlers:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]