made the striping of the ZebraTreeView handle the expanding/collapsing of TreeStore model rows correctly

This commit is contained in:
fgerlits 2006-03-02 18:36:54 +00:00
parent f21ed80b01
commit 59bcec4df2
2 changed files with 54 additions and 3 deletions

View file

@ -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:
/**

View file

@ -69,6 +69,10 @@ ZebraTreeView :: ZebraTreeView(Glib::RefPtr<Gtk::TreeModel> 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,10 +555,13 @@ ZebraTreeView :: renumberRows(void) throw ()
Gtk::TreeRow row = *iter;
row[modelColumns.rowNumberColumn] = rowNumber++;
for (it = row.children().begin(); it != row.children().end(); ++it) {
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++;
}
}
}
}