glom r1733 - in trunk: . glom glom/libglom/document glom/mode_design/users



Author: murrayc
Date: Fri Nov 21 15:56:29 2008
New Revision: 1733
URL: http://svn.gnome.org/viewvc/glom?rev=1733&view=rev

Log:
2008-11-21  Murray Cumming  <murrayc murrayc com>

* glom/frame_glom.cc: on_menu_file_export(): Correct the order of 
parameters to Document_Glom::get_data_layout_groups_plus_new_fields() 
so we actually get a sensible default set of fields instead of nothing.
This was only a problem since the addition of the active-layout feature 
on trunk.

Modified:
   trunk/ChangeLog
   trunk/glom/dialog_import_csv.cc
   trunk/glom/frame_glom.cc
   trunk/glom/libglom/document/document_glom.cc
   trunk/glom/mode_design/users/dialog_groups_list.cc

Modified: trunk/glom/dialog_import_csv.cc
==============================================================================
--- trunk/glom/dialog_import_csv.cc	(original)
+++ trunk/glom/dialog_import_csv.cc	Fri Nov 21 15:56:29 2008
@@ -289,11 +289,11 @@
   else
   {
     // Make the relevant widgets sensitive. We will make them insensitive
-    // again when a (nonrecoverable) error occurs.
-    m_sample_view->set_sensitive(true);
-    m_encoding_combo->set_sensitive(true);
-    m_first_line_as_title->set_sensitive(true);
-    m_sample_rows->set_sensitive(true);
+    // again when a (non-recoverable) error occurs.
+    m_sample_view->set_sensitive();
+    m_encoding_combo->set_sensitive();
+    m_first_line_as_title->set_sensitive();
+    m_sample_rows->set_sensitive();
 
     set_title(_("Import From CSV File"));
     m_target_table->set_markup("<b>" + Glib::Markup::escape_text(into_table) + "</b>");
@@ -305,10 +305,14 @@
     Document_Glom::type_vecFields fields(document->get_table_fields(into_table));
     for(Document_Glom::type_vecFields::const_iterator iter = fields.begin(); iter != fields.end(); ++ iter)
     {
+      sharedptr<Field> field = *iter;
+      if(!field)
+        continue;
+
       // Don't allow the primary key to be selected when it is an auto
       // increment key, since the value for the primary key is chosen
       // automatically anyway.
-      if(!(*iter)->get_primary_key() || !(*iter)->get_auto_increment())
+      if(!field->get_primary_key() || !field->get_auto_increment())
       {
         Gtk::TreeModel::iterator tree_iter = m_field_model->append();
         (*tree_iter)[m_field_columns.m_col_field] = *iter;
@@ -319,7 +323,7 @@
     m_file = Gio::File::create_for_uri(uri);
     m_file->read_async(sigc::mem_fun(*this, &Dialog_Import_CSV::on_file_read));
 
-    // Query the display name of the file to set in the title
+    // Query the display name of the file to set in the title:
     m_file->query_info_async(sigc::mem_fun(*this, &Dialog_Import_CSV::on_query_info), G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
 
     set_state(PARSING);
@@ -330,6 +334,7 @@
 {
   if(m_first_line_as_title->get_active() && m_rows.size() > 1)
     return m_rows.size() - 1;
+
   return m_rows.size();
 }
 
@@ -345,7 +350,9 @@
 
 const Glib::ustring& Dialog_Import_CSV::get_data(guint row, guint col)
 {
-  if(m_first_line_as_title->get_active()) ++ row;
+  if(m_first_line_as_title->get_active())
+    ++row;
+
   return m_rows[row][col];
 }
 
@@ -379,15 +386,15 @@
 void Dialog_Import_CSV::show_error_dialog(const Glib::ustring& primary, const Glib::ustring& secondary)
 {
   Gtk::MessageDialog dialog(*this, primary, false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK);
-  dialog.set_title("Error Importing CSV File");
+  dialog.set_title(_("Error Importing CSV File"));
   dialog.set_secondary_text(secondary);
   dialog.run();
 }
 
 void Dialog_Import_CSV::encoding_data_func(const Gtk::TreeModel::iterator& iter, Gtk::CellRendererText& renderer)
 {
-  Glib::ustring name = (*iter)[m_encoding_columns.m_col_name];
-  Glib::ustring charset = (*iter)[m_encoding_columns.m_col_charset];
+  const Glib::ustring name = (*iter)[m_encoding_columns.m_col_name];
+  const Glib::ustring charset = (*iter)[m_encoding_columns.m_col_charset];
 
   renderer.set_property("text", encoding_display(name, charset));
 }
@@ -432,19 +439,22 @@
 {
   try
   {
-    gssize size = m_stream->read_finish(result);
+    const gssize size = m_stream->read_finish(result);
     m_raw.insert(m_raw.end(), m_buffer->buf, m_buffer->buf + size);
 
     // If the parser already exists, but it is currently not parsing because it waits
     // for new input, then continue parsing.
     if(m_parser.get() && !m_parser->idle_connection.connected())
+    {
       m_parser->idle_connection = Glib::signal_idle().connect(sigc::mem_fun(*this, &Dialog_Import_CSV::on_idle_parse));
-
+    }
     // If the parser does not exist yet, then create a new parser, except when the
-    // current encoding does not work for the file in which case the user first
-    // has to choose another encoding.
+    // current encoding does not work for the file ,in which case the user must first
+    // choose another encoding.
     else if(!m_parser.get() && m_state != ENCODING_ERROR)
+    {
       begin_parse();
+    }
 
     if(size > 0)
     {
@@ -535,6 +545,7 @@
         iter = m_sample_model->append();
       else
         iter = m_sample_model->insert(iter);
+
       (*iter)[m_sample_columns.m_col_row] = 0;
 
       // Remove last row if we hit the limit
@@ -574,9 +585,10 @@
   {
     // Find index of first row to add
     guint row_index = current_sample_rows;
-    if(m_first_line_as_title->get_active()) ++ row_index;
+    if(m_first_line_as_title->get_active())
+      ++row_index;
 
-    for(guint i = current_sample_rows; i < new_sample_rows && row_index < m_rows.size(); ++ i, ++ row_index)
+    for(guint i = current_sample_rows; i < new_sample_rows && row_index < m_rows.size(); ++i, ++row_index)
     {
       Gtk::TreeModel::iterator iter = m_sample_model->append();
       (*iter)[m_sample_columns.m_col_row] = row_index;
@@ -587,7 +599,7 @@
 Glib::ustring Dialog_Import_CSV::get_current_encoding() const
 {
   Gtk::TreeModel::iterator iter = m_encoding_combo->get_active();
-  Glib::ustring encoding = (*iter)[m_encoding_columns.m_col_charset];
+  const Glib::ustring encoding = (*iter)[m_encoding_columns.m_col_charset];
 
   if(encoding.empty())
   {

Modified: trunk/glom/frame_glom.cc
==============================================================================
--- trunk/glom/frame_glom.cc	(original)
+++ trunk/glom/frame_glom.cc	Fri Nov 21 15:56:29 2008
@@ -516,7 +516,7 @@
   if(!document)
     return;
 
-  Document_Glom::type_list_layout_groups mapGroupSequence = document->get_data_layout_groups_plus_new_fields("details", document->get_active_layout_platform(), m_table_name);
+  Document_Glom::type_list_layout_groups mapGroupSequence = document->get_data_layout_groups_plus_new_fields("details", m_table_name, document->get_active_layout_platform());
 
   Gtk::Window* pWindowApp = get_app_window();
   g_assert(pWindowApp);
@@ -543,6 +543,7 @@
     return;
 
   dialog.get_layout_groups(mapGroupSequence);
+  std::cout << "DEBUG 0: mapGroupSequence.size()=" << mapGroupSequence.size() << std::endl;
 
   //const int index_primary_key = fieldsSequence.size() - 1;
 
@@ -563,7 +564,10 @@
   type_vecLayoutFields fieldsSequence = get_table_fields_to_show_for_sequence(found_set.m_table_name, sequence);
 
   if(fieldsSequence.empty())
+  {
+    std::cerr << "Glom: Frame_Glom::export_data_to_string(): No fields in sequence." << std::endl;
     return;
+  }
 
   const Glib::ustring query = Utils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsSequence, found_set.m_where_clause, found_set.m_extra_join, found_set.m_sort_clause, found_set.m_extra_group_by);
 
@@ -612,10 +616,13 @@
   type_vecLayoutFields fieldsSequence = get_table_fields_to_show_for_sequence(found_set.m_table_name, sequence);
 
   if(fieldsSequence.empty())
+  {
+    std::cerr << "Glom: Frame_Glom::export_data_to_stream(): No fields in sequence." << std::endl;
     return;
+  }
 
   const Glib::ustring query = Utils::build_sql_select_with_where_clause(found_set.m_table_name, fieldsSequence, found_set.m_where_clause, found_set.m_extra_join, found_set.m_sort_clause, found_set.m_extra_group_by);
-
+ 
   //TODO: Lock the database (prevent changes) during export.
   Glib::RefPtr<Gnome::Gda::DataModel> result = query_execute(query, get_app_window());
 
@@ -674,19 +681,20 @@
 
     if(file_chooser.run() == Gtk::RESPONSE_ACCEPT)
     {
+      file_chooser.hide();
+
       Dialog_Import_CSV* dialog = 0;
       Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(Utils::get_glade_file_path("glom.glade"), "dialog_import_csv");
       refXml->get_widget_derived("dialog_import_csv", dialog);
       add_view(dialog);
 
-      file_chooser.hide();
-
       dialog->import(file_chooser.get_uri(), m_table_name);
       while(Glom::Utils::dialog_run_with_help(dialog, "dialog_import_csv") == Gtk::RESPONSE_ACCEPT)
       {
         dialog->hide();
+
         Dialog_Import_CSV_Progress* progress_dialog = 0;
-      Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(Utils::get_glade_file_path("glom.glade"), "dialog_import_csv_progress");
+        Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(Utils::get_glade_file_path("glom.glade"), "dialog_import_csv_progress");
         refXml->get_widget_derived("dialog_import_csv_progress", progress_dialog);
         add_view(progress_dialog);
 
@@ -696,6 +704,7 @@
 
         remove_view(progress_dialog);
         delete progress_dialog;
+        progress_dialog = 0;
 
         // Force update from database so the newly added entries are shown
         show_table_refresh();

Modified: trunk/glom/libglom/document/document_glom.cc
==============================================================================
--- trunk/glom/libglom/document/document_glom.cc	(original)
+++ trunk/glom/libglom/document/document_glom.cc	Fri Nov 21 15:56:29 2008
@@ -1461,6 +1461,8 @@
 
 Document_Glom::type_list_layout_groups Document_Glom::get_data_layout_groups(const Glib::ustring& layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform) const
 {
+  //std::cout << "DEBUG: Document_Glom::get_data_layout_groups(): layout_name=" << layout_name << ", parent_table_name=" << parent_table_name << ", layout_platform=" << layout_platform << std::endl;
+
   type_tables::const_iterator iterFind = m_tables.find(parent_table_name);
   if(iterFind != m_tables.end())
   {
@@ -1493,7 +1495,7 @@
 
 void Document_Glom::set_data_layout_groups(const Glib::ustring& layout_name, const Glib::ustring& parent_table_name, const Glib::ustring& layout_platform, const type_list_layout_groups& groups)
 {
-  std::cout << "DEBUG: Document_Glom::set_data_layout_groups(): layout_name=" << layout_name << ", parent_table_name=" << parent_table_name << ", layout_platform=" << layout_platform << std::endl;
+  //std::cout << "DEBUG: Document_Glom::set_data_layout_groups(): layout_name=" << layout_name << ", parent_table_name=" << parent_table_name << ", layout_platform=" << layout_platform << std::endl;
   const Glib::ustring child_table_name = parent_table_name; //TODO: Remove this cruft.
 
   //g_warning("Document_Glom::set_data_layout_groups(): ADDING layout for table %s (child_table=%s), for layout %s", parent_table_name.c_str(), child_table_name.c_str(), layout_name.c_str());

Modified: trunk/glom/mode_design/users/dialog_groups_list.cc
==============================================================================
--- trunk/glom/mode_design/users/dialog_groups_list.cc	(original)
+++ trunk/glom/mode_design/users/dialog_groups_list.cc	Fri Nov 21 15:56:29 2008
@@ -129,7 +129,7 @@
     m_label_table_name->set_text(table_name);
     m_entry_table_title->set_text( document->get_table_title(table_name) );
 
-    Document_Glom::type_list_layout_groups mapGroups = document->get_data_layout_groups_plus_new_fields(layout, m_table_name);
+    Document_Glom::type_list_layout_groups mapGroups = document->get_data_layout_groups_plus_new_fields(layout, m_table_name, m_layout_platform);
 
     //If no information is stored in the document, then start with something:
 



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