[glom] TreeModelDbWithExtraText: Fix the use of Glib::Value.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] TreeModelDbWithExtraText: Fix the use of Glib::Value.
- Date: Mon, 4 Oct 2010 17:31:40 +0000 (UTC)
commit 18534200b665b470c9355b6495f3d42d966f5f3f
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Oct 4 16:27:23 2010 +0200
TreeModelDbWithExtraText: Fix the use of Glib::Value.
* glom/mode_data/datawidget/treemodel_db.cc: Intialize m_column_index_key
to -1 so we can really check that it is uninitialized.
* glom/mode_data/datawidget/treemodel_db_withextratext.cc: get_value_vfunc():
Initialize both value instances and always set the output value.
ChangeLog | 9 ++++
glom/libglom/utils.cc | 2 +-
glom/libglom/utils.h | 2 +-
glom/mode_data/datawidget/comboentry.cc | 41 +++++---------------
glom/mode_data/datawidget/treemodel_db.cc | 1 +
.../datawidget/treemodel_db_withextratext.cc | 22 ++++++++---
6 files changed, 38 insertions(+), 39 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9e9dd87..201e3ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,15 @@
2010-10-04 Murray Cumming <murrayc murrayc com>
+ TreeModelDbWithExtraText: Fix the use of Glib::Value.
+
+ * glom/mode_data/datawidget/treemodel_db.cc: Intialize m_column_index_key
+ to -1 so we can really check that it is uninitialized.
+ * glom/mode_data/datawidget/treemodel_db_withextratext.cc: get_value_vfunc():
+ Initialize both value instances and always set the output value.
+
+2010-10-04 Murray Cumming <murrayc murrayc com>
+
ComboEntry: Fix silly typo.
* glom/mode_data/datawidget/comboentry.cc: Remove left-over for() loop.
diff --git a/glom/libglom/utils.cc b/glom/libglom/utils.cc
index 812f687..baec8e0 100644
--- a/glom/libglom/utils.cc
+++ b/glom/libglom/utils.cc
@@ -132,7 +132,7 @@ Glib::ustring Utils::trim_whitespace(const Glib::ustring& text)
return result;
}
-Glib::ustring Utils::string_replace(const Glib::ustring& src, const Glib::ustring search_for, const Glib::ustring& replace_with)
+Glib::ustring Utils::string_replace(const Glib::ustring& src, const Glib::ustring& search_for, const Glib::ustring& replace_with)
{
if(search_for.empty())
{
diff --git a/glom/libglom/utils.h b/glom/libglom/utils.h
index 4415e08..3083ec1 100644
--- a/glom/libglom/utils.h
+++ b/glom/libglom/utils.h
@@ -42,7 +42,7 @@ namespace Utils
Glib::ustring trim_whitespace(const Glib::ustring& text);
-Glib::ustring string_replace(const Glib::ustring& src, const Glib::ustring search_for, const Glib::ustring& replace_with);
+Glib::ustring string_replace(const Glib::ustring& src, const Glib::ustring& search_for, const Glib::ustring& replace_with);
//typedef Base_DB::type_vecLayoutFields type_vecLayoutFields;
typedef std::vector< sharedptr<LayoutItem_Field> > type_vecLayoutFields;
diff --git a/glom/mode_data/datawidget/comboentry.cc b/glom/mode_data/datawidget/comboentry.cc
index 4968bb2..c043b72 100644
--- a/glom/mode_data/datawidget/comboentry.cc
+++ b/glom/mode_data/datawidget/comboentry.cc
@@ -73,37 +73,11 @@ const Gtk::Entry* ComboEntry::get_entry() const
void ComboEntry::init()
{
-#ifdef GLOM_ENABLE_CLIENT_ONLY
- //Maemo:
- set_selector(m_maemo_selector);
-
- //We don't use append_text_column(), because we want to specify no expand.
- //Glib::RefPtr<Hildon::TouchSelectorColumn> column =
- // m_maemo_selector.append_text_column(m_refModel);
- // Only in the latest hildonmm: Glib::RefPtr<Hildon::TouchSelectorColumn> column =
- // m_maemo_selector.append_column(m_refModel);
- Glib::RefPtr<Hildon::TouchSelectorColumn> column = Glib::wrap(hildon_touch_selector_append_column(
- HILDON_TOUCH_SELECTOR(m_maemo_selector.gobj()), GTK_TREE_MODEL(Glib::unwrap(m_refModel)), 0, static_cast<char*>(0)), true);
-
- column->pack_start(m_Columns.m_col_first, false);
- //Only in the latest hildonmm: column->set_text_column(m_Columns.m_col_first);
- column->set_property("text_column", 0);
-
- //Only in the latest hildonmm: m_maemo_selector->set_text_column(m_Columns.m_col_first);
- m_maemo_selector.set_text_column(0);
-
-
- //m_maemo_selector.set_model(0, m_refModel);
- //m_maemo_selector.set_text_column(0);
-#endif
-
//We use connect(slot, false) to connect before the default signal handler, because the default signal handler prevents _further_ handling.
-#ifndef GLOM_ENABLE_CLIENT_ONLY
- get_entry()->signal_button_press_event().connect(sigc::mem_fun(*this, &ComboEntry::on_entry_button_press_event), false);
-#endif // GLOM_ENABLE_CLIENT_ONLY
-
- get_entry()->signal_focus_out_event().connect(sigc::mem_fun(*this, &ComboEntry::on_entry_focus_out_event), false);
- get_entry()->signal_activate().connect(sigc::mem_fun(*this, &ComboEntry::on_entry_activate));
+ Gtk::Entry* entry = get_entry();
+ entry->signal_button_press_event().connect(sigc::mem_fun(*this, &ComboEntry::on_entry_button_press_event), false);
+ entry->signal_focus_out_event().connect(sigc::mem_fun(*this, &ComboEntry::on_entry_focus_out_event), false);
+ entry->signal_activate().connect(sigc::mem_fun(*this, &ComboEntry::on_entry_activate));
}
ComboEntry::~ComboEntry()
@@ -176,7 +150,12 @@ void ComboEntry::set_choices_related(const Document* document, const sharedptr<c
Glib::RefPtr<DbTreeModelWithExtraText> model_db =
Glib::RefPtr<DbTreeModelWithExtraText>::cast_dynamic(model);
if(model_db)
- set_text_column(model_db->get_text_column());
+ {
+ const int text_col = model_db->get_text_column();
+ //const GType debug_type = model_db->get_column_type(text_col);
+ //std::cout << "DEBUG: text_col=" << text_col << ", debug_type=" << g_type_name(debug_type) << std::endl;
+ set_text_column(text_col);
+ }
else
{
std::cerr << G_STRFUNC << ": The model is not a DbTreeModelWithExtraText." << std::endl;
diff --git a/glom/mode_data/datawidget/treemodel_db.cc b/glom/mode_data/datawidget/treemodel_db.cc
index d86c0bc..d2b550d 100644
--- a/glom/mode_data/datawidget/treemodel_db.cc
+++ b/glom/mode_data/datawidget/treemodel_db.cc
@@ -171,6 +171,7 @@ DbTreeModel::DbTreeModel(const FoundSet& found_set, const type_vec_const_layout_
Glib::Object(), //The custom GType is actually registered here.
m_columns_count(0),
m_found_set(found_set),
+ m_column_index_key(-1), //means it's not set yet.
m_data_model_rows_count(0),
m_data_model_columns_count(0),
m_count_extra_rows(0),
diff --git a/glom/mode_data/datawidget/treemodel_db_withextratext.cc b/glom/mode_data/datawidget/treemodel_db_withextratext.cc
index 5cd7c0c..e59bb67 100644
--- a/glom/mode_data/datawidget/treemodel_db_withextratext.cc
+++ b/glom/mode_data/datawidget/treemodel_db_withextratext.cc
@@ -38,8 +38,12 @@ DbTreeModelWithExtraText::DbTreeModelWithExtraText(const FoundSet& found_set, co
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())
+ if(m_column_index_key != -1 && (guint)m_column_index_key < fields_shown.size())
m_item_key = fields_shown[m_column_index_key];
+ else
+ {
+ std::cerr << G_STRFUNC << ": m_column_index_key is not set, or is out of range. m_column_index_key=" << m_column_index_key << ", size=" << fields_shown.size() << std::endl;
+ }
}
DbTreeModelWithExtraText::~DbTreeModelWithExtraText()
@@ -76,21 +80,27 @@ GType DbTreeModelWithExtraText::get_column_type_vfunc(int index) const
void DbTreeModelWithExtraText::get_value_vfunc(const TreeModel::iterator& iter, int column, Glib::ValueBase& value) const
{
+ //std::cout << G_STRFUNC << ": Debug: column=" << column << std::endl;
if(column == get_text_column())
{
+ Glib::ustring text;
+
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);
+ else
+ {
+ const DbValue dbvalue = get_key_value(iter);
+ 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.init( type_value_string::value_type() ); //TODO: Is there any way to avoid this step?
value = value_specific;
}
else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]