made the striping of the ZebraTreeView handle the expanding/collapsing of TreeStore model rows correctly
This commit is contained in:
parent
f21ed80b01
commit
59bcec4df2
2 changed files with 54 additions and 3 deletions
|
@ -217,6 +217,26 @@ class ZebraTreeView : public Gtk::TreeView
|
||||||
int* mapping)
|
int* mapping)
|
||||||
throw ();
|
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:
|
public:
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -69,6 +69,10 @@ ZebraTreeView :: ZebraTreeView(Glib::RefPtr<Gtk::TreeModel> treeModel)
|
||||||
&ZebraTreeView::onRowDeleted));
|
&ZebraTreeView::onRowDeleted));
|
||||||
treeModel->signal_rows_reordered().connect(sigc::mem_fun(*this,
|
treeModel->signal_rows_reordered().connect(sigc::mem_fun(*this,
|
||||||
&ZebraTreeView::onRowsReordered));
|
&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.
|
* Renumber the rows after they have changed.
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
@ -527,9 +555,12 @@ ZebraTreeView :: renumberRows(void) throw ()
|
||||||
Gtk::TreeRow row = *iter;
|
Gtk::TreeRow row = *iter;
|
||||||
row[modelColumns.rowNumberColumn] = rowNumber++;
|
row[modelColumns.rowNumberColumn] = rowNumber++;
|
||||||
|
|
||||||
for (it = row.children().begin(); it != row.children().end(); ++it) {
|
if (row_expanded(treeModel->get_path(row))) {
|
||||||
Gtk::TreeRow childRow = *it;
|
for (it = row.children().begin(); it != row.children().end();
|
||||||
childRow[modelColumns.rowNumberColumn] = rowNumber++;
|
++it) {
|
||||||
|
Gtk::TreeRow childRow = *it;
|
||||||
|
childRow[modelColumns.rowNumberColumn] = rowNumber++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue