[glom/feature_choices_show_all: 3/3] FlowTableWithFields: Added get_choices_widgets(from_field).
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/feature_choices_show_all: 3/3] FlowTableWithFields: Added get_choices_widgets(from_field).
- Date: Mon, 2 Aug 2010 17:14:29 +0000 (UTC)
commit 098bbc6254e009531c5c8505748413d830ee939f
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Aug 2 18:25:28 2010 +0200
FlowTableWithFields: Added get_choices_widgets(from_field).
* glom/mode_data/datawidget/datawidget.cc: Constructor: Only fill the
choices list at this point if show_all is set.
* glom/mode_data/flowtablewithfields.[h|cc]: Addef get_choices_widgets(),
like the existing get_portals() methods.
ChangeLog | 9 +++++
glom/mode_data/datawidget/datawidget.cc | 5 ++-
glom/mode_data/flowtablewithfields.cc | 57 ++++++++++++++++++++++++++++++-
glom/mode_data/flowtablewithfields.h | 9 ++++-
4 files changed, 77 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9049ccc..a5fc035 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2010-08-02 Murray Cumming <murrayc murrayc com>
+ FlowTableWithFields: Added get_choices_widgets(from_field).
+
+ * glom/mode_data/datawidget/datawidget.cc: Constructor: Only fill the
+ choices list at this point if show_all is set.
+ * glom/mode_data/flowtablewithfields.[h|cc]: Addef get_choices_widgets(),
+ like the existing get_portals() methods.
+
+2010-08-02 Murray Cumming <murrayc murrayc com>
+
Field Formatting: Related Choices: Add a Show All checkbox.
* glom/glom_developer.glade:
diff --git a/glom/mode_data/datawidget/datawidget.cc b/glom/mode_data/datawidget/datawidget.cc
index 3fd758b..7e2540d 100644
--- a/glom/mode_data/datawidget/datawidget.cc
+++ b/glom/mode_data/datawidget/datawidget.cc
@@ -154,7 +154,10 @@ DataWidget::DataWidget(const sharedptr<LayoutItem_Field>& field, const Glib::ust
//set_choices() needs this, for the numeric layout:
combo->set_layout_item( get_layout_item(), table_name);
- combo->set_choices_with_second( Utils::get_choice_values(field) );
+ //If !show_all then the list must be set every time we show the data,
+ //because it depends on another ID value:
+ if(show_all)
+ combo->set_choices_with_second( Utils::get_choice_values(field) );
}
}
else
diff --git a/glom/mode_data/flowtablewithfields.cc b/glom/mode_data/flowtablewithfields.cc
index e579b7e..10430ca 100644
--- a/glom/mode_data/flowtablewithfields.cc
+++ b/glom/mode_data/flowtablewithfields.cc
@@ -21,6 +21,7 @@
#include "flowtablewithfields.h"
#include <glom/mode_data/datawidget/datawidget.h>
#include <glom/mode_data/buttonglom.h>
+#include <glom/mode_data/datawidget/combochoices.h>
#include <glom/utility_widgets/notebookglom.h>
#include <glom/utility_widgets/notebooklabelglom.h>
#include <glom/utility_widgets/imageglom.h>
@@ -906,12 +907,66 @@ FlowTableWithFields::type_portals FlowTableWithFields::get_portals(const sharedp
return result;
}
+FlowTableWithFields::type_choice_widgets FlowTableWithFields::get_choice_widgets(const sharedptr<const LayoutItem_Field>& from_key)
+{
+ type_choice_widgets result;
+ if(!from_key)
+ return result;
+
+ const Glib::ustring from_key_name = from_key->get_name();
+
+ //Check the single-item widgets:
+ for(type_listFields::iterator iter = m_listFields.begin(); iter != m_listFields.end(); ++iter)
+ {
+ DataWidget* widget = iter->m_second;
+ DataWidgetChildren::ComboChoices* combochoices = dynamic_cast<DataWidgetChildren::ComboChoices*>(widget);
+ if(!combochoices)
+ continue;
+
+ const sharedptr<const LayoutItem> layout_item =
+ combochoices->get_layout_item();
+ const sharedptr<const LayoutItem_Field> field =
+ sharedptr<const LayoutItem_Field>::cast_dynamic(layout_item);
+ if(!field)
+ continue;
+
+ const FieldFormatting& format = field->get_formatting_used();
+
+ sharedptr<const Relationship> choice_relationship;
+ Glib::ustring choice_field, choice_second;
+ bool choice_show_all = false;
+ format.get_choices(choice_relationship, choice_field, choice_second, choice_show_all);
+ if(choice_show_all)
+ continue; //"Show All" choices don't use the ID field values.
+
+ if(choice_relationship->get_from_field() == from_key_name)
+ result.push_back(combochoices);
+ }
+
+ //Check the sub-flowtables:
+ for(type_sub_flow_tables::const_iterator iter = m_sub_flow_tables.begin(); iter != m_sub_flow_tables.end(); ++iter)
+ {
+ FlowTableWithFields* subtable = *iter;
+ if(subtable)
+ {
+ type_choice_widgets sub_list = subtable->get_choice_widgets(from_key);
+ if(!sub_list.empty())
+ {
+ //Add to the main result:
+ result.insert(result.end(), sub_list.begin(), sub_list.end());
+ }
+ }
+ }
+
+ return result;
+}
+
namespace
{
// Get the direct widgets represesenting a given layout item
// from a flowtable, without considering subflowtables:
template<typename InputIterator, typename OutputIterator>
- void get_direct_fields(InputIterator begin, InputIterator end, OutputIterator out, const sharedptr<const LayoutItem_Field>& layout_item, bool include_item)
+ static void get_direct_fields(InputIterator begin, InputIterator end, OutputIterator out, const sharedptr<const LayoutItem_Field>& layout_item, bool include_item)
{
for(InputIterator iter = begin; iter != end; ++iter)
{
diff --git a/glom/mode_data/flowtablewithfields.h b/glom/mode_data/flowtablewithfields.h
index 8cb7c38..103db5b 100644
--- a/glom/mode_data/flowtablewithfields.h
+++ b/glom/mode_data/flowtablewithfields.h
@@ -41,6 +41,7 @@
#include <glom/utility_widgets/layoutwidgetbase.h>
#include <glom/utility_widgets/layoutwidgetutils.h>
#include <glom/mode_data/box_data_list_related.h>
+#include <glom/mode_data/datawidget/combochoices.h>
#include "box_data_calendar_related.h"
#include <glom/mode_design/layout/treestore_layout.h> //Forthe enum.
#include <map>
@@ -162,11 +163,17 @@ private:
type_list_widgets get_field(const sharedptr<const LayoutItem_Field>& field, bool include_item);
type_list_const_widgets get_field(const sharedptr<const LayoutItem_Field>& field, bool include_item) const;
- typedef std::list< Box_Data_Portal* > type_portals;
+ typedef std::list<Box_Data_Portal*> type_portals;
/// Get portals whose relationships have @a from_key as the from_key.
type_portals get_portals(const sharedptr<const LayoutItem_Field>& from_key);
+
+ typedef std::list<DataWidgetChildren::ComboChoices*> type_choice_widgets;
+
+ /// Get choice widgets with !show_all relationships that have @a from_key as the from_key.
+ type_choice_widgets get_choice_widgets(const sharedptr<const LayoutItem_Field>& from_key);
+
/** Examine this flow table and all child flow tables, discovering which
* has the most columns.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]