2007-09-25 Benny Malengier <benny.malengier@gramps-project.org>

* src/DataViews/_MediaView.py: COLUMN_NAMES as class constant for reuse
	* src/DataViews/_RepositoryView.py: COLUMN_NAMES as class constant for reuse
	* src/DataViews/_SourceView.py: COLUMN_NAMES as class constant for reuse
	* src/DataViews/_EventView.py: COLUMN_NAMES as class constant for reuse
	* src/DataViews/_FamilyList.py: COLUMN_NAMES as class constant for reuse
	* src/DataViews/_PlaceView.py: COLUMN_NAMES as class constant for reuse
	* src/DataViews/_NoteView.py: COLUMN_NAMES as class constant for reuse
	* src/Selectors/_BaseSelector.py: add hideable searchbar to selector
	* src/Selectors/_SelectRepository.py: implement new BaseSelector methods
	* src/Selectors/_SelectSource.py: implement new BaseSelector methods
	* src/Selectors/_SelectEvent.py: implement new BaseSelector methods
	* src/Selectors/_SelectFamily.py: implement new BaseSelector methods,
	fix bug with wrong handle column
	* src/Selectors/_SelectPlace.py: implement new BaseSelector methods
	* src/Selectors/_SelectObject.py: implement new BaseSelector methods


svn: r9005
This commit is contained in:
Benny Malengier 2007-09-25 12:09:25 +00:00
parent e0a79c5103
commit 632586ccc1
15 changed files with 274 additions and 91 deletions

View File

@ -1,3 +1,20 @@
2007-09-25 Benny Malengier <benny.malengier@gramps-project.org>
* src/DataViews/_MediaView.py: COLUMN_NAMES as class constant for reuse
* src/DataViews/_RepositoryView.py: COLUMN_NAMES as class constant for reuse
* src/DataViews/_SourceView.py: COLUMN_NAMES as class constant for reuse
* src/DataViews/_EventView.py: COLUMN_NAMES as class constant for reuse
* src/DataViews/_FamilyList.py: COLUMN_NAMES as class constant for reuse
* src/DataViews/_PlaceView.py: COLUMN_NAMES as class constant for reuse
* src/DataViews/_NoteView.py: COLUMN_NAMES as class constant for reuse
* src/Selectors/_BaseSelector.py: add hideable searchbar to selector
* src/Selectors/_SelectRepository.py: implement new BaseSelector methods
* src/Selectors/_SelectSource.py: implement new BaseSelector methods
* src/Selectors/_SelectEvent.py: implement new BaseSelector methods
* src/Selectors/_SelectFamily.py: implement new BaseSelector methods,
fix bug with wrong handle column
* src/Selectors/_SelectPlace.py: implement new BaseSelector methods
* src/Selectors/_SelectObject.py: implement new BaseSelector methods
2007-09-25 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
* src/glade/Makefile.am:
* po/POTFILES.in:

View File

@ -50,14 +50,6 @@ from Filters.SideBar import EventSidebarFilter
#-------------------------------------------------------------------------
from gettext import gettext as _
column_names = [
_('Description'),
_('ID'),
_('Type'),
_('Date'),
_('Place'),
_('Last Changed'),
]
#-------------------------------------------------------------------------
#
@ -68,7 +60,15 @@ class EventView(PageView.ListView):
"""
EventView class, derived from the ListView
"""
COLUMN_NAMES = [
_('Description'),
_('ID'),
_('Type'),
_('Date'),
_('Place'),
_('Last Changed'),
]
ADD_MSG = _("Add a new event")
EDIT_MSG = _("Edit the selected event")
DEL_MSG = _("Delete the selected event")
@ -93,7 +93,8 @@ class EventView(PageView.ListView):
PageView.ListView.__init__(
self, _('Events'), dbstate, uistate,
column_names, len(column_names), DisplayModels.EventModel,
EventView.COLUMN_NAMES, len(EventView.COLUMN_NAMES),
DisplayModels.EventModel,
signal_map, dbstate.db.get_event_bookmarks(),
Bookmarks.EventBookmarks, filter_class=EventSidebarFilter)
@ -189,7 +190,7 @@ class EventView(PageView.ListView):
_('Select Event Columns'),
self.uistate,
self.dbstate.db.get_event_column_order(),
column_names,
EventView.COLUMN_NAMES,
self.set_column_order)
def set_column_order(self, clist):

View File

@ -48,21 +48,21 @@ from ReportBase import CATEGORY_QR_FAMILY
from gettext import gettext as _
import gtk
column_names = [
_('ID'),
_('Father'),
_('Mother'),
_('Relationship'),
_('Marriage Date'),
_('Last Changed'),
]
#-------------------------------------------------------------------------
#
# FamilyListView
#
#-------------------------------------------------------------------------
class FamilyListView(PageView.ListView):
COLUMN_NAMES = [
_('ID'),
_('Father'),
_('Mother'),
_('Relationship'),
_('Marriage Date'),
_('Last Changed'),
]
ADD_MSG = _("Add a new family")
EDIT_MSG = _("Edit the selected family")
@ -86,7 +86,8 @@ class FamilyListView(PageView.ListView):
PageView.ListView.__init__(
self, _('Family List'), dbstate, uistate,
column_names, len(column_names), DisplayModels.FamilyModel,
FamilyListView.COLUMN_NAMES, len(FamilyListView.COLUMN_NAMES),
DisplayModels.FamilyModel,
signal_map, dbstate.db.get_family_bookmarks(),
Bookmarks.FamilyBookmarks, filter_class=FamilySidebarFilter)
@ -103,7 +104,7 @@ class FamilyListView(PageView.ListView):
_('Select Family List Columns'),
self.uistate,
self.dbstate.db.get_family_list_column_order(),
column_names,
FamilyListView.COLUMN_NAMES,
self.set_column_order)
def set_column_order(self, clist):

View File

@ -64,14 +64,6 @@ from QuestionDialog import QuestionDialog, ErrorDialog
from Filters.SideBar import MediaSidebarFilter
from DdTargets import DdTargets
COLUMN_NAMES = [
_('Title'),
_('ID'),
_('Type'),
_('Path'),
_('Last Changed'),
_('Date'),
]
#-------------------------------------------------------------------------
#
@ -87,6 +79,15 @@ class MediaView(PageView.ListView):
selection changes or when the selected media object changes.
"""
COLUMN_NAMES = [
_('Title'),
_('ID'),
_('Type'),
_('Path'),
_('Last Changed'),
_('Date'),
]
ADD_MSG = _("Add a new media object")
EDIT_MSG = _("Edit the selected media object")
DEL_MSG = _("Delete the selected media object")
@ -105,7 +106,8 @@ class MediaView(PageView.ListView):
PageView.ListView.__init__(
self, _('Media'), dbstate, uistate,
COLUMN_NAMES, len(COLUMN_NAMES), DisplayModels.MediaModel,
MediaView.COLUMN_NAMES, len(MediaView.COLUMN_NAMES),
DisplayModels.MediaModel,
signal_map, dbstate.db.get_media_bookmarks(),
Bookmarks.MediaBookmarks, filter_class=MediaSidebarFilter)
@ -247,7 +249,7 @@ class MediaView(PageView.ListView):
_('Select Media Columns'),
self.uistate,
self.dbstate.db.get_media_column_order(),
COLUMN_NAMES,
MediaView.COLUMN_NAMES,
self.set_column_order)
def set_column_order(self, clist):

View File

@ -58,12 +58,6 @@ from Editors import EditNote, DeleteNoteQuery
#-------------------------------------------------------------------------
from gettext import gettext as _
column_names = [
_('ID'),
_('Type'),
_('Marker'),
_('Preview'),
]
#-------------------------------------------------------------------------
#
@ -71,6 +65,13 @@ column_names = [
#
#-------------------------------------------------------------------------
class NoteView(PageView.ListView):
COLUMN_NAMES = [
_('ID'),
_('Type'),
_('Marker'),
_('Preview'),
]
ADD_MSG = _("Add a new note")
EDIT_MSG = _("Edit the selected note")
@ -92,8 +93,8 @@ class NoteView(PageView.ListView):
}
PageView.ListView.__init__(
self, _('Notes'), dbstate, uistate, column_names,
len(column_names), DisplayModels.NoteModel, signal_map,
self, _('Notes'), dbstate, uistate, NoteView.COLUMN_NAMES,
len(NoteView.COLUMN_NAMES), DisplayModels.NoteModel, signal_map,
dbstate.db.get_note_bookmarks(),
Bookmarks.NoteBookmarks,
filter_class=NoteSidebarFilter,
@ -184,7 +185,7 @@ class NoteView(PageView.ListView):
_('Select Note Columns'),
self.uistate,
self.dbstate.db.get_note_column_order(),
column_names,
NoteView.COLUMN_NAMES,
self.set_column_order)
def set_column_order(self, clist):

View File

@ -57,20 +57,6 @@ from Filters.SideBar import PlaceSidebarFilter
#-------------------------------------------------------------------------
from gettext import gettext as _
column_names = [
_('Place Name'),
_('ID'),
_('Church Parish'),
_('ZIP/Postal Code'),
_('City'),
_('County'),
_('State'),
_('Country'),
_('Longitude'),
_('Latitude'),
_('Last Changed'),
_('Street'),
]
#-------------------------------------------------------------------------
#
@ -78,6 +64,21 @@ column_names = [
#
#-------------------------------------------------------------------------
class PlaceView(PageView.ListView):
COLUMN_NAMES = [
_('Place Name'),
_('ID'),
_('Church Parish'),
_('ZIP/Postal Code'),
_('City'),
_('County'),
_('State'),
_('Country'),
_('Longitude'),
_('Latitude'),
_('Last Changed'),
_('Street'),
]
ADD_MSG = _("Add a new place")
EDIT_MSG = _("Edit the selected place")
@ -99,8 +100,9 @@ class PlaceView(PageView.ListView):
}
PageView.ListView.__init__(
self, _('Places'), dbstate, uistate, column_names,
len(column_names), DisplayModels.PlaceModel, signal_map,
self, _('Places'), dbstate, uistate, PlaceView.COLUMN_NAMES,
len(PlaceView.COLUMN_NAMES),
DisplayModels.PlaceModel, signal_map,
dbstate.db.get_place_bookmarks(),
Bookmarks.PlaceBookmarks,
multiple=True,
@ -158,7 +160,7 @@ class PlaceView(PageView.ListView):
_('Select Place Columns'),
self.uistate,
self.dbstate.db.get_place_column_order(),
column_names,
PlaceView.COLUMN_NAMES,
self.set_column_order)
def set_column_order(self, clist):

View File

@ -58,20 +58,6 @@ from Filters.SideBar import RepoSidebarFilter
#-------------------------------------------------------------------------
from gettext import gettext as _
column_names = [
_('Name'),
_('ID'),
_('Type'),
_('Home URL'),
_('Street'),
_('ZIP/Postal Code'),
_('City'),
_('County'),
_('State'),
_('Country'),
_('Email'),
_('Search URL'),
]
#-------------------------------------------------------------------------
#
@ -79,7 +65,22 @@ column_names = [
#
#-------------------------------------------------------------------------
class RepositoryView(PageView.ListView):
COLUMN_NAMES = [
_('Name'),
_('ID'),
_('Type'),
_('Home URL'),
_('Street'),
_('ZIP/Postal Code'),
_('City'),
_('County'),
_('State'),
_('Country'),
_('Email'),
_('Search URL'),
]
ADD_MSG = _("Add a new repository")
EDIT_MSG = _("Edit the selected repository")
DEL_MSG = _("Delete the selected repository")
@ -101,7 +102,7 @@ class RepositoryView(PageView.ListView):
PageView.ListView.__init__(
self, _('Repositories'), dbstate, uistate,
column_names, len(column_names),
RepositoryView.COLUMN_NAMES, len(RepositoryView.COLUMN_NAMES),
DisplayModels.RepositoryModel, signal_map,
dbstate.db.get_repo_bookmarks(),
Bookmarks.RepoBookmarks,filter_class=RepoSidebarFilter)
@ -129,7 +130,7 @@ class RepositoryView(PageView.ListView):
_('Select Repository Columns'),
self.uistate,
self.dbstate.db.get_repository_column_order(),
column_names,
RepositoryView.COLUMN_NAMES,
self.set_column_order)
def set_column_order(self, clist):

View File

@ -57,14 +57,6 @@ from Filters.SideBar import SourceSidebarFilter
#-------------------------------------------------------------------------
from gettext import gettext as _
column_names = [
_('Title'),
_('ID'),
_('Author'),
_('Abbreviation'),
_('Publication Information'),
_('Last Changed'),
]
#-------------------------------------------------------------------------
#
@ -73,6 +65,15 @@ column_names = [
#-------------------------------------------------------------------------
class SourceView(PageView.ListView):
COLUMN_NAMES = [
_('Title'),
_('ID'),
_('Author'),
_('Abbreviation'),
_('Publication Information'),
_('Last Changed'),
]
ADD_MSG = _("Add a new source")
EDIT_MSG = _("Edit the selected source")
DEL_MSG = _("Delete the selected source")
@ -93,8 +94,9 @@ class SourceView(PageView.ListView):
}
PageView.ListView.__init__(
self, _('Sources'), dbstate, uistate, column_names,
len(column_names), DisplayModels.SourceModel, signal_map,
self, _('Sources'), dbstate, uistate,
SourceView.COLUMN_NAMES, len(SourceView.COLUMN_NAMES),
DisplayModels.SourceModel, signal_map,
dbstate.db.get_source_bookmarks(),
Bookmarks.SourceBookmarks, multiple=True,
filter_class=SourceSidebarFilter)
@ -124,7 +126,7 @@ class SourceView(PageView.ListView):
_('Select Source Columns'),
self.uistate,
self.dbstate.db.get_source_column_order(),
column_names,
SourceView.COLUMN_NAMES,
self.set_column_order)
def set_column_order(self, clist):

View File

@ -35,6 +35,7 @@ import pango
#-------------------------------------------------------------------------
import const
import ManagedWindow
from Filters import SearchBar
#-------------------------------------------------------------------------
#
@ -42,12 +43,22 @@ import ManagedWindow
#
#-------------------------------------------------------------------------
class BaseSelector(ManagedWindow.ManagedWindow):
"""Base class for the selectors, showing a dialog from which to select
one of the primary objects
"""
NONE = -1
TEXT = 0
MARKUP = 1
IMAGE = 2
def __init__(self, dbstate, uistate, track=[], filter=None, skip=set()):
def __init__(self, dbstate, uistate, track=[], filter=None, skip=set(),
show_search_bar = True):
'''Set up the dialog with the dbstate and uistate, track of parent
windows for ManagedWindow, initial filter for the model, skip with
set of handles to skip in the view, and search_bar to show the
SearchBar at the top or not.
'''
self.title = self.get_window_title()
ManagedWindow.ManagedWindow.__init__(self, uistate, track, self)
@ -59,18 +70,34 @@ class BaseSelector(ManagedWindow.ManagedWindow):
self.glade = gtk.glade.XML(const.GLADE_FILE,"select_person","gramps")
window = self.glade.get_widget('select_person')
title_label = self.glade.get_widget('title')
vbox = self.glade.get_widget('select_person_vbox')
self.tree = self.glade.get_widget('plist')
self.tree.connect('row-activated', self._on_row_activated)
self.colinfo = self.column_view_names()
#add the search bar
self.search_bar = SearchBar(dbstate, uistate,
self.build_tree)
filter_box = self.search_bar.build()
self.setup_filter()
vbox.pack_start(filter_box, False, False)
vbox.reorder_child(filter_box, 1)
self.set_window(window,title_label,self.title)
self.model = self.get_model_class()(self.db,skip=skip)
self.skip_list=skip
self.build_tree()
self.selection = self.tree.get_selection()
self.tree.set_model(self.model)
self.add_columns(self.tree)
self._local_init()
self.show()
#show or hide search bar?
self.set_show_search_bar(show_search_bar)
#Hide showall always (used in person selector only)
showbox = self.glade.get_widget('showall')
showbox.hide()
def add_columns(self,tree):
tree.set_fixed_height_mode(True)
@ -139,3 +166,53 @@ class BaseSelector(ManagedWindow.ManagedWindow):
def get_handle_column(self):
# return 3
assert False, "Must be defined in the subclass"
def set_show_search_bar(self, value):
'''make the search bar at the top shown
'''
self.show_search_bar = value
if not self.search_bar :
return
if self.show_search_bar :
self.search_bar.show()
else :
self.search_bar.hide()
def column_order(self):
"""
Column order for db columns
Derived classes must override this function.
"""
raise NotImplementedError
def column_view_names(self):
"""
Get correct column view names on which model is based
Derived classes must override this function.
"""
raise NotImplementedError
def setup_filter(self):
"""
Builds the default filters and add them to the filter bar.
"""
cols = []
for pair in [pair for pair in self.column_order() if pair[0]]:
cols.append((self.colinfo[pair[1]], pair[1]))
self.search_bar.setup_filter(cols)
def build_tree(self):
"""
Builds the selection people see in the Selector
"""
#search info for the
filter_info = (False, self.search_bar.get_value())
#reset the model
self.model = self.get_model_class()(self.db, skip=self.skip_list,
search=filter_info)
self.tree.set_model(self.model)

View File

@ -66,3 +66,17 @@ class SelectEvent(BaseSelector):
def get_handle_column(self):
return 6
def column_order(self):
"""
returns a tuple indicating the column order of the model
"""
return self.db.get_event_column_order()
def column_view_names(self):
"""
Get correct column view names on which model is based
"""
import DataViews
return DataViews.EventView.COLUMN_NAMES

View File

@ -59,4 +59,17 @@ class SelectFamily(BaseSelector):
return self.db.get_family_from_handle
def get_handle_column(self):
return 5
return 6
def column_order(self):
"""
returns a tuple indicating the column order of the model
"""
return self.db.get_family_list_column_order()
def column_view_names(self):
"""
Get correct column view names on which model is based
"""
import DataViews
return DataViews.FamilyListView.COLUMN_NAMES

View File

@ -93,3 +93,16 @@ class SelectObject(BaseSelector):
pix = ThumbNails.get_thumbnail_image(obj.get_path())
self.preview.set_from_pixbuf(pix)
gc.collect()
def column_order(self):
"""
returns a tuple indicating the column order of the model
"""
return self.db.get_media_column_order()
def column_view_names(self):
"""
Get correct column view names on which model is based
"""
import DataViews
return DataViews.MediaView.COLUMN_NAMES

View File

@ -59,3 +59,16 @@ class SelectPlace(BaseSelector):
def get_handle_column(self):
return PlaceModel.HANDLE_COL
def column_order(self):
"""
returns a tuple indicating the column order of the model
"""
return self.db.get_place_column_order()
def column_view_names(self):
"""
Get correct column view names on which model is based
"""
import DataViews
return DataViews.PlaceView.COLUMN_NAMES

View File

@ -59,3 +59,16 @@ class SelectRepository(BaseSelector):
def get_from_handle_func(self):
return self.db.get_repository_from_handle
def column_order(self):
"""
returns a tuple indicating the column order of the model
"""
return self.db.get_repository_column_order()
def column_view_names(self):
"""
Get correct column view names on which model is based
"""
import DataViews
return DataViews.RepositoryView.COLUMN_NAMES

View File

@ -59,3 +59,16 @@ class SelectSource(BaseSelector):
def get_handle_column(self):
return 6
def column_order(self):
"""
returns a tuple indicating the column order of the model
"""
return self.db.get_source_column_order()
def column_view_names(self):
"""
Get correct column view names on which model is based
"""
import DataViews
return DataViews.SourceView.COLUMN_NAMES