[glom/gtkmm4v4: 30/37] gtkmm4: TreeModel_DB: Use const_iterator.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom/gtkmm4v4: 30/37] gtkmm4: TreeModel_DB: Use const_iterator.
- Date: Wed, 15 Mar 2017 14:56:29 +0000 (UTC)
commit 06522e46e8cad8582b9b41b83293d26eea711ab9
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Mar 15 11:25:07 2017 +0100
gtkmm4: TreeModel_DB: Use const_iterator.
glom/mode_data/datawidget/combo.cc | 3 ++-
glom/mode_data/datawidget/treemodel_db.cc | 20 ++++++++++++++++----
glom/mode_data/datawidget/treemodel_db.h | 17 +++++++++++++----
3 files changed, 31 insertions(+), 9 deletions(-)
---
diff --git a/glom/mode_data/datawidget/combo.cc b/glom/mode_data/datawidget/combo.cc
index b5d065e..6d8c705 100644
--- a/glom/mode_data/datawidget/combo.cc
+++ b/glom/mode_data/datawidget/combo.cc
@@ -246,7 +246,8 @@ void ComboGlom::set_value(const Gnome::Gda::Value& value)
if(this_value == value)
{
found = true;
- set_active(row);
+ const auto iter = row.get_iter();
+ set_active(iter);
break;
}
}
diff --git a/glom/mode_data/datawidget/treemodel_db.cc b/glom/mode_data/datawidget/treemodel_db.cc
index bc22748..a81729a 100644
--- a/glom/mode_data/datawidget/treemodel_db.cc
+++ b/glom/mode_data/datawidget/treemodel_db.cc
@@ -704,13 +704,13 @@ bool DbTreeModel::get_iter_vfunc(const Path& path, iterator& iter) const
return iter_nth_root_child_vfunc(path[0], iter);
}
-DbTreeModel::type_datamodel_row_index DbTreeModel::get_datamodel_row_index_from_tree_row_iter(const
iterator& iter) const
+DbTreeModel::type_datamodel_row_index DbTreeModel::get_datamodel_row_index_from_tree_row_iter(const
const_iterator& iter) const
{
return GPOINTER_TO_INT(iter.gobj()->user_data);
}
-bool DbTreeModel::check_treeiter_validity(const iterator& iter) const
+bool DbTreeModel::check_treeiter_validity(const const_iterator& iter) const
{
if(!(iter->get_model_gobject()))
return false;
@@ -848,7 +848,7 @@ void DbTreeModel::set_key_value(const TreeModel::iterator& iter, const DbValue&
}
}
-DbTreeModel::DbValue DbTreeModel::get_key_value(const TreeModel::iterator& iter) const
+DbTreeModel::DbValue DbTreeModel::get_key_value(const TreeModel::const_iterator& iter) const
{
if(check_treeiter_validity(iter))
{
@@ -867,7 +867,7 @@ DbTreeModel::DbValue DbTreeModel::get_key_value(const TreeModel::iterator& iter)
return DbValue();
}
-bool DbTreeModel::get_is_placeholder(const TreeModel::iterator& iter) const
+bool DbTreeModel::get_is_placeholder(const TreeModel::const_iterator& iter) const
{
//g_warning("DbTreeModel::g et_is_placeholder()");
if(check_treeiter_validity(iter))
@@ -904,6 +904,12 @@ bool DbTreeModel::row_was_removed(const type_datamodel_row_index& datamodel_row)
return false; //If it was never accessed before then it has never been removed.
}
+Gtk::TreeModel::const_iterator DbTreeModel::get_last_row() const
+{
+ auto non_const = const_cast<DbTreeModel*>(this);
+ return non_const->get_last_row();
+}
+
Gtk::TreeModel::iterator DbTreeModel::get_last_row()
{
iterator result;
@@ -933,6 +939,12 @@ Gtk::TreeModel::iterator DbTreeModel::get_last_row()
return result;
}
+Gtk::TreeModel::const_iterator DbTreeModel::get_placeholder_row() const
+{
+ auto non_const = const_cast<DbTreeModel*>(this);
+ return non_const->get_placeholder_row();
+}
+
Gtk::TreeModel::iterator DbTreeModel::get_placeholder_row()
{
iterator result;
diff --git a/glom/mode_data/datawidget/treemodel_db.h b/glom/mode_data/datawidget/treemodel_db.h
index 26537e9..09a1f9e 100644
--- a/glom/mode_data/datawidget/treemodel_db.h
+++ b/glom/mode_data/datawidget/treemodel_db.h
@@ -110,7 +110,7 @@ public:
typedef DbTreeModelRow::DbValue DbValue;
void set_is_not_placeholder(const TreeModel::iterator& iter);
- bool get_is_placeholder(const TreeModel::iterator& iter) const;
+ bool get_is_placeholder(const TreeModel::const_iterator& iter) const;
/** Set the value of the primary key for the specified row.
*/
@@ -118,17 +118,26 @@ public:
/** Get the value of the primary key for the specified row.
*/
- DbValue get_key_value(const TreeModel::iterator& iter) const;
+ DbValue get_key_value(const TreeModel::const_iterator& iter) const;
/** Get the last row.
* This will never return the placeholder row.
*/
TreeModel::iterator get_last_row();
+ /** Get the last row.
+ * This will never return the placeholder row.
+ */
+ TreeModel::const_iterator get_last_row() const;
+
/** Get the placeholder row.
*/
TreeModel::iterator get_placeholder_row();
+ /** Get the placeholder row.
+ */
+ TreeModel::const_iterator get_placeholder_row() const;
+
/** Removes the given row from the list store.
* @param iter The iterator to the row to be removed.
* @result An iterator to the next row, or end() if there is none.
@@ -187,9 +196,9 @@ private:
void invalidate_iter(iterator& iter) const;
bool row_was_removed(const type_datamodel_row_index& row_iter) const;
- type_datamodel_row_index get_datamodel_row_index_from_tree_row_iter(const iterator& iter) const;
+ type_datamodel_row_index get_datamodel_row_index_from_tree_row_iter(const const_iterator& iter) const;
- bool check_treeiter_validity(const iterator& iter) const;
+ bool check_treeiter_validity(const const_iterator& iter) const;
//Structure:
unsigned int m_columns_count;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]