glom r1696 - in trunk: . glom/mode_data



Author: murrayc
Date: Tue Sep 30 14:34:58 2008
New Revision: 1696
URL: http://svn.gnome.org/viewvc/glom?rev=1696&view=rev

Log:
2008-09-30  Murray Cumming  <murrayc murrayc com>

* glom/mode_data/dialog_layout_details.cc:
* glom/mode_data/dialog_layout_details.h:
append_appropriate_row(): Make sure that this returns something even 
for related records portals, so we can add buttons, text, and images to 
them again.

Modified:
   trunk/ChangeLog
   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_details.h
   trunk/glom/mode_data/dialog_layout_list_related.cc
   trunk/glom/mode_data/dialog_layout_list_related.h

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	Tue Sep 30 14:34:58 2008
@@ -372,7 +372,7 @@
 }
 
 //Overridden so we can show related fields instead of fields from the parent table:
-void Dialog_Layout_Calendar_Related::on_button_field_add()
+void Dialog_Layout_Calendar_Related::on_button_add_field()
 {
   //Get the chosen field:
   //std::cout << "debug: related relationship=" << glom_get_sharedptr_name(m_portal->get_related_relationship()) << std::endl;

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	Tue Sep 30 14:34:58 2008
@@ -56,7 +56,7 @@
   virtual void save_to_document();
 
   //signal handlers:
-  virtual void on_button_field_add(); //override
+  virtual void on_button_add_field(); //override
   virtual void on_button_edit(); //override
  
   void on_combo_relationship_changed();

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	Tue Sep 30 14:34:58 2008
@@ -161,7 +161,7 @@
   m_button_field_formatting->signal_clicked().connect( sigc::mem_fun(*this, &Dialog_Layout_Details::on_button_field_formatting) );
 
   refGlade->get_widget("button_add_field", m_button_add_field);
-  m_button_add_field->signal_clicked().connect( sigc::mem_fun(*this, &Dialog_Layout_Details::on_button_field_add) );
+  m_button_add_field->signal_clicked().connect( sigc::mem_fun(*this, &Dialog_Layout_Details::on_button_add_field) );
 
   refGlade->get_widget("button_add_group", m_button_add_group);
   m_button_add_group->signal_clicked().connect( sigc::mem_fun(*this, &Dialog_Layout_Details::on_button_add_group) );
@@ -512,7 +512,7 @@
   enable_buttons();
 }
 
-void Dialog_Layout_Details::on_button_field_add()
+void Dialog_Layout_Details::on_button_add_field()
 {
   sharedptr<LayoutItem_Field> layout_item = offer_field_list(m_table_name, this);
   if(layout_item)
@@ -656,9 +656,10 @@
   Gtk::TreeModel::iterator parent = get_selected_group_parent();
 
   //Add the field details to the layout treeview:
-  Gtk::TreeModel::iterator iter;
   if(parent)
+  {
     result = m_model_items->append(parent->children());
+  }
   else
   {
     //Find the first group, and make the new row a child of that:
@@ -674,6 +675,12 @@
       if(layout_group && !layout_portal)
         result = m_model_items->append(iter_first->children());
     }
+
+    if(!result)
+    {
+      //For instance, for a Dialog_Layout_List_Related derived class, with a portal as the top-level group:
+      result = m_model_items->append();
+    }
   }
 
   return result;
@@ -1190,6 +1197,8 @@
                 }
                 else if(layout_item)
                   markup = layout_item->get_name();
+                else
+                  markup = Glib::ustring();
               }
             }
           }
@@ -1219,8 +1228,10 @@
       sharedptr<LayoutItem_Notebook> layout_notebook = sharedptr<LayoutItem_Notebook>::cast_dynamic(layout_item);
       if(layout_notebook)
         renderer_text->property_text() = _("(Notebook)");
-      else
+      else if(layout_item)
         renderer_text->property_text() = layout_item->get_title();
+      else
+        renderer_text->property_text() = Glib::ustring();
 
       sharedptr<LayoutGroup> layout_group = sharedptr<LayoutGroup>::cast_dynamic(layout_item);
       sharedptr<LayoutItem_Portal> layout_portal = sharedptr<LayoutItem_Portal>::cast_dynamic(layout_item);
@@ -1242,15 +1253,19 @@
     {
       Gtk::TreeModel::Row row = *iter;
       sharedptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
-     
-      sharedptr<LayoutItem_Button> layout_button = sharedptr<LayoutItem_Button>::cast_dynamic(layout_item);
-      sharedptr<LayoutItem_Text> layout_text = sharedptr<LayoutItem_Text>::cast_dynamic(layout_item);
-      sharedptr<LayoutItem_Field> layout_field = sharedptr<LayoutItem_Field>::cast_dynamic(layout_item);
-      const bool editable = (layout_field || layout_button || layout_text); //Only these have column widths that can be edited.
-      renderer_text->property_editable() = editable;
 
       guint column_width = 0;
-      layout_item->get_display_width(column_width);
+      if(layout_item)
+      {
+        sharedptr<LayoutItem_Button> layout_button = sharedptr<LayoutItem_Button>::cast_dynamic(layout_item);
+        sharedptr<LayoutItem_Text> layout_text = sharedptr<LayoutItem_Text>::cast_dynamic(layout_item);
+        sharedptr<LayoutItem_Field> layout_field = sharedptr<LayoutItem_Field>::cast_dynamic(layout_item);
+        const bool editable = (layout_field || layout_button || layout_text); //Only these have column widths that can be edited.
+        renderer_text->property_editable() = editable;
+      
+        layout_item->get_display_width(column_width);
+      }
+
       Glib::ustring text; 
       if(column_width) //Show nothing if no width has been specified, meaning that it's automatic.
         text = Utils::string_from_decimal(column_width);

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	Tue Sep 30 14:34:58 2008
@@ -61,7 +61,7 @@
   void on_button_up();
   void on_button_down();
   void on_button_field_delete();
-  virtual void on_button_field_add(); //overridden in derived class. 
+  virtual void on_button_add_field(); //overridden in derived class. 
   void on_button_add_group();
   void on_button_add_notebook();
   void on_button_add_related();

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	Tue Sep 30 14:34:58 2008
@@ -348,7 +348,7 @@
 }
 
 //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_List_Related::on_button_add_field()
 {
   //Get the chosen field:
   //std::cout << "debug: related relationship=" << glom_get_sharedptr_name(m_portal->get_related_relationship()) << std::endl;
@@ -358,7 +358,7 @@
   if(field)
   {
     //Add the field details to the layout treeview:
-    Gtk::TreeModel::iterator iter =  m_model_items->append();
+    Gtk::TreeModel::iterator iter = m_model_items->append();
     if(iter)
     {
       Gtk::TreeModel::Row row = *iter;

Modified: 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_list_related.h	Tue Sep 30 14:34:58 2008
@@ -51,7 +51,7 @@
   virtual void save_to_document();
 
   //signal handlers:
-  virtual void on_button_field_add(); //override
+  virtual void on_button_add_field(); //override
   virtual void on_button_edit(); //override
  
   void on_combo_relationship_changed();



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