diff --git a/livesupport/src/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h b/livesupport/src/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h index 6dce58e8e..df6f0a397 100644 --- a/livesupport/src/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h +++ b/livesupport/src/modules/widgets/include/LiveSupport/Widgets/ZebraTreeView.h @@ -217,6 +217,26 @@ class ZebraTreeView : public Gtk::TreeView int* mapping) throw (); + /** + * Event handler for the row_expanded signal. + * + * @param iter points to the expanded row. + * @param path points to the expanded row. + */ + void + onRowExpanded(const Gtk::TreeModel::iterator & iter, + const Gtk::TreeModel::Path & path) throw (); + + /** + * Event handler for the row_collapsed signal. + * + * @param iter points to the collapsed row. + * @param path points to the collapsed row. + */ + void + onRowCollapsed(const Gtk::TreeModel::iterator & iter, + const Gtk::TreeModel::Path & path) throw (); + public: /** diff --git a/livesupport/src/modules/widgets/src/ZebraTreeView.cxx b/livesupport/src/modules/widgets/src/ZebraTreeView.cxx index a06645424..96a99ea99 100644 --- a/livesupport/src/modules/widgets/src/ZebraTreeView.cxx +++ b/livesupport/src/modules/widgets/src/ZebraTreeView.cxx @@ -69,6 +69,10 @@ ZebraTreeView :: ZebraTreeView(Glib::RefPtr treeModel) &ZebraTreeView::onRowDeleted)); treeModel->signal_rows_reordered().connect(sigc::mem_fun(*this, &ZebraTreeView::onRowsReordered)); + this->signal_row_expanded().connect(sigc::mem_fun(*this, + &ZebraTreeView::onRowExpanded)); + this->signal_row_collapsed().connect(sigc::mem_fun(*this, + &ZebraTreeView::onRowCollapsed)); } @@ -510,6 +514,30 @@ ZebraTreeView :: onRowsReordered(const Gtk::TreeModel::Path & path, } +/*------------------------------------------------------------------------------ + * Event handler for the row_expanded signal. + *----------------------------------------------------------------------------*/ +void +ZebraTreeView :: onRowExpanded(const Gtk::TreeModel::iterator & iter, + const Gtk::TreeModel::Path & path) + throw () +{ + renumberRows(); +} + + +/*------------------------------------------------------------------------------ + * Event handler for the row_collapsed signal. + *----------------------------------------------------------------------------*/ +void +ZebraTreeView :: onRowCollapsed(const Gtk::TreeModel::iterator & iter, + const Gtk::TreeModel::Path & path) + throw () +{ + renumberRows(); +} + + /*------------------------------------------------------------------------------ * Renumber the rows after they have changed. *----------------------------------------------------------------------------*/ @@ -527,9 +555,12 @@ ZebraTreeView :: renumberRows(void) throw () Gtk::TreeRow row = *iter; row[modelColumns.rowNumberColumn] = rowNumber++; - for (it = row.children().begin(); it != row.children().end(); ++it) { - Gtk::TreeRow childRow = *it; - childRow[modelColumns.rowNumberColumn] = rowNumber++; + if (row_expanded(treeModel->get_path(row))) { + for (it = row.children().begin(); it != row.children().end(); + ++it) { + Gtk::TreeRow childRow = *it; + childRow[modelColumns.rowNumberColumn] = rowNumber++; + } } } }