glom r1570 - in trunk: . glom/mode_data
- From: arminb svn gnome org
- To: svn-commits-list gnome org
- Subject: glom r1570 - in trunk: . glom/mode_data
- Date: Tue, 15 Apr 2008 21:33:48 +0100 (BST)
Author: arminb
Date: Tue Apr 15 21:33:47 2008
New Revision: 1570
URL: http://svn.gnome.org/viewvc/glom?rev=1570&view=rev
Log:
2008-04-15 Armin Burgmeier <armin openismus com>
* glom/mode_data/box_data.h:
* glom/mode_data/box_data.cc: Made the show_layout_dialog() function
non-virtual and added two new (pure) virtual functions called
create_layout_dialog() and prepare_layout_dialog(). Create the dialog
in show_layout_dialog() if necessary, so the dialog is only created
when needed.
* glom/mode_data/box_data_list.h:
* glom/mode_data/box_data_details.h:
* glom/mode_data/box_data_list.cc:
* glom/mode_data/box_data_details.cc: Implement the two new virtual
functions.
* glom/mode_data/box_data_list_related.h:
* glom/mode_data/box_data_calendar_related.h:
* glom/mode_data/box_data_list_related.cc:
* glom/mode_data/box_data_calendar_related.cc: Removed the
m_pLayoutDialogRelated variable, and implement the two new virtual
functions instead. Removed the destructor which is no longer required.
(on_dialog_layout_hide): Cast m_pDialogLayout to a
Dialog_Layout_List_Related before usage. These changes clean up the
code in Box_Data_List_Related a bit.
Modified:
trunk/ChangeLog
trunk/glom/mode_data/box_data.cc
trunk/glom/mode_data/box_data.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_details.cc
trunk/glom/mode_data/box_data_details.h
trunk/glom/mode_data/box_data_list.cc
trunk/glom/mode_data/box_data_list.h
trunk/glom/mode_data/box_data_list_related.cc
trunk/glom/mode_data/box_data_list_related.h
Modified: trunk/glom/mode_data/box_data.cc
==============================================================================
--- trunk/glom/mode_data/box_data.cc (original)
+++ trunk/glom/mode_data/box_data.cc Tue Apr 15 21:33:47 2008
@@ -387,11 +387,15 @@
#ifndef GLOM_ENABLE_CLIENT_ONLY
void Box_Data::show_layout_dialog()
{
- if(m_pDialogLayout)
+ if(!m_pDialogLayout)
{
- m_pDialogLayout->set_document(m_layout_name, get_document(), m_table_name, m_FieldsShown); //TODO: Use m_TableFields?
- m_pDialogLayout->show();
+ m_pDialogLayout = create_layout_dialog();
+ add_view(m_pDialogLayout); //Give it access to the document.
+ m_pDialogLayout->signal_hide().connect( sigc::mem_fun(*this, &Box_Data::on_dialog_layout_hide) );
}
+
+ prepare_layout_dialog(m_pDialogLayout);
+ m_pDialogLayout->show();
}
#endif // !GLOM_ENABLE_CLIENT_ONLY
Modified: trunk/glom/mode_data/box_data.h
==============================================================================
--- trunk/glom/mode_data/box_data.h (original)
+++ trunk/glom/mode_data/box_data.h Tue Apr 15 21:33:47 2008
@@ -60,7 +60,7 @@
virtual bool confirm_discard_unstored_data() const;
#ifndef GLOM_ENABLE_CLIENT_ONLY
- virtual void show_layout_dialog();
+ void show_layout_dialog();
#endif // !GLOM_ENABLE_CLIENT_ONLY
Glib::ustring get_layout_name() const;
@@ -133,6 +133,11 @@
static Glib::ustring xslt_process(const xmlpp::Document& xml_document, const std::string& filepath_xslt);
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+ virtual Dialog_Layout* create_layout_dialog() const = 0;
+ virtual void prepare_layout_dialog(Dialog_Layout* dialog) = 0;
+#endif // !GLOM_ENABLE_CLIENT_ONLY
+
Gtk::Button m_Button_Find; //only used by _Find sub-classes. Should be MI.
Gtk::Label m_Label_FindStatus;
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 Tue Apr 15 21:33:47 2008
@@ -29,9 +29,6 @@
{
Box_Data_List_Related::Box_Data_List_Related()
-#ifndef GLOM_ENABLE_CLIENT_ONLY
-: m_pDialogLayoutRelated(0)
-#endif // !GLOM_ENABLE_CLIENT_ONLY
{
set_size_request(400, -1); //An arbitrary default.
@@ -53,44 +50,6 @@
add(m_Frame);
m_layout_name = "list_related"; //TODO: We need a unique name when 2 portals use the same table.
-
-#ifndef GLOM_ENABLE_CLIENT_ONLY
- //Delete the dialog from the base class, because we don't use it.
- if(m_pDialogLayout)
- {
- remove_view(m_pDialogLayout);
- delete m_pDialogLayout;
- m_pDialogLayout = 0;
- }
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-
-#ifndef GLOM_ENABLE_CLIENT_ONLY
- Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(GLOM_GLADEDIR "glom_developer.glade", "window_data_layout");
- if(refXml)
- {
- Dialog_Layout_List_Related* dialog = 0;
- refXml->get_widget_derived("window_data_layout", dialog);
- if(dialog)
- {
- //Use the new dialog:
- m_pDialogLayoutRelated = dialog;
- add_view(m_pDialogLayoutRelated); //Give it access to the document.
- m_pDialogLayoutRelated->signal_hide().connect( sigc::mem_fun(*this, &Box_Data::on_dialog_layout_hide) );
- }
- }
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-}
-
-Box_Data_List_Related::~Box_Data_List_Related()
-{
-#ifndef GLOM_ENABLE_CLIENT_ONLY
- if(m_pDialogLayoutRelated)
- {
- remove_view(m_pDialogLayoutRelated);
- delete m_pDialogLayoutRelated;
- m_pDialogLayoutRelated = 0;
- }
-#endif // !GLOM_ENABLE_CLIENT_ONLY
}
void Box_Data_List_Related::enable_buttons()
@@ -396,17 +355,6 @@
return type_vecLayoutFields();
}
-#ifndef GLOM_ENABLE_CLIENT_ONLY
-void Box_Data_List_Related::show_layout_dialog()
-{
- if(m_pDialogLayoutRelated)
- {
- m_pDialogLayoutRelated->set_document(m_layout_name, get_document(), m_portal);
- m_pDialogLayoutRelated->show();
- }
-}
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-
Box_Data_List_Related::type_signal_record_changed Box_Data_List_Related::signal_record_changed()
{
return m_signal_record_changed;
@@ -415,7 +363,9 @@
#ifndef GLOM_ENABLE_CLIENT_ONLY
void Box_Data_List_Related::on_dialog_layout_hide()
{
- m_portal = m_pDialogLayoutRelated->get_portal_layout();
+ Dialog_Layout_List_Related* dialog_related = dynamic_cast<Dialog_Layout_List_Related*>(m_pDialogLayout);
+ g_assert(dialog_related != NULL);
+ m_portal = dialog_related->get_portal_layout();
//Update the UI:
@@ -586,5 +536,27 @@
return result;
}
+Dialog_Layout* Box_Data_List_Related::create_layout_dialog() const
+{
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+ Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(GLOM_GLADEDIR "glom_developer.glade", "window_data_layout");
+ if(refXml)
+ {
+ Dialog_Layout_List_Related* dialog = 0;
+ refXml->get_widget_derived("window_data_layout", dialog);
+ return dialog;
+ }
+ }
+
+ return NULL;
+#endif // !GLOM_ENABLE_CLIENT_ONLY
+}
+
+void prepare_layout_dialog(Dialog_Layout* dialog)
+{
+ 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);
+}
} //namespace Glom
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 Tue Apr 15 21:33:47 2008
@@ -37,7 +37,6 @@
{
public:
Box_Data_List_Related();
- virtual ~Box_Data_List_Related();
/**
* @param portal: The full portal details
@@ -53,10 +52,6 @@
sharedptr<LayoutItem_Portal> get_portal() const;
virtual sharedptr<const Field> get_key_field() const;
-#ifndef GLOM_ENABLE_CLIENT_ONLY
- virtual void show_layout_dialog();
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-
sigc::signal<void, Gnome::Gda::Value> signal_record_added;
bool get_has_suitable_record_to_view_details() const;
@@ -83,6 +78,11 @@
virtual void enable_buttons(); //override
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+ virtual Dialog_Layout* create_layout_dialog() const; // override.
+ virtual void prepare_layout_dialog(Dialog_Layout* dialog); // override.
+#endif // !GLOM_ENABLE_CLIENT_ONLY
+
protected:
virtual Document_Glom::type_list_layout_groups create_layout_get_layout(); //override.
@@ -90,10 +90,6 @@
Gtk::Alignment m_Alignment;
Gtk::Label m_Label;
-#ifndef GLOM_ENABLE_CLIENT_ONLY
- Dialog_Layout_List_Related* m_pDialogLayoutRelated;
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-
sharedptr<LayoutItem_Portal> m_portal;
sharedptr<Field> m_key_field;
Gnome::Gda::Value m_key_value;
Modified: trunk/glom/mode_data/box_data_details.cc
==============================================================================
--- trunk/glom/mode_data/box_data_details.cc (original)
+++ trunk/glom/mode_data/box_data_details.cc Tue Apr 15 21:33:47 2008
@@ -61,22 +61,6 @@
add_view(&m_FlowTable); //Allow this to access the document too.
-#ifndef GLOM_ENABLE_CLIENT_ONLY
- //TODO_Performance: Instantiate this only when needed:
- Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(Utils::get_glade_file_path("glom_developer.glade"), "window_data_layout"); //TODO: Use a generic layout dialog?
- if(refXml)
- {
- Dialog_Layout_Details* dialog = 0;
- refXml->get_widget_derived("window_data_layout", dialog);
- if(dialog)
- {
- m_pDialogLayout = dialog;
- add_view(m_pDialogLayout); //Give it access to the document.
- m_pDialogLayout->signal_hide().connect( sigc::mem_fun(static_cast<Box_Data&>(*this), &Box_Data::on_dialog_layout_hide) );
- }
- }
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-
m_FlowTable.set_columns_count(1); //Sub-groups will have multiple columns (by default, there is one sub-group, with 2 columns).
m_FlowTable.set_padding(Utils::DEFAULT_SPACING_SMALL);
@@ -965,4 +949,24 @@
}
}
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+Dialog_Layout* Box_Data_Details::create_layout_dialog() const
+{
+ Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(Utils::get_glade_file_path("glom_developer.glade"), "window_data_layout"); //TODO: Use a generic layout dialog?
+ if(refXml)
+ {
+ Dialog_Layout_Details* dialog = 0;
+ refXml->get_widget_derived("window_data_layout", dialog);
+ return dialog;
+ }
+
+ return NULL;
+}
+
+void Box_Data_Details::prepare_layout_dialog(Dialog_Layout* dialog)
+{
+ dialog->set_document(m_layout_name, get_document(), m_table_name, m_FieldsShown); //TODO: Use m_TableFields?
+}
+#endif // !GLOM_ENABLE_CLIENT_ONLY
+
} //namespace Glom
Modified: trunk/glom/mode_data/box_data_details.h
==============================================================================
--- trunk/glom/mode_data/box_data_details.h (original)
+++ trunk/glom/mode_data/box_data_details.h Tue Apr 15 21:33:47 2008
@@ -111,6 +111,11 @@
virtual void recalculate_fields_for_related_records(const Glib::ustring& relationship_name);
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+ virtual Dialog_Layout* create_layout_dialog() const; // override.
+ virtual void prepare_layout_dialog(Dialog_Layout* dialog); // override.
+#endif // !GLOM_ENABLE_CLIENT_ONLY
+
sharedptr<Field> m_field_primary_key;
Gnome::Gda::Value m_primary_key_value;
Modified: trunk/glom/mode_data/box_data_list.cc
==============================================================================
--- trunk/glom/mode_data/box_data_list.cc (original)
+++ trunk/glom/mode_data/box_data_list.cc Tue Apr 15 21:33:47 2008
@@ -39,21 +39,6 @@
{
m_layout_name = "list";
-#ifndef GLOM_ENABLE_CLIENT_ONLY
- Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(Utils::get_glade_file_path("glom_developer.glade"), "window_data_layout"); //TODO: Use a generic layout dialog?
- if(refXml)
- {
- Dialog_Layout_List* dialog = 0;
- refXml->get_widget_derived("window_data_layout", dialog);
- if(dialog)
- {
- m_pDialogLayout = dialog;
- add_view(m_pDialogLayout); //Give it access to the document.
- m_pDialogLayout->signal_hide().connect( sigc::mem_fun(*this, &Box_Data::on_dialog_layout_hide) );
- }
- }
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-
//m_strHint = _("When you change the data in a field the database is updated immediately.\n Click [Add] or enter data into the last row to add a new record.\n Leave automatic ID fields empty - they will be filled for you.\nOnly the first 100 records are shown.");
pack_start(m_AddDel);
@@ -925,7 +910,25 @@
Box_Data::on_dialog_layout_hide();
m_reset_column_widths = false;
}
-#endif //GLOM_ENABLE_CLIENT_ONLY
+
+Dialog_Layout* Box_Data_List::create_layout_dialog() const
+{
+ Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(Utils::get_glade_file_path("glom_developer.glade"), "window_data_layout"); //TODO: Use a generic layout dialog?
+ if(refXml)
+ {
+ Dialog_Layout_List* dialog = 0;
+ refXml->get_widget_derived("window_data_layout", dialog);
+ return dialog;
+ }
+
+ return NULL;
+}
+
+void Box_Data_List::prepare_layout_dialog(Dialog_Layout* dialog)
+{
+ dialog->set_document(m_layout_name, get_document(), m_table_name, m_FieldsShown); //TODO: Use m_TableFields?
+}
+#endif // !GLOM_ENABLE_CLIENT_ONLY
} //namespace Glom
Modified: trunk/glom/mode_data/box_data_list.h
==============================================================================
--- trunk/glom/mode_data/box_data_list.h (original)
+++ trunk/glom/mode_data/box_data_list.h Tue Apr 15 21:33:47 2008
@@ -106,6 +106,11 @@
virtual void print_layout();
virtual void print_layout_group(xmlpp::Element* node_parent, const sharedptr<const LayoutGroup>& group);
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+ virtual Dialog_Layout* create_layout_dialog() const; // override.
+ virtual void prepare_layout_dialog(Dialog_Layout* dialog); // override.
+#endif // !GLOM_ENABLE_CLIENT_ONLY
+
//Member widgers:
mutable DbAddDel_WithButtons m_AddDel; //mutable because its get_ methods aren't const.
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 Tue Apr 15 21:33:47 2008
@@ -30,9 +30,6 @@
{
Box_Data_List_Related::Box_Data_List_Related()
-#ifndef GLOM_ENABLE_CLIENT_ONLY
-: m_pDialogLayoutRelated(0)
-#endif // !GLOM_ENABLE_CLIENT_ONLY
{
set_size_request(400, -1); //An arbitrary default.
@@ -54,44 +51,6 @@
add(m_Frame);
m_layout_name = "list_related"; //TODO: We need a unique name when 2 portals use the same table.
-
-#ifndef GLOM_ENABLE_CLIENT_ONLY
- //Delete the dialog from the base class, because we don't use it.
- if(m_pDialogLayout)
- {
- remove_view(m_pDialogLayout);
- delete m_pDialogLayout;
- m_pDialogLayout = 0;
- }
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-
-#ifndef GLOM_ENABLE_CLIENT_ONLY
- Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(Utils::get_glade_file_path("glom_developer.glade"), "window_data_layout");
- if(refXml)
- {
- Dialog_Layout_List_Related* dialog = 0;
- refXml->get_widget_derived("window_data_layout", dialog);
- if(dialog)
- {
- //Use the new dialog:
- m_pDialogLayoutRelated = dialog;
- add_view(m_pDialogLayoutRelated); //Give it access to the document.
- m_pDialogLayoutRelated->signal_hide().connect( sigc::mem_fun(*this, &Box_Data::on_dialog_layout_hide) );
- }
- }
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-}
-
-Box_Data_List_Related::~Box_Data_List_Related()
-{
-#ifndef GLOM_ENABLE_CLIENT_ONLY
- if(m_pDialogLayoutRelated)
- {
- remove_view(m_pDialogLayoutRelated);
- delete m_pDialogLayoutRelated;
- m_pDialogLayoutRelated = 0;
- }
-#endif // !GLOM_ENABLE_CLIENT_ONLY
}
void Box_Data_List_Related::enable_buttons()
@@ -397,17 +356,6 @@
return type_vecLayoutFields();
}
-#ifndef GLOM_ENABLE_CLIENT_ONLY
-void Box_Data_List_Related::show_layout_dialog()
-{
- if(m_pDialogLayoutRelated)
- {
- m_pDialogLayoutRelated->set_document(m_layout_name, get_document(), m_portal);
- m_pDialogLayoutRelated->show();
- }
-}
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-
Box_Data_List_Related::type_signal_record_changed Box_Data_List_Related::signal_record_changed()
{
return m_signal_record_changed;
@@ -416,7 +364,9 @@
#ifndef GLOM_ENABLE_CLIENT_ONLY
void Box_Data_List_Related::on_dialog_layout_hide()
{
- m_portal = m_pDialogLayoutRelated->get_portal_layout();
+ Dialog_Layout_List_Related* dialog_related = dynamic_cast<Dialog_Layout_List_Related*>(m_pDialogLayout);
+ g_assert(dialog_related != NULL);
+ m_portal = dialog_related->get_portal_layout();
//Update the UI:
@@ -587,5 +537,26 @@
return result;
}
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+Dialog_Layout* Box_Data_List_Related::create_layout_dialog() const
+{
+ Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(Utils::get_glade_file_path("glom_developer.glade"), "window_data_layout");
+ if(refXml)
+ {
+ Dialog_Layout_List_Related* dialog = 0;
+ refXml->get_widget_derived("window_data_layout", dialog);
+ return dialog;
+ }
+
+ return NULL;
+}
+
+void Box_Data_List_Related::prepare_layout_dialog(Dialog_Layout* dialog)
+{
+ 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);
+}
+#endif // !GLOM_ENABLE_CLIENT_ONLY
} //namespace Glom
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 Tue Apr 15 21:33:47 2008
@@ -37,7 +37,6 @@
{
public:
Box_Data_List_Related();
- virtual ~Box_Data_List_Related();
/**
* @param portal: The full portal details
@@ -53,10 +52,6 @@
sharedptr<LayoutItem_Portal> get_portal() const;
virtual sharedptr<const Field> get_key_field() const;
-#ifndef GLOM_ENABLE_CLIENT_ONLY
- virtual void show_layout_dialog();
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-
sigc::signal<void, Gnome::Gda::Value> signal_record_added;
bool get_has_suitable_record_to_view_details() const;
@@ -83,6 +78,11 @@
virtual void enable_buttons(); //override
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+ virtual Dialog_Layout* create_layout_dialog() const; // override.
+ virtual void prepare_layout_dialog(Dialog_Layout* dialog); // override.
+#endif // !GLOM_ENABLE_CLIENT_ONLY
+
protected:
virtual Document_Glom::type_list_layout_groups create_layout_get_layout(); //override.
@@ -90,10 +90,6 @@
Gtk::Alignment m_Alignment;
Gtk::Label m_Label;
-#ifndef GLOM_ENABLE_CLIENT_ONLY
- Dialog_Layout_List_Related* m_pDialogLayoutRelated;
-#endif // !GLOM_ENABLE_CLIENT_ONLY
-
sharedptr<LayoutItem_Portal> m_portal;
sharedptr<Field> m_key_field;
Gnome::Gda::Value m_key_value;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]