glom r1679 - in trunk: . glom/libglom glom/mode_data glom/mode_design/print_layouts
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: glom r1679 - in trunk: . glom/libglom glom/mode_data glom/mode_design/print_layouts
- Date: Thu, 4 Sep 2008 22:47:59 +0000 (UTC)
Author: murrayc
Date: Thu Sep 4 22:47:59 2008
New Revision: 1679
URL: http://svn.gnome.org/viewvc/glom?rev=1679&view=rev
Log:
2008-09-05 Murray Cumming <murrayc murrayc com>
* glom/mode_data/box_data_calendar_related.cc:
* glom/mode_data/box_data_calendar_related.h:
* glom/mode_data/box_data_list_related.cc:
* glom/mode_data/box_data_list_related.h:
* glom/mode_data/box_data_portal.cc:
* glom/mode_data/box_data_portal.h: Added init_db_details()
method overloads that take a parent table instead of a
portal, to use when no relationship has been chosen yet.
* glom/mode_data/dialog_layout_calendar_related.cc:
* glom/mode_data/dialog_layout_calendar_related.h:
Added set_document() that takes a table instead of a portal,
as the other portal layout dialogs do already.
* glom/mode_data/flowtablewithfields.cc:
Specify a from table name instead of a portal when
no relationship has been chosen yet.
* glom/mode_data/dialog_layout_list_related.cc: Cope with a
a null portal, so the user can choose the relationship on this
dialog without choosing the relationship separately first.
* glom/mode_data/dialog_layout_details.cc: Do not ask for the
relationship whenever adding a portal.
* glom/libglom/utils.cc:
* glom/libglom/utils.h: Added show_window_until_hide().
* glom/mode_design/print_layouts/canvas_print_layout.cc:
* glom/mode_design/print_layouts/canvas_print_layout.h:
Block when showing the layout dialog for a portal.
Modified:
trunk/ChangeLog
trunk/glom/libglom/utils.cc
trunk/glom/libglom/utils.h
trunk/glom/mode_data/box_data_calendar_related.cc
trunk/glom/mode_data/box_data_calendar_related.h
trunk/glom/mode_data/box_data_list_related.cc
trunk/glom/mode_data/box_data_list_related.h
trunk/glom/mode_data/box_data_portal.cc
trunk/glom/mode_data/box_data_portal.h
trunk/glom/mode_data/dialog_layout_calendar_related.cc
trunk/glom/mode_data/dialog_layout_calendar_related.h
trunk/glom/mode_data/dialog_layout_details.cc
trunk/glom/mode_data/dialog_layout_list_related.cc
trunk/glom/mode_data/flowtablewithfields.cc
trunk/glom/mode_design/print_layouts/canvas_layout_item.cc
trunk/glom/mode_design/print_layouts/canvas_print_layout.cc
trunk/glom/mode_design/print_layouts/canvas_print_layout.h
Modified: trunk/glom/libglom/utils.cc
==============================================================================
--- trunk/glom/libglom/utils.cc (original)
+++ trunk/glom/libglom/utils.cc Thu Sep 4 22:47:59 2008
@@ -897,4 +897,37 @@
dialog.run();
}
+namespace
+{
+
+static void on_window_hide(Glib::RefPtr<Glib::MainLoop> main_loop, sigc::connection handler_connection)
+{
+ handler_connection.disconnect(); //This should release a main_loop reference.
+ main_loop->quit();
+
+ //main_loop should be destroyed soon, because nothing else is using it.
+}
+
+} //anonymous namespace.
+
+void Utils::show_window_until_hide(Gtk::Window* window)
+{
+ if(!window)
+ return;
+
+ Glib::RefPtr<Glib::MainLoop> main_loop = Glib::MainLoop::create(false /* not running */);
+
+ //Stop the main_loop when the window is hidden:
+ sigc::connection handler_connection; //TODO: There seems to be a crash if this is on the same line.
+ handler_connection = window->signal_hide().connect(
+ sigc::bind(
+ sigc::ptr_fun(&on_window_hide),
+ main_loop, handler_connection
+ ) );
+
+ window->show();
+ main_loop->run(); //Run and block until it is stopped by the hide signal handler.
+}
+
+
} //namespace Glom
Modified: trunk/glom/libglom/utils.h
==============================================================================
--- trunk/glom/libglom/utils.h (original)
+++ trunk/glom/libglom/utils.h Thu Sep 4 22:47:59 2008
@@ -107,6 +107,8 @@
void show_ok_dialog(const Glib::ustring& title, const Glib::ustring& message, Gtk::Window& parent, Gtk::MessageType message_type);
+void show_window_until_hide(Gtk::Window* window);
+
} //namespace Utils
} //namespace Glom
Modified: trunk/glom/mode_data/box_data_calendar_related.cc
==============================================================================
--- trunk/glom/mode_data/box_data_calendar_related.cc (original)
+++ trunk/glom/mode_data/box_data_calendar_related.cc Thu Sep 4 22:47:59 2008
@@ -65,17 +65,37 @@
//m_calendar.set_allow_view_details(view_details_possible); //Don't allow the user to go to a record in a hidden table.
}
-bool Box_Data_Calendar_Related::init_db_details(const sharedptr<const LayoutItem_CalendarPortal>& portal, bool show_title)
+bool Box_Data_Calendar_Related::init_db_details(const sharedptr<const LayoutItem_Portal>& portal, bool show_title)
{
- m_portal = glom_sharedptr_clone(portal);
+ //This calls the other method overload:
+ return Box_Data_Portal::init_db_details(portal, show_title);
+}
- LayoutWidgetBase::m_table_name = m_portal->get_table_used(Glib::ustring() /* parent table_name, not used. */);
- Base_DB_Table::m_table_name = LayoutWidgetBase::m_table_name;
+bool Box_Data_Calendar_Related::init_db_details(const Glib::ustring& parent_table, bool show_title)
+{
+ //std::cout << "DEBUG: Box_Data_Calendar_Related::init_db_details(): " << parent_table << std::endl;
- const Glib::ustring relationship_title = m_portal->get_title_used(Glib::ustring() /* parent title - not relevant */);
-
+ m_parent_table = parent_table;
+
+ if(m_portal)
+ LayoutWidgetBase::m_table_name = m_portal->get_table_used(Glib::ustring() /* parent table_name, not used. */);
+ else
+ LayoutWidgetBase::m_table_name = Glib::ustring();
+
+ Base_DB_Table::m_table_name = LayoutWidgetBase::m_table_name;
+
+ //TODO: This is duplicated in box_data_related_list.cc and box_data_portal.cc. Just use code from the base class?
if(show_title)
{
+ Glib::ustring relationship_title;
+ if(m_portal && m_portal->get_has_relationship_name())
+ relationship_title = m_portal->get_title_used(Glib::ustring() /* parent title - not relevant */);
+ else
+ {
+ //Note to translators: This text is shown instead of a table title, when the table has not yet been chosen.
+ relationship_title = _("Undefined Table");
+ }
+
m_Label.set_markup(Bakery::App_Gtk::util_bold_message(relationship_title));
m_Label.show();
@@ -89,7 +109,10 @@
m_Alignment.set_padding(0, 0, 0, 0); //The box itself has padding of 6.
}
- m_key_field = get_fields_for_table_one_field(LayoutWidgetBase::m_table_name, m_portal->get_to_field_used());
+ if(m_portal)
+ m_key_field = get_fields_for_table_one_field(LayoutWidgetBase::m_table_name, m_portal->get_to_field_used());
+ else
+ m_key_field.clear();
enable_buttons();
@@ -248,7 +271,7 @@
sharedptr<Field> field_primary_key; //TODO: = m_calendar.get_key_field();
//Create the link by setting the foreign key
- if(m_key_field)
+ if(m_key_field && m_portal)
{
Glib::ustring strQuery = "UPDATE \"" + m_portal->get_table_used(Glib::ustring() /* not relevant */) + "\"";
strQuery += " SET \"" + /* get_table_name() + "." +*/ m_key_field->get_name() + "\" = " + m_key_field->sql(m_key_value);
@@ -334,7 +357,16 @@
g_assert(related_dialog != NULL);
sharedptr<LayoutItem_CalendarPortal> derived_portal = sharedptr<LayoutItem_CalendarPortal>::cast_dynamic(m_portal);
- related_dialog->set_document(m_layout_name, get_document(), derived_portal);
+ if(derived_portal && derived_portal->get_has_relationship_name())
+ {
+ std::cout << "DEBUG: Box_Data_Calendar_Related::(): portal was not null" << std::endl;
+ related_dialog->set_document(m_layout_name, get_document(), derived_portal);
+ }
+ else
+ {
+ std::cout << "DEBUG: Box_Data_Calendar_Related::(): m_parent_table=" << m_parent_table << std::endl;
+ related_dialog->set_document(m_layout_name, get_document(), m_parent_table);
+ }
}
#endif // !GLOM_ENABLE_CLIENT_ONLY
@@ -349,7 +381,7 @@
sharedptr<LayoutItem_CalendarPortal> derived_portal = sharedptr<LayoutItem_CalendarPortal>::cast_dynamic(m_portal);
if(!derived_portal)
{
- std::cout << "DEBUG: Box_Data_Calendar_Related::on_calendar_details(): date_field is NULL" << std::endl;
+ //std::cout << "DEBUG: Box_Data_Calendar_Related::on_calendar_details(): date_field is NULL" << std::endl;
return Glib::ustring();
}
Modified: trunk/glom/mode_data/box_data_calendar_related.h
==============================================================================
--- trunk/glom/mode_data/box_data_calendar_related.h (original)
+++ trunk/glom/mode_data/box_data_calendar_related.h Thu Sep 4 22:47:59 2008
@@ -42,7 +42,11 @@
/**
* @param portal: The full portal details
*/
- virtual bool init_db_details(const sharedptr<const LayoutItem_CalendarPortal>& portal, bool show_title = true);
+ virtual bool init_db_details(const sharedptr<const LayoutItem_Portal>& portal, bool show_title = true);
+
+ /** Use this if no portal is yet defined, so the user can use the context menu to define a portal.
+ */
+ virtual bool init_db_details(const Glib::ustring& parent_table, bool show_title = true);
protected:
virtual bool fill_from_database(); //Override.
Modified: trunk/glom/mode_data/box_data_list_related.cc
==============================================================================
--- trunk/glom/mode_data/box_data_list_related.cc (original)
+++ trunk/glom/mode_data/box_data_list_related.cc Thu Sep 4 22:47:59 2008
@@ -61,15 +61,32 @@
bool Box_Data_List_Related::init_db_details(const sharedptr<const LayoutItem_Portal>& portal, bool show_title)
{
- m_portal = glom_sharedptr_clone(portal);
+ //This calls the other method overload:
+ return Box_Data_Portal::init_db_details(portal, show_title);
+}
+
+bool Box_Data_List_Related::init_db_details(const Glib::ustring& parent_table, bool show_title)
+{
+ m_parent_table = parent_table;
+
+ if(m_portal)
+ LayoutWidgetBase::m_table_name = m_portal->get_table_used(Glib::ustring() /* parent table_name, not used. */);
+ else
+ LayoutWidgetBase::m_table_name = Glib::ustring();
- LayoutWidgetBase::m_table_name = m_portal->get_table_used(Glib::ustring() /* parent table_name, not used. */);
Base_DB_Table::m_table_name = LayoutWidgetBase::m_table_name;
- const Glib::ustring relationship_title = m_portal->get_title_used(Glib::ustring() /* parent title - not relevant */);
-
if(show_title)
{
+ Glib::ustring relationship_title;
+ if(m_portal && m_portal->get_has_relationship_name())
+ relationship_title = m_portal->get_title_used(Glib::ustring() /* parent title - not relevant */);
+ else
+ {
+ //Note to translators: This text is shown instead of a table title, when the table has not yet been chosen.
+ relationship_title = _("Undefined Table");
+ }
+
m_Label.set_markup(Bakery::App_Gtk::util_bold_message(relationship_title));
m_Label.show();
@@ -83,7 +100,11 @@
m_Alignment.set_padding(0, 0, 0, 0); //The box itself has padding of 6.
}
- m_key_field = get_fields_for_table_one_field(LayoutWidgetBase::m_table_name, m_portal->get_to_field_used());
+ if(m_portal)
+ m_key_field = get_fields_for_table_one_field(LayoutWidgetBase::m_table_name, m_portal->get_to_field_used());
+ else
+ m_key_field.clear();
+
//Prevent impossible multiple related records:
const bool single_related = (m_key_field && (m_key_field->get_unique_key() || m_key_field->get_primary_key()));
@@ -129,7 +150,7 @@
}
//Prevent addition of new records if that is what the relationship specifies:
- if(allow_add && m_portal->get_relationship())
+ if(allow_add && m_portal && m_portal->get_relationship())
allow_add = m_portal->get_relationship()->get_auto_create();
m_AddDel.set_allow_add(allow_add);
@@ -252,7 +273,7 @@
sharedptr<Field> field_primary_key = m_AddDel.get_key_field();
//Create the link by setting the foreign key
- if(m_key_field)
+ if(m_key_field && m_portal)
{
Glib::ustring strQuery = "UPDATE \"" + m_portal->get_table_used(Glib::ustring() /* not relevant */) + "\"";
strQuery += " SET \"" + /* get_table_name() + "." +*/ m_key_field->get_name() + "\" = " + m_key_field->sql(m_key_value);
@@ -322,7 +343,11 @@
{
Dialog_Layout_List_Related* related_dialog = dynamic_cast<Dialog_Layout_List_Related*>(dialog);
g_assert(related_dialog != NULL);
- related_dialog->set_document(m_layout_name, get_document(), m_portal);
+
+ if(m_portal && m_portal->get_has_relationship_name())
+ related_dialog->set_document(m_layout_name, get_document(), m_portal);
+ else
+ related_dialog->set_document(m_layout_name, get_document(), m_parent_table);
}
#endif // !GLOM_ENABLE_CLIENT_ONLY
Modified: trunk/glom/mode_data/box_data_list_related.h
==============================================================================
--- trunk/glom/mode_data/box_data_list_related.h (original)
+++ trunk/glom/mode_data/box_data_list_related.h Thu Sep 4 22:47:59 2008
@@ -40,6 +40,10 @@
*/
virtual bool init_db_details(const sharedptr<const LayoutItem_Portal>& portal, bool show_title = true);
+ /** Use this if no portal is yet defined, so the user can use the context menu to define a portal.
+ */
+ virtual bool init_db_details(const Glib::ustring& parent_table, bool show_title = true);
+
protected:
virtual bool fill_from_database(); //Override.
Modified: trunk/glom/mode_data/box_data_portal.cc
==============================================================================
--- trunk/glom/mode_data/box_data_portal.cc (original)
+++ trunk/glom/mode_data/box_data_portal.cc Thu Sep 4 22:47:59 2008
@@ -55,13 +55,37 @@
{
m_portal = glom_sharedptr_clone(portal);
- LayoutWidgetBase::m_table_name = m_portal->get_table_used(Glib::ustring() /* parent table_name, not used. */);
+ Glib::ustring parent_table;
+ if(m_portal)
+ parent_table = m_portal->get_from_table();
+
+ return init_db_details(parent_table, show_title);
+}
+
+//TODO: Is this base class implemenation actually called by anything?
+bool Box_Data_Portal::init_db_details(const Glib::ustring& parent_table, bool show_title)
+{
+ m_parent_table = parent_table;
+
+ if(m_portal)
+ LayoutWidgetBase::m_table_name = m_portal->get_table_used(Glib::ustring() /* parent table_name, not used. */);
+ else
+ LayoutWidgetBase::m_table_name = Glib::ustring();
+
Base_DB_Table::m_table_name = LayoutWidgetBase::m_table_name;
- const Glib::ustring relationship_title = m_portal->get_title_used(Glib::ustring() /* parent title - not relevant */);
-
if(show_title)
{
+ //TODO: This same code is in box_data_related_list.cc. Remove the duplication.
+ Glib::ustring relationship_title;
+ if(m_portal && m_portal->get_has_relationship_name())
+ relationship_title = m_portal->get_title_used(Glib::ustring() /* parent title - not relevant */);
+ else
+ {
+ //Note to translators: This text is shown instead of a table title, when the table has not yet been chosen.
+ relationship_title = _("Undefined Table");
+ }
+
m_Label.set_markup(Bakery::App_Gtk::util_bold_message(relationship_title));
m_Label.show();
@@ -86,7 +110,7 @@
{
m_key_value = foreign_key_value;
- if(m_key_field)
+ if(m_key_field && m_portal)
{
if(!Conversions::value_is_empty(m_key_value))
{
@@ -172,7 +196,7 @@
Box_Data_Portal::type_vecLayoutFields Box_Data_Portal::get_fields_to_show() const
{
const Document_Glom* document = get_document();
- if(document)
+ if(document && m_portal)
{
Document_Glom::type_list_layout_groups mapGroups;
mapGroups.push_back(m_portal);
@@ -224,6 +248,9 @@
//Initialize output parameters:
table_name = Glib::ustring();
+ if(!m_portal)
+ return;
+
//Check whether a relationship was specified:
bool navigation_relationship_main = false;
sharedptr<const UsesRelationship> navigation_relationship = m_portal->get_navigation_relationship_specific(navigation_relationship_main);
Modified: trunk/glom/mode_data/box_data_portal.h
==============================================================================
--- trunk/glom/mode_data/box_data_portal.h (original)
+++ trunk/glom/mode_data/box_data_portal.h Thu Sep 4 22:47:59 2008
@@ -43,6 +43,10 @@
*/
virtual bool init_db_details(const sharedptr<const LayoutItem_Portal>& portal, bool show_title = true);
+ /** Use this if no portal is yet defined, so the user can use the context menu to define a portal.
+ */
+ virtual bool init_db_details(const Glib::ustring& parent_table, bool show_title = true);
+
/** Update a portal if a relevant value in its parent table has changed.
*
* @param foreign_key_value: The value that should be found in this table.
@@ -89,6 +93,7 @@
Gtk::Label m_Label;
sharedptr<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.
sharedptr<Field> m_key_field;
Gnome::Gda::Value m_key_value;
Modified: trunk/glom/mode_data/dialog_layout_calendar_related.cc
==============================================================================
--- trunk/glom/mode_data/dialog_layout_calendar_related.cc (original)
+++ trunk/glom/mode_data/dialog_layout_calendar_related.cc Thu Sep 4 22:47:59 2008
@@ -89,22 +89,36 @@
{
}
+
void Dialog_Layout_Calendar_Related::set_document(const Glib::ustring& layout, Document_Glom* document, const sharedptr<const LayoutItem_CalendarPortal>& portal)
{
+ m_portal = glom_sharedptr_clone(portal);
+
+ Glib::ustring from_table;
+ if(portal)
+ from_table = portal->get_from_table();
+
+ set_document(layout, document, from_table);
+}
+
+void Dialog_Layout_Calendar_Related::set_document(const Glib::ustring& layout, Document_Glom* document, const Glib::ustring& from_table)
+{
+ if(!m_portal)
+ {
+ m_portal = sharedptr<LayoutItem_CalendarPortal>::create(); //The rest of the class assumes that this is not null.
+ }
+
type_vecLayoutFields empty_fields; //Just to satisfy the base class.
- Dialog_Layout::set_document(layout, document, portal->get_relationship()->get_from_table(), empty_fields);
- //m_table_name is now actually the parent_table_name.
- m_portal = glom_sharedptr_clone(portal);
+
+ Dialog_Layout::set_document(layout, document, from_table, empty_fields);
+ //m_table_name is now actually the parent_table_name.
update_ui();
}
void Dialog_Layout_Calendar_Related::update_ui(bool including_relationship_list)
{
- if(!m_portal || !(m_portal->get_relationship()))
- return;
-
m_modified = false;
const Glib::ustring related_table_name = m_portal->get_table_used(Glib::ustring() /* parent table - not relevant*/);
@@ -119,12 +133,18 @@
bool show_child_relationships = m_checkbutton_show_child_relationships->get_active();
//For the showing of child relationships if necessary:
- if(!show_child_relationships && m_portal->get_related_relationship())
+ if(!show_child_relationships && m_portal && m_portal->get_related_relationship())
{
show_child_relationships = true;
}
- m_combo_relationship->set_relationships(document, m_portal->get_relationship()->get_from_table(), show_child_relationships, false /* don't show parent table */); //We don't show the optional parent table because portal use _only_ relationships, of course.
+ Glib::ustring from_table;
+ if(m_portal->get_has_relationship_name())
+ from_table = m_portal->get_relationship()->get_from_table();
+ else
+ from_table = m_table_name;
+
+ m_combo_relationship->set_relationships(document, from_table, show_child_relationships, false /* don't show parent table */); //We don't show the optional parent table because portal use _only_ relationships, of course.
if(show_child_relationships != m_checkbutton_show_child_relationships->get_active())
{
@@ -133,12 +153,15 @@
}
//Set the table name and title:
- sharedptr<LayoutItem_CalendarPortal> portal_temp = m_portal;
+ //sharedptr<LayoutItem_CalendarPortal> portal_temp = m_portal;
m_combo_relationship->set_selected_relationship(m_portal->get_relationship(), m_portal->get_related_relationship());
Document_Glom::type_list_layout_groups mapGroups;
- mapGroups.push_back(m_portal);
- document->fill_layout_field_details(related_table_name, mapGroups); //Update with full field information.
+ if(m_portal)
+ {
+ mapGroups.push_back(m_portal);
+ document->fill_layout_field_details(related_table_name, mapGroups); //Update with full field information.
+ }
//Show the field layout
//typedef std::list< Glib::ustring > type_listStrings;
Modified: trunk/glom/mode_data/dialog_layout_calendar_related.h
==============================================================================
--- trunk/glom/mode_data/dialog_layout_calendar_related.h (original)
+++ trunk/glom/mode_data/dialog_layout_calendar_related.h Thu Sep 4 22:47:59 2008
@@ -43,6 +43,9 @@
* @param table_fields: The actual fields in the table, in case the document does not yet know about them all.
*/
virtual void set_document(const Glib::ustring& layout, Document_Glom* document, const sharedptr<const LayoutItem_CalendarPortal>& portal);
+
+ virtual void set_document(const Glib::ustring& layout, Document_Glom* document, const Glib::ustring& parent_table);
+
virtual void update_ui(bool including_relationships_list = true);
sharedptr<Relationship> get_relationship() const;
Modified: trunk/glom/mode_data/dialog_layout_details.cc
==============================================================================
--- trunk/glom/mode_data/dialog_layout_details.cc (original)
+++ trunk/glom/mode_data/dialog_layout_details.cc Thu Sep 4 22:47:59 2008
@@ -764,16 +764,18 @@
{
Gtk::TreeModel::iterator parent = get_selected_group_parent();
+ /* We don't need to ask this because the portal layout dialog can now handle an empty portal:
sharedptr<Relationship> relationship = offer_relationship_list();
if(relationship)
{
+ */
Gtk::TreeModel::iterator iter = append_appropriate_row();
if(iter)
{
Gtk::TreeModel::Row row = *iter;
sharedptr<LayoutItem_Portal> portal = sharedptr<LayoutItem_Portal>::create();
- portal->set_relationship(relationship);
+ //portal->set_relationship(relationship);
row[m_model_items->m_columns.m_col_layout_item] = portal;
//Scroll to, and select, the new row:
@@ -785,7 +787,9 @@
m_modified = true;
}
+ /*
}
+ */
enable_buttons();
}
@@ -794,16 +798,18 @@
{
Gtk::TreeModel::iterator parent = get_selected_group_parent();
+ /* We don't need to ask this because the portal layout dialog can now handle an empty portal:
sharedptr<Relationship> relationship = offer_relationship_list();
if(relationship)
{
+ */
Gtk::TreeModel::iterator iter = append_appropriate_row();
if(iter)
{
Gtk::TreeModel::Row row = *iter;
sharedptr<LayoutItem_Portal> portal = sharedptr<LayoutItem_CalendarPortal>::create();
- portal->set_relationship(relationship);
+ //portal->set_relationship(relationship);
row[m_model_items->m_columns.m_col_layout_item] = portal;
//Scroll to, and select, the new row:
@@ -815,7 +821,7 @@
m_modified = true;
}
- }
+ //}
enable_buttons();
}
Modified: trunk/glom/mode_data/dialog_layout_list_related.cc
==============================================================================
--- trunk/glom/mode_data/dialog_layout_list_related.cc (original)
+++ trunk/glom/mode_data/dialog_layout_list_related.cc Thu Sep 4 22:47:59 2008
@@ -81,6 +81,11 @@
void Dialog_Layout_List_Related::set_document(const Glib::ustring& layout, Document_Glom* document, const Glib::ustring& from_table)
{
+ if(!m_portal)
+ {
+ m_portal = sharedptr<LayoutItem_Portal>::create(); //The rest of the class assumes that this is not null.
+ }
+
type_vecLayoutFields empty_fields; //Just to satisfy the base class.
Dialog_Layout::set_document(layout, document, from_table, empty_fields);
//m_table_name is now actually the parent_table_name.
@@ -101,8 +106,8 @@
void Dialog_Layout_List_Related::update_ui(bool including_relationship_list)
{
- if(!m_portal || !(m_portal->get_relationship()))
- return;
+ if(!m_portal)
+ return;
m_modified = false;
@@ -123,7 +128,13 @@
show_child_relationships = true;
}
- m_combo_relationship->set_relationships(document, m_portal->get_relationship()->get_from_table(), show_child_relationships, false /* don't show parent table */); //We don't show the optional parent table because portal use _only_ relationships, of course.
+ Glib::ustring from_table;
+ if(m_portal->get_has_relationship_name())
+ from_table = m_portal->get_relationship()->get_from_table();
+ else
+ from_table = m_table_name;
+
+ m_combo_relationship->set_relationships(document, from_table, show_child_relationships, false /* don't show parent table */); //We don't show the optional parent table because portal use _only_ relationships, of course.
if(show_child_relationships != m_checkbutton_show_child_relationships->get_active())
{
@@ -132,15 +143,18 @@
}
//Set the table name and title:
- sharedptr<LayoutItem_Portal> portal_temp = m_portal;
- m_combo_relationship->set_selected_relationship(m_portal->get_relationship(), m_portal->get_related_relationship());
-
+ //sharedptr<LayoutItem_Portal> portal_temp = m_portal;
Document_Glom::type_list_layout_groups mapGroups;
- mapGroups.push_back(m_portal);
- document->fill_layout_field_details(related_table_name, mapGroups); //Update with full field information.
+ if(m_portal)
+ {
+ m_combo_relationship->set_selected_relationship(m_portal->get_relationship(), m_portal->get_related_relationship());
- //Show the field layout
- //typedef std::list< Glib::ustring > type_listStrings;
+ mapGroups.push_back(m_portal);
+ document->fill_layout_field_details(related_table_name, mapGroups); //Update with full field information.
+
+ //Show the field layout
+ //typedef std::list< Glib::ustring > type_listStrings;
+ }
m_model_items->clear();
@@ -240,6 +254,7 @@
//Add the fields to the portal:
//The code that created this dialog must read m_portal back out again.
+
m_portal->remove_all_items();
guint field_sequence = 1; //0 means no sequence
Modified: trunk/glom/mode_data/flowtablewithfields.cc
==============================================================================
--- trunk/glom/mode_data/flowtablewithfields.cc (original)
+++ trunk/glom/mode_data/flowtablewithfields.cc Thu Sep 4 22:47:59 2008
@@ -248,27 +248,32 @@
Document_Glom* pDocument = static_cast<Document_Glom*>(get_document());
if(pDocument)
{
+ Box_Data_List_Related* portal_box = Gtk::manage(new Box_Data_List_Related);
+ add_view(portal_box); //Give it access to the document, needed to get the layout and fields information.
+
+ //Create the layout:
+ if(portal && portal->get_has_relationship_name())
+ portal_box->init_db_details(portal, show_title);
+ else
+ portal_box->init_db_details(m_table_name, show_title);
+
+ Glib::ustring to_table;
sharedptr<Relationship> relationship = pDocument->get_relationship(m_table_name, portal->get_relationship_name());
if(relationship)
- {
- Box_Data_List_Related* portal_box = Gtk::manage(new Box_Data_List_Related);
- add_view(portal_box); //Give it access to the document, needed to get the layout and fields information.
+ to_table = relationship->get_to_table();
- portal_box->init_db_details(portal, show_title); //Create the layout
+ portal_box->set_layout_item(portal, to_table);
+ portal_box->show();
- portal_box->set_layout_item(portal, relationship->get_to_table());
- portal_box->show();
+ m_portals.push_back(portal_box);
- m_portals.push_back(portal_box);
+ //Connect signals:
+ //Just reemit this object's signal when receiving the same signal from the portal:
+ signal_connect_for_reemit_1arg(portal_box->signal_portal_record_changed(), signal_related_record_changed());
- //Connect signals:
- //Just reemit this object's signal when receiving the same signal from the portal:
- signal_connect_for_reemit_1arg(portal_box->signal_portal_record_changed(), signal_related_record_changed());
+ portal_box->signal_user_requested_details().connect( sigc::bind( sigc::mem_fun(*this, &FlowTableWithFields::on_portal_user_requested_details), portal_box));
- portal_box->signal_user_requested_details().connect( sigc::bind( sigc::mem_fun(*this, &FlowTableWithFields::on_portal_user_requested_details), portal_box));
-
- return portal_box;
- }
+ return portal_box;
}
return 0;
@@ -282,27 +287,32 @@
Document_Glom* pDocument = static_cast<Document_Glom*>(get_document());
if(pDocument)
{
+ Box_Data_Calendar_Related* portal_box = Gtk::manage(new Box_Data_Calendar_Related);
+ add_view(portal_box); //Give it access to the document, needed to get the layout and fields information.
+
+ //Create the layout:
+ if(portal && portal->get_has_relationship_name())
+ portal_box->init_db_details(portal, show_title);
+ else
+ portal_box->init_db_details(m_table_name, show_title);
+
+ Glib::ustring to_table;
sharedptr<Relationship> relationship = pDocument->get_relationship(m_table_name, portal->get_relationship_name());
if(relationship)
- {
- Box_Data_Calendar_Related* portal_box = Gtk::manage(new Box_Data_Calendar_Related);
- add_view(portal_box); //Give it access to the document, needed to get the layout and fields information.
-
- portal_box->init_db_details(portal, show_title); //Create the layout
+ to_table = relationship->get_to_table();
- portal_box->set_layout_item(portal, relationship->get_to_table());
- portal_box->show();
+ portal_box->set_layout_item(portal, to_table);
+ portal_box->show();
- m_portals.push_back(portal_box);
+ m_portals.push_back(portal_box);
- //Connect signals:
- //Just reemit this object's signal when receiving the same signal from the portal:
- signal_connect_for_reemit_1arg(portal_box->signal_portal_record_changed(), signal_related_record_changed());
+ //Connect signals:
+ //Just reemit this object's signal when receiving the same signal from the portal:
+ signal_connect_for_reemit_1arg(portal_box->signal_portal_record_changed(), signal_related_record_changed());
- portal_box->signal_user_requested_details().connect( sigc::bind( sigc::mem_fun(*this, &FlowTableWithFields::on_portal_user_requested_details), portal_box));
+ portal_box->signal_user_requested_details().connect( sigc::bind( sigc::mem_fun(*this, &FlowTableWithFields::on_portal_user_requested_details), portal_box));
- return portal_box;
- }
+ return portal_box;
}
return 0;
@@ -322,6 +332,8 @@
add(*portal_box, true /* expand */);
add_layoutwidgetbase(portal_box, add_before);
}
+ else
+ std::cerr << "FlowTableWithFields::add_layout_portal_at_position(): No portal was created." << std::endl;
}
void FlowTableWithFields::add_layout_notebook_at_position(const sharedptr<LayoutItem_Notebook>& notebook, const type_list_layoutwidgets::iterator& add_before)
Modified: trunk/glom/mode_design/print_layouts/canvas_layout_item.cc
==============================================================================
--- trunk/glom/mode_design/print_layouts/canvas_layout_item.cc (original)
+++ trunk/glom/mode_design/print_layouts/canvas_layout_item.cc Thu Sep 4 22:47:59 2008
@@ -206,12 +206,15 @@
sharedptr<LayoutItem_Portal> portal = sharedptr<LayoutItem_Portal>::cast_dynamic(m_layout_item);
if(portal)
{
+ std::cout << "DEBUG: found portal: items=" << portal->get_items_count() << std::endl;
+
Glib::RefPtr<CanvasTableMovable> canvas_item = CanvasTableMovable::create();
- canvas_item->property_vert_grid_line_width() = 2;
+ canvas_item->property_vert_grid_line_width() = 1;
+ canvas_item->property_horz_grid_line_width() = 1;
canvas_item->property_stroke_color() = "black";
//Show as many rows as can fit in the height.
- const double row_height = portal->get_print_layout_row_height(); //TODO: Let the user specify the row height
+ const double row_height = portal->get_print_layout_row_height();
double ignore_x = 0;
double ignore_y = 0;
double total_width = 0;
Modified: trunk/glom/mode_design/print_layouts/canvas_print_layout.cc
==============================================================================
--- trunk/glom/mode_design/print_layouts/canvas_print_layout.cc (original)
+++ trunk/glom/mode_design/print_layouts/canvas_print_layout.cc Thu Sep 4 22:47:59 2008
@@ -105,10 +105,13 @@
for(LayoutGroup::type_list_items::const_iterator iter = group->m_list_items.begin(); iter != group->m_list_items.end(); ++iter)
{
sharedptr<LayoutItem> item = *iter;
+
+ sharedptr<LayoutItem_Portal> portal = sharedptr<LayoutItem_Portal>::cast_dynamic(item);
sharedptr<LayoutGroup> group = sharedptr<LayoutGroup>::cast_dynamic(item);
- if(group)
+ if(group && !portal)
{
add_layout_group(group);
+ continue;
}
else
{
@@ -178,6 +181,7 @@
{
*/
sharedptr<LayoutItem> layout_item = canvas_item->get_layout_item();
+ std::cout << "DEBUG: saving layout_item type=" << layout_item->get_part_type_name() << std::endl;
update_layout_position_from_canvas(layout_item, canvas_item);
group->add_item(layout_item);
@@ -281,7 +285,7 @@
layout_item->set_print_layout_position(x, y, width, height);
}
-sharedptr<LayoutItem_Portal> Canvas_PrintLayout::offer_related_records(const sharedptr<LayoutItem_Portal>& portal, Gtk::Widget* parent)
+sharedptr<LayoutItem_Portal> Canvas_PrintLayout::offer_related_records(const sharedptr<LayoutItem_Portal>& portal, Gtk::Window* parent)
{
sharedptr<LayoutItem_Portal> result = portal;
@@ -304,14 +308,17 @@
else
dialog->set_document("TODO_layout_name", get_document(), portal);
- //m_pDialogLayout->signal_hide().connect( sigc::mem_fun(*this, &Box_Data::on_dialog_layout_hide) );
- dialog->run();
-
-
+ if(parent)
+ dialog->set_transient_for(*parent);
- //TODO: block.
+ Utils::show_window_until_hide(dialog);
result = dialog->get_portal_layout();
+ if(!result)
+ std::cout << "DEBUG: result is empty." << std::endl;
+ else
+ std::cout << "result->get_items_count():" << result->get_items_count() << std::endl;
+
delete dialog;
dialog = 0;
@@ -360,6 +367,8 @@
}
}
+ m_modified = true;
+
m_context_item.clear();
}
Modified: trunk/glom/mode_design/print_layouts/canvas_print_layout.h
==============================================================================
--- trunk/glom/mode_design/print_layouts/canvas_print_layout.h (original)
+++ trunk/glom/mode_design/print_layouts/canvas_print_layout.h Thu Sep 4 22:47:59 2008
@@ -71,7 +71,7 @@
void add_layout_group_children(const sharedptr<LayoutGroup>& group);
void fill_layout_group(const sharedptr<LayoutGroup>& group);
- sharedptr<LayoutItem_Portal> offer_related_records(const sharedptr<LayoutItem_Portal>& portal, Gtk::Widget* parent);
+ sharedptr<LayoutItem_Portal> offer_related_records(const sharedptr<LayoutItem_Portal>& portal, Gtk::Window* parent);
void on_item_show_context_menu(guint button, guint32 activate_time, Glib::RefPtr<CanvasLayoutItem> item);
void on_context_menu_edit();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]