Can the Place Selector be changed to the Flat instead of Hierarchical

How hard would it be to change the Place Selector from Hierarchical to Flat list?

Intermittently, the Place Selector becomes incredibly slow on my system. Through a multitude of tests, I have been unable to isolate the slowdown.

Perhaps the problem is sorting out the hierarchy? So maybe a flat list would be fast. It’d be nice to do an experiment.

1 Like

Been there. Done that.

0009700: Select Place search & Source/Citation hierarchy should NOT automatically open

1 Like

Those patches attempt a different thing entirely. The patches show the difference between an automatically Expanded to the active place and a Collapsed ‘Place Tree’ hierarchy. Since the problem seems to be in constructing the hierarchy, it doesn’t even get to the point where expanded and collapsed make a difference.

The Place category has 2 view modes: ‘Place Tree’ and a (flat) ‘Places’.

I’m hoping for an experiment with a flat base selector instead of the Tree base selector.

edit the file (version 5.1.5)

gramps\gui\selectors\selectplace.py

change line 36

from ..views.treemodels.placemodel import PlaceTreeModel

to

from ..views.treemodels.placemodel import PlaceListModel


change line 62

return PlaceTreeModel

to

return PlaceListModel


at line 66 change

        return [
            (_('Name'),  200, BaseSelector.TEXT, 0),
            (_('ID'),    75,  BaseSelector.TEXT, 1),
            (_('Type'),  100, BaseSelector.TEXT, 3),
            (_('Title'), 300, BaseSelector.TEXT, 2),
            (_('Last Change'), 150, BaseSelector.TEXT, 9),
            ]

to

        return [
            #(_('Name'),  200, BaseSelector.TEXT, 0),
            (_('Title'), 300, BaseSelector.TEXT, 2),
            (_('Type'),  100, BaseSelector.TEXT, 3),
            (_('ID'),    75,  BaseSelector.TEXT, 1),
            (_('Last Change'), 150, BaseSelector.TEXT, 9),
            ]

You might want to give the Title more space than 300.

3 Likes

Wow! That’s faster than I’ve seen the Place Selector populate in 2 years!!!

2 Likes

Forgot to say ‘thank you’. So… thank you!

That probably resolves 1 of my 2 biggest intermittent problems where Gramps could become unusable and has to be restarted!

(That just leaves finding a cause and solution for when switching between Categories and active record gets ‘stuck’.)

There are a few things I’ve learned not to do … like not using the “OK” keybinding without 'tab’bing to the next field, or, avoid accidental orphaning of spawned records by clicking the OK button of a parent window before those of its spawned windows.

But it is hard to avoid the hidden pitfalls.

Re clicking the wrong OK. Me too.
To minimize this I move the windows so the child hides the OK button of the parent. Work for me most of the time.
I just wish the columns in the windows would remember their size when moved.

@SNoiraud has a PR for this. PR1306

1 Like

Changing the Person Selector tot he flat list evidentially must involve something more.

Even though the PersonListModel class is defined in gramps\gui\views\treemodels\peoplemodel.py , doing the similar thing for the
gramps\gui\selectors\selectperson.py

of changing Line 86

return PersonTreeModel

to

return PersonListModel

causes the following error to appear in the Console when sharing a Person to a new Family in the Family Editor dialog:

2022-11-29 14:52:29.644: ERROR: grampsapp.py: line 174: Unhandled exception
Traceback (most recent call last):
  File "C:\Program Files\GrampsAIO64-5.1.5\gramps\gui\editors\editfamily.py", line 931, in sel_father_clicked
    skip=[x.ref for x in self.obj.get_child_ref_list()])
  File "C:\Program Files\GrampsAIO64-5.1.5\gramps\gui\selectors\selectperson.py", line 73, in __init__
    skip, show_search_bar, default)
  File "C:\Program Files\GrampsAIO64-5.1.5\gramps\gui\selectors\baseselector.py", line 132, in __init__
    self.build_tree()
  File "C:\Program Files\GrampsAIO64-5.1.5\gramps\gui\selectors\baseselector.py", line 296, in build_tree
    self.model = self.get_model_class()(
  File "C:\Program Files\GrampsAIO64-5.1.5\gramps\gui\selectors\selectperson.py", line 86, in get_model_class
    return PersonListModel
NameError: name 'PersonListModel' is not defined

You also need to import PersonListModel at line 37

That allowed for selecting a child to a family with the flat list.

Adding a parent to a family has an initial filter for either male or female. This feature did not like the flat list.

1 Like

Adding a Child worked well for me too. Will have to work out the Gender filtering for the Parent selectors.

More importantly, the Ctrl+F seek-as-you-type Find box regained usability. With the Tree-based selector, the search would usually time-out and blank itself before scrolling to the name. And since the filtering features for the Selector are disabled with larger lists, this feature is critical.

Just twigged onto the realization that if Gender Prejudice is eliminated for relationships, then the Mother (Partner2) & Father (Partner1) person selectors would have to stop filtering on Gender anyway.