add uistate to models
This commit is contained in:
parent
e24faddabb
commit
2574202a46
@ -268,11 +268,10 @@ class BaseSelector(ManagedWindow):
|
||||
|
||||
#reset the model with correct sorting
|
||||
self.clear_model()
|
||||
self.model = self.get_model_class()(self.db, self.sort_col,
|
||||
self.sortorder,
|
||||
sort_map=self.column_order(),
|
||||
skip=self.skip_list,
|
||||
search=filter_info)
|
||||
self.model = self.get_model_class()(
|
||||
self.db, self.uistate, self.sort_col, self.sortorder,
|
||||
sort_map=self.column_order(), skip=self.skip_list,
|
||||
search=filter_info)
|
||||
|
||||
self.tree.set_model(self.model)
|
||||
|
||||
@ -317,11 +316,10 @@ class BaseSelector(ManagedWindow):
|
||||
def show_toggle(self, obj):
|
||||
filter_info = None if obj.get_active() else self.filter
|
||||
self.clear_model()
|
||||
self.model = self.get_model_class()(self.db, self.sort_col,
|
||||
self.sortorder,
|
||||
sort_map=self.column_order(),
|
||||
skip=self.skip_list,
|
||||
search=filter_info)
|
||||
self.model = self.get_model_class()(
|
||||
self.db, self.uistate, self.sort_col, self.sortorder,
|
||||
sort_map=self.column_order(), skip=self.skip_list,
|
||||
search=filter_info)
|
||||
self.tree.set_model(self.model)
|
||||
self.tree.grab_focus()
|
||||
|
||||
|
@ -320,9 +320,9 @@ class ListView(NavigationView):
|
||||
if self.model:
|
||||
self.list.set_model(None)
|
||||
self.model.destroy()
|
||||
self.model = self.make_model(self.dbstate.db, self.sort_col,
|
||||
search=filter_info,
|
||||
sort_map=self.column_order())
|
||||
self.model = self.make_model(
|
||||
self.dbstate.db, self.uistate, self.sort_col,
|
||||
search=filter_info, sort_map=self.column_order())
|
||||
else:
|
||||
#the entire data to show is already in memory.
|
||||
#run only the part that determines what to show
|
||||
@ -647,10 +647,9 @@ class ListView(NavigationView):
|
||||
self.model.reverse_order()
|
||||
self.list.set_model(self.model)
|
||||
else:
|
||||
self.model = self.make_model(self.dbstate.db, self.sort_col,
|
||||
self.sort_order,
|
||||
search=filter_info,
|
||||
sort_map=self.column_order())
|
||||
self.model = self.make_model(
|
||||
self.dbstate.db, self.uistate, self.sort_col, self.sort_order,
|
||||
search=filter_info, sort_map=self.column_order())
|
||||
|
||||
self.list.set_model(self.model)
|
||||
|
||||
|
@ -56,8 +56,8 @@ class CitationListModel(CitationBaseModel, FlatBaseModel):
|
||||
"""
|
||||
Flat citation model. (Original code in CitationBaseModel).
|
||||
"""
|
||||
def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None,
|
||||
skip=set(), sort_map=None):
|
||||
def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING,
|
||||
search=None, skip=set(), sort_map=None):
|
||||
self.map = db.get_raw_citation_data
|
||||
self.gen_cursor = db.get_citation_cursor
|
||||
self.fmap = [
|
||||
@ -94,8 +94,8 @@ class CitationListModel(CitationBaseModel, FlatBaseModel):
|
||||
self.citation_src_chan,
|
||||
self.citation_tag_color
|
||||
]
|
||||
FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip,
|
||||
sort_map=sort_map)
|
||||
FlatBaseModel.__init__(self, db, uistate, scol, order, search=search,
|
||||
skip=skip, sort_map=sort_map)
|
||||
|
||||
def destroy(self):
|
||||
"""
|
||||
|
@ -65,8 +65,8 @@ class CitationTreeModel(CitationBaseModel, TreeBaseModel):
|
||||
"""
|
||||
Hierarchical citation model.
|
||||
"""
|
||||
def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None,
|
||||
skip=set(), sort_map=None):
|
||||
def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING,
|
||||
search=None, skip=set(), sort_map=None):
|
||||
self.db = db
|
||||
self.number_items = self.db.get_number_of_sources
|
||||
self.map = self.db.get_raw_source_data
|
||||
@ -100,7 +100,7 @@ class CitationTreeModel(CitationBaseModel, TreeBaseModel):
|
||||
self.source_src_tag_color
|
||||
]
|
||||
|
||||
TreeBaseModel.__init__(self, self.db, scol=scol, order=order,
|
||||
TreeBaseModel.__init__(self, self.db, uistate, scol=scol, order=order,
|
||||
search=search, skip=skip, sort_map=sort_map,
|
||||
nrgroups=1,
|
||||
group_can_have_handle=True,
|
||||
|
@ -71,8 +71,8 @@ INVALID_DATE_FORMAT = config.get('preferences.invalid-date-format')
|
||||
#-------------------------------------------------------------------------
|
||||
class EventModel(FlatBaseModel):
|
||||
|
||||
def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None,
|
||||
skip=set(), sort_map=None):
|
||||
def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING,
|
||||
search=None, skip=set(), sort_map=None):
|
||||
self.gen_cursor = db.get_event_cursor
|
||||
self.map = db.get_raw_event_data
|
||||
|
||||
@ -100,8 +100,8 @@ class EventModel(FlatBaseModel):
|
||||
self.column_participant,
|
||||
self.column_tag_color
|
||||
]
|
||||
FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip,
|
||||
sort_map=sort_map)
|
||||
FlatBaseModel.__init__(self, db, uistate, scol, order, search=search,
|
||||
skip=skip, sort_map=sort_map)
|
||||
|
||||
def destroy(self):
|
||||
"""
|
||||
|
@ -56,8 +56,8 @@ invalid_date_format = config.get('preferences.invalid-date-format')
|
||||
#-------------------------------------------------------------------------
|
||||
class FamilyModel(FlatBaseModel):
|
||||
|
||||
def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None,
|
||||
skip=set(), sort_map=None):
|
||||
def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING,
|
||||
search=None, skip=set(), sort_map=None):
|
||||
self.gen_cursor = db.get_family_cursor
|
||||
self.map = db.get_raw_family_data
|
||||
self.fmap = [
|
||||
@ -82,8 +82,8 @@ class FamilyModel(FlatBaseModel):
|
||||
self.sort_change,
|
||||
self.column_tag_color,
|
||||
]
|
||||
FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip,
|
||||
sort_map=sort_map)
|
||||
FlatBaseModel.__init__(self, db, uistate, scol, order, search=search,
|
||||
skip=skip, sort_map=sort_map)
|
||||
|
||||
def destroy(self):
|
||||
"""
|
||||
|
@ -450,7 +450,7 @@ class FlatBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel):
|
||||
so as to have localized sort
|
||||
"""
|
||||
|
||||
def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING,
|
||||
def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING,
|
||||
search=None, skip=set(),
|
||||
sort_map=None):
|
||||
cput = time.clock()
|
||||
|
@ -52,8 +52,8 @@ from .flatbasemodel import FlatBaseModel
|
||||
#-------------------------------------------------------------------------
|
||||
class MediaModel(FlatBaseModel):
|
||||
|
||||
def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None,
|
||||
skip=set(), sort_map=None):
|
||||
def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING,
|
||||
search=None, skip=set(), sort_map=None):
|
||||
self.gen_cursor = db.get_media_cursor
|
||||
self.map = db.get_raw_media_data
|
||||
|
||||
@ -80,8 +80,8 @@ class MediaModel(FlatBaseModel):
|
||||
self.sort_change,
|
||||
self.column_tag_color,
|
||||
]
|
||||
FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip,
|
||||
sort_map=sort_map)
|
||||
FlatBaseModel.__init__(self, db, uistate, scol, order, search=search,
|
||||
skip=skip, sort_map=sort_map)
|
||||
|
||||
def destroy(self):
|
||||
"""
|
||||
|
@ -52,8 +52,8 @@ from gramps.gen.lib import (Note, NoteType, StyledText)
|
||||
class NoteModel(FlatBaseModel):
|
||||
"""
|
||||
"""
|
||||
def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None,
|
||||
skip=set(), sort_map=None):
|
||||
def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING,
|
||||
search=None, skip=set(), sort_map=None):
|
||||
"""Setup initial values for instance variables."""
|
||||
self.gen_cursor = db.get_note_cursor
|
||||
self.map = db.get_raw_note_data
|
||||
@ -75,8 +75,8 @@ class NoteModel(FlatBaseModel):
|
||||
self.sort_change,
|
||||
self.column_tag_color
|
||||
]
|
||||
FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip,
|
||||
sort_map=sort_map)
|
||||
FlatBaseModel.__init__(self, db, uistate, scol, order, search=search,
|
||||
skip=skip, sort_map=sort_map)
|
||||
|
||||
def destroy(self):
|
||||
"""
|
||||
|
@ -573,11 +573,11 @@ class PersonListModel(PeopleBaseModel, FlatBaseModel):
|
||||
"""
|
||||
Listed people model.
|
||||
"""
|
||||
def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None,
|
||||
skip=set(), sort_map=None):
|
||||
def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING,
|
||||
search=None, skip=set(), sort_map=None):
|
||||
PeopleBaseModel.__init__(self, db)
|
||||
FlatBaseModel.__init__(self, db, search=search, skip=skip, scol=scol,
|
||||
order=order, sort_map=sort_map)
|
||||
FlatBaseModel.__init__(self, db, uistate, search=search, skip=skip,
|
||||
scol=scol, order=order, sort_map=sort_map)
|
||||
|
||||
def destroy(self):
|
||||
"""
|
||||
@ -590,11 +590,11 @@ class PersonTreeModel(PeopleBaseModel, TreeBaseModel):
|
||||
"""
|
||||
Hierarchical people model.
|
||||
"""
|
||||
def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None,
|
||||
skip=set(), sort_map=None):
|
||||
def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING,
|
||||
search=None, skip=set(), sort_map=None):
|
||||
PeopleBaseModel.__init__(self, db)
|
||||
TreeBaseModel.__init__(self, db, search=search, skip=skip, scol=scol,
|
||||
order=order, sort_map=sort_map)
|
||||
TreeBaseModel.__init__(self, db, uistate, search=search, skip=skip,
|
||||
scol=scol, order=order, sort_map=sort_map)
|
||||
|
||||
def destroy(self):
|
||||
"""
|
||||
|
@ -230,12 +230,12 @@ class PlaceListModel(PlaceBaseModel, FlatBaseModel):
|
||||
"""
|
||||
Flat place model. (Original code in PlaceBaseModel).
|
||||
"""
|
||||
def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None,
|
||||
skip=set(), sort_map=None):
|
||||
def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING,
|
||||
search=None, skip=set(), sort_map=None):
|
||||
|
||||
PlaceBaseModel.__init__(self, db)
|
||||
FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip,
|
||||
sort_map=sort_map)
|
||||
FlatBaseModel.__init__(self, db, uistate, scol, order, search=search,
|
||||
skip=skip, sort_map=sort_map)
|
||||
|
||||
def destroy(self):
|
||||
"""
|
||||
@ -253,11 +253,11 @@ class PlaceTreeModel(PlaceBaseModel, TreeBaseModel):
|
||||
"""
|
||||
Hierarchical place model.
|
||||
"""
|
||||
def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None,
|
||||
skip=set(), sort_map=None):
|
||||
def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING,
|
||||
search=None, skip=set(), sort_map=None):
|
||||
|
||||
PlaceBaseModel.__init__(self, db)
|
||||
TreeBaseModel.__init__(self, db, scol=scol, order=order,
|
||||
TreeBaseModel.__init__(self, db, uistate, scol=scol, order=order,
|
||||
search=search, skip=skip, sort_map=sort_map,
|
||||
nrgroups=3,
|
||||
group_can_have_handle=True)
|
||||
|
@ -49,8 +49,8 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
#-------------------------------------------------------------------------
|
||||
class RepositoryModel(FlatBaseModel):
|
||||
|
||||
def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None,
|
||||
skip=set(), sort_map=None):
|
||||
def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING,
|
||||
search=None, skip=set(), sort_map=None):
|
||||
self.gen_cursor = db.get_repository_cursor
|
||||
self.get_handles = db.get_repository_handles
|
||||
self.map = db.get_raw_repository_data
|
||||
@ -92,8 +92,8 @@ class RepositoryModel(FlatBaseModel):
|
||||
self.column_tag_color
|
||||
]
|
||||
|
||||
FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip,
|
||||
sort_map=sort_map)
|
||||
FlatBaseModel.__init__(self, db, uistate, scol, order, search=search,
|
||||
skip=skip, sort_map=sort_map)
|
||||
|
||||
def destroy(self):
|
||||
"""
|
||||
|
@ -49,8 +49,8 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
#-------------------------------------------------------------------------
|
||||
class SourceModel(FlatBaseModel):
|
||||
|
||||
def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None,
|
||||
skip=set(), sort_map=None):
|
||||
def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING,
|
||||
search=None, skip=set(), sort_map=None):
|
||||
self.map = db.get_raw_source_data
|
||||
self.gen_cursor = db.get_source_cursor
|
||||
self.fmap = [
|
||||
@ -75,8 +75,8 @@ class SourceModel(FlatBaseModel):
|
||||
self.sort_change,
|
||||
self.column_tag_color
|
||||
]
|
||||
FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip,
|
||||
sort_map=sort_map)
|
||||
FlatBaseModel.__init__(self, db, uistate, scol, order, search=search,
|
||||
skip=skip, sort_map=sort_map)
|
||||
|
||||
def destroy(self):
|
||||
"""
|
||||
|
@ -274,12 +274,9 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel):
|
||||
secondary object type.
|
||||
"""
|
||||
|
||||
def __init__(self, db,
|
||||
search=None, skip=set(),
|
||||
scol=0, order=Gtk.SortType.ASCENDING, sort_map=None,
|
||||
nrgroups = 1,
|
||||
group_can_have_handle = False,
|
||||
has_secondary=False):
|
||||
def __init__(self, db, uistate, search=None, skip=set(), scol=0,
|
||||
order=Gtk.SortType.ASCENDING, sort_map=None, nrgroups = 1,
|
||||
group_can_have_handle = False, has_secondary=False):
|
||||
cput = time.clock()
|
||||
GObject.GObject.__init__(self)
|
||||
BaseModel.__init__(self)
|
||||
|
Loading…
Reference in New Issue
Block a user