[glom/maemo5] Added missing files.



commit 750a6202f0da3e0b377be86ac7f44ed4424c4be1
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Sep 18 22:34:15 2009 +0200

    Added missing files.

 ChangeLog                                   |    1 -
 glom/navigation/maemo/pickerbutton_table.cc |  119 +++++++++++++++++++++++++++
 glom/navigation/maemo/pickerbutton_table.h  |   75 +++++++++++++++++
 3 files changed, 194 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index dce179e..e569544 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -156,7 +156,6 @@ Refactoring Dialog_Import_CSV: created testcase for the CsvParser's signal emiss
 	 in the exception code path. That makes no difference for postgres but
 	 is needed for sqlite.
 
-
 2009-09-07  Murray Cumming  <murrayc murrayc com>
 
 	* glom/box_reports.[h|cc]:
diff --git a/glom/navigation/maemo/pickerbutton_table.cc b/glom/navigation/maemo/pickerbutton_table.cc
new file mode 100644
index 0000000..0ee7ad1
--- /dev/null
+++ b/glom/navigation/maemo/pickerbutton_table.cc
@@ -0,0 +1,119 @@
+/* Glom
+ *
+ * Copyright (C) 2009 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 <glom/navigation/maemo/pickerbutton_table.h>
+#include <glibmm/i18n.h>
+
+namespace Glom
+{
+
+PickerButton_Table::PickerButton_Table()
+{
+  m_list_store = Gtk::ListStore::create(m_model_columns);
+
+  //If this uses the 0th model column, then that should be documented in hildon.
+  Glib::RefPtr<Hildon::TouchSelectorColumn> title_column =
+    m_touchselector.append_text_column(m_list_store);
+  title_column->set_property("text-column", 0); // TODO: Add a TextSelectorColumn::set_text_column() method?
+  
+  set_selector(m_touchselector);
+  set_title(_("Table"));
+}
+
+PickerButton_Table::~PickerButton_Table()
+{
+}
+
+void PickerButton_Table::load_from_document()
+{
+  fill_from_database();
+}
+
+
+bool PickerButton_Table::fill_from_database()
+{
+  Document* document = get_document();
+  if(!document)
+    return false;
+
+  //Fill the model:
+  m_list_store->clear();
+  Document::type_listTableInfo listTablesDocument = document->get_tables();
+
+  const type_vec_strings vecTables = get_table_names_from_database();
+  for(type_vec_strings::const_iterator iter = vecTables.begin(); iter != vecTables.end(); iter++)
+  {
+    const Glib::ustring strName = *iter;
+    sharedptr<TableInfo> table_info;
+
+    Document::type_listTableInfo::const_iterator iterFind = 
+      std::find_if(listTablesDocument.begin(), listTablesDocument.end(), predicate_FieldHasName<TableInfo>(strName));
+    if(iterFind == listTablesDocument.end())
+      continue;
+    
+    //Check whether it should be hidden:
+    table_info = *iterFind;
+    if(!table_info || table_info->m_hidden)
+      continue;
+    
+    //Add to the model:
+    Gtk::TreeModel::iterator model_iter = m_list_store->append();
+    Gtk::TreeModel::Row row = *model_iter;
+    row[m_model_columns.m_name] = table_info->get_name();
+    row[m_model_columns.m_title] = table_info->get_title_or_name();
+  }
+
+  return true;
+}
+
+
+void PickerButton_Table::set_table_name(const Glib::ustring& table_name)
+{
+  for(Gtk::TreeModel::iterator iter = m_list_store->children().begin(); iter != m_list_store->children().end(); ++iter)
+  {
+    const Glib::ustring& this_text = (*iter)[m_model_columns.m_name];
+
+    if(this_text == table_name)
+    {
+      //TODO: set_selected(iter);
+      return; //success
+    }
+  }
+
+  //Not found, so mark it as blank:
+  std::cerr << "PickerButton_Table::set_table_name(): table_name not found in list: " << table_name << std::endl;
+  //TODO: unset_active();
+}
+
+Glib::ustring PickerButton_Table::get_table_name() const
+{
+  //TODO: Check if this should be const:
+  Hildon::TouchSelector* unconst_selector = const_cast<Hildon::TouchSelector*>(&m_touchselector);
+  Gtk::TreeModel::iterator iter = unconst_selector->get_selected(0);
+  if(!iter)
+    return Glib::ustring();
+
+  Gtk::TreeModel::Row row = *iter;
+  const Glib::ustring name = row[m_model_columns.m_name];
+  return name;
+}
+
+} //namespace Glom
+
diff --git a/glom/navigation/maemo/pickerbutton_table.h b/glom/navigation/maemo/pickerbutton_table.h
new file mode 100644
index 0000000..5b70719
--- /dev/null
+++ b/glom/navigation/maemo/pickerbutton_table.h
@@ -0,0 +1,75 @@
+/* Glom
+ *
+ * Copyright (C) 2009 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_PICKERBUTTON_TABLE_H
+#define GLOM_PICKERBUTTON_TABLE_H
+
+#include <hildonmm/picker-button.h>
+#include <glom/base_db.h>
+
+namespace Glom
+{
+
+/** This widget offers a list of tables in the database,
+  * allowing the user to select a table.
+  */
+class PickerButton_Table
+: public Hildon::PickerButton,
+  public Base_DB
+{
+public:
+  PickerButton_Table();
+  virtual ~PickerButton_Table();
+
+  void set_table_name(const Glib::ustring& table_name);
+  Glib::ustring get_table_name() const;
+
+  virtual bool fill_from_database(); //override
+
+private:
+  virtual void load_from_document(); //override.
+
+  //Signal handlers:
+ 
+  guint m_colTableName;
+  guint m_colTitle;
+
+  Hildon::TouchSelector m_touchselector;
+
+  //Tree model columns:
+  //These columns are used by the model that is created by the default constructor
+  class ModelColumns : public Gtk::TreeModel::ColumnRecord
+  {
+  public:
+    ModelColumns()
+    { add(m_title); add(m_name); }
+
+    Gtk::TreeModelColumn<Glib::ustring> m_title;
+    Gtk::TreeModelColumn<Glib::ustring> m_name;
+  };
+
+  ModelColumns m_model_columns;
+  Glib::RefPtr<Gtk::ListStore> m_list_store;
+};
+
+} //namespace Glom
+
+#endif //GLOM_PICKERBUTTON_TABLE_H
+



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