Re: [gtkmm] Custom TreeStore Problems



Christof Petig wrote:

What I did was:
- sorted insertion of 10000 lines into a TreeStore (actually it becomes a subtree whenever columns match)
  the sort criterion was a custom class defining operator<
  key and additional data were referenced by smart pointers (handles)


Does sorted insertion mean that you are inserting into a sorted TreeStore? That's a killer... I use the following code to avoid the overhead (though in this case, I'm using a ListStore):

int sort_column_id;
Gtk::SortType order;
bool sorted;


// Temporarily disable sorting if enabled
// (this makes a huge performance difference)
if (sorted = listModel->get_sort_column_id(sort_column_id, order)) {
    // Work around GTK bug 87556:
    // listModel->set_sort_column_id
    // (Gtk::TreeSortable::DEFAULT_SORT_COLUMN_ID, Gtk::SORT_ASCENDING);
    listModel->gobj()->sort_column_id = -2;
}

// Do inserting here...

if (sorted) {
    listModel->set_sort_column_id(sort_column_id, order);
}

--
Christer Palm




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