media sorting enabled
svn: r4631
This commit is contained in:
parent
2f6c93d5d9
commit
6d00c95e8c
@ -1,3 +1,7 @@
|
||||
2005-05-19 Don Allingham <don@gramps-project.org>
|
||||
* src/MediaView.py: enable sorting by columns
|
||||
* src/DisplayModels.py: enable sorting by columns for MediaModel
|
||||
|
||||
2005-05-19 Alex Roitman <shura@gramps-project.org>
|
||||
* src/MergePeople.py (merge_family_pair): Properly use handles.
|
||||
|
||||
|
@ -428,7 +428,7 @@ class PlaceModel(BaseModel):
|
||||
#-------------------------------------------------------------------------
|
||||
class MediaModel(BaseModel):
|
||||
|
||||
def __init__(self,db):
|
||||
def __init__(self,db,scol=0,order=gtk.SORT_ASCENDING):
|
||||
self.gen_cursor = db.get_media_cursor
|
||||
self.map = db.media_map
|
||||
|
||||
@ -452,7 +452,7 @@ class MediaModel(BaseModel):
|
||||
self.column_place,
|
||||
self.column_handle,
|
||||
]
|
||||
BaseModel.__init__(self,db)
|
||||
BaseModel.__init__(self,db,scol,order)
|
||||
|
||||
def on_get_n_columns(self):
|
||||
return len(self.fmap)+1
|
||||
|
@ -84,6 +84,7 @@ class MediaView:
|
||||
self.topWindow = glade.get_widget("gramps")
|
||||
self.renderer = gtk.CellRendererText()
|
||||
self.model = DisplayModels.MediaModel(self.db)
|
||||
self.sort_col = 0
|
||||
|
||||
self.selection = self.list.get_selection()
|
||||
self.list.set_model(self.model)
|
||||
@ -130,13 +131,51 @@ class MediaView:
|
||||
self.build_columns()
|
||||
self.build_tree()
|
||||
|
||||
def column_clicked(self,obj,data):
|
||||
if self.sort_col != data:
|
||||
order = gtk.SORT_ASCENDING
|
||||
else:
|
||||
if (self.columns[data].get_sort_order() == gtk.SORT_DESCENDING
|
||||
or self.columns[data].get_sort_indicator() == False):
|
||||
order = gtk.SORT_ASCENDING
|
||||
else:
|
||||
order = gtk.SORT_DESCENDING
|
||||
self.sort_col = data
|
||||
handle = self.first_selected()
|
||||
self.model = DisplayModels.MediaModel(self.parent.db,
|
||||
self.sort_col,order)
|
||||
self.list.set_model(self.model)
|
||||
|
||||
colmap = self.parent.db.get_place_column_order()
|
||||
|
||||
if handle:
|
||||
path = self.model.on_get_path(handle)
|
||||
self.selection.select_path(path)
|
||||
self.list.scroll_to_cell(path,None,1,0.5,0)
|
||||
for i in range(0,len(self.columns)):
|
||||
self.columns[i].set_sort_indicator(i==colmap[data][1]-1)
|
||||
self.columns[self.sort_col].set_sort_order(order)
|
||||
|
||||
def first_selected(self):
|
||||
mlist = []
|
||||
self.selection.selected_foreach(self.blist,mlist)
|
||||
if mlist:
|
||||
return mlist[0]
|
||||
else:
|
||||
return None
|
||||
|
||||
def blist(self,store,path,iter,list):
|
||||
handle = store.get_value(iter,_HANDLE_COL)
|
||||
list.append(handle)
|
||||
|
||||
def build_columns(self):
|
||||
for column in self.columns:
|
||||
self.list.remove_column(column)
|
||||
|
||||
column = gtk.TreeViewColumn(_('Title'), self.renderer,text=0)
|
||||
column.set_resizable(True)
|
||||
|
||||
column.connect('clicked',self.column_clicked,0)
|
||||
column.set_clickable(True)
|
||||
column.set_min_width(225)
|
||||
self.list.append_column(column)
|
||||
self.columns = [column]
|
||||
@ -149,6 +188,8 @@ class MediaView:
|
||||
column = gtk.TreeViewColumn(name, self.renderer, text=pair[1])
|
||||
column.set_resizable(True)
|
||||
column.set_min_width(75)
|
||||
column.set_clickable(True)
|
||||
column.connect('clicked',self.column_clicked,index)
|
||||
self.columns.append(column)
|
||||
self.list.append_column(column)
|
||||
index += 1
|
||||
|
Loading…
Reference in New Issue
Block a user