I have a Gtk.TreeView with a custom model (inheriting from Gtk.TreeModel) and I show ~150K rows. I'm using PyGtk, but it should not matter that much.
The GUI interaction is ok, but when activating interactive-search, it takes forever (~10sec per char). From what I understood from Searching a ListStore and tested, the interactive-search checks each row of the ListStore (internally stored as linked-list) to find the value.
Since I am searching a sorted column, I want to do binary search.
How can I do that ? Do I need to re-program the interactive-search from scratch ? Can TreeModelSort be useful ? (I do not get how its internals are managed)
If I roll my own search UI, I'm not sure how to start. A sketch looks like that :
- Disable built-in interactive search
- Create a search UI, and connect it to the right keypress
- Manually do a binary search in my custom representation of the data (or in the sorted shown rows if random access is possible)
- Select the correct match.
For 3. it seems from GtkTreeModel that have a random access to rows:
A gtk.TreeModel object supports some of the Python Mapping protocol that allows you to retrieve a gtk.TreeModelRow object representing a row in the model.
Is it truly and efficiently random access ?