glom r1450 - in trunk: . examples glom glom/libglom glom/libglom/data_structure glom/mode_data glom/utility_widgets/db_adddel



Author: murrayc
Date: Sat Mar  8 21:54:46 2008
New Revision: 1450
URL: http://svn.gnome.org/viewvc/glom?rev=1450&view=rev

Log:
2008-03-08  Murray Cumming  <murrayc murrayc com>

* glom/libglom/data_structure/glomconversions.cc:
* glom/libglom/data_structure/glomconversions.h:
Added get_double_for_gda_value_numeric().
* glom/base_db.cc: auto_increment_insert_first_if_necessary(),
recalculate_next_auto_increment_value(),
get_next_auto_increment_value():
Return a GdaNumeric Gda::Value, not a string one, and
do the conversion without the locale affecting it.
* glom/utility_widgets/db_adddel/glom_db_treemodel.cc:
fill_values_if_necessary(): Create default values of the correct type. 
* glom/libglom/utils.cc:
* glom/libglom/utils.h: Removed decimal_from_string() because it is 
no longer used.
This avoids a warning about an incorrect type when adding a row in 
the list view.

* examples/example_music_collection.glom: Song table:
Added Artists doubly-related fields on details and recreate this 
example.

Modified:
   trunk/ChangeLog
   trunk/examples/example_music_collection.glom
   trunk/glom/base_db.cc
   trunk/glom/libglom/data_structure/glomconversions.cc
   trunk/glom/libglom/data_structure/glomconversions.h
   trunk/glom/libglom/utils.cc
   trunk/glom/libglom/utils.h
   trunk/glom/mode_data/box_data.cc
   trunk/glom/utility_widgets/db_adddel/db_adddel.cc
   trunk/glom/utility_widgets/db_adddel/glom_db_treemodel.cc

Modified: trunk/examples/example_music_collection.glom
==============================================================================
--- trunk/examples/example_music_collection.glom	(original)
+++ trunk/examples/example_music_collection.glom	Sat Mar  8 21:54:46 2008
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <glom_document translation_original_locale="en_US" database_title="Music Collection" is_example="true" format_version="1">
-  <connection server="localhost" database="glom_musiccollection21"/>
+  <connection server="localhost" database="glom_musiccollection21" port="5433"/>
   
   
   
@@ -133,128 +133,189 @@
 
 
 
-<table name="albums" overview_x="15" overview_y="9" title="Albums"><example_rows>3,'','Sign ''O'' The Times',2,1,1987
-0,'','Born To Run',0,0,1975
-2,'','The Wild, the Innocent, &amp; the E-Street Shuffle',0,0,1973
-1,'','True Blue',1,1,1987
-4,'','Superfly',3,2,1972
-</example_rows><fields><field name="album_id" primary_key="true" unique="true" auto_increment="true" type="Number" title="Album ID"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></field>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<table name="albums" overview_x="15" overview_y="9" title="Albums"><example_rows><example_row><value column="album_id">3</value><value column="comments">''</value><value column="name">'Sign ''O'' The Times'</value><value column="artist_id">2</value><value column="publisher_id">1</value><value column="year">1987</value></example_row><example_row><value column="album_id">0</value><value column="comments">''</value><value column="name">'Born To Run'</value><value column="artist_id">0</value><value column="publisher_id">0</value><value column="year">1975</value></example_row><example_row><value column="album_id">2</value><value column="comments">''</value><value column="name">'The Wild, the Innocent, &amp; the E-Street Shuffle'</value><value column="artist_id">0</value><value column="publisher_id">0</value><value column="year">1973</value></example_row><example_row><value column="album_id">1</value><value column="comments">''</value><value column="name">'True Blue'</value><value
  column="artist_id">1</value><value column="publisher_id">1</value><value column="year">1987</value></example_row><example_row><value column="album_id">4</value><value column="comments">''</value><value column="name">'Superfly'</value><value column="artist_id">3</value><value column="publisher_id">2</value><value column="year">1972</value></example_row></example_rows><fields><field name="album_id" primary_key="true" unique="true" auto_increment="true" type="Number" title="Album ID"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2"/></field>
 <field name="comments" type="Text" title="Comments"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline="true" format_text_multiline_height_lines="6"/></field>
 <field name="name" type="Text" title="Name"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></field>
-<field name="artist_id" type="Number" title="Artist ID"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6" choices_related="true" choices_related_relationship="artist" choices_related_field="artist_id" choices_related_second="name"/></field>
-<field name="publisher_id" type="Number" title="Publisher ID"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6" choices_related="true" choices_related_relationship="publisher" choices_related_field="publishers_id" choices_related_second="name"/></field>
-<field name="year" type="Number" title="Year"><calculation></calculation><formatting format_decimal_places="2" format_text_multiline_height_lines="6"/></field>
+<field name="artist_id" type="Number" title="Artist ID"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" choices_related="true" choices_related_relationship="artist" choices_related_field="artist_id" choices_related_second="name"/></field>
+<field name="publisher_id" type="Number" title="Publisher ID"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" choices_related="true" choices_related_relationship="publisher" choices_related_field="publishers_id" choices_related_second="name"/></field>
+<field name="year" type="Number" title="Year"><calculation></calculation><formatting format_decimal_places="2"/></field>
 </fields>
 <relationships><relationship name="artist" key="artist_id" other_table="artists" other_key="artist_id" title="Artist"/>
 <relationship name="publisher" key="publisher_id" other_table="publishers" other_key="publishers_id" title="Publisher"/>
 <relationship name="songs" key="album_id" other_table="songs" other_key="album_id" auto_create="true" allow_edit="true" title="Songs"/>
 </relationships>
-<data_layouts><data_layout name="details" parent_table="albums"><data_layout_groups><data_layout_group name="main" columns_count="1" sequence="1"><data_layout_group name="overview" columns_count="2" sequence="1" title="Overview"><trans_set><trans loc="de_DE" val="Overview"/></trans_set><data_layout_item name="album_id" editable="true" use_default_formatting="true" sequence="1"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="name" editable="true" use_default_formatting="true" sequence="2"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group><data_layout_group name="details" columns_count="2" sequence="2" title="Details"><trans_set><trans loc="de_DE" val="Details"/></trans_set><data_layout_group name="artist" columns_count="1" sequence="1" title="Artist"><trans_set><trans loc
 ="de_DE" val="Artist"/></trans_set><data_layout_item name="artist_id" editable="true" use_default_formatting="true" sequence="1"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="name" relationship="artist" editable="true" use_default_formatting="true" sequence="2"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group><data_layout_group name="publisher" columns_count="1" sequence="2" title="Publisher"><trans_set><trans loc="de_DE" val="Publisher"/></trans_set><data_layout_item name="publisher_id" editable="true" use_default_formatting="true" sequence="1"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="name" relationship="publisher" editable="true" use_default_formatting="
 true" sequence="2"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group><data_layout_item name="year" editable="true" use_default_formatting="true" sequence="3"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_portal relationship="songs" name="" columns_count="1" sequence="4"><data_layout_item name="name" editable="true" use_default_formatting="true" sequence="1"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_portal><data_layout_item name="comments" editable="true" use_default_formatting="true" sequence="5"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group></data_layout_group>
+<data_layouts><data_layout name="details" parent_table="albums"><data_layout_groups><data_layout_group name="main"><data_layout_group name="overview" columns_count="2" title="Overview"><trans_set><trans loc="de_DE" val="Overview"/></trans_set><data_layout_item name="album_id" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2"/></data_layout_item><data_layout_item name="name" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group><data_layout_group name="details" columns_count="2" title="Details"><trans_set><trans loc="de_DE" val="Details"/></trans_set><data_layout_group name="artist" title="Artist"><trans_set><trans loc="de_DE" val="Artist"/></trans_set><data_layout_item name="artist_id" editable="true" use_default_formatting="true"><formatting format_thousands_separato
 r="true" format_decimal_places="2"/></data_layout_item><data_layout_item name="name" relationship="artist" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group><data_layout_group name="publisher" title="Publisher"><trans_set><trans loc="de_DE" val="Publisher"/></trans_set><data_layout_item name="publisher_id" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2"/></data_layout_item><data_layout_item name="name" relationship="publisher" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group><data_layout_item name="year" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places=
 "2"/></data_layout_item><data_layout_portal relationship="songs"><data_layout_item name="name" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_portal><data_layout_item name="comments" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group></data_layout_group>
 </data_layout_groups></data_layout>
-<data_layout name="list" parent_table="albums"><data_layout_groups><data_layout_group name="toplevel" columns_count="1"><data_layout_item name="name" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="year" editable="true" use_default_formatting="true" sequence="1"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group>
+<data_layout name="list" parent_table="albums"><data_layout_groups><data_layout_group name="toplevel"><data_layout_item name="name" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="year" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2"/></data_layout_item></data_layout_group>
 </data_layout_groups></data_layout>
 </data_layouts>
-<reports><report name="albums_by_artist" show_table_title="true" title="Albums By Artist"><data_layout_groups><data_layout_group name="" columns_count="1"><data_layout_item_groupby name="" columns_count="1" sequence="1"><groupby name="artist_id" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></groupby><secondary_fields><data_layout_group name="" columns_count="1"><data_layout_item name="name" relationship="artist" editable="true" use_default_formatting="true" sequence="1"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/><title_custom use_custom="true" title="Artist Name"/></data_layout_item></data_layout_group></secondary_fields><data_layout_item name="name" editable="true" use_default_formatting="true" sequence="1"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multi
 line_height_lines="6"/></data_layout_item><data_layout_item name="year" editable="true" use_default_formatting="true" sequence="2"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_item_groupby></data_layout_group>
+<reports><report name="albums_by_artist" show_table_title="true" title="Albums By Artist"><data_layout_groups><data_layout_group><data_layout_item_groupby><groupby name="artist_id" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2"/></groupby><secondary_fields><data_layout_group><data_layout_item name="name" relationship="artist" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/><title_custom use_custom="true" title="Artist Name"/></data_layout_item></data_layout_group></secondary_fields><data_layout_item name="name" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="year" editable="true" use_default_formatting="true"><formatting format_thousands_separator
 ="true" format_decimal_places="2"/></data_layout_item></data_layout_item_groupby></data_layout_group>
 </data_layout_groups></report>
-</reports>
+
+</reports><print_layouts/>
 
 </table>
-<table name="artists" default="true" overview_x="407" overview_y="119" title="Artists"><example_rows>0,'','','Bruce Springsteen'
-1,'','','Madonna'
-2,'','','Prince'
-3,'','','Curtis Mayfield'
-</example_rows><fields><field name="artist_id" primary_key="true" unique="true" auto_increment="true" type="Number" title="Artist ID"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></field>
+<table name="artists" default="true" overview_x="407" overview_y="119" title="Artists"><example_rows><example_row><value column="artist_id">0</value><value column="description">''</value><value column="comments">''</value><value column="name">'Bruce Springsteen'</value></example_row><example_row><value column="artist_id">1</value><value column="description">''</value><value column="comments">''</value><value column="name">'Madonna'</value></example_row><example_row><value column="artist_id">2</value><value column="description">''</value><value column="comments">''</value><value column="name">'Prince'</value></example_row><example_row><value column="artist_id">3</value><value column="description">''</value><value column="comments">''</value><value column="name">'Curtis Mayfield'</value></example_row><example_row><value column="artist_id">4</value><value column="description">''</value><value column="comments">''</value><value column="name">'sdsd'</value></example_row><example_
 row><value column="artist_id">5</value><value column="description">''</value><value column="comments">''</value><value column="name">'fdf'</value></example_row><example_row><value column="artist_id">6</value><value column="description">''</value><value column="comments">''</value><value column="name">'Curtis Mayfield'</value></example_row></example_rows><fields><field name="artist_id" primary_key="true" unique="true" auto_increment="true" type="Number" title="Artist ID"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2"/></field>
 <field name="description" type="Text" title="Description"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></field>
 <field name="comments" type="Text" title="Comments"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline="true" format_text_multiline_height_lines="6"/></field>
 <field name="name" type="Text" title="Name"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></field>
 </fields>
 <relationships><relationship name="albums" key="artist_id" other_table="albums" other_key="artist_id" auto_create="true" allow_edit="true" title="Albums"/>
 </relationships>
-<data_layouts><data_layout name="details" parent_table="artists"><data_layout_groups><data_layout_group name="main" columns_count="1" sequence="1"><data_layout_group name="overview" columns_count="2" sequence="1" title="Overview"><trans_set><trans loc="de_DE" val="Overview"/></trans_set><data_layout_item name="artist_id" editable="true" use_default_formatting="true" sequence="1"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="name" editable="true" use_default_formatting="true" sequence="2"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group><data_layout_group name="details" columns_count="2" sequence="2" title="Details"><trans_set><trans loc="de_DE" val="Details"/></trans_set><data_layout_item name="description" editable="true" use_default_formatting="true" sequence="1"><f
 ormatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_portal relationship="albums" name="" columns_count="1" sequence="2"><data_layout_item name="name" editable="true" use_default_formatting="true" sequence="1"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="year" editable="true" use_default_formatting="true" sequence="2"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_portal><data_layout_item name="comments" editable="true" use_default_formatting="true" sequence="3"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group></data_layout_group>
+<data_layouts><data_layout name="details" parent_table="artists"><data_layout_groups><data_layout_group name="main"><data_layout_group name="overview" columns_count="2" title="Overview"><trans_set><trans loc="de_DE" val="Overview"/></trans_set><data_layout_item name="artist_id" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2"/></data_layout_item><data_layout_item name="name" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group><data_layout_group name="details" columns_count="2" title="Details"><trans_set><trans loc="de_DE" val="Details"/></trans_set><data_layout_item name="description" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_
 layout_portal relationship="albums"><data_layout_item name="name" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="year" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2"/></data_layout_item></data_layout_portal><data_layout_item name="comments" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group></data_layout_group>
 </data_layout_groups></data_layout>
-<data_layout name="list" parent_table="artists"><data_layout_groups><data_layout_group name="main" columns_count="1" sequence="1"><data_layout_item name="artist_id" editable="true" use_default_formatting="true" sequence="1"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="name" editable="true" use_default_formatting="true" sequence="2"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="description" editable="true" use_default_formatting="true" sequence="3"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="comments" editable="true" use_default_formatting="true" sequence="4"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_
 height_lines="6"/></data_layout_item></data_layout_group>
+<data_layout name="list" parent_table="artists"><data_layout_groups><data_layout_group name="main"><data_layout_item name="artist_id" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2"/></data_layout_item><data_layout_item name="name" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="description" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="comments" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group>
 </data_layout_groups></data_layout>
 </data_layouts>
-<reports/>
+<reports/><print_layouts/>
 
 </table>
-<table name="publishers" overview_x="411" overview_y="235" title="Publishers"><example_rows>0,'','Sony'
-1,'','Warner Bros'
-2,'','Rhino'
-</example_rows><fields><field name="publishers_id" primary_key="true" unique="true" auto_increment="true" type="Number" title="Publisher ID"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></field>
+<table name="publishers" overview_x="411" overview_y="235" title="Publishers"><example_rows><example_row><value column="publishers_id">0</value><value column="comments">''</value><value column="name">'Sony'</value></example_row><example_row><value column="publishers_id">1</value><value column="comments">''</value><value column="name">'Warner Bros'</value></example_row><example_row><value column="publishers_id">2</value><value column="comments">''</value><value column="name">'Rhino'</value></example_row></example_rows><fields><field name="publishers_id" primary_key="true" unique="true" auto_increment="true" type="Number" title="Publisher ID"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2"/></field>
 <field name="comments" type="Text" title="Comments"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline="true" format_text_multiline_height_lines="6"/></field>
 <field name="name" type="Text" title="Name"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></field>
 </fields>
 <relationships><relationship name="albums" key="publishers_id" other_table="albums" other_key="publisher_id" title="Albums"/>
 </relationships>
-<data_layouts><data_layout name="details" parent_table="publishers"><data_layout_groups><data_layout_group name="main" columns_count="1" sequence="1"><data_layout_group name="overview" columns_count="2" sequence="1" title="Overview"><trans_set><trans loc="de_DE" val="Overview"/></trans_set><data_layout_item name="publishers_id" editable="true" use_default_formatting="true" sequence="1"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="name" editable="true" use_default_formatting="true" sequence="2"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group><data_layout_group name="details" columns_count="1" sequence="2" title="Details"><trans_set><trans loc="de_DE" val="Details"/></trans_set><data_layout_item name="comments" editable="true" use_default_formatting="true" sequence="1
 "><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_portal relationship="albums" name="" columns_count="1" sequence="2"><data_layout_item name="album_id" use_default_formatting="true" sequence="1"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="name" use_default_formatting="true" sequence="2"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="name" relationship="artist" use_default_formatting="true" sequence="3"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_portal></data_layout_group></data_layout_group>
+<data_layouts><data_layout name="details" parent_table="publishers"><data_layout_groups><data_layout_group name="main"><data_layout_group name="overview" columns_count="2" title="Overview"><trans_set><trans loc="de_DE" val="Overview"/></trans_set><data_layout_item name="publishers_id" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2"/></data_layout_item><data_layout_item name="name" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group><data_layout_group name="details" title="Details"><trans_set><trans loc="de_DE" val="Details"/></trans_set><data_layout_item name="comments" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_portal 
 relationship="albums"><data_layout_item name="album_id" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2"/></data_layout_item><data_layout_item name="name" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="name" relationship="artist" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_portal></data_layout_group></data_layout_group>
 </data_layout_groups></data_layout>
-<data_layout name="list" parent_table="publishers"><data_layout_groups><data_layout_group name="main" columns_count="1" sequence="1"><data_layout_item name="publishers_id" editable="true" use_default_formatting="true" sequence="1"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="comments" editable="true" use_default_formatting="true" sequence="2"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="name" editable="true" use_default_formatting="true" sequence="3"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group>
+<data_layout name="list" parent_table="publishers"><data_layout_groups><data_layout_group name="main"><data_layout_item name="publishers_id" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2"/></data_layout_item><data_layout_item name="comments" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="name" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group>
 </data_layout_groups></data_layout>
 </data_layouts>
-<reports/>
+<reports/><print_layouts/>
 
 </table>
-<table name="songs" overview_x="407" overview_y="7" title="Songs"><example_rows>0,'',0,'Thunder Road'
-1,'',0,'Tenth Avenue Freeze Out'
-2,'',0,'Night'
-3,'',0,'Backstreets'
-4,'',0,'Born To Run'
-5,'',0,'She''s The One'
-6,'',0,'Meeting Across The River'
-7,'',0,'Jungleland'
-8,'',2,'E Street Shuffle'
-9,'',2,'4th of July, Asbury Park (Sandy)'
-10,'',2,'Kitty''s Back'
-11,'',2,'Wild Billy''s Circus Story'
-12,'',2,'Incident on 57th Street'
-13,'',2,'Rosalita (Come out Tonight)'
-14,'',2,'New York City Serenade'
-15,'',3,'Sign ''O'' The Times'
-16,'',3,'Play In The Sunshine'
-17,'',3,'Housequake'
-18,'',3,'Ballad of Dorothy Parker'
-19,'',3,'It'
-20,'',3,'Starfish and Coffee'
-21,'',3,'Slow Love'
-22,'',3,'Hot Thing'
-23,'',3,'Forever In My Life'
-24,'',3,'U Got The Look'
-25,'',3,'If I Was Your Girlfriend'
-26,'',3,'Strange Relationship'
-27,'',3,'I Could Never Take The Place Of Your Man'
-28,'',3,'The Cross'
-29,'',3,'It''s Gonna Be A Beautiful Night'
-30,'',3,'Adore'
-31,'',1,'Papa Don''t Preach'
-32,'',1,'Open Your Heart'
-33,'',1,'White Heart'
-34,'',1,'Live To Tell'
-35,'',1,'Where''s The Party'
-36,'',1,'True Blue'
-37,'',1,'La Isla Bonita'
-38,'',1,'Jimmy Jimmy'
-39,'',1,'Love Makes The World Go Round'
-40,'',4,'Little Child Runnin'' Wild'
-41,'',4,'Pusherman'
-42,'',4,'Freddie''s Dead'
-43,'',4,'Junkie Chase (Instrumental)'
-44,'',4,'Give Me Your Love (Love Song)'
-45,'',4,'Eddie You Should Know Better'
-46,'',4,'No Thing On Me (Cocaine Song)'
-47,'',4,'Think (Instrumental)'
-48,'',4,'Superfly'
-</example_rows><fields><field name="songs_id" primary_key="true" unique="true" auto_increment="true" type="Number" title="Song ID"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></field>
+<table name="songs" overview_x="407" overview_y="7" title="Songs"><example_rows><example_row><value column="songs_id">0</value><value column="comments">''</value><value column="album_id">0</value><value column="name">'Thunder Road'</value></example_row><example_row><value column="songs_id">1</value><value column="comments">''</value><value column="album_id">0</value><value column="name">'Tenth Avenue Freeze Out'</value></example_row><example_row><value column="songs_id">2</value><value column="comments">''</value><value column="album_id">0</value><value column="name">'Night'</value></example_row><example_row><value column="songs_id">3</value><value column="comments">''</value><value column="album_id">0</value><value column="name">'Backstreets'</value></example_row><example_row><value column="songs_id">4</value><value column="comments">''</value><value column="album_id">0</value><value column="name">'Born To Run'</value></example_row><example_row><value column="songs_id">5</v
 alue><value column="comments">''</value><value column="album_id">0</value><value column="name">'She''s The One'</value></example_row><example_row><value column="songs_id">6</value><value column="comments">''</value><value column="album_id">0</value><value column="name">'Meeting Across The River'</value></example_row><example_row><value column="songs_id">7</value><value column="comments">''</value><value column="album_id">0</value><value column="name">'Jungleland'</value></example_row><example_row><value column="songs_id">8</value><value column="comments">''</value><value column="album_id">2</value><value column="name">'E Street Shuffle'</value></example_row><example_row><value column="songs_id">9</value><value column="comments">''</value><value column="album_id">2</value><value column="name">'4th of July, Asbury Park (Sandy)'</value></example_row><example_row><value column="songs_id">10</value><value column="comments">''</value><value column="album_id">2</value><value column
 ="name">'Kitty''s Back'</value></example_row><example_row><value column="songs_id">11</value><value column="comments">''</value><value column="album_id">2</value><value column="name">'Wild Billy''s Circus Story'</value></example_row><example_row><value column="songs_id">12</value><value column="comments">''</value><value column="album_id">2</value><value column="name">'Incident on 57th Street'</value></example_row><example_row><value column="songs_id">13</value><value column="comments">''</value><value column="album_id">2</value><value column="name">'Rosalita (Come out Tonight)'</value></example_row><example_row><value column="songs_id">14</value><value column="comments">''</value><value column="album_id">2</value><value column="name">'New York City Serenade'</value></example_row><example_row><value column="songs_id">15</value><value column="comments">''</value><value column="album_id">3</value><value column="name">'Sign ''O'' The Times'</value></example_row><example_row><va
 lue column="songs_id">16</value><value column="comments">''</value><value column="album_id">3</value><value column="name">'Play In The Sunshine'</value></example_row><example_row><value column="songs_id">17</value><value column="comments">''</value><value column="album_id">3</value><value column="name">'Housequake'</value></example_row><example_row><value column="songs_id">18</value><value column="comments">''</value><value column="album_id">3</value><value column="name">'Ballad of Dorothy Parker'</value></example_row><example_row><value column="songs_id">19</value><value column="comments">''</value><value column="album_id">3</value><value column="name">'It'</value></example_row><example_row><value column="songs_id">20</value><value column="comments">''</value><value column="album_id">3</value><value column="name">'Starfish and Coffee'</value></example_row><example_row><value column="songs_id">21</value><value column="comments">''</value><value column="album_id">3</value><va
 lue column="name">'Slow Love'</value></example_row><example_row><value column="songs_id">22</value><value column="comments">''</value><value column="album_id">3</value><value column="name">'Hot Thing'</value></example_row><example_row><value column="songs_id">23</value><value column="comments">''</value><value column="album_id">3</value><value column="name">'Forever In My Life'</value></example_row><example_row><value column="songs_id">24</value><value column="comments">''</value><value column="album_id">3</value><value column="name">'U Got The Look'</value></example_row><example_row><value column="songs_id">25</value><value column="comments">''</value><value column="album_id">3</value><value column="name">'If I Was Your Girlfriend'</value></example_row><example_row><value column="songs_id">26</value><value column="comments">''</value><value column="album_id">3</value><value column="name">'Strange Relationship'</value></example_row><example_row><value column="songs_id">27</v
 alue><value column="comments">''</value><value column="album_id">3</value><value column="name">'I Could Never Take The Place Of Your Man'</value></example_row><example_row><value column="songs_id">28</value><value column="comments">''</value><value column="album_id">3</value><value column="name">'The Cross'</value></example_row><example_row><value column="songs_id">29</value><value column="comments">''</value><value column="album_id">3</value><value column="name">'It''s Gonna Be A Beautiful Night'</value></example_row><example_row><value column="songs_id">30</value><value column="comments">''</value><value column="album_id">3</value><value column="name">'Adore'</value></example_row><example_row><value column="songs_id">31</value><value column="comments">''</value><value column="album_id">1</value><value column="name">'Papa Don''t Preach'</value></example_row><example_row><value column="songs_id">32</value><value column="comments">''</value><value column="album_id">1</value><
 value column="name">'Open Your Heart'</value></example_row><example_row><value column="songs_id">33</value><value column="comments">''</value><value column="album_id">1</value><value column="name">'White Heart'</value></example_row><example_row><value column="songs_id">34</value><value column="comments">''</value><value column="album_id">1</value><value column="name">'Live To Tell'</value></example_row><example_row><value column="songs_id">35</value><value column="comments">''</value><value column="album_id">1</value><value column="name">'Where''s The Party'</value></example_row><example_row><value column="songs_id">36</value><value column="comments">''</value><value column="album_id">1</value><value column="name">'True Blue'</value></example_row><example_row><value column="songs_id">37</value><value column="comments">''</value><value column="album_id">1</value><value column="name">'La Isla Bonita'</value></example_row><example_row><value column="songs_id">38</value><value c
 olumn="comments">''</value><value column="album_id">1</value><value column="name">'Jimmy Jimmy'</value></example_row><example_row><value column="songs_id">39</value><value column="comments">''</value><value column="album_id">1</value><value column="name">'Love Makes The World Go Round'</value></example_row><example_row><value column="songs_id">40</value><value column="comments">''</value><value column="album_id">4</value><value column="name">'Little Child Runnin'' Wild'</value></example_row><example_row><value column="songs_id">41</value><value column="comments">''</value><value column="album_id">4</value><value column="name">'Pusherman'</value></example_row><example_row><value column="songs_id">42</value><value column="comments">''</value><value column="album_id">4</value><value column="name">'Freddie''s Dead'</value></example_row><example_row><value column="songs_id">43</value><value column="comments">''</value><value column="album_id">4</value><value column="name">'Junkie
  Chase (Instrumental)'</value></example_row><example_row><value column="songs_id">44</value><value column="comments">''</value><value column="album_id">4</value><value column="name">'Give Me Your Love (Love Song)'</value></example_row><example_row><value column="songs_id">45</value><value column="comments">''</value><value column="album_id">4</value><value column="name">'Eddie You Should Know Better'</value></example_row><example_row><value column="songs_id">46</value><value column="comments">''</value><value column="album_id">4</value><value column="name">'No Thing On Me (Cocaine Song)'</value></example_row><example_row><value column="songs_id">47</value><value column="comments">''</value><value column="album_id">4</value><value column="name">'Think (Instrumental)'</value></example_row><example_row><value column="songs_id">48</value><value column="comments">''</value><value column="album_id">4</value><value column="name">'Superfly'</value></example_row></example_rows><field
 s><field name="songs_id" primary_key="true" unique="true" auto_increment="true" type="Number" title="Song ID"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2"/></field>
 <field name="comments" type="Text" title="Comments"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline="true" format_text_multiline_height_lines="6"/></field>
-<field name="album_id" type="Number" title="Album ID"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></field>
+<field name="album_id" type="Number" title="Album ID"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2"/></field>
 <field name="name" type="Text" title="Name"><calculation></calculation><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></field>
 </fields>
-<relationships><relationship name="albu" key="album_id" other_table="albums" other_key="album_id" title="Album"/>
+<relationships><relationship name="album" key="album_id" other_table="albums" other_key="album_id" title="Album"/>
 </relationships>
-<data_layouts><data_layout name="details" parent_table="songs"><data_layout_groups><data_layout_group name="main" columns_count="1" sequence="1"><data_layout_group name="overview" columns_count="2" sequence="1" title="Overview"><trans_set><trans loc="de_DE" val="Overview"/></trans_set><data_layout_item name="songs_id" editable="true" use_default_formatting="true" sequence="1"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="name" editable="true" use_default_formatting="true" sequence="2"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group><data_layout_group name="details" columns_count="2" sequence="2" title="Details"><trans_set><trans loc="de_DE" val="Details"/></trans_set><data_layout_item name="comments" editable="true" use_default_formatting="true" sequence="1"><formatt
 ing format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="album_id" editable="true" use_default_formatting="true" sequence="2"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="name" relationship="albu" editable="true" use_default_formatting="true" sequence="3"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group></data_layout_group>
+<data_layouts><data_layout name="details" parent_table="songs"><data_layout_groups><data_layout_group name="main"><data_layout_group name="overview" columns_count="2" title="Overview"><trans_set><trans loc="de_DE" val="Overview"/></trans_set><data_layout_item name="songs_id" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2"/></data_layout_item><data_layout_item name="name" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group><data_layout_group name="details" columns_count="2" title="Details"><trans_set><trans loc="de_DE" val="Details"/></trans_set><data_layout_group name="album" title="Album"><data_layout_item name="album_id" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2"/></data_layout_item><data
 _layout_item name="name" relationship="album" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group><data_layout_group name="artist" title="Album Artist"><data_layout_item name="artist_id" relationship="album" related_relationship="artist" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2"/></data_layout_item><data_layout_item name="name" relationship="album" related_relationship="artist" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group><data_layout_item name="comments" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"
 /></data_layout_item></data_layout_group></data_layout_group>
+</data_layout_groups></data_layout>
+<data_layout name="list" parent_table="songs"><data_layout_groups><data_layout_group name="main"><data_layout_item name="songs_id" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2"/></data_layout_item><data_layout_item name="comments" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item><data_layout_item name="album_id" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2"/></data_layout_item><data_layout_item name="name" editable="true" use_default_formatting="true"><formatting format_thousands_separator="true" format_decimal_places="2" format_text_multiline_height_lines="6"/></data_layout_item></data_layout_group>
 </data_layout_groups></data_layout>
 </data_layouts>
-<reports/>
+<reports/><print_layouts/>
 
 </table>
 <groups><!--These are only used when recreating a database from an example file. The actual access-control is on the server, of course.--></groups>

Modified: trunk/glom/base_db.cc
==============================================================================
--- trunk/glom/base_db.cc	(original)
+++ trunk/glom/base_db.cc	Sat Mar  8 21:54:46 2008
@@ -853,9 +853,16 @@
   else
   {
     //Return the value so that a calling function does not need to do a second SELECT.
-    value = datamodel->get_value_at(0, 0);
+    const Gnome::Gda::Value actual_value = datamodel->get_value_at(0, 0);
+    
+    //But the caller wants a numeric value not a text value
+    //(our system_autoincrements table has it as text, for future flexibility):
+    const std::string actual_value_text = actual_value.get_string();
+    bool success = false;
+    value = Conversions::parse_value(Field::TYPE_NUMERIC, actual_value_text, success, true /* iso_format */);
   }
 
+  //std::cout << "Base_DB::auto_increment_insert_first_if_necessary: returning value of type=" << value.get_value_type() << std::endl;
   return value;
 }
 
@@ -870,8 +877,8 @@
   if(datamodel && datamodel->get_n_rows() && datamodel->get_n_columns())
   {
     //Increment it:
-    const Gnome::Gda::Value value_max = datamodel->get_value_at(0, 0);
-    long num_max = Utils::decimal_from_string(value_max.to_string()); //TODO: Is this sensible? Probably not.
+    const Gnome::Gda::Value value_max = datamodel->get_value_at(0, 0); // A GdaNumeric.
+    double num_max = Conversions::get_double_for_gda_value_numeric(value_max);
     ++num_max;
 
     //Set it in the glom system table:
@@ -896,8 +903,7 @@
 Gnome::Gda::Value Base_DB::get_next_auto_increment_value(const Glib::ustring& table_name, const Glib::ustring& field_name) const
 {
   const Gnome::Gda::Value result = auto_increment_insert_first_if_necessary(table_name, field_name);
-  long num_result = 0;
-  num_result = Utils::decimal_from_string(result.to_string()); //TODO: Is this sensible? Probably not.
+  double num_result = Conversions::get_double_for_gda_value_numeric(result); 
 
 
   //Increment the next_value:

Modified: trunk/glom/libglom/data_structure/glomconversions.cc
==============================================================================
--- trunk/glom/libglom/data_structure/glomconversions.cc	(original)
+++ trunk/glom/libglom/data_structure/glomconversions.cc	Sat Mar  8 21:54:46 2008
@@ -169,6 +169,29 @@
   return get_text_for_gda_value(glom_type, value, std::locale("") /* the user's current locale */, numeric_format); //Get the current locale.
 }
 
+double Conversions::get_double_for_gda_value_numeric(const Gnome::Gda::Value& value)
+{
+  if(value.get_value_type() != GDA_TYPE_NUMERIC)
+  {
+    std::cerr << "Conversions::get_double_for_gda_value_numeric(): expected NUMERIC but GdaValue type is: " << g_type_name(value.get_value_type()) << std::endl;
+    return 0;
+  }
+
+  const GdaNumeric* gda_numeric = value.get_numeric();
+  std::string text_in_c_locale;
+  if(gda_numeric && gda_numeric->number) //A char* - I assume that it formatted as per the C locale. murrayc. TODO: Do we need to look at the other fields?
+    text_in_c_locale = gda_numeric->number; //What formatting does this use?
+
+  //Get an actual numeric value, so we can get a locale-specific text representation:
+  std::stringstream the_stream;
+  the_stream.imbue( std::locale::classic() ); //The C locale.
+  the_stream.str(text_in_c_locale); //Avoid using << because Glib::ustring does implicit character conversion with that.
+
+  double number = 0;
+  the_stream >> number;
+  return number;
+}
+
 Glib::ustring Conversions::get_text_for_gda_value(Field::glom_field_type glom_type, const Gnome::Gda::Value& value, const std::locale& locale, const NumericFormat& numeric_format, bool iso_format)
 {
   if(value.is_null()) //The type can be null for any of the actual field types.
@@ -215,23 +238,11 @@
   {
     if(value.get_value_type() != GDA_TYPE_NUMERIC)
     {
-      //TODO: This happens for ID columns, because the TreeModel returns a gchararray GValue, in treeviewcolumn_on_cell_data(). Needs some investigation.
       std::cerr << "Conversions::get_text_for_gda_value(): glom field type is NUMERIC but GdaValue type is: " << g_type_name(value.get_value_type()) << std::endl;
       return value.to_string();
     }
 
-    const GdaNumeric* gda_numeric = value.get_numeric();
-    std::string text_in_c_locale;
-    if(gda_numeric && gda_numeric->number) //A char* - I assume that it formatted as per the C locale. murrayc. TODO: Do we need to look at the other fields?
-      text_in_c_locale = gda_numeric->number; //What formatting does this use?
-
-    //Get an actual numeric value, so we can get a locale-specific text representation:
-    std::stringstream the_stream;
-    the_stream.imbue( std::locale::classic() ); //The C locale.
-    the_stream.str(text_in_c_locale); //Avoid using << because Glib::ustinrg does implicit character conversion with that.
-
-    double number = 0;
-    the_stream >> number;
+    const double number = get_double_for_gda_value_numeric(value);
 
     //Get the locale-specific text representation, in the required format:
     std::stringstream another_stream;
@@ -330,7 +341,7 @@
 
 Gnome::Gda::Value Conversions::parse_value(Field::glom_field_type glom_type, const Glib::ustring& text, const NumericFormat& numeric_format, bool& success, bool iso_format)
 {
-  std::locale the_locale = (iso_format ? std::locale::classic() :  std::locale("") /* The user's current locale */);
+  const std::locale the_locale = (iso_format ? std::locale::classic() :  std::locale("") /* The user's current locale */);
 
   //Put a NULL in the database for empty dates, times, and numerics, because 0 would be an actual value.
   //But we use "" for strings, because the distinction between NULL and "" would not be clear to users.
@@ -390,7 +401,7 @@
 
     //Try to parse the inputted number, according to the current locale.
     std::stringstream the_stream;
-    the_stream.imbue( the_locale ); //Parse it as per the current locale.
+    the_stream.imbue( the_locale ); //Parse it as per the specified locale.
     the_stream.str(text_to_parse); //Avoid << because it does implicit character conversion (though that might not be a problem here. Not sure). murrayc
     double the_number = 0;
     the_stream >> the_number;  //TODO: Does this throw any exception if the text is an invalid time?

Modified: trunk/glom/libglom/data_structure/glomconversions.h
==============================================================================
--- trunk/glom/libglom/data_structure/glomconversions.h	(original)
+++ trunk/glom/libglom/data_structure/glomconversions.h	Sat Mar  8 21:54:46 2008
@@ -37,6 +37,10 @@
   Glib::ustring get_text_for_gda_value(Field::glom_field_type glom_type, const Gnome::Gda::Value& value, const NumericFormat& numeric_format = NumericFormat());
   Glib::ustring get_text_for_gda_value(Field::glom_field_type glom_type, const Gnome::Gda::Value& value, const std::locale& locale, const NumericFormat& numeric_format = NumericFormat(), bool iso_format = false);
 
+  //This is easier than using the GdaNumeric API,
+  //which normally involves text-to-number parsing.
+  double get_double_for_gda_value_numeric(const Gnome::Gda::Value& value);
+
   Glib::ustring format_time(const tm& tm_data);
   Glib::ustring format_time(const tm& tm_data, const std::locale& locale, bool iso_format = false);
   Glib::ustring format_date(const tm& tm_data);

Modified: trunk/glom/libglom/utils.cc
==============================================================================
--- trunk/glom/libglom/utils.cc	(original)
+++ trunk/glom/libglom/utils.cc	Sat Mar  8 21:54:46 2008
@@ -577,19 +577,6 @@
   return result;
 }
 
-guint Utils::decimal_from_string(const Glib::ustring& str)
-{
-  //TODO_Performance:
-
-  //Convert it to a numeric type:
-  std::stringstream stream;
-  stream << str;
-  guint id_numeric = 0;
-  stream >> id_numeric;
-
-  return id_numeric;
-}
-
 Glib::ustring Utils::title_from_string(const Glib::ustring& text)
 {
   Glib::ustring result;

Modified: trunk/glom/libglom/utils.h
==============================================================================
--- trunk/glom/libglom/utils.h	(original)
+++ trunk/glom/libglom/utils.h	Sat Mar  8 21:54:46 2008
@@ -80,8 +80,10 @@
 
 Glib::ustring create_local_image_uri(const Gnome::Gda::Value& value);
 
+/** Get a decimal text representation of the number,
+ * in the current locale.
+ */
 Glib::ustring string_from_decimal(guint decimal);
-guint decimal_from_string(const Glib::ustring& str);
 
 /** Create an appropriate title for an ID string.
  * For instance, date_of_birth would become Date Of Birth.

Modified: trunk/glom/mode_data/box_data.cc
==============================================================================
--- trunk/glom/mode_data/box_data.cc	(original)
+++ trunk/glom/mode_data/box_data.cc	Sat Mar  8 21:54:46 2008
@@ -451,7 +451,7 @@
     //if(value.is_number())
     //  result = value.get_integer();
     //else
-    result = decimal_from_string(value.to_string());
+    result = get_double_for_gda_value_numeric(value);
 
     ++result; 
   }

Modified: trunk/glom/utility_widgets/db_adddel/db_adddel.cc
==============================================================================
--- trunk/glom/utility_widgets/db_adddel/db_adddel.cc	(original)
+++ trunk/glom/utility_widgets/db_adddel/db_adddel.cc	Sat Mar  8 21:54:46 2008
@@ -1360,7 +1360,7 @@
   if(path_string.empty())
     return;
 
-  Gtk::TreePath path(path_string);
+  const Gtk::TreePath path(path_string);
 
   //Get the row from the path:
   Gtk::TreeModel::iterator iter = m_refListStore->get_iter(path);
@@ -1368,13 +1368,13 @@
   {
     Gtk::TreeModel::Row row = *iter;
 
-    int tree_model_column_index = data_model_column_index + get_count_hidden_system_columns();
+    const int tree_model_column_index = data_model_column_index + get_count_hidden_system_columns();
 
     Gnome::Gda::Value value_old;
     row.get_value(tree_model_column_index, value_old);
 
     const bool bValueOld = (value_old.get_value_type() == G_TYPE_BOOLEAN) && value_old.get_boolean();
-    bool bValueNew = !bValueOld;
+    const bool bValueNew = !bValueOld;
     Gnome::Gda::Value value_new;
     value_new.set(bValueNew);
     //Store the user's new value in the model:
@@ -1440,7 +1440,7 @@
   if(path_string.empty())
     return;
 
-  Gtk::TreePath path(path_string);
+  const Gtk::TreePath path(path_string);
 
   //Get the row from the path:
   Gtk::TreeModel::iterator iter = m_refListStore->get_iter(path);
@@ -1452,6 +1452,7 @@
 
     Gnome::Gda::Value valOld;
     row.get_value(treemodel_column_index, valOld);
+    //std::cout << "debug: valOld type=" << valOld.get_value_type() << std::endl;
 
     //Store the user's new text in the model:
     //row.set_value(treemodel_column_index, new_text);
@@ -1489,7 +1490,7 @@
       //Make sure that the entered data is suitable for this field type:
       bool success = false;
 
-      Gnome::Gda::Value value = Conversions::parse_value(field_type, new_text, item_field->get_formatting_used().m_numeric_format, success);
+      const Gnome::Gda::Value value = Conversions::parse_value(field_type, new_text, item_field->get_formatting_used().m_numeric_format, success);
       if(!success)
       {
           //Tell the user and offer to revert or try again:
@@ -1547,7 +1548,9 @@
       else
       {
         //Store the value in the model:
+        //std::cout << "debug: setting value: column=" << treemodel_column_index << ", type=" << value.get_value_type() << std::endl;
         row.set_value(treemodel_column_index, value);
+        //std::cout << "debug: after setting value" << std::endl;
       }
 
       if(!bIsAdd)
@@ -1556,7 +1559,7 @@
       //Fire appropriate signal:
       if(bIsAdd)
       {
-        //Signal that a new key was added"
+        //Signal that a new key was added:
         if(m_allow_add)
           m_signal_user_added.emit(row, model_column_index);
       }
@@ -1946,6 +1949,9 @@
 
 void DbAddDel::treeviewcolumn_on_cell_data(Gtk::CellRenderer* renderer, const Gtk::TreeModel::iterator& iter, int model_column_index, int data_model_column_index)
 {
+  //std::cout << "debug: DbAddDel::treeviewcolumn_on_cell_data()" << std::endl; 
+
+
   if(iter)
   {
     const DbAddDelColumnInfo& column_info = m_ColumnTypes[model_column_index];
@@ -1958,6 +1964,13 @@
       Gnome::Gda::Value value;
       treerow->get_value(col_real, value);
 
+      /*
+      GType debug_type = value.get_value_type();
+      std::cout << "  debug: DbAddDel::treeviewcolumn_on_cell_data(): GdaValue from TreeModel::get_value(): GType=" << debug_type << std::endl;
+      if(debug_type)
+         std::cout << "    GType name=\"" << g_type_name(debug_type) << "\"" << std::endl; 
+      */
+
       switch(field->get_glom_type())
       {
         case(Field::TYPE_BOOLEAN):
@@ -1992,7 +2005,7 @@
           Gtk::CellRendererText* pDerived = dynamic_cast<Gtk::CellRendererText*>(renderer);
           if(pDerived)
           {
-            //std::cout << "debug field name=" << field->get_name() << ", glom type=" << field->get_glom_type() << std::endl;
+            //std::cout << "  debug: DbAddDel::treeviewcolumn_on_cell_data(): field name=" << field->get_name() << ", glom type=" << field->get_glom_type() << std::endl;
             const Glib::ustring text = Conversions::get_text_for_gda_value(field->get_glom_type(), value, field->get_formatting_used().m_numeric_format);
             //g_assert(text != "NULL");
             g_object_set(pDerived->gobj(), "text", text.c_str(), (gpointer)NULL);

Modified: trunk/glom/utility_widgets/db_adddel/glom_db_treemodel.cc
==============================================================================
--- trunk/glom/utility_widgets/db_adddel/glom_db_treemodel.cc	(original)
+++ trunk/glom/utility_widgets/db_adddel/glom_db_treemodel.cc	Sat Mar  8 21:54:46 2008
@@ -251,8 +251,14 @@
     std::cout << "1000" << std::endl;  
   }
 
-  if(!m_values_retrieved)
+  if(m_values_retrieved)
   {
+     //std::cout << "debug: DbTreeModelRow::fill_values_if_necessary(): already retrieved" << std::endl;
+  }
+  else
+  {
+     //std::cout << "debug: DbTreeModelRow::fill_values_if_necessary(): retrieving" << std::endl;
+  
     if((row < (int)model.m_data_model_rows_count) && model.m_gda_datamodel)
     {
       Glib::RefPtr<Gnome::Gda::DataModelIter> iter = model.m_gda_datamodel->create_iter();
@@ -265,6 +271,7 @@
         {
           Glib::RefPtr<Gnome::Gda::Parameter> param = iter->get_param_for_column(i);
           m_db_values[i] = param->get_value();
+          //std::cout << "  debug: col=" << i << ", GType=" << m_db_values[i].get_value_type() << std::endl;
         }
 
         Glib::RefPtr<Gnome::Gda::Parameter> param = iter->get_param_for_column(model.m_column_index_key);
@@ -279,14 +286,28 @@
       //g_warning("DbTreeModelRow::fill_values_if_necessary(): Non-db row.");
       if(m_extra)
       {
+        //std::cout << "  debug: DbTreeModelRow::fill_values_if_necessary(): using default value" << std::endl;
+  
         //It is an extra row, added with append().
-        //Use the default values.
       }
       else if(!m_removed)
       {
         //It must be the last blank placeholder row.
         //m_placeholder = true;
       }
+
+      //Create default values, if necessary, of the correct types:
+      //Examine the columns in the returned DataModel:
+      for(guint col = 0; col < model.m_data_model_columns_count; ++col)
+      {
+        if(m_db_values.find(col) == m_db_values.end()) //If there is not already a value in the map for this column.
+        {
+          Glib::RefPtr<Gnome::Gda::Column> column = model.m_gda_datamodel->describe_column(col);
+          Gnome::Gda::Value value;
+          value.init(column->get_g_type());
+          m_db_values[col] = value;
+        }
+      }
     }
 
   }
@@ -297,6 +318,23 @@
 void DbTreeModelRow::set_value(DbTreeModel& model, int column, int row, const DbValue& value)
 {
   fill_values_if_necessary(model, row);
+
+  //Check that the value has the correct type:
+  /*
+  Glib::RefPtr<const Gnome::Gda::Column> gdacolumn = model.m_gda_datamodel->describe_column(column);
+  const GType debug_type_in = value.get_value_type();
+  const GType debug_type_expected = gdacolumn->get_g_type();
+  if(debug_type_in != debug_type_expected)
+  {
+    std::cout << "debug: DbTreeModelRow::set_value(): expected GType=" << debug_type_expected << ", but received GType=" << debug_type_in << std::endl;
+    if(debug_type_expected)
+      std::cout << "  expected GType name=\"" << g_type_name(debug_type_expected) << "\"" << std::endl;
+
+    if(debug_type_in)
+      std::cout << "  received GType name=\"" << g_type_name(debug_type_in) << "\"" << std::endl;
+  }
+  */
+
   m_db_values[column] = value;
 }
 
@@ -309,7 +347,10 @@
   if(iterFind != m_db_values.end())
     return iterFind->second;
   else
+  {
+    std::cout << "debug: DbTreeModelRow::get_value(): column not found." << std::endl;
     return DbValue();
+  }
 }
 
 DbTreeModel::GlueItem::GlueItem(const DbTreeModel::type_datamodel_iter& row_iter)
@@ -519,6 +560,15 @@
       params->add_parameter("ITER_MODEL_ONLY", value);
 
       m_gda_datamodel = m_connection->get_gda_connection()->execute_select_command(sql_query, params);
+
+      //Examine the columns in the returned DataModel:
+      /*
+      for(int col = 0; col < m_gda_datamodel->get_n_columns(); ++col)
+      {
+        Glib::RefPtr<Gnome::Gda::Column> column = m_gda_datamodel->describe_column(col);
+        std::cout << "  debug: column index=" << col << ", name=" << column->get_name() << ", type=" << g_type_name(column->get_g_type()) << std::endl;
+      }
+      */
     }
     catch(const Glib::Exception& ex)
     {
@@ -597,11 +647,20 @@
 
 void DbTreeModel::get_value_vfunc(const TreeModel::iterator& iter, int column, Glib::ValueBase& value) const
 {
+  //std::cout << "debug: DbTreeModel::get_value_vfunc(): column=" << column << std::endl;
+
   if(check_treeiter_validity(iter))
   {
+    //std::cout << "  debug: DbTreeModel::get_value_vfunc() 1" << std::endl;
+
     if(column < (int)m_columns_count)
     {
+       //std::cout << "  debug: DbTreeModel::get_value_vfunc() 1.1" << std::endl;
+
       //Get the correct ValueType from the Gtk::TreeModel::Column's type, so we don't have to repeat it here:
+      //(This would be a custom boxed type for our Gda::Value (stored inside the TreeModel's Glib::Value just as an int or char* would be stored in it.)
+      //std::cout << "  debug: DbTreeModel::get_value_vfunc(): column=" << column << ", value type=" << g_type_name(typeModelColumn::ValueType::value_type()) << std::endl;
+
       typeModelColumn::ValueType value_specific;
       value_specific.init( typeModelColumn::ValueType::value_type() );  //TODO: Is there any way to avoid this step?
 
@@ -614,6 +673,8 @@
       const unsigned int internal_rows_count = get_internal_rows_count();
       if( dataRowIter < internal_rows_count) //!= m_rows.end())
       {
+         //std::cout << "  debug: DbTreeModel::get_value_vfunc() 1.2" << std::endl;
+
         //const typeRow& dataRow = *dataRowIter;
 
         //g_warning("DbTreeModel::get_value_vfunc 1: column=%d, row=%d", column, dataRowIter);
@@ -624,8 +685,12 @@
         const int column_sql = column;
         if(column_sql < (int)m_columns_count) //TODO_Performance: Remove the checks.
         {
+           //std::cout << "  debug: DbTreeModel::get_value_vfunc() 1.3" << std::endl;
+
           if( !(dataRowIter < (internal_rows_count - 1)))
           {
+              //std::cout << "  debug: DbTreeModel::get_value_vfunc() 1.4" << std::endl;
+
              //std::cout << "DbTreeModel::get_value_vfunc: row " << dataRowIter << " is placeholder" << std::endl;
 
              //If it's after the database rows then it must be a placeholder row.
@@ -634,13 +699,41 @@
           }
           else
           {
+            /*
+            std::cout << "  debug: DbTreeModel::get_value_vfunc() 1.4b: column_sql=" << column_sql << std::endl;
+            //Examine the columns in the returned DataModel:
+            for(int col = 0; col < m_gda_datamodel->get_n_columns(); ++col)
+            {
+              Glib::RefPtr<Gnome::Gda::Column> column = m_gda_datamodel->describe_column(col);
+              std::cout << "    debug: column index=" << col << ", name=" << column->get_name() << ", type=" << g_type_name(column->get_g_type()) << std::endl;
+            }
+            */
+
+            //Double check that the result has the correct type:
+            //Glib::RefPtr<const Gnome::Gda::Column> column = m_gda_datamodel->describe_column(column_sql);
+            //const GType gtype_expected = column->get_g_type();
+
             result = row_details.get_value(const_cast<DbTreeModel&>(*this), column_sql, dataRowIter); //m_gda_datamodel->get_value_at(column_sql, dataRowIter); //dataRow.m_db_values[column];
+  
+            /*
+            if((result.get_value_type() != 0) && (result.get_value_type() != gtype_expected))
+            {
+              std::cout << "  debug: DbTreeModel::get_value_vfunc(): column_sql=" << column_sql << ", describe_column() returned GType: " << gtype_expected << " but get_value() returned GType: " << result.get_value_type() << std::endl;
+            }
+            */
           }
         }
         else
           g_warning("DbTreeModel::get_value_vfunc: column out of bounds: sql_col=%d, max=%d.", column_sql, m_columns_count);
 
 
+        /*
+        GType debug_type = result.get_value_type();
+        std::cout << "  debug: DbTreeModel::get_value_vfunc(): result value type: GType=" << debug_type << std::endl;
+        if(debug_type)
+          std::cout << "    GType name=\"" << g_type_name(debug_type) << "\"" << std::endl; 
+        */
+
         value_specific.set(result); //The compiler would complain if the type was wrong.
         value.init( Glib::Value< DbValue >::value_type() ); //TODO: Is there any way to avoid this step? Can't it copy the type as well as the value?
         value = value_specific;



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