[glom] Choices combos: Fix ComboBoxEntry by using a virtual text column.



commit 56db4eebc6da836a8d94dfba2a26111d529da79b
Author: Murray Cumming <murrayc murrayc com>
Date:   Sun Oct 3 20:34:20 2010 +0200

    Choices combos: Fix ComboBoxEntry by using a virtual text column.
    
    * glom/mode_data/datawidget/treemodel_db.[h|cc]: Simplify the create()
    methods, removing the one that takes TreeModelColumns.
    * Makefile_glom.am:
    * glom/mode_data/datawidget/treemodel_db_withextratext.[h|cc]: A derived
    model (actually always used, but it keeps the code separate) that has an
    extra virtual text model, because GtkComboBoxEntry requires a text column.
    ( https://bugzilla.gnome.org/show_bug.cgi?id=631167 )
    * glom/mode_data/datawidget/combochoiceswithtreemodel.cc:
    set_choices_related(): Use the new derived model instead.
    * glom/mode_data/db_adddel/db_adddel.cc: Adapted.
    * glom/mode_data/datawidget/comboentry.cc: set_choices_related():
    Use the virtual text column.

 ChangeLog                                          |   17 +++
 Makefile_glom.am                                   |    2 +
 .../datawidget/combochoiceswithtreemodel.cc        |    9 +-
 glom/mode_data/datawidget/comboentry.cc            |   16 +++-
 glom/mode_data/datawidget/treemodel_db.cc          |   91 ++++++-----------
 glom/mode_data/datawidget/treemodel_db.h           |   28 +++---
 .../datawidget/treemodel_db_withextratext.cc       |  107 ++++++++++++++++++++
 .../datawidget/treemodel_db_withextratext.h        |   69 +++++++++++++
 glom/mode_data/db_adddel/db_adddel.cc              |    2 +-
 9 files changed, 259 insertions(+), 82 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1adb92d..b755bdb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,23 @@
 
 	* configure.ac:
 
+2010-10-03  Murray Cumming  <murrayc murrayc com>
+
+	Choices combos: Fix ComboBoxEntry by using a virtual text column.
+
+	* glom/mode_data/datawidget/treemodel_db.[h|cc]: Simplify the create() 
+	methods, removing the one that takes TreeModelColumns.
+	* Makefile_glom.am:
+	* glom/mode_data/datawidget/treemodel_db_withextratext.[h|cc]: A derived 
+	model (actually always used, but it keeps the code separate) that has an 
+	extra virtual text model, because GtkComboBoxEntry requires a text column.
+	( https://bugzilla.gnome.org/show_bug.cgi?id=631167 )
+	* glom/mode_data/datawidget/combochoiceswithtreemodel.cc:
+	set_choices_related(): Use the new derived model instead.
+	* glom/mode_data/db_adddel/db_adddel.cc: Adapted.
+	* glom/mode_data/datawidget/comboentry.cc: set_choices_related(): 
+	Use the virtual text column.
+
 2010-10-02  Murray Cumming  <murrayc murrayc com>
 
 	Choices combos: Reuse the list view implementation. Only works for Combo now.
diff --git a/Makefile_glom.am b/Makefile_glom.am
index cc019a9..d1a71bd 100644
--- a/Makefile_glom.am
+++ b/Makefile_glom.am
@@ -141,6 +141,8 @@ glom_source_files = \
 	glom/mode_data/datawidget/combo_as_radio_buttons.h			\
 	glom/mode_data/datawidget/treemodel_db.cc		\
 	glom/mode_data/datawidget/treemodel_db.h \
+	glom/mode_data/datawidget/treemodel_db_withextratext.cc		\
+	glom/mode_data/datawidget/treemodel_db_withextratext.h \
 	glom/mode_find/box_data_details_find.cc				\
 	glom/mode_find/box_data_details_find.h				\
 	glom/mode_find/box_data_list_find.cc				\
diff --git a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
index cc4dff9..e5bc8b3 100644
--- a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
+++ b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
@@ -19,7 +19,7 @@
  */
 
 #include "combochoiceswithtreemodel.h"
-#include <glom/mode_data/datawidget/treemodel_db.h>
+#include <glom/mode_data/datawidget/treemodel_db_withextratext.h>
 #include <libglom/data_structure/glomconversions.h>
 #include <glom/utils_ui.h>
 #include <glibmm/i18n.h>
@@ -233,10 +233,13 @@ void ComboChoicesWithTreeModel::set_choices_related(const Document* document, co
 
 
   m_db_layout_items.clear();
-  m_refModel = DbTreeModel::create_from_items(found_set, layout_items, true /* allow_view */, false /* find mode */, m_db_layout_items);
+
+  //We create DbTreeModelWithExtraText rather than just DbTreeModel, 
+  //because ComboEntry needs it.
+  m_refModel = DbTreeModelWithExtraText::create(found_set, layout_items, true /* allow_view */, false /* find mode */, m_db_layout_items);
   if(!m_refModel)
   {
-    std::cerr << G_STRFUNC << ": DbTreeModel::create_from_items() returned a null model." << std::endl;
+    std::cerr << G_STRFUNC << ": DbTreeModel::create() returned a null model." << std::endl;
   }
 
   //The derived class's (virtual) implementation calls this base method and
diff --git a/glom/mode_data/datawidget/comboentry.cc b/glom/mode_data/datawidget/comboentry.cc
index 590415b..3b0325f 100644
--- a/glom/mode_data/datawidget/comboentry.cc
+++ b/glom/mode_data/datawidget/comboentry.cc
@@ -23,6 +23,7 @@
 #include <gtkmm/messagedialog.h>
 #include <glom/dialog_invalid_data.h>
 #include <glom/mode_data/datawidget/cellcreation.h>
+#include <glom/mode_data/datawidget/treemodel_db_withextratext.h>
 #include <libglom/data_structure/glomconversions.h>
 #include <glom/application.h>
 #include <glibmm/i18n.h>
@@ -169,8 +170,19 @@ void ComboEntry::set_choices_related(const Document* document, const sharedptr<c
   //Show the model in the view:
   set_model(model);
   //clear() breaks GtkComboBoxEntry. TODO: Fix the C code? clear();
-  set_text_column(0); //TODO: Add a virtual model to TreeModelDb so we always have a text model?
-
+  
+  //The DB model has a special virtual text column,
+  //and the simple model just has text in all columns:
+  Glib::RefPtr<DbTreeModelWithExtraText> model_db = 
+    Glib::RefPtr<DbTreeModelWithExtraText>::cast_dynamic(model);
+  if(model_db)
+    set_text_column(model_db->get_text_column());
+  else
+  {
+    std::cerr << G_STRFUNC << ": The model is not a DbTreeModelWithExtraText." << std::endl;
+    return;
+  }
+  
   const guint columns_count = model->get_n_columns();
   for(guint i = 0; i < columns_count; ++i)
   for(type_vec_const_layout_items::const_iterator iter = m_db_layout_items.begin(); iter != m_db_layout_items.end(); ++iter)
diff --git a/glom/mode_data/datawidget/treemodel_db.cc b/glom/mode_data/datawidget/treemodel_db.cc
index ba47239..e40e831 100644
--- a/glom/mode_data/datawidget/treemodel_db.cc
+++ b/glom/mode_data/datawidget/treemodel_db.cc
@@ -166,13 +166,11 @@ DbTreeModelRow::DbValue DbTreeModelRow::get_value(DbTreeModel& model, int column
 //Intialize static variable:
 bool DbTreeModel::m_iface_initialized = false;
 
-DbTreeModel::DbTreeModel(const Gtk::TreeModelColumnRecord& columns, const FoundSet& found_set, const type_vec_const_fields& column_fields, int column_index_key, bool get_records, bool find_mode)
+DbTreeModel::DbTreeModel(const FoundSet& found_set, const type_vec_const_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown)
 : Glib::ObjectBase( typeid(DbTreeModel) ), //register a custom GType.
   Glib::Object(), //The custom GType is actually registered here.
   m_columns_count(0),
   m_found_set(found_set),
-  m_column_fields(column_fields),
-  m_column_index_key(column_index_key),
   m_data_model_rows_count(0),
   m_data_model_columns_count(0),
   m_count_extra_rows(0),
@@ -189,39 +187,6 @@ DbTreeModel::DbTreeModel(const Gtk::TreeModelColumnRecord& columns, const FoundS
     m_iface_initialized = true; //Prevent us from calling add_interface() on the same gtype again.
   }
 
-
-  //The Column information that can be used with TreeView::append(), TreeModel::iterator[], etc.
-  m_columns_count = columns.size(); //1 extra for the key.
-
-  g_assert(m_columns_count == column_fields.size());
-
-  refresh_from_database(m_found_set);
-}
-
-DbTreeModel::~DbTreeModel()
-{
-  clear();
-}
-
-
-Glib::RefPtr<DbTreeModel> DbTreeModel::create(const Gtk::TreeModelColumnRecord& columns, const FoundSet& found_set, const type_vec_const_fields& column_fields, int column_index_key, bool get_records, bool find_mode)
-{
-  return Glib::RefPtr<DbTreeModel>( new DbTreeModel(columns, found_set, column_fields, column_index_key, get_records, find_mode) );
-}
-
-Glib::RefPtr<DbTreeModel> DbTreeModel::create_from_items(const FoundSet& found_set, const type_vec_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown)
-{
-  //Create a const version of the input, because C++ can't convert it automatically:
-  type_vec_const_layout_items const_items;
-  const_items.insert(const_items.end(), layout_items.begin(), layout_items.end());
-
-  return create_from_items(found_set, const_items, get_records, find_mode, fields_shown);
-}
-
-Glib::RefPtr<DbTreeModel> DbTreeModel::create_from_items(const FoundSet& found_set, const type_vec_const_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown)
-{
-  Glib::RefPtr<DbTreeModel> result;
-
   typedef Gtk::TreeModelColumn<Gnome::Gda::Value> type_modelcolumn_value;
   typedef std::vector< type_modelcolumn_value* > type_vecModelColumns;
   type_vecModelColumns vecModelColumns(layout_items.size(), 0);
@@ -233,22 +198,12 @@ Glib::RefPtr<DbTreeModel> DbTreeModel::create_from_items(const FoundSet& found_s
   //Database columns:
   DbTreeModel::type_vec_const_fields fields;
   {
-    type_vecModelColumns::size_type i = 0;
     for(type_vec_const_layout_items::const_iterator iter = layout_items.begin(); iter != layout_items.end(); ++iter)
     {
       sharedptr<const LayoutItem_Field> item_field = sharedptr<const LayoutItem_Field>::cast_dynamic(*iter);
       if(item_field)
       {
-        type_modelcolumn_value* pModelColumn = new type_modelcolumn_value;
-
-        //Store it so we can use it and delete it later:
-        vecModelColumns[i] = pModelColumn;
-
-        record.add( *pModelColumn );
-
         fields.push_back(item_field);
-
-        i++;
       }
     }
   }
@@ -280,14 +235,7 @@ Glib::RefPtr<DbTreeModel> DbTreeModel::create_from_items(const FoundSet& found_s
       ++column_index_key;
     }
 
-    if(key_found)
-    {
-      //Create the model from the ColumnRecord:
-      //Note that the model will use a dummy Gda DataModel if m_find_mode is true.
-      //std::cout << "debug: Creating new DbTreeModel() for table=" << m_found_set.m_table_name << std::endl;
-      result =  DbTreeModel::create(record, found_set, fields, column_index_key, get_records, find_mode);
-    }
-    else
+    if(!key_found)
     {
       std::cerr << G_STRFUNC << ": no primary key field found in the list of items:" << std::endl;
       for(DbTreeModel::type_vec_const_fields::const_iterator iter = fields.begin(); iter != fields.end(); ++iter)
@@ -296,18 +244,37 @@ Glib::RefPtr<DbTreeModel> DbTreeModel::create_from_items(const FoundSet& found_s
         if(layout_item)
           std::cerr << "  field: " << layout_item->get_name() << std::endl;
       }
+      
+      return;
     }
+      
+    m_column_index_key = column_index_key;
+      
+    //The Column information that can be used with TreeView::append(), TreeModel::iterator[], etc.
+    m_columns_count = fields.size();
+    refresh_from_database(m_found_set);
   }
+}
 
-  //Delete the vector's items:
-  for(type_vecModelColumns::iterator iter = vecModelColumns.begin(); iter != vecModelColumns.end(); ++iter)
-  {
-     type_modelcolumn_value* pModelColumn = *iter;
-     if(pModelColumn)
-       delete pModelColumn;
-  }
 
-  return result;
+DbTreeModel::~DbTreeModel()
+{
+  clear();
+}
+
+
+Glib::RefPtr<DbTreeModel> DbTreeModel::create(const FoundSet& found_set, const type_vec_const_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown)
+{
+  return Glib::RefPtr<DbTreeModel>( new DbTreeModel(found_set, layout_items, get_records, find_mode, fields_shown) );
+}
+
+Glib::RefPtr<DbTreeModel> DbTreeModel::create(const FoundSet& found_set, const type_vec_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown)
+{
+  //Create a const version of the input, because C++ can't convert it automatically:
+  type_vec_const_layout_items const_items;
+  const_items.insert(const_items.end(), layout_items.begin(), layout_items.end());
+
+  return create(found_set, const_items, get_records, find_mode, fields_shown);
 }
 
 bool DbTreeModel::refresh_from_database(const FoundSet& found_set)
diff --git a/glom/mode_data/datawidget/treemodel_db.h b/glom/mode_data/datawidget/treemodel_db.h
index 3fbfcba..ee741c9 100644
--- a/glom/mode_data/datawidget/treemodel_db.h
+++ b/glom/mode_data/datawidget/treemodel_db.h
@@ -61,6 +61,7 @@ public:
   bool m_extra; //A temporary new row.
 };
 
+
 class DbTreeModel
   : public Glib::Object,
     public Gtk::TreeModel
@@ -72,32 +73,29 @@ public:
 
   friend class DbTreeModelRow;
 
-private:
-
-  DbTreeModel(const Gtk::TreeModelColumnRecord& columns, const FoundSet& found_set, const type_vec_const_fields& column_fields, int column_index_key, bool get_records = true, bool find_mode = false);
-  virtual ~DbTreeModel();
-
- /** Create a new model, using the specified fields.
-   * The LayoutItem_Fields should already have their full field details.
-   */
-  static Glib::RefPtr<DbTreeModel> create(const Gtk::TreeModelColumnRecord& columns, const FoundSet& found_set, const type_vec_const_fields& column_fields, int column_index_key, bool get_records = true, bool find_mode = false);
-
 public:
-
   typedef std::vector< sharedptr<LayoutItem> > type_vec_layout_items;
   typedef std::vector< sharedptr<const LayoutItem> > type_vec_const_layout_items;
+  
+protected:
+
+  DbTreeModel(const FoundSet& found_set, const type_vec_const_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown);
 
+  virtual ~DbTreeModel();
+public:
 
+
+ 
   /** A convenience method, creating the model from a list of LayoutItems,
    * instead of a list of LayoutItem_Fields.
    */
-  static Glib::RefPtr<DbTreeModel> create_from_items(const FoundSet& found_set, const type_vec_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown);
+  static Glib::RefPtr<DbTreeModel> create(const FoundSet& found_set, const type_vec_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown);
 
   /** A convenience method, creating the model from a list of LayoutItems,
    * instead of a list of LayoutItem_Fields.
    * Any LayoutItem_Fields should already have their full field details.
    */
-  static Glib::RefPtr<DbTreeModel> create_from_items(const FoundSet& found_set, const type_vec_const_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown);
+  static Glib::RefPtr<DbTreeModel> create(const FoundSet& found_set, const type_vec_const_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown);
 
   typedef DbTreeModelRow::DbValue DbValue;
 
@@ -136,6 +134,7 @@ private:
 
   bool refresh_from_database(const FoundSet& found_set);
 
+protected:
    // Overrides:
    virtual Gtk::TreeModelFlags get_flags_vfunc() const;
    virtual int get_n_columns_vfunc() const;
@@ -154,12 +153,13 @@ private:
    virtual bool iter_parent_vfunc(const iterator& child, iterator& iter) const;
    virtual Path get_path_vfunc(const iterator& iter) const;
    virtual bool get_iter_vfunc(const Path& path, iterator& iter) const;
+private:
 
    bool iter_is_valid(const iterator& iter) const;
 
    virtual void set_value_impl(const iterator& row, int column, const Glib::ValueBase& value);
 
-private:
+protected: //TODO: Make some things private again if possible.
    typedef DbTreeModelRow typeRow; //X columns, all of type Value.
 
    //We use a std::list instead of a std::vector, though it is slower to access via an index,
diff --git a/glom/mode_data/datawidget/treemodel_db_withextratext.cc b/glom/mode_data/datawidget/treemodel_db_withextratext.cc
new file mode 100644
index 0000000..8b3b118
--- /dev/null
+++ b/glom/mode_data/datawidget/treemodel_db_withextratext.cc
@@ -0,0 +1,107 @@
+/* Glom
+ *
+ * Copyright (C) 2001-2005 Murray Cumming
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <iostream>
+#include "treemodel_db_withextratext.h"
+
+#include <libglom/connectionpool.h>
+#include <libglom/data_structure/glomconversions.h> //For util_build_sql
+#include <libglom/utils.h>
+#include <libglom/db_utils.h>
+
+#include "glom/application.h"
+
+namespace Glom
+{
+
+typedef Glib::Value<Glib::ustring> type_value_string;
+
+DbTreeModelWithExtraText::DbTreeModelWithExtraText(const FoundSet& found_set, const type_vec_const_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown)
+: DbTreeModel(found_set, layout_items, get_records, find_mode, fields_shown)
+{
+  //Remember the key field details so we can use it later to get a text representation.
+  if(m_column_index_key > 0 && (guint)m_column_index_key < fields_shown.size())
+    m_item_key = fields_shown[m_column_index_key];
+}
+
+DbTreeModelWithExtraText::~DbTreeModelWithExtraText()
+{
+  clear();
+}
+
+Glib::RefPtr<DbTreeModelWithExtraText> DbTreeModelWithExtraText::create(const FoundSet& found_set, const type_vec_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown)
+{
+  //Create a const version of the input, because C++ can't convert it automatically:
+  type_vec_const_layout_items const_items;
+  const_items.insert(const_items.end(), layout_items.begin(), layout_items.end());
+
+  return create(found_set, const_items, get_records, find_mode, fields_shown);
+}
+
+Glib::RefPtr<DbTreeModelWithExtraText> DbTreeModelWithExtraText::create(const FoundSet& found_set, const type_vec_const_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown)
+{
+  return Glib::RefPtr<DbTreeModelWithExtraText>( new DbTreeModelWithExtraText(found_set, layout_items, get_records, find_mode, fields_shown) );
+}
+
+int DbTreeModelWithExtraText::get_n_columns_vfunc() const
+{
+  return DbTreeModel::get_n_columns_vfunc() + 1;
+}
+
+GType DbTreeModelWithExtraText::get_column_type_vfunc(int index) const
+{
+  if(index == get_text_column())
+    return type_value_string::value_type();
+  else
+    return DbTreeModel::get_column_type_vfunc(index);
+}
+
+void DbTreeModelWithExtraText::get_value_vfunc(const TreeModel::iterator& iter, int column, Glib::ValueBase& value) const
+{
+  if(column == get_text_column())
+  {
+    if(m_item_key)
+    {
+      std::cerr << G_STRFUNC << ": m_item_key is null." << std::endl;
+      return;
+    }
+
+    const DbValue dbvalue = get_key_value(iter);
+    const Glib::ustring text =
+      Conversions::get_text_for_gda_value(m_item_key->get_glom_type(), dbvalue, m_item_key->get_formatting_used().m_numeric_format);
+      
+    type_value_string value_specific;
+    value_specific.init( type_value_string::value_type() );  //TODO: Is there any way to avoid this step?
+    value_specific.set(text);
+    value = value_specific;
+  }
+  else
+  {
+    DbTreeModel::get_value_vfunc(iter, column, value);
+  }
+}
+
+int DbTreeModelWithExtraText::get_text_column() const
+{
+  return get_n_columns_vfunc() - 1;
+}
+
+
+} //namespace Glom
diff --git a/glom/mode_data/datawidget/treemodel_db_withextratext.h b/glom/mode_data/datawidget/treemodel_db_withextratext.h
new file mode 100644
index 0000000..83bad5e
--- /dev/null
+++ b/glom/mode_data/datawidget/treemodel_db_withextratext.h
@@ -0,0 +1,69 @@
+/* Glom
+ *
+ * Copyright (C) 2001-2010 Murray Cumming
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef GLOM_UTILITY_WIDGETS_DB_TREEMODEL_WITHEXTRATEXTH
+#define GLOM_UTILITY_WIDGETS_DB_TREEMODEL_WITHEXTRATEXTH
+
+#include <glom/mode_data/datawidget/treemodel_db.h>
+
+namespace Glom
+{
+
+/** This awkward class is just a version of DbTreeModel that has an 
+ * extra text column that is a text representation of the primary key,
+ * for use in a GtkComboEntry, which requires a text column in the model.
+ */
+class DbTreeModelWithExtraText
+  : public DbTreeModel
+{
+public:
+private:
+
+  DbTreeModelWithExtraText(const FoundSet& found_set, const type_vec_const_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown);
+  virtual ~DbTreeModelWithExtraText();
+
+public:
+
+  /** A convenience method, creating the model from a list of LayoutItems,
+   * instead of a list of LayoutItem_Fields.
+   */
+  static Glib::RefPtr<DbTreeModelWithExtraText> create(const FoundSet& found_set, const type_vec_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown);
+
+  /** A convenience method, creating the model from a list of LayoutItems,
+   * instead of a list of LayoutItem_Fields.
+   * Any LayoutItem_Fields should already have their full field details.
+   */
+  static Glib::RefPtr<DbTreeModelWithExtraText> create(const FoundSet& found_set, const type_vec_const_layout_items& layout_items, bool get_records, bool find_mode, Base_DB::type_vecConstLayoutFields& fields_shown);
+  
+  /** This column is a text representation of the primary key column.
+   */
+  int get_text_column() const;
+
+private:
+  virtual int get_n_columns_vfunc() const;
+  virtual GType get_column_type_vfunc(int index) const;
+  virtual void get_value_vfunc(const TreeModel::iterator& iter, int column, Glib::ValueBase& value) const;
+  
+  sharedptr<const LayoutItem_Field> m_item_key;
+};
+
+} //namespace Glom
+
+#endif // GLOM_UTILITY_WIDGETS_DB_TREEMODEL_WITHEXTRATEXTH
diff --git a/glom/mode_data/db_adddel/db_adddel.cc b/glom/mode_data/db_adddel/db_adddel.cc
index dfe5e18..bfdd7b1 100644
--- a/glom/mode_data/db_adddel/db_adddel.cc
+++ b/glom/mode_data/db_adddel/db_adddel.cc
@@ -730,7 +730,7 @@ void DbAddDel::construct_specified_columns()
     return;
   }
 
-  m_refListStore = DbTreeModel::create_from_items(m_found_set, m_column_items, m_allow_view, m_find_mode, m_FieldsShown);
+  m_refListStore = DbTreeModel::create(m_found_set, m_column_items, m_allow_view, m_find_mode, m_FieldsShown);
   //m_FieldsShown is needed by Base_DB_Table_Data::record_new().
 
   #ifdef GLOM_ENABLE_MAEMO



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