[glom] Field Formatting: Related Choices: Default to showing the primary key.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Field Formatting: Related Choices: Default to showing the primary key.
- Date: Sun, 29 Jan 2012 20:13:02 +0000 (UTC)
commit 5eb8d49384a917c61f7bb5fd3d24db30ff08184d
Author: Murray Cumming <murrayc murrayc com>
Date: Sun Jan 29 21:12:56 2012 +0100
Field Formatting: Related Choices: Default to showing the primary key.
* glom/mode_design/layout/layout_item_dialogs/box_formatting.cc:
on_combo_choices_relationship_changed(): By default, automatically
choose the related table's primary key as the field to show in the
choices. Other fields should then be shown (or looked up) based on the
chosen ID.
This avoids the confusion noticed here: https://bugzilla.gnome.org/show_bug.cgi?id=668759#c21
ChangeLog | 11 +++++++++++
.../layout/layout_item_dialogs/box_formatting.cc | 11 +++++++++--
2 files changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index adacddc..95b4958 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2012-01-29 Murray Cumming <murrayc murrayc com>
+ Field Formatting: Related Choices: Default to showing the primary key.
+
+ * glom/mode_design/layout/layout_item_dialogs/box_formatting.cc:
+ on_combo_choices_relationship_changed(): By default, automatically
+ choose the related table's primary key as the field to show in the
+ choices. Other fields should then be shown (or looked up) based on the
+ chosen ID.
+ This avoids the confusion noticed here: https://bugzilla.gnome.org/show_bug.cgi?id=668759#c21
+
+2012-01-29 Murray Cumming <murrayc murrayc com>
+
CellRendererDbList: Do not crash if one of the fields is hidden.
* glom/mode_data/datawidget/cellrenderer_dblist.cc:
diff --git a/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc b/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
index 9a235a0..31a2ca4 100644
--- a/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
@@ -447,12 +447,19 @@ void Box_Formatting::on_combo_choices_relationship_changed()
Document* pDocument = get_document();
if(pDocument)
{
- //Show the list of formats from this relationship:
+ //Show the list of fields from this relationship:
if(relationship)
{
- const Document::type_vec_fields vecFields = pDocument->get_table_fields(relationship->get_to_table());
+ const Glib::ustring related_table = relationship->get_to_table();
+ const Document::type_vec_fields vecFields = pDocument->get_table_fields(related_table);
m_combo_choices_field->set_fields(vecFields);
+ //Default to using the Primary Key field from the related table,
+ //because this is almost always what people want to use:
+ const sharedptr<Field> related_primary_key = pDocument->get_field_primary_key(related_table);
+ if(related_primary_key)
+ m_combo_choices_field->set_selected_field(related_primary_key);
+
//Update the show-all dialog's list:
//If the related table name has changed then the list of fields will probably
//be ignored, clearing the list, but we try to preserve it if possible:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]