[glom] Box_Data_Portal: Use get/set_layout_item() instead of m_portal.



commit e27a28f3a67e00bcfb0d722708ace90882635377
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Mar 18 15:56:38 2016 +0100

    Box_Data_Portal: Use get/set_layout_item() instead of m_portal.

 glom/mode_data/box_data_calendar_related.cc |    6 +++---
 glom/mode_data/box_data_list_related.cc     |    8 +++++---
 glom/mode_data/box_data_portal.cc           |   11 ++++++-----
 glom/mode_data/box_data_portal.h            |    3 +--
 4 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/glom/mode_data/box_data_calendar_related.cc b/glom/mode_data/box_data_calendar_related.cc
index 4591ebd..4d586dd 100644
--- a/glom/mode_data/box_data_calendar_related.cc
+++ b/glom/mode_data/box_data_calendar_related.cc
@@ -360,11 +360,11 @@ void Box_Data_Calendar_Related::on_dialog_layout_hide()
 {
   auto dialog_related = dynamic_cast<Dialog_Layout_Calendar_Related*>(m_pDialogLayout);
   g_assert(dialog_related);
-  m_portal = dialog_related->get_portal_layout();
-
+  const auto portal = dialog_related->get_portal_layout();
+  set_layout_item(portal, "" /* TODO */);
 
   //Update the UI:
-  auto derived_portal = std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(m_portal);
+  auto derived_portal = std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(portal);
   init_db_details(derived_portal);
 
   Box_Data::on_dialog_layout_hide();
diff --git a/glom/mode_data/box_data_list_related.cc b/glom/mode_data/box_data_list_related.cc
index 55f05e8..fc82ab9 100644
--- a/glom/mode_data/box_data_list_related.cc
+++ b/glom/mode_data/box_data_list_related.cc
@@ -343,18 +343,20 @@ void Box_Data_List_Related::on_dialog_layout_hide()
 {
   auto dialog_related = dynamic_cast<Dialog_Layout_List_Related*>(m_pDialogLayout);
   g_assert(dialog_related);
-  m_portal = dialog_related->get_portal_layout();
+
+  const auto portal = dialog_related->get_portal_layout();
+  set_layout_item(portal, "" /* TODO */);
 
 
   //Update the UI:
-  init_db_details(m_portal);
+  init_db_details(portal);
 
   Box_Data::on_dialog_layout_hide();
 
   auto pLayoutItem = std::dynamic_pointer_cast<LayoutItem_Portal>(get_layout_item());
   if(pLayoutItem)
   {
-    *pLayoutItem = *m_portal;
+    *pLayoutItem = *portal;
     signal_layout_changed().emit(); //TODO: Check whether it has really changed.
   }
 }
diff --git a/glom/mode_data/box_data_portal.cc b/glom/mode_data/box_data_portal.cc
index c4d3202..3f2f843 100644
--- a/glom/mode_data/box_data_portal.cc
+++ b/glom/mode_data/box_data_portal.cc
@@ -94,11 +94,12 @@ void Box_Data_Portal::make_record_related(const Gnome::Gda::Value& related_recor
 
 bool Box_Data_Portal::init_db_details(const std::shared_ptr<const LayoutItem_Portal>& portal, bool 
show_title)
 {
-  m_portal = glom_sharedptr_clone(portal);
+  auto portal_stored = glom_sharedptr_clone(portal);
+  set_layout_item(portal_stored, "" /* TODO */);
 
   Glib::ustring parent_table;
-  if(m_portal)
-    parent_table = m_portal->get_from_table();
+  if(portal_stored)
+    parent_table = portal_stored->get_from_table();
 
   return init_db_details(parent_table, show_title);
 }
@@ -164,12 +165,12 @@ bool Box_Data_Portal::refresh_data_from_database_with_foreign_key(const Gnome::G
 
 std::shared_ptr<LayoutItem_Portal> Box_Data_Portal::get_portal()
 {
-  return m_portal;
+  return std::dynamic_pointer_cast<LayoutItem_Portal>(get_layout_item());
 }
 
 std::shared_ptr<const LayoutItem_Portal> Box_Data_Portal::get_portal() const
 {
-  return m_portal;
+  return std::dynamic_pointer_cast<const LayoutItem_Portal>(get_layout_item());
 }
 
 std::shared_ptr<const Field> Box_Data_Portal::get_key_field() const
diff --git a/glom/mode_data/box_data_portal.h b/glom/mode_data/box_data_portal.h
index dd73b70..c4bc673 100644
--- a/glom/mode_data/box_data_portal.h
+++ b/glom/mode_data/box_data_portal.h
@@ -122,8 +122,7 @@ protected:
   Gtk::Frame m_Frame;
   Gtk::Label m_Label;
 
-  std::shared_ptr<LayoutItem_Portal> m_portal;
-  Glib::ustring m_parent_table; //A duplicate of the from_table in m_portal, but only when m_portal is not 
null.
+  Glib::ustring m_parent_table; //A duplicate of the from_table in the poral, but only when get_portal() is 
not null.
   
   // m_key_field and m_key_value are the field and its value in this table that 
   // must match another field in the parent table.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]