glom r1577 - in trunk/glom: . libglom/data_structure/layout libglom/document mode_data utility_widgets/calendar utility_widgets/db_adddel
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: glom r1577 - in trunk/glom: . libglom/data_structure/layout libglom/document mode_data utility_widgets/calendar utility_widgets/db_adddel
- Date: Mon, 21 Apr 2008 12:15:52 +0100 (BST)
Author: murrayc
Date: Mon Apr 21 11:15:51 2008
New Revision: 1577
URL: http://svn.gnome.org/viewvc/glom?rev=1577&view=rev
Log:
2008-04-21 Murray Cumming <murrayc murrayc com>
* glom/glom.glade:
* glom/glom_developer.glade: Moved dialog_data_invalid_format to the
non-developer .glade file, where the code expects it to be, preventing
a crash.
Added:
trunk/glom/mode_data/dialog_layout_calendar_related.cc
- copied, changed from r1576, /trunk/glom/mode_data/dialog_layout_list_related.cc
trunk/glom/mode_data/dialog_layout_calendar_related.h
- copied, changed from r1576, /trunk/glom/mode_data/dialog_layout_list_related.h
Modified:
trunk/glom/Makefile.am
trunk/glom/combobox_fields.cc
trunk/glom/combobox_fields.h
trunk/glom/glom_developer.glade
trunk/glom/libglom/data_structure/layout/Makefile.am
trunk/glom/libglom/document/document_glom.cc
trunk/glom/mode_data/Makefile.am
trunk/glom/mode_data/box_data_calendar_related.cc
trunk/glom/mode_data/box_data_calendar_related.h
trunk/glom/mode_data/dialog_layout_details.cc
trunk/glom/mode_data/dialog_layout_details.h
trunk/glom/mode_data/dialog_layout_list.cc
trunk/glom/mode_data/flowtablewithfields.cc
trunk/glom/mode_data/flowtablewithfields.h
trunk/glom/utility_widgets/calendar/Makefile.am
trunk/glom/utility_widgets/calendar/glomgtkcalendar.c
trunk/glom/utility_widgets/db_adddel/db_adddel.h
Modified: trunk/glom/Makefile.am
==============================================================================
--- trunk/glom/Makefile.am (original)
+++ trunk/glom/Makefile.am Mon Apr 21 11:15:51 2008
@@ -39,7 +39,7 @@
combobox_fields.h combobox_fields.cc \
combobox_relationship.h combobox_relationship.cc \
dialog_connection.h dialog_connection.cc \
- dialog_existing_or_new.h dialog_existing_or_new.cc \
+ dialog_existing_or_new.h dialog_existing_or_new.cc \
dialog_invalid_data.h dialog_invalid_data.cc \
filechooser_export.h filechooser_export.cc \
box_reports.h box_reports.cc \
@@ -75,6 +75,7 @@
utility_widgets/adddel/libutility_widgets_adddel.a \
utility_widgets/adddel/eggcolumnchooser/libutility_widgets_adddel_eggcolumnchooserdialog.a \
utility_widgets/db_adddel/libutility_widgets_db_adddel.a \
+ utility_widgets/calendar/libutility_widgets_calendar.a \
utility_widgets/canvas/libutility_widgets_canvas.a \
utility_widgets/cellrendererlist/libutility_widgets_cellrendererlist.a \
utility_widgets/eggtoolpalette/libeggtoolpalette.la \
Modified: trunk/glom/combobox_fields.cc
==============================================================================
--- trunk/glom/combobox_fields.cc (original)
+++ trunk/glom/combobox_fields.cc Mon Apr 21 11:15:51 2008
@@ -113,6 +113,9 @@
const Document_Glom::type_vecFields fields = document->get_table_fields(parent_table_name);
+ if(!m_model)
+ return;
+
m_model->clear();
//Fill the model:
@@ -127,8 +130,40 @@
}
}
+void ComboBox_Fields::set_fields(Document_Glom* document, const Glib::ustring parent_table_name, Field::glom_field_type field_type)
+{
+ if(!document)
+ return;
+
+ const Document_Glom::type_vecFields fields = document->get_table_fields(parent_table_name);
+
+ if(!m_model)
+ return;
+
+ m_model->clear();
+
+ //Fill the model:
+ for(type_vecFields::const_iterator iter = fields.begin(); iter != fields.end(); ++iter)
+ {
+ sharedptr<Field> rel = *iter;
+ if(rel && (rel->get_glom_type() == field_type))
+ {
+ std::cout << "DEBUG: ComboBox_Fields::set_fields() 1" << std::endl;
+ Gtk::TreeModel::iterator tree_iter = m_model->append();
+ std::cout << "DEBUG: ComboBox_Fields::set_fields() 2" << std::endl;
+ Gtk::TreeModel::Row row = *tree_iter;
+
+ row[m_model_columns.m_field] = rel;
+ row[m_model_columns.m_separator] = false;
+ }
+ }
+}
+
void ComboBox_Fields::set_fields(const type_vecFields& fields, bool with_none_item)
{
+ if(!m_model)
+ return;
+
m_model->clear();
if(with_none_item)
Modified: trunk/glom/combobox_fields.h
==============================================================================
--- trunk/glom/combobox_fields.h (original)
+++ trunk/glom/combobox_fields.h Mon Apr 21 11:15:51 2008
@@ -39,9 +39,26 @@
virtual ~ComboBox_Fields();
typedef std::vector< sharedptr<Field> > type_vecFields;
+
+ /** Fill the combo box with fields.
+ * @param fields The fields to show in the combo box.
+ * @param with_none_type Whether to show an extra None item.
+ */
void set_fields(const type_vecFields& fields, bool with_none_item = false);
+ /** Fill the combo box with fields.
+ * @param document The Document, used to get the list of fields.
+ * @param parent_table_name The table whose fields should be shown.
+ * @param field_type Show only fields of this type.
+ */
void set_fields(Document_Glom* document, const Glib::ustring parent_table_name);
+
+ /** Fill the combo box with fields, but only fields of a certain type.
+ * @param document The Document, used to get the list of fields.
+ * @param parent_table_name The table whose fields should be shown.
+ * @param field_type Show only fields of this type.
+ */
+ void set_fields(Document_Glom* document, const Glib::ustring parent_table_name, Field::glom_field_type field_type);
void set_selected_field(const sharedptr<const Field>& field);
void set_selected_field(const Glib::ustring& field_name);
Modified: trunk/glom/glom_developer.glade
==============================================================================
--- trunk/glom/glom_developer.glade (original)
+++ trunk/glom/glom_developer.glade Mon Apr 21 11:15:51 2008
@@ -8580,6 +8580,56 @@
<property name="position">5</property>
</packing>
</child>
+ <child>
+ <widget class="GtkButton" id="button_add_related_calendar">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="tooltip" translatable="yes">Add a related records calendar portal. This is a calendar showing records from a related table. Remember to edit this layout item to specify the relationship to use, and the fields to show from the related table.</property>
+ <property name="response_id">0</property>
+ <child>
+ <widget class="GtkAlignment" id="alignment22">
+ <property name="visible">True</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <child>
+ <widget class="GtkHBox" id="hbox29">
+ <property name="visible">True</property>
+ <property name="spacing">2</property>
+ <child>
+ <widget class="GtkImage" id="image19">
+ <property name="visible">True</property>
+ <property name="stock">gtk-add</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label74">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Add Related Calendar</property>
+ <property name="use_underline">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
<child>
<widget class="GtkButton" id="button_add_related">
<property name="visible">True</property>
@@ -9038,6 +9088,60 @@
<property name="position">2</property>
</packing>
</child>
+ <child>
+ <widget class="GtkFrame" id="frame_calendar">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">GTK_SHADOW_NONE</property>
+ <child>
+ <widget class="GtkAlignment" id="alignment25">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <widget class="GtkHBox" id="hbox44">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkLabel" id="label26">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Date Field</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkComboBox" id="combobox_date_field">
+ <property name="visible">True</property>
+ <property name="tooltip" translatable="yes">This field will be used to decide which records to show in the calendar.</property>
+ <!-- <property name="row_span_column">1</property> -->
+ <!-- <property name="active">1</property> -->
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="frame_navigation1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Dates</b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="type">label_item</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox7">
<property name="visible">True</property>
Modified: trunk/glom/libglom/data_structure/layout/Makefile.am
==============================================================================
--- trunk/glom/libglom/data_structure/layout/Makefile.am (original)
+++ trunk/glom/libglom/data_structure/layout/Makefile.am Mon Apr 21 11:15:51 2008
@@ -7,6 +7,7 @@
layoutgroup.h layoutgroup.cc \
layoutitem_field.h layoutitem_field.cc \
layoutitem_portal.h layoutitem_portal.cc \
+ layoutitem_calendarportal.h layoutitem_calendarportal.cc \
layoutitem_notebook.h layoutitem_notebook.cc \
layoutitem_button.h layoutitem_button.cc \
layoutitem_text.h layoutitem_text.cc \
Modified: trunk/glom/libglom/document/document_glom.cc
==============================================================================
--- trunk/glom/libglom/document/document_glom.cc (original)
+++ trunk/glom/libglom/document/document_glom.cc Mon Apr 21 11:15:51 2008
@@ -29,6 +29,7 @@
#include <glom/libglom/data_structure/layout/layoutitem_button.h>
#include <glom/libglom/data_structure/layout/layoutitem_text.h>
#include <glom/libglom/data_structure/layout/layoutitem_image.h>
+#include <glom/libglom/data_structure/layout/layoutitem_calendarportal.h>
#include <glom/libglom/data_structure/layout/layoutitem_line.h>
#include <glom/libglom/standard_table_prefs_fields.h>
#include <giomm.h>
@@ -67,6 +68,8 @@
#define GLOM_NODE_DATA_LAYOUT_PORTAL "data_layout_portal"
#define GLOM_NODE_DATA_LAYOUT_PORTAL_NAVIGATIONRELATIONSHIP "portal_navigation_relationship"
#define GLOM_ATTRIBUTE_PORTAL_NAVIGATIONRELATIONSHIP_MAIN "navigation_main"
+#define GLOM_NODE_DATA_LAYOUT_CALENDAR_PORTAL "data_layout_calendar_portal"
+#define GLOM_ATTRIBUTE_PORTAL_CALENDAR_DATE_FIELD "date_field"
#define GLOM_NODE_DATA_LAYOUT_ITEM "data_layout_item" //A field.
#define GLOM_NODE_LAYOUT_ITEM_CUSTOM_TITLE "title_custom"
#define GLOM_ATTRIBUTE_LAYOUT_ITEM_CUSTOM_TITLE_USE "use_custom"
@@ -2044,9 +2047,18 @@
load_after_layout_group(element, table_name, notebook, with_print_layout_positions);
item_added = notebook;
}
- else if(element->get_name() == GLOM_NODE_DATA_LAYOUT_PORTAL)
+ else if( (element->get_name() == GLOM_NODE_DATA_LAYOUT_PORTAL) || (element->get_name() == GLOM_NODE_DATA_LAYOUT_CALENDAR_PORTAL) )
{
- sharedptr<LayoutItem_Portal> portal = sharedptr<LayoutItem_Portal>::create();
+ sharedptr<LayoutItem_Portal> portal;
+ sharedptr<LayoutItem_CalendarPortal> calendar_portal;
+
+ if(element->get_name() == GLOM_NODE_DATA_LAYOUT_PORTAL)
+ portal = sharedptr<LayoutItem_Portal>::create();
+ else if(element->get_name() == GLOM_NODE_DATA_LAYOUT_CALENDAR_PORTAL)
+ {
+ calendar_portal = sharedptr<LayoutItem_CalendarPortal>::create();
+ portal = calendar_portal;
+ }
load_after_layout_item_usesrelationship(element, table_name, portal);
@@ -2071,6 +2083,15 @@
portal->set_navigation_relationship_specific(relationship_navigation_specific_main, relationship_navigation_specific);
load_after_layout_group(element, portal->get_table_used(table_name), portal, with_print_layout_positions);
+
+ //Get the calendar portal's date field:
+ if(calendar_portal)
+ {
+ const Glib::ustring date_field_name = get_node_attribute_value(element, GLOM_ATTRIBUTE_PORTAL_CALENDAR_DATE_FIELD);
+ sharedptr<Field> date_field = get_field(calendar_portal->get_table_used(table_name), date_field_name);
+ calendar_portal->set_date_field(date_field);
+ }
+
item_added = portal;
}
else if(element->get_name() == GLOM_NODE_DATA_LAYOUT_ITEM_GROUPBY)
@@ -2837,7 +2858,17 @@
sharedptr<const LayoutItem_Portal> portal = sharedptr<const LayoutItem_Portal>::cast_dynamic(group);
if(portal) //If it is a related records portal
{
- child = node->add_child(GLOM_NODE_DATA_LAYOUT_PORTAL);
+ sharedptr<const LayoutItem_CalendarPortal> calendar_portal = sharedptr<const LayoutItem_CalendarPortal>::cast_dynamic(portal);
+ if(calendar_portal)
+ {
+ child = node->add_child(GLOM_NODE_DATA_LAYOUT_CALENDAR_PORTAL);
+ sharedptr<const Field> date_field = calendar_portal->get_date_field();
+ if(date_field)
+ set_node_attribute_value(child, GLOM_ATTRIBUTE_PORTAL_CALENDAR_DATE_FIELD, date_field->get_name());
+ }
+ else
+ child = node->add_child(GLOM_NODE_DATA_LAYOUT_PORTAL);
+
save_before_layout_item_usesrelationship(child, portal);
//Portal navigation details:
Modified: trunk/glom/mode_data/Makefile.am
==============================================================================
--- trunk/glom/mode_data/Makefile.am (original)
+++ trunk/glom/mode_data/Makefile.am Mon Apr 21 11:15:51 2008
@@ -11,6 +11,7 @@
box_data_details.cc box_data_details.h \
box_data_list_related.cc box_data_list_related.h \
box_data_list.cc box_data_list.h \
+ box_data_calendar_related.cc box_data_calendar_related.h \
notebook_data.cc notebook_data.h \
dialog_layout.cc dialog_layout.h \
dialog_choose_field.cc dialog_choose_field.h \
@@ -21,6 +22,7 @@
if !GLOM_ENABLE_CLIENT_ONLY
libmode_data_a_SOURCES += dialog_layout_list.cc dialog_layout_list.h \
dialog_layout_details.cc dialog_layout_details.h \
+ dialog_layout_calendar_related.cc dialog_layout_calendar_related.h \
dialog_layout_list_related.cc dialog_layout_list_related.h \
treestore_layout.cc treestore_layout.h
endif
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 Mon Apr 21 11:15:51 2008
@@ -18,8 +18,9 @@
* Boston, MA 02111-1307, USA.
*/
-#include "box_data_list_related.h"
-#include "dialog_layout_list_related.h"
+#include "box_data_calendar_related.h"
+#include "dialog_layout_calendar_related.h"
+#include <glom/application.h>
#include <glom/libglom/data_structure/glomconversions.h>
#include <glom/frame_glom.h> //For show_ok_dialog()
#include <bakery/App/App_Gtk.h> //For util_bold_message().
@@ -28,7 +29,8 @@
namespace Glom
{
-Box_Data_List_Related::Box_Data_List_Related()
+Box_Data_Calendar_Related::Box_Data_Calendar_Related()
+: m_pMenuPopup(0)
{
set_size_request(400, -1); //An arbitrary default.
@@ -44,21 +46,28 @@
m_Alignment.set_padding(Utils::DEFAULT_SPACING_SMALL /* top */, 0, Utils::DEFAULT_SPACING_LARGE /* left */, 0);
m_Alignment.show();
- remove(m_AddDel);
- m_Alignment.add(m_AddDel);
- m_AddDel.show();
+ remove(m_AddDel); //TODO: Don't even have this at all.
+ m_Alignment.add(m_calendar);
+ m_calendar.show();
add(m_Frame);
+
+ //Tell the calendar how to get the record details to show:
+ m_calendar.set_detail_func( sigc::mem_fun(*this, &Box_Data_Calendar_Related::on_calendar_details) );
+
+ setup_menu();
+ //m_calendar.add_events(Gdk::BUTTON_PRESS_MASK); //Allow us to catch button_press_event and button_release_event
+ m_calendar.signal_button_press_event().connect_notify( sigc::mem_fun(*this, &Box_Data_Calendar_Related::on_calendar_button_press_event) );
- m_layout_name = "list_related"; //TODO: We need a unique name when 2 portals use the same table.
+ m_layout_name = "list_related_calendar"; //TODO: We need a unique name when 2 portals use the same table.
}
-void Box_Data_List_Related::enable_buttons()
+void Box_Data_Calendar_Related::enable_buttons()
{
- const bool view_details_possible = get_has_suitable_record_to_view_details();
- m_AddDel.set_allow_view_details(view_details_possible); //Don't allow the user to go to a record in a hidden table.
+ //const bool view_details_possible = get_has_suitable_record_to_view_details();
+ //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_List_Related::init_db_details(const sharedptr<const LayoutItem_Portal>& portal, bool show_title)
+bool Box_Data_Calendar_Related::init_db_details(const sharedptr<const LayoutItem_CalendarPortal>& portal, bool show_title)
{
m_portal = glom_sharedptr_clone(portal);
@@ -91,7 +100,7 @@
return Box_Data_List::init_db_details(found_set); //Calls create_layout() and fill_from_database().
}
-bool Box_Data_List_Related::refresh_data_from_database_with_foreign_key(const Gnome::Gda::Value& foreign_key_value)
+bool Box_Data_Calendar_Related::refresh_data_from_database_with_foreign_key(const Gnome::Gda::Value& foreign_key_value)
{
m_key_value = foreign_key_value;
@@ -135,14 +144,13 @@
found_set.m_where_clause = "\"" + where_clause_to_table_name + "\".\"" + relationship->get_to_field() + "\" = " + where_clause_to_key_field->sql(m_key_value);
-
- //g_warning("refresh_data_from_database(): where_clause=%s", where_clause.c_str());
- return Box_Data_List::refresh_data_from_database_with_where_clause(found_set);
+ m_found_set = found_set;
+ return true;
}
else
{
//If there is no from key value then no records can be shown:
- refresh_data_from_database_blank();
+ //TODO
return true;
}
}
@@ -151,11 +159,13 @@
//If there is no to field then this relationship specifies all records in the table.
FoundSet found_set = m_found_set;
found_set.m_where_clause = Glib::ustring();
- return Box_Data_List::refresh_data_from_database_with_where_clause(found_set);
+ return true;
}
+
+ //The actual data is retrieved in the detail_func handler.
}
-bool Box_Data_List_Related::fill_from_database()
+bool Box_Data_Calendar_Related::fill_from_database()
{
bool result = false;
bool allow_add = true;
@@ -192,12 +202,12 @@
if(allow_add && m_portal->get_relationship())
allow_add = m_portal->get_relationship()->get_auto_create();
- m_AddDel.set_allow_add(allow_add);
+ //TODO: m_calendar.set_allow_add(allow_add);
return result;
}
-void Box_Data_List_Related::on_record_added(const Gnome::Gda::Value& primary_key_value, const Gtk::TreeModel::iterator& row)
+void Box_Data_Calendar_Related::on_record_added(const Gnome::Gda::Value& primary_key_value, const Gtk::TreeModel::iterator& row)
{
//primary_key_value is a new autogenerated or human-entered key for the row.
//It has already been added to the database.
@@ -212,7 +222,7 @@
//m_key_field is the field in this table that must match another field in the parent table.
sharedptr<LayoutItem_Field> layout_item = sharedptr<LayoutItem_Field>::create();
layout_item->set_full_field_details(m_key_field);
- key_value = m_AddDel.get_value(row, layout_item);
+ //TODO: key_value = m_calendar.get_value(row, layout_item);
}
Box_Data_List::on_record_added(key_value, row); //adds blank row.
@@ -227,11 +237,11 @@
}
else if(Conversions::value_is_empty(m_key_value))
{
- g_warning("Box_Data_List_Related::on_record_added(): m_key_value is NULL.");
+ g_warning("Box_Data_Calendar_Related::on_record_added(): m_key_value is NULL.");
}
else
{
- sharedptr<Field> field_primary_key = m_AddDel.get_key_field();
+ sharedptr<Field> field_primary_key; //TODO: = m_calendar.get_key_field();
//Create the link by setting the foreign key
if(m_key_field)
@@ -246,7 +256,7 @@
sharedptr<LayoutItem_Field> layout_item = sharedptr<LayoutItem_Field>::create();
layout_item->set_full_field_details(field_primary_key);
- m_AddDel.set_value(row, layout_item, m_key_value);
+ //TODO: m_calendar.set_value(row, layout_item, m_key_value);
}
}
@@ -254,28 +264,28 @@
}
}
-sharedptr<LayoutItem_Portal> Box_Data_List_Related::get_portal() const
+sharedptr<LayoutItem_CalendarPortal> Box_Data_Calendar_Related::get_portal() const
{
return m_portal;
}
-sharedptr<const Field> Box_Data_List_Related::get_key_field() const
+sharedptr<const Field> Box_Data_Calendar_Related::get_key_field() const
{
return m_key_field;
}
-void Box_Data_List_Related::on_record_deleted(const Gnome::Gda::Value& /* primary_key_value */)
+void Box_Data_Calendar_Related::on_record_deleted(const Gnome::Gda::Value& /* primary_key_value */)
{
//Allow the parent record (Details view) to recalculate aggregations:
signal_record_changed().emit(m_portal->get_relationship_name());
}
-void Box_Data_List_Related::on_adddel_user_changed(const Gtk::TreeModel::iterator& row, guint col)
+void Box_Data_Calendar_Related::on_adddel_user_changed(const Gtk::TreeModel::iterator& row, guint col)
{
if(!(m_portal->get_relationship_used_allows_edit()))
{
- std::cerr << "Box_Data_List_Related::on_adddel_user_added() called on non-editable portal. This should not happen." << std::endl;
+ std::cerr << "Box_Data_Calendar_Related::on_adddel_user_added() called on non-editable portal. This should not happen." << std::endl;
return;
}
@@ -287,11 +297,11 @@
signal_record_changed().emit(m_portal->get_relationship_name());
}
-void Box_Data_List_Related::on_adddel_user_added(const Gtk::TreeModel::iterator& row, guint col_with_first_value)
+void Box_Data_Calendar_Related::on_adddel_user_added(const Gtk::TreeModel::iterator& row, guint col_with_first_value)
{
if(!m_portal->get_relationship_used_allows_edit())
{
- std::cerr << "Box_Data_List_Related::on_adddel_user_added() called on non-editable portal. This should not happen." << std::endl;
+ std::cerr << "Box_Data_Calendar_Related::on_adddel_user_added() called on non-editable portal. This should not happen." << std::endl;
return;
}
@@ -303,8 +313,8 @@
if(m_key_field && (m_key_field->get_unique_key() || m_key_field->get_primary_key()))
{
- if(m_AddDel.get_count() > 0) //If there is already 1 record
- bAllowAdd = false;
+ //TODO: if(m_calendar.get_count() > 0) //If there is already 1 record
+ // bAllowAdd = false;
}
if(bAllowAdd)
@@ -324,7 +334,7 @@
}
}
-Box_Data_List_Related::type_vecLayoutFields Box_Data_List_Related::get_fields_to_show() const
+Box_Data_Calendar_Related::type_vecLayoutFields Box_Data_Calendar_Related::get_fields_to_show() const
{
const Document_Glom* document = get_document();
if(document)
@@ -355,15 +365,15 @@
return type_vecLayoutFields();
}
-Box_Data_List_Related::type_signal_record_changed Box_Data_List_Related::signal_record_changed()
+Box_Data_Calendar_Related::type_signal_record_changed Box_Data_Calendar_Related::signal_record_changed()
{
return m_signal_record_changed;
}
#ifndef GLOM_ENABLE_CLIENT_ONLY
-void Box_Data_List_Related::on_dialog_layout_hide()
+void Box_Data_Calendar_Related::on_dialog_layout_hide()
{
- Dialog_Layout_List_Related* dialog_related = dynamic_cast<Dialog_Layout_List_Related*>(m_pDialogLayout);
+ Dialog_Layout_Calendar_Related* dialog_related = dynamic_cast<Dialog_Layout_Calendar_Related*>(m_pDialogLayout);
g_assert(dialog_related != NULL);
m_portal = dialog_related->get_portal_layout();
@@ -373,7 +383,7 @@
Box_Data::on_dialog_layout_hide();
- sharedptr<LayoutItem_Portal> pLayoutItem = sharedptr<LayoutItem_Portal>::cast_dynamic(get_layout_item());
+ sharedptr<LayoutItem_CalendarPortal> pLayoutItem = sharedptr<LayoutItem_CalendarPortal>::cast_dynamic(get_layout_item());
if(pLayoutItem)
{
*pLayoutItem = *m_portal;
@@ -382,7 +392,7 @@
}
#endif // !GLOM_ENABLE_CLIENT_ONLY
-void Box_Data_List_Related::on_adddel_user_requested_add()
+void Box_Data_Calendar_Related::on_adddel_user_requested_add()
{
//Prevent an add on a portal with no fields:
//TODO: Warn the user instead of just doing nothing.
@@ -393,7 +403,7 @@
-bool Box_Data_List_Related::get_has_suitable_record_to_view_details() const
+bool Box_Data_Calendar_Related::get_has_suitable_record_to_view_details() const
{
Glib::ustring navigation_table_name;
sharedptr<const UsesRelationship> navigation_relationship;
@@ -402,7 +412,7 @@
return !(navigation_table_name.empty());
}
-void Box_Data_List_Related::get_suitable_table_to_view_details(Glib::ustring& table_name, sharedptr<const UsesRelationship>& relationship) const
+void Box_Data_Calendar_Related::get_suitable_table_to_view_details(Glib::ustring& table_name, sharedptr<const UsesRelationship>& relationship) const
{
//Initialize output parameters:
@@ -442,13 +452,13 @@
if(navigation_table_name.empty())
{
- std::cerr << "Box_Data_List_Related::get_suitable_table_to_view_details(): navigation_table_name is empty." << std::endl;
+ std::cerr << "Box_Data_Calendar_Related::get_suitable_table_to_view_details(): navigation_table_name is empty." << std::endl;
return;
}
if(document->get_table_is_hidden(navigation_table_name))
{
- std::cerr << "Box_Data_List_Related::get_suitable_table_to_view_details(): navigation_table_name indicates a hidden table: " << navigation_table_name << std::endl;
+ std::cerr << "Box_Data_Calendar_Related::get_suitable_table_to_view_details(): navigation_table_name indicates a hidden table: " << navigation_table_name << std::endl;
return;
}
@@ -456,7 +466,7 @@
relationship = navigation_relationship;
}
-void Box_Data_List_Related::get_suitable_record_to_view_details(const Gnome::Gda::Value& primary_key_value, Glib::ustring& table_name, Gnome::Gda::Value& table_primary_key_value) const
+void Box_Data_Calendar_Related::get_suitable_record_to_view_details(const Gnome::Gda::Value& primary_key_value, Glib::ustring& table_name, Gnome::Gda::Value& table_primary_key_value) const
{
//Initialize output parameters:
table_name = Glib::ustring();
@@ -487,7 +497,7 @@
type_vecLayoutFields fieldsToGet;
fieldsToGet.push_back(layout_item);
- const Glib::ustring query = Utils::build_sql_select_with_key(m_portal->get_table_used(Glib::ustring() /* not relevant */), fieldsToGet, m_AddDel.get_key_field(), primary_key_value);
+ const Glib::ustring query; //TODO: = Utils::build_sql_select_with_key(m_portal->get_table_used(Glib::ustring() /* not relevant */), fieldsToGet, m_calendar.get_key_field(), primary_key_value);
Glib::RefPtr<Gnome::Gda::DataModel> data_model = query_execute(query);
@@ -498,20 +508,20 @@
table_name = navigation_table_name;
table_primary_key_value = data_model->get_value_at(0, 0);
- //std::cout << "Box_Data_List_Related::get_suitable_record_to_view_details(): table_primary_key_value=" << table_primary_key_value.to_string() << std::endl;
+ //std::cout << "Box_Data_Calendar_Related::get_suitable_record_to_view_details(): table_primary_key_value=" << table_primary_key_value.to_string() << std::endl;
//The value is empty when there there is no record to match the key in the related table:
//For instance, if an invoice lines record mentions a product id, but the product does not exist in the products table.
if(Conversions::value_is_empty(table_primary_key_value))
{
value_found = false;
- std::cout << "debug: Box_Data_List_Related::get_suitable_record_to_view_details(): SQL query returned empty primary key." << std::endl;
+ std::cout << "debug: Box_Data_Calendar_Related::get_suitable_record_to_view_details(): SQL query returned empty primary key." << std::endl;
}
}
else
{
value_found = false;
- std::cout << "debug: Box_Data_List_Related::get_suitable_record_to_view_details(): SQL query returned no suitable primary key." << std::endl;
+ std::cout << "debug: Box_Data_Calendar_Related::get_suitable_record_to_view_details(): SQL query returned no suitable primary key." << std::endl;
}
if(!value_found)
@@ -526,7 +536,7 @@
}
}
-Document_Glom::type_list_layout_groups Box_Data_List_Related::create_layout_get_layout()
+Document_Glom::type_list_layout_groups Box_Data_Calendar_Related::create_layout_get_layout()
{
Document_Glom::type_list_layout_groups result;
@@ -536,27 +546,202 @@
return result;
}
-Dialog_Layout* Box_Data_List_Related::create_layout_dialog() const
+Dialog_Layout* Box_Data_Calendar_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;
+ Dialog_Layout_Calendar_Related* dialog = 0;
refXml->get_widget_derived("window_data_layout", dialog);
return dialog;
- }
}
-
- return NULL;
#endif // !GLOM_ENABLE_CLIENT_ONLY
+
+ return NULL;
}
-void prepare_layout_dialog(Dialog_Layout* dialog)
+void Box_Data_Calendar_Related::prepare_layout_dialog(Dialog_Layout* dialog)
{
- Dialog_Layout_List_Related* related_dialog = dynamic_cast<Dialog_Layout_List_Related*>(dialog);
+ Dialog_Layout_Calendar_Related* related_dialog = dynamic_cast<Dialog_Layout_Calendar_Related*>(dialog);
g_assert(related_dialog != NULL);
related_dialog->set_document(m_layout_name, get_document(), m_portal);
}
+Glib::ustring Box_Data_Calendar_Related::on_calendar_details(guint year, guint month, guint day)
+{
+ Glib::Date date(day, Glib::Date::Month(month+1), year);
+ Gnome::Gda::Value value(date);
+
+ const Glib::ustring sql_query = Utils::build_sql_select_with_where_clause(m_found_set.m_table_name, m_FieldsShown, m_found_set.m_where_clause, m_found_set.m_extra_join, m_found_set.m_sort_clause, m_found_set.m_extra_group_by);
+ Glib::RefPtr<Gnome::Gda::DataModel> datamodel = query_execute(sql_query, get_app_window());
+ if(!(datamodel && datamodel->get_n_rows()))
+ return Glib::ustring();
+
+ Glib::ustring result;
+ const int row_index = 0;
+ int column_index = 0;
+ for(type_vecLayoutFields::const_iterator iter = m_FieldsShown.begin(); iter != m_FieldsShown.end(); ++iter)
+ {
+ sharedptr<LayoutItem> layout_item = *iter;
+
+ Glib::ustring text;
+
+ //Text for a text item:
+ sharedptr<LayoutItem_Text> layout_item_text = sharedptr<LayoutItem_Text>::cast_dynamic(layout_item);
+ if(layout_item_text)
+ text = layout_item_text->get_text();
+ else
+ {
+ //Text for a field:
+ sharedptr<LayoutItem_Field> layout_item_field = sharedptr<LayoutItem_Field>::cast_dynamic(layout_item);
+ if(layout_item_field)
+ {
+ const Gnome::Gda::Value value = datamodel->get_value_at(row_index, column_index);
+ text = Conversions::get_text_for_gda_value(layout_item_field->get_glom_type(), value, layout_item_field->get_formatting_used().m_numeric_format);
+
+ ++column_index;
+ }
+ }
+
+ if(!text.empty())
+ {
+ if(!result.empty())
+ result += ", "; //TODO: Internationalization?
+
+ result += text;
+ }
+ }
+
+ return result;
+}
+
+void Box_Data_Calendar_Related::setup_menu()
+{
+ m_refActionGroup = Gtk::ActionGroup::create();
+
+ m_refActionGroup->add(Gtk::Action::create("ContextMenu", "Context Menu") );
+
+ m_refContextEdit = Gtk::Action::create("ContextEdit", Gtk::Stock::EDIT);
+
+ m_refActionGroup->add(m_refContextEdit,
+ sigc::mem_fun(*this, &Box_Data_Calendar_Related::on_MenuPopup_activate_Edit) );
+
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+ // Don't add ContextLayout in client only mode because it would never
+ // be sensitive anyway
+ m_refContextLayout = Gtk::Action::create("ContextLayout", _("Layout"));
+ m_refActionGroup->add(m_refContextLayout,
+ sigc::mem_fun(*this, &Box_Data_Calendar_Related::on_MenuPopup_activate_layout) );
+
+ //TODO: This does not work until this widget is in a container in the window:
+ App_Glom* pApp = get_application();
+ if(pApp)
+ {
+ pApp->add_developer_action(m_refContextLayout); //So that it can be disabled when not in developer mode.
+ pApp->update_userlevel_ui(); //Update our action's sensitivity.
+ }
+#endif // !GLOM_ENABLE_CLIENT_ONLY
+
+ m_refUIManager = Gtk::UIManager::create();
+
+ m_refUIManager->insert_action_group(m_refActionGroup);
+
+ //TODO: add_accel_group(m_refUIManager->get_accel_group());
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try
+ {
+#endif
+ Glib::ustring ui_info =
+ "<ui>"
+ " <popup name='ContextMenu'>"
+ " <menuitem action='ContextEdit'/>"
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+ " <menuitem action='ContextLayout'/>"
+#endif
+ " </popup>"
+ "</ui>";
+
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
+ m_refUIManager->add_ui_from_string(ui_info);
+ }
+ catch(const Glib::Error& ex)
+ {
+ std::cerr << "building menus failed: " << ex.what();
+ }
+#else
+ std::auto_ptr<Glib::Error> error;
+ m_refUIManager->add_ui_from_string(ui_info, error);
+ if(error.get() != NULL)
+ {
+ std::cerr << "building menus failed: " << error->what();
+ }
+#endif //GLIBMM_EXCEPTIONS_ENABLED
+
+ //Get the menu:
+ m_pMenuPopup = dynamic_cast<Gtk::Menu*>( m_refUIManager->get_widget("/ContextMenu") );
+ if(!m_pMenuPopup)
+ g_warning("menu not found");
+
+
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+ if(pApp)
+ m_refContextLayout->set_sensitive(pApp->get_userlevel() == AppState::USERLEVEL_DEVELOPER);
+#endif // !GLOM_ENABLE_CLIENT_ONLY
+}
+
+void Box_Data_Calendar_Related::on_calendar_button_press_event(GdkEventButton *event)
+{
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+ //Enable/Disable items.
+ //We did this earlier, but get_application is more likely to work now:
+ App_Glom* pApp = get_application();
+ if(pApp)
+ {
+ pApp->add_developer_action(m_refContextLayout); //So that it can be disabled when not in developer mode.
+ pApp->update_userlevel_ui(); //Update our action's sensitivity.
+ }
+#endif
+
+ GdkModifierType mods;
+ gdk_window_get_pointer( Gtk::Widget::gobj()->window, 0, 0, &mods );
+ if(mods & GDK_BUTTON3_MASK)
+ {
+ //Give user choices of actions on this item:
+ m_pMenuPopup->popup(event->button, event->time);
+ return; //handled.
+ }
+ else
+ {
+ if(event->type == GDK_2BUTTON_PRESS)
+ {
+ //Double-click means edit.
+ //Don't do this usually, because users sometimes double-click by accident when they just want to edit a cell.
+
+ //TODO: If the cell is not editable, handle the double-click as an edit/selection.
+ //on_MenuPopup_activate_Edit();
+ return; //Not handled.
+ }
+ }
+
+ return; //Not handled. TODO: Call base class?
+}
+
+void
+Box_Data_Calendar_Related::on_MenuPopup_activate_Edit()
+{
+ const Gnome::Gda::Value primary_key_value; //TODO: = m_AddDel.get_value_key(row); //The primary key is in the key.
+
+ signal_user_requested_details().emit(primary_key_value);
+}
+
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+void Box_Data_Calendar_Related::on_MenuPopup_activate_layout()
+{
+ show_layout_dialog();
+}
+#endif // !GLOM_ENABLE_CLIENT_ONLY
+
+
} //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 Mon Apr 21 11:15:51 2008
@@ -18,30 +18,32 @@
* Boston, MA 02111-1307, USA.
*/
-#ifndef BOX_DATA_LIST_RELATED_H
-#define BOX_DATA_LIST_RELATED_H
+#ifndef BOX_DATA_CALENDAR_RELATED_H
+#define BOX_DATA_CALENDAR_RELATED_H
#include "config.h" // GLOM_ENABLE_CLIENT_ONLY
#include "box_data_list.h"
+#include <glom/libglom/data_structure/layout/layoutitem_calendarportal.h>
#include "../utility_widgets/layoutwidgetbase.h"
+#include "../utility_widgets/calendar/glomcalendar.h"
namespace Glom
{
-class Dialog_Layout_List_Related;
+class Dialog_Layout_Calendar_Related;
-class Box_Data_List_Related :
+class Box_Data_Calendar_Related :
public Box_Data_List,
public LayoutWidgetBase
{
public:
- Box_Data_List_Related();
+ Box_Data_Calendar_Related();
/**
* @param portal: The full portal details
*/
- virtual bool init_db_details(const sharedptr<const LayoutItem_Portal>& portal, bool show_title = true);
+ virtual bool init_db_details(const sharedptr<const LayoutItem_CalendarPortal>& portal, bool show_title = true);
/**
* @param foreign_key_value: The value that should be found in this table.
@@ -49,7 +51,7 @@
*/
virtual bool refresh_data_from_database_with_foreign_key(const Gnome::Gda::Value& foreign_key_value);
- sharedptr<LayoutItem_Portal> get_portal() const;
+ sharedptr<LayoutItem_CalendarPortal> get_portal() const;
virtual sharedptr<const Field> get_key_field() const;
sigc::signal<void, Gnome::Gda::Value> signal_record_added;
@@ -83,16 +85,40 @@
virtual void prepare_layout_dialog(Dialog_Layout* dialog); // override.
#endif // !GLOM_ENABLE_CLIENT_ONLY
+ Glib::ustring on_calendar_details(guint year, guint month, guint day);
+
+ void setup_menu();
+ void on_calendar_button_press_event(GdkEventButton *event);
+
+ void on_MenuPopup_activate_Edit();
+ void on_MenuPopup_activate_Add();
+ void on_MenuPopup_activate_Delete();
+
+ #ifndef GLOM_ENABLE_CLIENT_ONLY
+ void on_MenuPopup_activate_layout();
+ #endif
+
protected:
virtual Document_Glom::type_list_layout_groups create_layout_get_layout(); //override.
Gtk::Frame m_Frame;
Gtk::Alignment m_Alignment;
Gtk::Label m_Label;
+ GlomGtk::Calendar m_calendar;
- sharedptr<LayoutItem_Portal> m_portal;
+ sharedptr<LayoutItem_CalendarPortal> m_portal;
sharedptr<Field> m_key_field;
Gnome::Gda::Value m_key_value;
+
+ //TODO: Avoid repeating these in so many widgets:
+ Gtk::Menu* m_pMenuPopup;
+ Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup;
+ Glib::RefPtr<Gtk::UIManager> m_refUIManager;
+ Glib::RefPtr<Gtk::Action> m_refContextEdit, m_refContextAdd, m_refContextDelete;
+
+#ifndef GLOM_ENABLE_CLIENT_ONLY
+ Glib::RefPtr<Gtk::Action> m_refContextLayout;
+#endif
type_signal_record_changed m_signal_record_changed;
};
Copied: trunk/glom/mode_data/dialog_layout_calendar_related.cc (from r1576, /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_calendar_related.cc Mon Apr 21 11:15:51 2008
@@ -18,7 +18,7 @@
* Boston, MA 02111-1307, USA.
*/
-#include "dialog_layout_list_related.h"
+#include "dialog_layout_calendar_related.h"
#include "dialog_choose_field.h"
#include "../layout_item_dialogs/dialog_field_layout.h"
#include <bakery/App/App_Gtk.h> //For util_bold_message().
@@ -30,14 +30,15 @@
namespace Glom
{
-Dialog_Layout_List_Related::Dialog_Layout_List_Related(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade)
+Dialog_Layout_Calendar_Related::Dialog_Layout_Calendar_Related(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade)
: Dialog_Layout_List(cobject, refGlade),
m_combo_relationship(0),
m_checkbutton_show_child_relationships(0),
m_radio_navigation_automatic(0),
m_radio_navigation_specify(0),
m_label_navigation_automatic(0),
- m_combo_navigation_specify(0)
+ m_combo_navigation_specify(0),
+ m_combobox_date_field(0)
{
// Show the appropriate alternate widgets:
m_box_table_widgets->hide();
@@ -45,10 +46,10 @@
m_box_related_navigation->show();
refGlade->get_widget_derived("combo_relationship_name", m_combo_relationship);
- m_combo_relationship->signal_changed().connect(sigc::mem_fun(*this, &Dialog_Layout_List_Related::on_combo_relationship_changed));
+ m_combo_relationship->signal_changed().connect(sigc::mem_fun(*this, &Dialog_Layout_Calendar_Related::on_combo_relationship_changed));
refGlade->get_widget("checkbutton_show_child_relationships", m_checkbutton_show_child_relationships);
- m_checkbutton_show_child_relationships->signal_toggled().connect(sigc::mem_fun(*this, &Dialog_Layout_List_Related::on_checkbutton_show_child_relationships));
+ m_checkbutton_show_child_relationships->signal_toggled().connect(sigc::mem_fun(*this, &Dialog_Layout_Calendar_Related::on_checkbutton_show_child_relationships));
@@ -59,13 +60,22 @@
refGlade->get_widget("radiobutton_navigation_specify", m_radio_navigation_specify);
refGlade->get_widget_derived("combobox_navigation_specify", m_combo_navigation_specify);
make_sensitivity_depend_on_toggle_button(*m_radio_navigation_specify, *m_combo_navigation_specify);
- m_combo_navigation_specify->signal_changed().connect(sigc::mem_fun(*this, &Dialog_Layout_List_Related::on_combo_navigation_specific_changed));
+ m_combo_navigation_specify->signal_changed().connect(sigc::mem_fun(*this, &Dialog_Layout_Calendar_Related::on_combo_navigation_specific_changed));
-
+ refGlade->get_widget_derived("combobox_date_field", m_combobox_date_field);
+ m_combobox_date_field->signal_changed().connect(sigc::mem_fun(*this, &Dialog_Layout_Calendar_Related::on_combo_date_field_changed));
+
+
m_modified = false;
//show_all_children();
+ //The base class hid this, but we do want it here:
+ //(We share one glade definition for several dialogs.)
+ Gtk::Frame* box_calendar = 0;
+ refGlade->get_widget("frame_calendar", box_calendar);
+ box_calendar->show();
+
//This entry must be in the Glade file, because it's used by the base class,
//but we don't want it here, because it is confusing when dealing with relationships:
if(m_entry_table_title)
@@ -75,11 +85,11 @@
m_label_table_title->hide(); // We don't use this (it's from the base class).
}
-Dialog_Layout_List_Related::~Dialog_Layout_List_Related()
+Dialog_Layout_Calendar_Related::~Dialog_Layout_Calendar_Related()
{
}
-void Dialog_Layout_List_Related::set_document(const Glib::ustring& layout, Document_Glom* document, const sharedptr<const LayoutItem_Portal>& portal)
+void Dialog_Layout_Calendar_Related::set_document(const Glib::ustring& layout, Document_Glom* document, const sharedptr<const LayoutItem_CalendarPortal>& portal)
{
type_vecLayoutFields empty_fields; //Just to satisfy the base class.
Dialog_Layout::set_document(layout, document, portal->get_relationship()->get_from_table(), empty_fields);
@@ -90,7 +100,7 @@
update_ui();
}
-void Dialog_Layout_List_Related::update_ui(bool including_relationship_list)
+void Dialog_Layout_Calendar_Related::update_ui(bool including_relationship_list)
{
if(!m_portal || !(m_portal->get_relationship()))
return;
@@ -123,7 +133,7 @@
}
//Set the table name and title:
- sharedptr<LayoutItem_Portal> 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;
@@ -138,7 +148,7 @@
for(Document_Glom::type_list_layout_groups::const_iterator iter = mapGroups.begin(); iter != mapGroups.end(); ++iter)
{
sharedptr<const LayoutGroup> group = *iter;
- sharedptr<const LayoutGroup> portal = sharedptr<const LayoutItem_Portal>::cast_dynamic(group);
+ sharedptr<const LayoutGroup> portal = sharedptr<const LayoutItem_CalendarPortal>::cast_dynamic(group);
if(portal)
{
for(LayoutGroup::type_list_items::const_iterator iterInner = group->m_list_items.begin(); iterInner != group->m_list_items.end(); ++iterInner)
@@ -215,10 +225,19 @@
m_label_navigation_automatic->set_text(automatic_navigation_description);
+ sharedptr<Field> debugfield = m_portal->get_date_field();
+ if(!debugfield)
+ std::cout << "DEBUG: set_document(): date field is NULL" << std::endl;
+ else
+ std::cout << "DEBUG: set_document(): date field:" << debugfield->get_name() << std::endl;
+
+ m_combobox_date_field->set_fields(document, related_table_name, Field::TYPE_DATE);
+ m_combobox_date_field->set_selected_field(m_portal->get_date_field());
+
m_modified = false;
}
-void Dialog_Layout_List_Related::save_to_document()
+void Dialog_Layout_Calendar_Related::save_to_document()
{
Dialog_Layout::save_to_document();
@@ -267,15 +286,23 @@
sharedptr<UsesRelationship> none;
m_portal->set_navigation_relationship_specific(false, none);
}
+
+ m_portal->set_date_field( m_combobox_date_field->get_selected_field() );
+
+ sharedptr<Field> debugfield = m_portal->get_date_field();
+ if(!debugfield)
+ std::cout << "DEBUG: save_to_document(): date field is NULL" << std::endl;
+ else
+ std::cout << "DEBUG: save_to_document(): date field:" << debugfield->get_name() << std::endl;
}
}
-void Dialog_Layout_List_Related::on_checkbutton_show_child_relationships()
+void Dialog_Layout_Calendar_Related::on_checkbutton_show_child_relationships()
{
update_ui();
}
-void Dialog_Layout_List_Related::on_combo_relationship_changed()
+void Dialog_Layout_Calendar_Related::on_combo_relationship_changed()
{
if(!m_portal)
return;
@@ -305,24 +332,29 @@
}
}
-sharedptr<Relationship> Dialog_Layout_List_Related::get_relationship() const
+sharedptr<Relationship> Dialog_Layout_Calendar_Related::get_relationship() const
{
std::cout << "debug: I wonder if this function is used." << std::endl;
return m_combo_relationship->get_selected_relationship();
}
-sharedptr<LayoutItem_Portal> Dialog_Layout_List_Related::get_portal_layout()
+sharedptr<LayoutItem_CalendarPortal> Dialog_Layout_Calendar_Related::get_portal_layout()
{
return m_portal;
}
-void Dialog_Layout_List_Related::on_combo_navigation_specific_changed()
+void Dialog_Layout_Calendar_Related::on_combo_navigation_specific_changed()
+{
+ m_modified = true;
+}
+
+void Dialog_Layout_Calendar_Related::on_combo_date_field_changed()
{
m_modified = true;
}
//Overridden so we can show related fields instead of fields from the parent table:
-void Dialog_Layout_List_Related::on_button_field_add()
+void Dialog_Layout_Calendar_Related::on_button_field_add()
{
//Get the chosen field:
//std::cout << "debug: related relationship=" << glom_get_sharedptr_name(m_portal->get_related_relationship()) << std::endl;
@@ -348,7 +380,7 @@
}
}
-void Dialog_Layout_List_Related::on_button_edit()
+void Dialog_Layout_Calendar_Related::on_button_edit()
{
Glib::RefPtr<Gtk::TreeView::Selection> refTreeSelection = m_treeview_fields->get_selection();
if(refTreeSelection)
@@ -384,6 +416,5 @@
}
}
-
} //namespace Glom
Copied: trunk/glom/mode_data/dialog_layout_calendar_related.h (from r1576, /trunk/glom/mode_data/dialog_layout_list_related.h)
==============================================================================
--- /trunk/glom/mode_data/dialog_layout_list_related.h (original)
+++ trunk/glom/mode_data/dialog_layout_calendar_related.h Mon Apr 21 11:15:51 2008
@@ -22,17 +22,19 @@
#define GLOM_MODE_DATA_DIALOG_LAYOUT_LIST_RELATED_H
#include "dialog_layout_list.h"
-#include "../utility_widgets/combo_textglade.h"
-#include "../combobox_relationship.h"
+#include <glom/libglom/data_structure/layout/layoutitem_calendarportal.h>
+#include <glom/utility_widgets/combo_textglade.h>
+#include <glom/combobox_relationship.h>
+#include <glom/combobox_fields.h>
namespace Glom
{
-class Dialog_Layout_List_Related : public Dialog_Layout_List
+class Dialog_Layout_Calendar_Related : public Dialog_Layout_List
{
public:
- Dialog_Layout_List_Related(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade);
- virtual ~Dialog_Layout_List_Related();
+ Dialog_Layout_Calendar_Related(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& refGlade);
+ virtual ~Dialog_Layout_Calendar_Related();
/**
* @param layout "list" or "details"
@@ -40,11 +42,11 @@
* @param table_name The table name.
* @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_Portal>& portal);
+ virtual void set_document(const Glib::ustring& layout, Document_Glom* document, const sharedptr<const LayoutItem_CalendarPortal>& portal);
virtual void update_ui(bool including_relationships_list = true);
sharedptr<Relationship> get_relationship() const;
- sharedptr<LayoutItem_Portal> get_portal_layout();
+ sharedptr<LayoutItem_CalendarPortal> get_portal_layout();
protected:
@@ -57,17 +59,20 @@
void on_combo_relationship_changed();
void on_combo_navigation_specific_changed();
+ void on_combo_date_field_changed();
void on_checkbutton_show_child_relationships();
ComboBox_Relationship* m_combo_relationship;
Gtk::CheckButton* m_checkbutton_show_child_relationships;
- sharedptr<LayoutItem_Portal> m_portal;
+ sharedptr<LayoutItem_CalendarPortal> m_portal;
Gtk::RadioButton* m_radio_navigation_automatic;
Gtk::RadioButton* m_radio_navigation_specify;
Gtk::Label* m_label_navigation_automatic;
ComboBox_Relationship* m_combo_navigation_specify;
+
+ ComboBox_Fields* m_combobox_date_field;
};
} //namespace Glom
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 Mon Apr 21 11:15:51 2008
@@ -45,6 +45,7 @@
m_button_field_add_group(0),
m_button_add_notebook(0),
m_button_add_related(0),
+ m_button_add_related_calendar(0),
m_button_add_button(0),
m_button_add_text(0),
m_button_add_image(0),
@@ -62,6 +63,10 @@
refGlade->get_widget("frame_related_table_navigation", m_box_related_navigation);
m_box_related_navigation->hide();
+ Gtk::Frame* box_calendar = 0;
+ refGlade->get_widget("frame_calendar", box_calendar);
+ box_calendar->hide();
+
refGlade->get_widget("label_table_name", m_label_table_name);
refGlade->get_widget("treeview_fields", m_treeview_fields);
@@ -147,6 +152,9 @@
refGlade->get_widget("button_add_related", m_button_add_related);
m_button_add_related->signal_clicked().connect( sigc::mem_fun(*this, &Dialog_Layout_Details::on_button_add_related) );
+ refGlade->get_widget("button_add_related_calendar", m_button_add_related_calendar);
+ m_button_add_related_calendar->signal_clicked().connect( sigc::mem_fun(*this, &Dialog_Layout_Details::on_button_add_related_calendar) );
+
refGlade->get_widget("button_add_button", m_button_add_button);
m_button_add_button->signal_clicked().connect( sigc::mem_fun(*this, &Dialog_Layout_Details::on_button_add_button) );
@@ -782,6 +790,36 @@
enable_buttons();
}
+void Dialog_Layout_Details::on_button_add_related_calendar()
+{
+ Gtk::TreeModel::iterator parent = get_selected_group_parent();
+
+ 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);
+ row[m_model_items->m_columns.m_col_layout_item] = portal;
+
+ //Scroll to, and select, the new row:
+ Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = m_treeview_fields->get_selection();
+ if(refTreeSelection)
+ refTreeSelection->select(iter);
+
+ m_treeview_fields->scroll_to_row( Gtk::TreeModel::Path(iter) );
+
+ m_modified = true;
+ }
+ }
+
+ enable_buttons();
+}
+
Gtk::TreeModel::iterator Dialog_Layout_Details::get_selected_group_parent() const
{
//Get the selected group, or a suitable parent group, or the first group:
@@ -1076,7 +1114,11 @@
sharedptr<LayoutItem_Portal> layout_portal = sharedptr<LayoutItem_Portal>::cast_dynamic(layout_item);
if(layout_portal)
{
- markup = _("Related: ") + layout_portal->get_relationship_name();
+ sharedptr<LayoutItem_CalendarPortal> layout_calendar = sharedptr<LayoutItem_CalendarPortal>::cast_dynamic(layout_portal);
+ if(layout_calendar)
+ markup = _("Related Calendar: ") + layout_portal->get_relationship_name();
+ else
+ markup = _("Related List: ") + layout_portal->get_relationship_name();
}
else
{
Modified: trunk/glom/mode_data/dialog_layout_details.h
==============================================================================
--- trunk/glom/mode_data/dialog_layout_details.h (original)
+++ trunk/glom/mode_data/dialog_layout_details.h Mon Apr 21 11:15:51 2008
@@ -65,6 +65,7 @@
void on_button_field_add_group();
void on_button_add_notebook();
void on_button_add_related();
+ void on_button_add_related_calendar();
void on_button_add_button();
void on_button_add_text();
void on_button_add_image();
@@ -96,6 +97,7 @@
Gtk::Button* m_button_field_add_group;
Gtk::Button* m_button_add_notebook;
Gtk::Button* m_button_add_related;
+ Gtk::Button* m_button_add_related_calendar;
Gtk::Button* m_button_add_button;
Gtk::Button* m_button_add_text;
Gtk::Button* m_button_add_image;
Modified: trunk/glom/mode_data/dialog_layout_list.cc
==============================================================================
--- trunk/glom/mode_data/dialog_layout_list.cc (original)
+++ trunk/glom/mode_data/dialog_layout_list.cc Mon Apr 21 11:15:51 2008
@@ -36,6 +36,13 @@
//These do not make sense in a list:
m_button_add_notebook->hide();
m_button_add_related->hide();
+ m_button_add_related_calendar->hide();
+
+ //We don't want this part of the dialog:
+ //(We share one glade definition for several dialogs.)
+ Gtk::Frame* box_calendar = 0;
+ refGlade->get_widget("frame_calendar", box_calendar);
+ box_calendar->hide();
}
Dialog_Layout_List::~Dialog_Layout_List()
Modified: trunk/glom/mode_data/flowtablewithfields.cc
==============================================================================
--- trunk/glom/mode_data/flowtablewithfields.cc (original)
+++ trunk/glom/mode_data/flowtablewithfields.cc Mon Apr 21 11:15:51 2008
@@ -120,7 +120,11 @@
sharedptr<LayoutItem_Portal> portal = sharedptr<LayoutItem_Portal>::cast_dynamic(item);
if(portal)
{
- add_layout_related_at_position(portal, add_before);
+ sharedptr<LayoutItem_CalendarPortal> calendar_portal = sharedptr<LayoutItem_CalendarPortal>::cast_dynamic(portal);
+ if(calendar_portal)
+ add_layout_related_calendar_at_position(calendar_portal, add_before);
+ else
+ add_layout_related_at_position(portal, add_before);
}
else
{
@@ -272,6 +276,39 @@
return 0;
}
+Box_Data_Calendar_Related* FlowTableWithFields::create_related_calendar(const sharedptr<LayoutItem_CalendarPortal>& portal, bool show_title)
+{
+ if(!portal)
+ return 0;
+
+ Document_Glom* pDocument = static_cast<Document_Glom*>(get_document());
+ if(pDocument)
+ {
+ 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
+
+ portal_box->set_layout_item(portal, relationship->get_to_table());
+ portal_box->show();
+
+ m_calendar_portals.push_back(portal_box);
+
+ //Connect signals:
+ portal_box->signal_record_changed().connect( sigc::mem_fun(*this, &FlowTableWithFields::on_portal_record_changed) );
+
+ portal_box->signal_user_requested_details().connect( sigc::bind( sigc::mem_fun(*this, &FlowTableWithFields::on_calendar_portal_user_requested_details), portal_box));
+
+ return portal_box;
+ }
+ }
+
+ return 0;
+}
+
void FlowTableWithFields::add_layout_related_at_position(const sharedptr<LayoutItem_Portal>& portal, const type_list_layoutwidgets::iterator& add_before)
{
Box_Data_List_Related* portal_box = create_related(portal);
@@ -282,6 +319,16 @@
}
}
+void FlowTableWithFields::add_layout_related_calendar_at_position(const sharedptr<LayoutItem_CalendarPortal>& portal, const type_list_layoutwidgets::iterator& add_before)
+{
+ Box_Data_Calendar_Related* portal_box = create_related_calendar(portal);
+ if(portal_box)
+ {
+ add(*portal_box, true /* expand */);
+ add_layoutwidgetbase(portal_box, add_before);
+ }
+}
+
void FlowTableWithFields::add_layout_notebook_at_position(const sharedptr<LayoutItem_Notebook>& notebook, const type_list_layoutwidgets::iterator& add_before)
{
if(!notebook)
@@ -1141,6 +1188,32 @@
}
}
+void FlowTableWithFields::on_calendar_portal_user_requested_details(Gnome::Gda::Value primary_key_value, Box_Data_Calendar_Related* portal_box)
+{
+ sharedptr<const LayoutItem_CalendarPortal> portal = portal_box->get_portal();
+ if(!portal)
+ return;
+
+ const Glib::ustring related_table = portal->get_table_used(Glib::ustring() /* parent table - not relevant */);
+ if(related_table.empty())
+ return;
+
+ if(get_document()->get_table_is_hidden(related_table))
+ {
+ //Try to find a doubly-related table that is not hidden, and open that instead:
+ Glib::ustring doubly_related_table_name;
+ Gnome::Gda::Value doubly_related_primary_key;
+ portal_box->get_suitable_record_to_view_details(primary_key_value, doubly_related_table_name, doubly_related_primary_key);
+
+ if(!(doubly_related_table_name.empty()) && !Conversions::value_is_empty(doubly_related_primary_key))
+ signal_requested_related_details().emit(doubly_related_table_name, doubly_related_primary_key);
+ }
+ else
+ {
+ signal_requested_related_details().emit(related_table, primary_key_value);
+ }
+}
+
void FlowTableWithFields::on_flowtable_requested_related_details(const Glib::ustring& table_name, Gnome::Gda::Value primary_key_value)
{
//Forward it to the parent:
Modified: trunk/glom/mode_data/flowtablewithfields.h
==============================================================================
--- trunk/glom/mode_data/flowtablewithfields.h (original)
+++ trunk/glom/mode_data/flowtablewithfields.h Mon Apr 21 11:15:51 2008
@@ -32,6 +32,7 @@
#include <glom/libglom/data_structure/layout/layoutitem_field.h>
#include <glom/libglom/data_structure/layout/layoutitem_notebook.h>
#include <glom/libglom/data_structure/layout/layoutitem_portal.h>
+#include <glom/libglom/data_structure/layout/layoutitem_calendarportal.h>
#include <glom/libglom/data_structure/layout/layoutitem_button.h>
#include <glom/libglom/data_structure/layout/layoutitem_text.h>
#include <glom/libglom/data_structure/layout/layoutitem_placeholder.h>
@@ -40,6 +41,7 @@
#include <glom/utility_widgets/layoutwidgetbase.h>
#include <glom/utility_widgets/layoutwidgetutils.h>
#include "box_data_list_related.h"
+#include "box_data_calendar_related.h"
#include "treestore_layout.h" //Forthe enum.
#include <map>
#include <list>
@@ -164,6 +166,7 @@
#endif // !GLOM_ENABLE_CLIENT_ONLY
void on_portal_user_requested_details(Gnome::Gda::Value primary_key_value, Box_Data_List_Related* portal_box);
+ void on_calendar_portal_user_requested_details(Gnome::Gda::Value primary_key_value, Box_Data_Calendar_Related* portal_box);
class Info
{
@@ -188,6 +191,9 @@
typedef std::list< Box_Data_List_Related* > type_portals;
type_portals m_portals;
+ typedef std::list< Box_Data_Calendar_Related* > type_calendar_portals;
+ type_calendar_portals m_calendar_portals;
+
//Remember the sequence of LayoutWidgetBase widgets, so we can iterate over them later:
typedef std::list< LayoutWidgetBase* > type_list_layoutwidgets;
type_list_layoutwidgets m_list_layoutwidgets;
@@ -204,10 +210,11 @@
void add_layout_group_at_position(const sharedptr<LayoutGroup>& group, const type_list_layoutwidgets::iterator& add_before);
void add_layout_notebook_at_position(const sharedptr<LayoutItem_Notebook>& notebook, const type_list_layoutwidgets::iterator& add_before);
void add_layout_related_at_position(const sharedptr<LayoutItem_Portal>& portal, const type_list_layoutwidgets::iterator& add_before);
+ void add_layout_related_calendar_at_position(const sharedptr<LayoutItem_CalendarPortal>& portal, const type_list_layoutwidgets::iterator& add_before);
#ifndef GLOM_ENABLE_CLIENT_ONLY
- virtual void on_dnd_add_placeholder(LayoutWidgetBase* above);
- virtual void on_dnd_remove_placeholder();
+ virtual void on_dnd_add_placeholder(LayoutWidgetBase* above);
+ virtual void on_dnd_remove_placeholder();
// Methods for the different layout object
virtual void on_dnd_add_layout_item_field (LayoutWidgetBase* above);
@@ -227,6 +234,7 @@
sharedptr<LayoutItem_Portal> get_layout_item_from_relation();
Box_Data_List_Related* create_related(const sharedptr<LayoutItem_Portal>& portal, bool show_title = true);
+ Box_Data_Calendar_Related* create_related_calendar(const sharedptr<LayoutItem_CalendarPortal>& portal, bool show_title = true);
Gtk::Alignment* m_placeholder;
Modified: trunk/glom/utility_widgets/calendar/Makefile.am
==============================================================================
--- trunk/glom/utility_widgets/calendar/Makefile.am (original)
+++ trunk/glom/utility_widgets/calendar/Makefile.am Mon Apr 21 11:15:51 2008
@@ -2,6 +2,6 @@
AM_CPPFLAGS = -I top_srcdir@/ $(GLOM_CFLAGS)
-noinst_LIBRARIES = libutility_widgets_cellrendererlist.a
-libutility_widgets_cellrendererlist_a_SOURCES = glomgtkcalendar.c glomgtkcalendar.h \
- glomcalendar.cc glomcalendar.h
+noinst_LIBRARIES = libutility_widgets_calendar.a
+libutility_widgets_calendar_a_SOURCES = glomgtkcalendar.c glomgtkcalendar.h \
+ glomcalendar.cc glomcalendar.h
Modified: trunk/glom/utility_widgets/calendar/glomgtkcalendar.c
==============================================================================
--- trunk/glom/utility_widgets/calendar/glomgtkcalendar.c (original)
+++ trunk/glom/utility_widgets/calendar/glomgtkcalendar.c Mon Apr 21 11:15:51 2008
@@ -717,7 +717,7 @@
#endif
priv = calendar->priv = G_TYPE_INSTANCE_GET_PRIVATE (calendar,
- GTK_TYPE_CALENDAR,
+ GLOM_GTK_TYPE_CALENDAR,
GlomGtkCalendarPrivate);
GTK_WIDGET_SET_FLAGS (widget, GTK_CAN_FOCUS);
@@ -3570,7 +3570,7 @@
GtkWidget*
glom_gtk_calendar_new (void)
{
- return g_object_new (GTK_TYPE_CALENDAR, NULL);
+ return g_object_new (GLOM_GTK_TYPE_CALENDAR, NULL);
}
/**
Modified: trunk/glom/utility_widgets/db_adddel/db_adddel.h
==============================================================================
--- trunk/glom/utility_widgets/db_adddel/db_adddel.h (original)
+++ trunk/glom/utility_widgets/db_adddel/db_adddel.h Mon Apr 21 11:15:51 2008
@@ -260,6 +260,7 @@
//Signal handlers:
void treeviewcolumn_on_cell_data(Gtk::CellRenderer* renderer, const Gtk::TreeModel::iterator& iter, int model_column_index, int data_model_column_index);
+ //TODO: Remove virtuals after checking that there are no method overrides:
virtual void on_treeview_cell_edited(const Glib::ustring& path_string, const Glib::ustring& new_text, int model_column_index, int data_model_column_index);
virtual void on_treeview_cell_edited_bool(const Glib::ustring& path_string, int model_column_index, int data_model_column_index);
@@ -268,12 +269,12 @@
virtual bool on_button_press_event_Popup(GdkEventButton* event);
- virtual void on_MenuPopup_activate_Edit();
- virtual void on_MenuPopup_activate_Add();
- virtual void on_MenuPopup_activate_Delete();
+ void on_MenuPopup_activate_Edit();
+ void on_MenuPopup_activate_Add();
+ void on_MenuPopup_activate_Delete();
#ifndef GLOM_ENABLE_CLIENT_ONLY
- virtual void on_MenuPopup_activate_layout();
+ void on_MenuPopup_activate_layout();
#endif
virtual void on_treeview_button_press_event(GdkEventButton* event);
@@ -339,6 +340,7 @@
Glib::ustring m_open_button_title; //Allow us to change "Open" to "Select".
+ //TODO: Avoid repeating these in so many widgets:
Gtk::Menu* m_pMenuPopup;
Glib::RefPtr<Gtk::ActionGroup> m_refActionGroup;
Glib::RefPtr<Gtk::UIManager> m_refUIManager;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]