Commit e27a28f3 authored by Murray Cumming's avatar Murray Cumming
Browse files

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

parent 59fb983e
......@@ -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();
......
......@@ -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.
}
}
......
......@@ -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
......
......@@ -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.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment