[glom/feature_choices_related_layout] In progress
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/feature_choices_related_layout] In progress
- Date: Wed, 11 Aug 2010 21:38:42 +0000 (UTC)
commit 940206fcaef84f7d1d9d90359ca61601805a8e94
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Aug 11 23:38:31 2010 +0200
In progress
.../layout/layout_item_dialogs/box_formatting.cc | 38 +++++++++++++----
glom/utility_widgets/db_adddel/db_adddel.cc | 45 +++++++++++++++----
glom/utility_widgets/db_adddel/db_adddel.h | 2 +-
3 files changed, 66 insertions(+), 19 deletions(-)
---
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 ccba10a..cc327f5 100644
--- a/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
@@ -237,9 +237,29 @@ void Box_Formatting::set_formatting(const FieldFormatting& format, bool show_num
m_combo_choices_relationship->set_relationships(vecRelationships);
sharedptr<const Relationship> choices_relationship;
- sharedptr<const LayoutItem_Field> choices_field, choices_field_second;
+ sharedptr<const LayoutItem_Field> choices_field;
+ sharedptr<const LayoutGroup> choices_field_extras;
bool choices_show_all = false;
- format.get_choices_related(choices_relationship, choices_field, choices_field_second, choices_show_all);
+ format.get_choices_related(choices_relationship, choices_field, choices_field_extras, choices_show_all);
+
+ sharedptr<const LayoutItem_Field> choices_field_second;
+ if(choices_field_extras)
+ {
+ const LayoutGroup::type_list_const_items extra_fields
+ = choices_field_extras->get_items_recursive();
+
+ for(LayoutGroup::type_list_const_items::const_iterator iterExtra = extra_fields.begin();
+ iterExtra != extra_fields.end(); ++iterExtra)
+ {
+ const sharedptr<const LayoutItem> item = *iterExtra;
+ const sharedptr<const LayoutItem_Field> item_field = sharedptr<const LayoutItem_Field>::cast_dynamic(item);
+ if(item_field)
+ {
+ choices_field_second = item_field;
+ break;
+ }
+ }
+ }
m_combo_choices_relationship->set_selected_relationship(choices_relationship);
on_combo_choices_relationship_changed(); //Fill the combos so we can set their active items.
@@ -312,13 +332,15 @@ bool Box_Formatting::get_formatting(FieldFormatting& format) const
m_checkbutton_choices_restricted->get_active(),
m_checkbutton_choices_restricted_as_radio_buttons->get_active());
- const sharedptr<const Relationship> choices_relationship = m_combo_choices_relationship->get_selected_relationship();
- sharedptr<LayoutItem_Field> layout_choice_first = sharedptr<LayoutItem_Field>::create();
- layout_choice_first->set_name(m_combo_choices_field->get_selected_field_name());
- sharedptr<LayoutItem_Field> layout_choice_second = sharedptr<LayoutItem_Field>::create();
- layout_choice_second->set_name(m_combo_choices_field_second->get_selected_field_name());
+ const sharedptr<const Relationship> choices_relationship = m_combo_choices_relationship->get_selected_relationship();
+ sharedptr<LayoutItem_Field> layout_choice_first = sharedptr<LayoutItem_Field>::create();
+ layout_choice_first->set_name(m_combo_choices_field->get_selected_field_name());
+ sharedptr<LayoutItem_Field> layout_choice_second = sharedptr<LayoutItem_Field>::create();
+ layout_choice_second->set_name(m_combo_choices_field_second->get_selected_field_name());
+ sharedptr<LayoutGroup> layout_choice_extras = sharedptr<LayoutGroup>::create();
+ layout_choice_extras->add_item(layout_choice_second);
m_format.set_choices_related(choices_relationship,
- layout_choice_first, layout_choice_second,
+ layout_choice_first, layout_choice_extras,
m_checkbutton_choices_related_show_all->get_active());
//Custom choices:
diff --git a/glom/utility_widgets/db_adddel/db_adddel.cc b/glom/utility_widgets/db_adddel/db_adddel.cc
index 2aa7274..fd5315b 100644
--- a/glom/utility_widgets/db_adddel/db_adddel.cc
+++ b/glom/utility_widgets/db_adddel/db_adddel.cc
@@ -832,15 +832,16 @@ Gtk::CellRenderer* DbAddDel::construct_specified_columns_cellrenderer(const shar
else if(item_field && item_field->get_formatting_used().get_has_related_choices())
{
sharedptr<const Relationship> choice_relationship;
- sharedptr<const LayoutItem_Field> choice_field, choice_second;
+ sharedptr<const LayoutItem_Field> choice_field;
+ sharedptr<const LayoutGroup> choice_extras;
bool choice_show_all;
- item_field->get_formatting_used().get_choices_related(choice_relationship, choice_field, choice_second, choice_show_all);
+ item_field->get_formatting_used().get_choices_related(choice_relationship, choice_field, choice_extras, choice_show_all);
if(choice_relationship && choice_field)
{
const Glib::ustring to_table = choice_relationship->get_to_table();
- const bool use_second = choice_second;
+ const bool use_second = choice_extras;
pCellRendererCombo->set_use_second(use_second);
//TODO: Update this when the relationship's field value changes:
@@ -848,7 +849,7 @@ Gtk::CellRenderer* DbAddDel::construct_specified_columns_cellrenderer(const shar
{
const Utils::type_list_values_with_second list_values =
Utils::get_choice_values_all(get_document(), item_field);
- set_cell_choices(pCellRendererCombo, choice_field, choice_second, list_values);
+ set_cell_choices(pCellRendererCombo, choice_field, choice_extras, list_values);
}
}
}
@@ -1235,7 +1236,7 @@ void DbAddDel::set_value_selected(const sharedptr<const LayoutItem_Field>& layou
set_value(get_item_selected(), layout_item, value);
}
-void DbAddDel::set_cell_choices(CellRendererList* cell, const sharedptr<const LayoutItem_Field>& layout_choice_first, const sharedptr<const LayoutItem_Field>& layout_choice_second, const Utils::type_list_values_with_second& list_values)
+void DbAddDel::set_cell_choices(CellRendererList* cell, const sharedptr<const LayoutItem_Field>& layout_choice_first, const sharedptr<const LayoutGroup>& layout_choice_extras, const Utils::type_list_values_with_second& list_values)
{
if(!cell)
return;
@@ -1249,11 +1250,34 @@ void DbAddDel::set_cell_choices(CellRendererList* cell, const sharedptr<const La
Conversions::get_text_for_gda_value(
layout_choice_first->get_glom_type(), iter->first, layout_choice_first->get_formatting_used().m_numeric_format);
+ //TODO: Support multiple extra fields:
+ //For now, use only the first extra field:
+ sharedptr<const LayoutItem_Field> layout_choice_second;
+ if(layout_choice_extras)
+ {
+ const LayoutGroup::type_list_const_items extra_fields
+ = layout_choice_extras->get_items_recursive();
+
+ for(LayoutGroup::type_list_const_items::const_iterator iterExtra = extra_fields.begin();
+ iterExtra != extra_fields.end(); ++iterExtra)
+ {
+ const sharedptr<const LayoutItem> item = *iterExtra;
+ const sharedptr<const LayoutItem_Field> item_field = sharedptr<const LayoutItem_Field>::cast_dynamic(item);
+ if(item_field)
+ {
+ layout_choice_second = item_field;
+ break;
+ }
+ }
+ }
+
Glib::ustring second;
- if(layout_choice_second)
+ const Utils::type_list_values extra_values = iter->second;
+ if(layout_choice_second && !extra_values.empty())
{
+ const Gnome::Gda::Value value = *(extra_values.begin()); //TODO: Use a vector instead?
second = Conversions::get_text_for_gda_value(
- layout_choice_second->get_glom_type(), iter->second, layout_choice_second->get_formatting_used().m_numeric_format);
+ layout_choice_second->get_glom_type(), value, layout_choice_second->get_formatting_used().m_numeric_format);
}
cell->append_list_item(first, second);
@@ -1296,11 +1320,12 @@ void DbAddDel::refresh_cell_choices_data_from_database_with_foreign_key(guint mo
Utils::get_choice_values(get_document(), layout_field, foreign_key_value);
sharedptr<const Relationship> choice_relationship;
- sharedptr<const LayoutItem_Field> layout_choice_first, layout_choice_second;
+ sharedptr<const LayoutItem_Field> layout_choice_first;
+ sharedptr<const LayoutGroup> layout_choice_extras;
bool choice_show_all = false;
- layout_field->get_formatting_used().get_choices_related(choice_relationship, layout_choice_first, layout_choice_second, choice_show_all);
+ layout_field->get_formatting_used().get_choices_related(choice_relationship, layout_choice_first, layout_choice_extras, choice_show_all);
- set_cell_choices(cell, layout_choice_first, layout_choice_second, list_values);
+ set_cell_choices(cell, layout_choice_first, layout_choice_extras, list_values);
}
void DbAddDel::remove_all_columns()
diff --git a/glom/utility_widgets/db_adddel/db_adddel.h b/glom/utility_widgets/db_adddel/db_adddel.h
index d453c83..e09521d 100644
--- a/glom/utility_widgets/db_adddel/db_adddel.h
+++ b/glom/utility_widgets/db_adddel/db_adddel.h
@@ -390,7 +390,7 @@ private:
//TODO: Remove this and use AppGlom::get_application() instead?
Application* get_application();
- void set_cell_choices(CellRendererList* cell, const sharedptr<const LayoutItem_Field>& layout_choice_first, const sharedptr<const LayoutItem_Field>& layout_choice_second, const Utils::type_list_values_with_second& list_values);
+ void set_cell_choices(CellRendererList* cell, const sharedptr<const LayoutItem_Field>& layout_choice_first, const sharedptr<const LayoutGroup>& layout_choice_extras, const Utils::type_list_values_with_second& list_values);
void refresh_cell_choices_data_from_database_with_foreign_key(guint model_index, const Gnome::Gda::Value& foreign_key_value);
static void apply_formatting(Gtk::CellRenderer* renderer, const sharedptr<const LayoutItem_WithFormatting>& layout_item);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]