Re: TreeView: Multiple selection inefficient?



Murray Cumming wrote:
On Mon, 2005-04-11 at 12:47 +0200, Matthias Kaeppler wrote:

Murray Cumming wrote:


You don't have to call foreach() on each row. But if you really want to
examine each selection whenever the selection changes, what's the
alternative?

Hopefully you more often want to just know the first and last selected
rows, or if anything is selected at all. Then you wouldn't have to call
foreach() on them all.


That's correct, but how can I achieve this? It would be enough for me to only know the first and last row which is among the selection. Maybe even only the last.


get_selected_rows().


Since Glib::ListHandle doesn't work for me, I tried using a normal STL container instead:

void FileBrowser::on_selection_changed()
{
std::list<Gtk::TreeModel::Path> selected_rows = m_tree_selection->get_selected_rows();

std::list<Gtk::TreeModel::Path>::reverse_iterator riter = selected_rows.rbegin();

    m_last_row = *( m_model->get_iter( *riter ) );
// m_tree_selection->selected_foreach_iter( sigc::mem_fun( *this, &FileBrowser::selection_callback ) );
}

This compiles, but the program crashes.

--
Matthias Kaeppler




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]