fixes to StatisticsChart
svn: r3901
This commit is contained in:
parent
0c638f4595
commit
b4c0e9df90
@ -1,3 +1,10 @@
|
|||||||
|
2005-01-11 Eero Tamminen <eerot@sf>
|
||||||
|
* src/plugins/StatisticsChart.py: remove localization from command
|
||||||
|
line options help and put it back to dialog additions. Have
|
||||||
|
options in code in same order as in the GUI. Alias
|
||||||
|
options_class.handler.options_dict for more readable code.
|
||||||
|
Fix sort and gender option parsing.
|
||||||
|
|
||||||
2005-01-11 Alex Roitman <shura@alex.neuro.umn.edu>
|
2005-01-11 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||||
* src/GrampsGconfKeys.py (get_event_id_prefix): Typo.
|
* src/GrampsGconfKeys.py (get_event_id_prefix): Typo.
|
||||||
* src/GrampsIniKeys.py (get_event_id_prefix): Typo.
|
* src/GrampsIniKeys.py (get_event_id_prefix): Typo.
|
||||||
|
@ -263,7 +263,8 @@ class Extract:
|
|||||||
items[key] = 1
|
items[key] = 1
|
||||||
return items
|
return items
|
||||||
|
|
||||||
# GLOBAL: ready instance for others to use
|
# GLOBAL: required so that we get access to _Extract.extractors[]
|
||||||
|
# Unfortunately class variables cannot reference instance methods :-/
|
||||||
_Extract = Extract()
|
_Extract = Extract()
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
@ -293,18 +294,17 @@ class StatisticsChart(Report.Report):
|
|||||||
filters.extend(GenericFilter.CustomFilters.get_filters())
|
filters.extend(GenericFilter.CustomFilters.get_filters())
|
||||||
filterfun = filters[filter_num]
|
filterfun = filters[filter_num]
|
||||||
|
|
||||||
year_from = options_class.handler.options_dict['year_from']
|
options = options_class.handler.options_dict
|
||||||
year_to = options_class.handler.options_dict['year_to']
|
year_from = options['year_from']
|
||||||
gender = options_class.handler.options_dict['gender']
|
year_to = options['year_to']
|
||||||
|
gender = options['gender']
|
||||||
|
|
||||||
extract = _Extract.extractors[options_class.handler.options_dict['extract']]
|
(title, extractfun) = _Extract.extractors[options['extract']]
|
||||||
# extract requested items from the database and count them
|
# extract requested items from the database and count them
|
||||||
self.items = _Extract.collect_data(database, filterfun, extract[1],
|
self.items = _Extract.collect_data(database, filterfun, extractfun,
|
||||||
gender, year_from, year_to,
|
gender, year_from, year_to, options['no_years'])
|
||||||
options_class.handler.options_dict['no_years'])
|
|
||||||
# generate sorted item lookup index index
|
# generate sorted item lookup index index
|
||||||
self.index_items(options_class.handler.options_dict['sort'],
|
self.index_items(options['sort'], options['reverse'])
|
||||||
options_class.handler.options_dict['reverse'])
|
|
||||||
|
|
||||||
# title needs both data extraction method name + gender name
|
# title needs both data extraction method name + gender name
|
||||||
if gender == Person.male:
|
if gender == Person.male:
|
||||||
@ -315,9 +315,9 @@ class StatisticsChart(Report.Report):
|
|||||||
genderstr = None
|
genderstr = None
|
||||||
|
|
||||||
if genderstr:
|
if genderstr:
|
||||||
self.title = "%s (%s): %04d-%04d" % (extract[0], genderstr, year_from, year_to)
|
self.title = "%s (%s): %04d-%04d" % (title, genderstr, year_from, year_to)
|
||||||
else:
|
else:
|
||||||
self.title = "%s: %04d-%04d" % (extract[0], year_from, year_to)
|
self.title = "%s: %04d-%04d" % (title, year_from, year_to)
|
||||||
|
|
||||||
self.setup()
|
self.setup()
|
||||||
|
|
||||||
@ -457,32 +457,32 @@ class StatisticsChartOptions(ReportOptions.ReportOptions):
|
|||||||
def set_new_options(self):
|
def set_new_options(self):
|
||||||
# Options specific for this report
|
# Options specific for this report
|
||||||
self.options_dict = {
|
self.options_dict = {
|
||||||
'year_to' : time.localtime()[0],
|
|
||||||
'year_from' : 1700,
|
|
||||||
'no_years' : 0,
|
|
||||||
'extract' : 0,
|
'extract' : 0,
|
||||||
'gender' : Person.unknown,
|
|
||||||
'sort' : _SORT_VALUE,
|
'sort' : _SORT_VALUE,
|
||||||
'reverse' : 0
|
'reverse' : 0,
|
||||||
|
'year_from' : 1700,
|
||||||
|
'year_to' : time.localtime()[0],
|
||||||
|
'no_years' : 0,
|
||||||
|
'gender' : Person.unknown
|
||||||
}
|
}
|
||||||
self.options_help = {
|
self.options_help = {
|
||||||
'year_to' : ("=num", _("Birth year until which to include people"),
|
'extract' : ("=num", "Data to show",
|
||||||
_("smaller than %d") % self.options_dict['year_to']),
|
|
||||||
'year_from' : ("=num", _("Birth year from which to include people"),
|
|
||||||
_("earlier than 'year_to' value")),
|
|
||||||
'no_years' : ("=num", _("Include people without birth years"),
|
|
||||||
[_("No"), _("Yes")], True),
|
|
||||||
'gender' : ("=num", _('Genders included'),
|
|
||||||
[ "%d\t%s" % item for item in self._genders],
|
|
||||||
False),
|
|
||||||
'extract' : ("=num", _('Data to show'),
|
|
||||||
[item[0] for item in _Extract.extractors],
|
[item[0] for item in _Extract.extractors],
|
||||||
False),
|
False),
|
||||||
'sort' : ("=num", _('Sorted by'),
|
'sort' : ("=num", "Sorted by",
|
||||||
[ "%d\t%s" % item for item in self._sorts],
|
["%d\t%s" % item for item in self._sorts],
|
||||||
False),
|
False),
|
||||||
'reverse' : ("=num", _("Sort in reverse order"),
|
'reverse' : ("=num", "Sort in reverse order",
|
||||||
[_("No"), _("Yes")], True)
|
["No", "Yes"], True),
|
||||||
|
'year_from' : ("=num", "Birth year from which to include people",
|
||||||
|
"earlier than 'year_to' value"),
|
||||||
|
'year_to' : ("=num", "Birth year until which to include people",
|
||||||
|
("smaller than %d") % self.options_dict['year_to']),
|
||||||
|
'no_years' : ("=num", "Include people without birth years",
|
||||||
|
["No", "Yes"], True),
|
||||||
|
'gender' : ("=num", "Genders included",
|
||||||
|
["%d\t%s" % item for item in self._genders],
|
||||||
|
False)
|
||||||
}
|
}
|
||||||
|
|
||||||
def enable_options(self):
|
def enable_options(self):
|
||||||
@ -550,7 +550,7 @@ class StatisticsChartOptions(ReportOptions.ReportOptions):
|
|||||||
self.extract_menu.append_text(item[0])
|
self.extract_menu.append_text(item[0])
|
||||||
self.extract_menu.set_active(self.options_dict['extract'])
|
self.extract_menu.set_active(self.options_dict['extract'])
|
||||||
tip = _("Select which data is collected and which statistics is shown.")
|
tip = _("Select which data is collected and which statistics is shown.")
|
||||||
dialog.add_option(self.options_help['extract'][1], self.extract_menu, tip)
|
dialog.add_option(_("Data to show"), self.extract_menu, tip)
|
||||||
|
|
||||||
# how to sort the data
|
# how to sort the data
|
||||||
self.sort_menu = gtk.combo_box_new_text()
|
self.sort_menu = gtk.combo_box_new_text()
|
||||||
@ -560,11 +560,11 @@ class StatisticsChartOptions(ReportOptions.ReportOptions):
|
|||||||
if item[0] == self.options_dict['sort']:
|
if item[0] == self.options_dict['sort']:
|
||||||
self.sort_menu.set_active(item_idx)
|
self.sort_menu.set_active(item_idx)
|
||||||
tip = _("Select how the statistical data is sorted.")
|
tip = _("Select how the statistical data is sorted.")
|
||||||
dialog.add_option(self.options_help['sort'][1], self.sort_menu, tip)
|
dialog.add_option(_("Sorted by"), self.sort_menu, tip)
|
||||||
|
|
||||||
# sorting order
|
# sorting order
|
||||||
tip = _("Check to reverse the sorting order.")
|
tip = _("Check to reverse the sorting order.")
|
||||||
self.reverse = gtk.CheckButton(self.options_help['reverse'][1])
|
self.reverse = gtk.CheckButton(_("Sort in reverse order"))
|
||||||
self.reverse.set_active(self.options_dict['reverse'])
|
self.reverse.set_active(self.options_dict['reverse'])
|
||||||
dialog.add_option(None, self.reverse, tip)
|
dialog.add_option(None, self.reverse, tip)
|
||||||
self.reverse.show()
|
self.reverse.show()
|
||||||
@ -585,7 +585,7 @@ class StatisticsChartOptions(ReportOptions.ReportOptions):
|
|||||||
|
|
||||||
# include people without birth year?
|
# include people without birth year?
|
||||||
tip = _("Check this if you want people who have no birth date or year to be accounted also in the statistics.")
|
tip = _("Check this if you want people who have no birth date or year to be accounted also in the statistics.")
|
||||||
self.no_years = gtk.CheckButton(self.options_help['no_years'][1])
|
self.no_years = gtk.CheckButton(_("Include people without birth years"))
|
||||||
self.no_years.set_active(self.options_dict['no_years'])
|
self.no_years.set_active(self.options_dict['no_years'])
|
||||||
dialog.add_option(None, self.no_years, tip)
|
dialog.add_option(None, self.no_years, tip)
|
||||||
self.no_years.show()
|
self.no_years.show()
|
||||||
@ -598,19 +598,19 @@ class StatisticsChartOptions(ReportOptions.ReportOptions):
|
|||||||
if item[0] == self.options_dict['gender']:
|
if item[0] == self.options_dict['gender']:
|
||||||
self.gender_menu.set_active(item_idx)
|
self.gender_menu.set_active(item_idx)
|
||||||
tip = _("Select which genders are included into statistics.")
|
tip = _("Select which genders are included into statistics.")
|
||||||
dialog.add_option(self.options_help['gender'][1], self.gender_menu, tip)
|
dialog.add_option(_("Genders included"), self.gender_menu, tip)
|
||||||
|
|
||||||
def parse_user_options(self, dialog):
|
def parse_user_options(self, dialog):
|
||||||
"""
|
"""
|
||||||
Parses the custom options that we have added.
|
Parses the custom options that we have added.
|
||||||
"""
|
"""
|
||||||
|
self.options_dict['extract'] = self.extract_menu.get_active()
|
||||||
|
self.options_dict['sort'] = self._sorts[self.sort_menu.get_active()][0]
|
||||||
|
self.options_dict['reverse'] = int(self.reverse.get_active())
|
||||||
self.options_dict['year_to'] = int(self.to_box.get_text())
|
self.options_dict['year_to'] = int(self.to_box.get_text())
|
||||||
self.options_dict['year_from'] = int(self.from_box.get_text())
|
self.options_dict['year_from'] = int(self.from_box.get_text())
|
||||||
self.options_dict['no_years'] = int(self.no_years.get_active())
|
self.options_dict['no_years'] = int(self.no_years.get_active())
|
||||||
self.options_dict['gender'] = self.gender_menu.get_active()
|
self.options_dict['gender'] = self._genders[self.gender_menu.get_active()][0]
|
||||||
self.options_dict['extract'] = self.extract_menu.get_active()
|
|
||||||
self.options_dict['sort'] = self.sort_menu.get_active()
|
|
||||||
self.options_dict['reverse'] = int(self.reverse.get_active())
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
|
Loading…
Reference in New Issue
Block a user