예제 #1
0
class FamilyLinesOptions(MenuReportOptions):
    """
    Defines all of the controls necessary
    to configure the FamilyLines report.
    """
    def __init__(self, name, dbase):
        self.limit_parents = None
        self.max_parents = None
        self.limit_children = None
        self.max_children = None
        self.include_images = None
        self.image_location = None
        self.justyears = None
        self.include_dates = None
        MenuReportOptions.__init__(self, name, dbase)

    def add_menu_options(self, menu):

        # ---------------------
        category_name = _('Report Options')
        add_option = partial(menu.add_option, category_name)
        # ---------------------

        followpar = BooleanOption(_('Follow parents to determine '
                                    '"family lines"'), True)
        followpar.set_help(_('Parents and their ancestors will be '
                             'considered when determining "family lines".'))
        add_option('followpar', followpar)

        followchild = BooleanOption(_('Follow children to determine '
                                      '"family lines"'), True)
        followchild.set_help(_('Children will be considered when '
                               'determining "family lines".'))
        add_option('followchild', followchild)

        remove_extra_people = BooleanOption(_('Try to remove extra '
                                              'people and families'), True)
        remove_extra_people.set_help(_('People and families not directly '
                                       'related to people of interest will '
                                       'be removed when determining '
                                       '"family lines".'))
        add_option('removeextra', remove_extra_people)

        arrow = EnumeratedListOption(_("Arrowhead direction"), 'd')
        for i in range( 0, len(_ARROWS) ):
            arrow.add_item(_ARROWS[i]["value"], _ARROWS[i]["name"])
        arrow.set_help(_("Choose the direction that the arrows point."))
        add_option("arrow", arrow)

        color = EnumeratedListOption(_("Graph coloring"), "filled")
        for i in range(len(_COLORS)):
            color.add_item(_COLORS[i]["value"], _COLORS[i]["name"])
        color.set_help(_("Males will be shown with blue, females "
                         "with red, unless otherwise set above for filled. "
                         "If the sex of an individual "
                         "is unknown it will be shown with gray."))
        add_option("color", color)

        roundedcorners = EnumeratedListOption(_("Rounded corners"), '')
        for i in range( 0, len(_CORNERS) ):
            roundedcorners.add_item(_CORNERS[i]["value"], _CORNERS[i]["name"])
        roundedcorners.set_help(_("Use rounded corners e.g. to differentiate "
                         "between women and men."))
        add_option("useroundedcorners", roundedcorners)

        stdoptions.add_gramps_id_option(menu, category_name, ownline=True)

        # ---------------------
        category_name = _('Report Options (2)')
        add_option = partial(menu.add_option, category_name)
        # ---------------------

        stdoptions.add_name_format_option(menu, category_name)

        stdoptions.add_private_data_option(menu, category_name, default=False)

        stdoptions.add_living_people_option(menu, category_name)

        locale_opt = stdoptions.add_localization_option(menu, category_name)

        stdoptions.add_date_format_option(menu, category_name, locale_opt)

        # --------------------------------
        add_option = partial(menu.add_option, _('People of Interest'))
        # --------------------------------

        person_list = PersonListOption(_('People of interest'))
        person_list.set_help(_('People of interest are used as a starting '
                               'point when determining "family lines".'))
        add_option('gidlist', person_list)

        self.limit_parents = BooleanOption(_('Limit the number of ancestors'),
                                           False)
        self.limit_parents.set_help(_('Whether to '
                                      'limit the number of ancestors.'))
        add_option('limitparents', self.limit_parents)
        self.limit_parents.connect('value-changed', self.limit_changed)

        self.max_parents = NumberOption('', 50, 10, 9999)
        self.max_parents.set_help(_('The maximum number '
                                    'of ancestors to include.'))
        add_option('maxparents', self.max_parents)

        self.limit_children = BooleanOption(_('Limit the number '
                                              'of descendants'),
                                            False)
        self.limit_children.set_help(_('Whether to '
                                       'limit the number of descendants.'))
        add_option('limitchildren', self.limit_children)
        self.limit_children.connect('value-changed', self.limit_changed)

        self.max_children = NumberOption('', 50, 10, 9999)
        self.max_children.set_help(_('The maximum number '
                                     'of descendants to include.'))
        add_option('maxchildren', self.max_children)

        # --------------------
        category_name = _('Include')
        add_option = partial(menu.add_option, category_name)
        # --------------------

        self.include_dates = BooleanOption(_('Include dates'), True)
        self.include_dates.set_help(_('Whether to include dates for people '
                                      'and families.'))
        add_option('incdates', self.include_dates)
        self.include_dates.connect('value-changed', self.include_dates_changed)

        self.justyears = BooleanOption(_("Limit dates to years only"), False)
        self.justyears.set_help(_("Prints just dates' year, neither "
                                  "month or day nor date approximation "
                                  "or interval are shown."))
        add_option("justyears", self.justyears)

        include_places = BooleanOption(_('Include places'), True)
        include_places.set_help(_('Whether to include placenames for people '
                                  'and families.'))
        add_option('incplaces', include_places)

        include_num_children = BooleanOption(_('Include the number of '
                                               'children'), True)
        include_num_children.set_help(_('Whether to include the number of '
                                        'children for families with more '
                                        'than 1 child.'))
        add_option('incchildcnt', include_num_children)

        self.include_images = BooleanOption(_('Include '
                                              'thumbnail images of people'),
                                            True)
        self.include_images.set_help(_('Whether to '
                                       'include thumbnail images of people.'))
        add_option('incimages', self.include_images)
        self.include_images.connect('value-changed', self.images_changed)

        self.image_location = EnumeratedListOption(_('Thumbnail location'), 0)
        self.image_location.add_item(0, _('Above the name'))
        self.image_location.add_item(1, _('Beside the name'))
        self.image_location.set_help(_('Where the thumbnail image '
                                       'should appear relative to the name'))
        add_option('imageonside', self.image_location)

        self.image_size = EnumeratedListOption(_('Thumbnail size'), SIZE_NORMAL)
        self.image_size.add_item(SIZE_NORMAL, _('Normal'))
        self.image_size.add_item(SIZE_LARGE, _('Large'))
        self.image_size.set_help(_('Size of the thumbnail image'))
        add_option('imagesize', self.image_size)

        # ----------------------------
        add_option = partial(menu.add_option, _('Family Colors'))
        # ----------------------------

        surname_color = SurnameColorOption(_('Family colors'))
        surname_color.set_help(_('Colors to use for various family lines.'))
        add_option('surnamecolors', surname_color)

        # -------------------------
        add_option = partial(menu.add_option, _('Individuals'))
        # -------------------------

        color_males = ColorOption(_('Males'), '#e0e0ff')
        color_males.set_help(_('The color to use to display men.'))
        add_option('colormales', color_males)

        color_females = ColorOption(_('Females'), '#ffe0e0')
        color_females.set_help(_('The color to use to display women.'))
        add_option('colorfemales', color_females)

        color_unknown = ColorOption(_('Unknown'), '#e0e0e0')
        color_unknown.set_help(_('The color to use '
                                 'when the gender is unknown.'))
        add_option('colorunknown', color_unknown)

        color_family = ColorOption(_('Families'), '#ffffe0')
        color_family.set_help(_('The color to use to display families.'))
        add_option('colorfamilies', color_family)

        self.limit_changed()
        self.images_changed()

    def limit_changed(self):
        """
        Handle the change of limiting parents and children.
        """
        self.max_parents.set_available(self.limit_parents.get_value())
        self.max_children.set_available(self.limit_children.get_value())

    def images_changed(self):
        """
        Handle the change of including images.
        """
        self.image_location.set_available(self.include_images.get_value())
        self.image_size.set_available(self.include_images.get_value())

    def include_dates_changed(self):
        """
        Enable/disable menu items if dates are required
        """
        if self.include_dates.get_value():
            self.justyears.set_available(True)
        else:
            self.justyears.set_available(False)
예제 #2
0
class AncestorTreeOptions(MenuReportOptions):
    """
    Defines options and provides handling interface.
    """
    def __init__(self, name, dbase):
        self.__db = dbase
        self.__pid = None
        self.box_Y_sf = None
        self.box_shadow_sf = None
        MenuReportOptions.__init__(self, name, dbase)

    def get_subject(self):
        """ Return a string that describes the subject of the report. """
        gid = self.__pid.get_value()
        person = self.__db.get_person_from_gramps_id(gid)
        return _nd.display(person)

    def add_menu_options(self, menu):

        ##################
        category_name = _("Tree Options")

        self.__pid = PersonOption(_("Center Person"))
        self.__pid.set_help(_("The center person for the tree"))
        menu.add_option(category_name, "pid", self.__pid)

        siblings = BooleanOption(_('Include siblings of the center person'),
                                 False)
        siblings.set_help(
            _("Whether to only display the center person or all "
              "of his/her siblings too"))
        menu.add_option(category_name, "inc_siblings", siblings)

        self.max_gen = NumberOption(_("Generations"), 10, 1, 50)
        self.max_gen.set_help(
            _("The number of generations to include "
              "in the tree"))
        menu.add_option(category_name, "maxgen", self.max_gen)

        self.fillout = EnumeratedListOption(_("Display unknown\ngenerations"),
                                            0)
        self.fillout.set_help(
            _("The number of generations of empty "
              "boxes that will be displayed"))
        menu.add_option(category_name, "fill_out", self.fillout)

        self.max_gen.connect('value-changed', self.__fillout_vals)
        self.__fillout_vals()

        compress = BooleanOption(_('Compress tree'), True)
        compress.set_help(
            _("Whether to remove any extra blank spaces set "
              "aside for people that are unknown"))
        menu.add_option(category_name, "compress_tree", compress)

        self.show_idx = BooleanOption(_('Show Index'), False)
        self.show_idx.set_help(_("Display index of each person"))
        menu.add_option(category_name, "show_idx", self.show_idx)
        self.show_idx.connect('value-changed', self._showidx_changed)

        self.start_idx = NumberOption(_("Start Index"), 1, 1, 50)
        self.start_idx.set_help(_("The start index"))
        menu.add_option(category_name, "start_idx", self.start_idx)

        #better to 'Show siblings of\nthe center person
        #Spouse_disp = EnumeratedListOption(_("Show spouses of\nthe center "
        #                                     "person"), 0)
        #Spouse_disp.add_item(0, _("No.  Do not show Spouses"))
        #Spouse_disp.add_item(1, _("Yes, and use the Main Display Format"))
        #Spouse_disp.add_item(2, _("Yes, and use the Secondary "
        #                           "Display Format"))
        #Spouse_disp.set_help(_("Show spouses of the center person?"))
        #menu.add_option(category_name, "Spouse_disp", Spouse_disp)

        ##################
        category_name = _("Report Options")

        self.title = EnumeratedListOption(_("Report Title"), 0)
        self.title.add_item(0, _("Do not include a title"))
        self.title.add_item(1, _("Include Report Title"))
        self.title.set_help(_("Choose a title for the report"))
        menu.add_option(category_name, "report_title", self.title)

        border = BooleanOption(_('Include a border'), False)
        border.set_help(_("Whether to make a border around the report."))
        menu.add_option(category_name, "inc_border", border)

        prnnum = BooleanOption(_('Include Page Numbers'), False)
        prnnum.set_help(_("Whether to print page numbers on each page."))
        menu.add_option(category_name, "inc_pagenum", prnnum)

        self.scale = EnumeratedListOption(_("Scale tree to fit"), 0)
        self.scale.add_item(0, _("Do not scale tree"))
        self.scale.add_item(1, _("Scale tree to fit page width only"))
        self.scale.add_item(2, _("Scale tree to fit the size of the page"))
        self.scale.set_help(
            _("Whether to scale the tree to fit a specific paper size"))
        menu.add_option(category_name, "scale_tree", self.scale)
        self.scale.connect('value-changed', self.__check_blank)

        if "BKI" not in self.name.split(","):
            self.__onepage = BooleanOption(
                _("Resize Page to Fit Tree size\n"
                  "\n"
                  "Note: Overrides options in the 'Paper Option' tab"), False)
            self.__onepage.set_help(
                _("Whether to resize the page to fit the size \n"
                  "of the tree.  Note:  the page will have a \n"
                  "non standard size.\n"
                  "\n"
                  "With this option selected, the following will happen:\n"
                  "\n"
                  "With the 'Do not scale tree' option the page\n"
                  "  is resized to the height/width of the tree\n"
                  "\n"
                  "With 'Scale tree to fit page width only' the height of\n"
                  "  the page is resized to the height of the tree\n"
                  "\n"
                  "With 'Scale tree to fit the size of the page' the page\n"
                  "  is resized to remove any gap in either height or width"))
            menu.add_option(category_name, "resize_page", self.__onepage)
            self.__onepage.connect('value-changed', self.__check_blank)
        else:
            self.__onepage = None

        self.__blank = BooleanOption(_('Include Blank Pages'), True)
        self.__blank.set_help(_("Whether to include pages that are blank."))
        menu.add_option(category_name, "inc_blank", self.__blank)

        self.__check_blank()

        ##################
        category_name = _("Report Options (2)")

        stdoptions.add_name_format_option(menu, category_name)

        stdoptions.add_living_people_option(menu, category_name)

        stdoptions.add_private_data_option(menu, category_name)

        locale_opt = stdoptions.add_localization_option(menu, category_name)

        stdoptions.add_date_format_option(menu, category_name, locale_opt)

        ##################
        category_name = _("Display")

        disp = TextOption(
            _("Father\nDisplay Format"),
            ["$n", "%s $b" % _BORN, "-{%s $d}" % _DIED])
        disp.set_help(_("Display format for the fathers box."))
        menu.add_option(category_name, "father_disp", disp)

        #Will add when libsubstkeyword supports it.
        #missing = EnumeratedListOption(_("Replace missing\nplaces\\dates \
        #                                 with"), 0)
        #missing.add_item(0, _("Does not display anything"))
        #missing.add_item(1, _("Displays '_____'"))
        #missing.set_help(_("What will print when information is not known"))
        #menu.add_option(category_name, "miss_val", missing)

        disp_mom = TextOption(
            _("Mother\nDisplay Format"),
            ["$n", "%s $b" % _BORN,
             "%s $m" % _MARR,
             "-{%s $d}" % _DIED])
        disp_mom.set_help(_("Display format for the mothers box."))
        menu.add_option(category_name, "mother_disp", disp_mom)

        center_disp = EnumeratedListOption(
            _("Center person uses\n"
              "which format"), 0)
        center_disp.add_item(0, _("Use Fathers Display format"))
        center_disp.add_item(1, _("Use Mothers display format"))
        center_disp.set_help(_("The display format for the center person"))
        menu.add_option(category_name, "center_uses", center_disp)

        self.incmarr = BooleanOption(_('Include Marriage box'), False)
        self.incmarr.set_help(
            _("Whether to include a separate marital box in the report"))
        menu.add_option(category_name, "inc_marr", self.incmarr)
        self.incmarr.connect('value-changed', self._incmarr_changed)

        self.marrdisp = StringOption(_("Marriage\nDisplay Format"),
                                     "%s $m" % _MARR)
        self.marrdisp.set_help(_("Display format for the marital box."))
        menu.add_option(category_name, "marr_disp", self.marrdisp)
        self._incmarr_changed()

        ##################
        category_name = _("Advanced")

        repldisp = TextOption(
            _("Replace Display Format:\n'Replace this'/' with this'"), [])
        repldisp.set_help(_("i.e.\nUnited States of America/U.S.A."))
        menu.add_option(category_name, "replace_list", repldisp)

        # TODO this code is never used and so I conclude it is for future use
        # self.__include_images = BooleanOption(
        #                       _('Include thumbnail images of people'), False)
        # self.__include_images.set_help(
        #                       _("Whether to include thumbnails of people."))
        # menu.add_option(category_name, "includeImages",
        #                 self.__include_images)

        self.usenote = BooleanOption(_('Include a note'), False)
        self.usenote.set_help(_("Whether to include a note on the report."))
        menu.add_option(category_name, "inc_note", self.usenote)
        self.usenote.connect('value-changed', self._usenote_changed)

        self.notedisp = TextOption(_("Note"), [])
        self.notedisp.set_help(_("Add a note\n\n" "$T inserts today's date"))
        menu.add_option(category_name, "note_disp", self.notedisp)

        locales = NoteType(0, 1)
        self.notelocal = EnumeratedListOption(_("Note Location"), 0)
        for num, text in locales.note_locals():
            self.notelocal.add_item(num, text)
        self.notelocal.set_help(_("Where to place the note."))
        menu.add_option(category_name, "note_place", self.notelocal)
        self._usenote_changed()

        self.box_Y_sf = NumberOption(_("inter-box scale factor"), 1.00, 0.10,
                                     2.00, 0.01)
        self.box_Y_sf.set_help(
            _("Make the inter-box spacing bigger or smaller"))
        menu.add_option(category_name, "box_Yscale", self.box_Y_sf)

        self.box_shadow_sf = NumberOption(_("box shadow scale factor"), 1.00,
                                          0.00, 2.00, 0.01)  # down to 0
        self.box_shadow_sf.set_help(_("Make the box shadow bigger or smaller"))
        menu.add_option(category_name, "shadowscale", self.box_shadow_sf)

    def _incmarr_changed(self):
        """
        If Marriage box is not enabled, disable Marriage Display Format box
        """
        value = self.incmarr.get_value()
        self.marrdisp.set_available(value)

    def _usenote_changed(self):
        """
        If Note box is not enabled, disable Note Location box
        """
        value = self.usenote.get_value()
        self.notelocal.set_available(value)

    def _showidx_changed(self):
        """
        If Show Index box is enabled, enable Start Index field
        """
        value = self.show_idx.get_value()
        self.start_idx.set_available(value)

    def __check_blank(self):
        if self.__onepage:
            value = not self.__onepage.get_value()
        else:
            value = True
        off = value and (self.scale.get_value() != 2)
        self.__blank.set_available(off)

    def __fillout_vals(self):
        max_gen = self.max_gen.get_value()
        old_val = self.fillout.get_value()
        item_list = []
        item_list.append(
            [0, _("No generations of empty boxes "
                  "for unknown ancestors")])
        if max_gen > 1:
            item_list.append([
                1,
                _("One Generation of empty boxes "
                  "for unknown ancestors")
            ])

        item_list.extend([
            itr,
            str(itr) + _(" Generations of empty boxes for unknown ancestors")
        ] for itr in range(2, max_gen))

        self.fillout.set_items(item_list)
        if old_val + 2 > len(item_list):
            self.fillout.set_value(len(item_list) - 2)

    def make_default_style(self, default_style):
        """Make the default output style for the Ancestor Tree."""

        # Paragraph Styles:
        font = FontStyle()
        font.set_size(9)
        font.set_type_face(FONT_SANS_SERIF)
        para_style = ParagraphStyle()
        para_style.set_font(font)
        para_style.set_description(
            _('The basic style used for the text display.'))
        default_style.add_paragraph_style("AC2-Normal", para_style)
        box_shadow = PT2CM(font.get_size()) * .6

        font = FontStyle()
        font.set_size(9)
        font.set_type_face(FONT_SANS_SERIF)
        para_style = ParagraphStyle()
        para_style.set_font(font)
        para_style.set_description(
            _('The basic style used for the note display.'))
        default_style.add_paragraph_style("AC2-Note", para_style)

        font = FontStyle()
        font.set_size(16)
        font.set_type_face(FONT_SANS_SERIF)
        para_style = ParagraphStyle()
        para_style.set_font(font)
        para_style.set_alignment(PARA_ALIGN_CENTER)
        para_style.set_description(_('The style used for the title.'))
        default_style.add_paragraph_style("AC2-Title", para_style)

        # Draw styles
        graph_style = GraphicsStyle()
        graph_style.set_paragraph_style("AC2-Normal")
        graph_style.set_shadow(1, box_shadow)  # shadow set by text size
        graph_style.set_fill_color((255, 255, 255))
        default_style.add_draw_style("AC2-box", graph_style)

        graph_style = GraphicsStyle()
        graph_style.set_paragraph_style("AC2-Normal")
        #graph_style.set_shadow(0, PT2CM(9))  # shadow set by text size
        graph_style.set_fill_color((255, 255, 255))
        default_style.add_draw_style("AC2-fam-box", graph_style)

        graph_style = GraphicsStyle()
        graph_style.set_paragraph_style("AC2-Note")
        graph_style.set_fill_color((255, 255, 255))
        default_style.add_draw_style("AC2-note-box", graph_style)

        # TODO this seems meaningless, as only the text is displayed
        graph_style = GraphicsStyle()
        graph_style.set_paragraph_style("AC2-Title")
        graph_style.set_color((0, 0, 0))
        graph_style.set_fill_color((255, 255, 255))
        graph_style.set_line_width(0)
        graph_style.set_description(_("Cannot edit this reference"))
        default_style.add_draw_style("AC2-Title-box", graph_style)

        graph_style = GraphicsStyle()
        default_style.add_draw_style("AC2-line", graph_style)
예제 #3
0
class TAMexportOptions(MenuReportOptions):
    """
    Defines all of the controls necessary
    to configure the FamilyLines report.
    """
    def __init__(self, name, dbase):
        self.limit_parents = None
        self.max_parents = None
        self.limit_children = None
        self.max_children = None
        MenuReportOptions.__init__(self, name, dbase)

    def add_menu_options(self, menu):

        # ---------------------
        category_name = _('Report Options')
        add_option = partial(menu.add_option, category_name)
        # ---------------------

        add_option(
            'followpar',
            Option(_('Follow parents to determine '
                     '"family lines"'), True))
        add_option(
            'followchild',
            Option(_('Follow children to determine '
                     '"family lines"'), True))

        stdoptions.add_name_format_option(menu, category_name)

        # no use for places so far...
        #stdoptions.add_place_format_option(menu, category_name)

        stdoptions.add_private_data_option(menu, category_name, default=False)

        stdoptions.add_living_people_option(menu, category_name)
        # disable 'living_people' until we actually repect its value
        self.menu.get_option_by_name('living_people').set_available(False)

        locale_opt = stdoptions.add_localization_option(menu, category_name)
        stdoptions.add_date_format_option(menu, category_name, locale_opt)

        self.include_dates = BooleanOption(_('Include dates'), True)
        self.include_dates.set_help(_('Whether to include dates for people.'))
        add_option('incdates', self.include_dates)
        self.include_dates.connect('value-changed', self.includedates_changed)

        # --------------------------------
        add_option = partial(menu.add_option, _('Edge people'))
        # --------------------------------

        person_list = PersonListOption(_('Edge people'))
        person_list.set_help(
            _('Edge people are used as boundaries. '
              'They will not be traversed when determining the full "family".')
        )
        add_option('edgelist', person_list)
        self.edgelist = person_list

        self.limit_parents = BooleanOption(_('Limit the number of ancestors'),
                                           False)
        self.limit_parents.set_help(
            _('Whether to '
              'limit the number of ancestor generations.'))
        add_option('limitparents', self.limit_parents)
        self.limit_parents.connect('value-changed', self.limit_changed)

        self.max_parents = NumberOption('', 50, 0, 9999)
        self.max_parents.set_help(
            _('The maximum number '
              'of ancestor generations to include.'))
        add_option('maxparents', self.max_parents)

        self.limit_children = BooleanOption(
            _('Limit the number '
              'of descendants'), False)
        self.limit_children.set_help(
            _('Whether to '
              'limit the number of descendant generations.'))
        add_option('limitchildren', self.limit_children)
        self.limit_children.connect('value-changed', self.limit_changed)

        self.max_children = NumberOption('', 50, 0, 9999)
        self.max_children.set_help(
            _('The maximum number '
              'of descendant generations to include.'))
        add_option('maxchildren', self.max_children)

        # --------------------------------
        add_option = partial(menu.add_option, _('Interesting people'))
        # --------------------------------
        add_option('gidlist', Option(_('Some people'), " "))

        # sometimes we don't want to list living people
        includeall_people = BooleanOption(_('Include all people'), False)
        includeall_people.set_help(_('Mark all people as interesting.'))
        add_option('allpeople', includeall_people)
        includeall_people.connect('value-changed',
                                  self.includeallpeople_changed)

        remove_extra_people = BooleanOption(
            _('Try to remove extra '
              'people and families'), True)
        remove_extra_people.set_help(
            _('People and families not directly '
              'related to people of interest will '
              'be removed when determining '
              '"family lines".'))
        add_option('removeextra', remove_extra_people)

        person_list = PersonListOption(_('Interesting people'))
        person_list.set_help(
            _('People whose families to include '
              'apart from the "Main Person".'))
        add_option('interestlist', person_list)

        # --------------------
        add_option = partial(menu.add_option, _('Include'))
        # --------------------

        self.limit_changed()

    def limit_changed(self):
        """
        Handle the change of limiting parents and children.
        """
        self.max_parents.set_available(self.limit_parents.get_value())
        self.max_children.set_available(self.limit_children.get_value())

    def includedates_changed(self):
        date_option = self.menu.get_option_by_name('date_format')
        if not date_option:
            return
        date_option.set_available(self.include_dates.get_value())

    def includeallpeople_changed(self):
        allpeople = self.menu.get_option_by_name('allpeople')
        if not allpeople: return
        removeextra = self.menu.get_option_by_name('removeextra')
        if not removeextra: return
        removeextra.set_available(not allpeople.get_value())
예제 #4
0
class ReportOptions(MenuReportOptions):
    """Heatmap report options."""
    def __init__(self, name, dbase):
        self.db = dbase
        MenuReportOptions.__init__(self, name, dbase)

    def add_menu_options(self, menu):
        """Create menu options."""

        # -------------------
        # GENERAL options tab
        # -------------------
        self.get_person_filters(menu)
        fltr = EnumeratedListOption(_("Filter"), 0)
        fltr.set_items(menu.filter_list)
        menu.add_option(_("General"), "fltr", fltr)

        pers_id = PersonOption(_("Person"))
        menu.add_option(_("General"), "pers_id", pers_id)

        filter_list2 = [(0, _("OpenStreetMap")), (1, _("Stamen Terrain")),
                        (2, _("Stamen Toner")), (3, _("Stamen Watercolor")),
                        (4, _("CartoDB Positron")),
                        (5, _("CartoDB DarkMatter"))]
        tiles = EnumeratedListOption(_("Map tiles"), 0)
        tiles.set_items(filter_list2)
        menu.add_option(_("General"), "tiles", tiles)

        radius = NumberOption(_("Point size"), 15, 1, 50)
        radius.set_help(_("Set the size of the heatmap points.\nDefault: 15"))
        menu.add_option(_("General"), "radius", radius)

        path = DestinationOption(_("File path"), "")
        path.set_directory_entry(True)
        menu.add_option(_("General"), "path", path)

        txt = _("For the file name only english letters A-Z, a-z and "
                "numbers 0-9 as well as the characters space, underline and "
                "hypen are allowed. The file name also has to "
                "start and end with an alphanumeric character."
                "The file extention '.html' is added by the report.")
        file_name = StringOption(_("File name"), "")
        file_name.set_help(txt)
        menu.add_option(_("General"), "name", file_name)

        # -------------------
        # ADVANCED options tab
        # -------------------
        self.enable_start = BooleanOption(_("Enable custom start position"),
                                          False)
        self.enable_start.set_help(
            _("Enabling will force the map open at your custom "
              "start position and zoom."))
        menu.add_option(_("Advanced"), "enable_start", self.enable_start)
        self.enable_start.connect('value-changed', self.update_start_options)

        self.start_lat = StringOption(_("Start latitude"), "50.0")
        self.start_lat.set_help(
            _("Set custom start position latitude\nDefault: 50.0"))
        menu.add_option(_("Advanced"), "start_lat", self.start_lat)

        self.start_lon = StringOption(_("Start longitude"), "10.0")
        self.start_lon.set_help(
            _("Set custom start position longitude\nDefault: 10.0"))
        menu.add_option(_("Advanced"), "start_lon", self.start_lon)

        self.start_zoom = NumberOption(_("Start zoom"), 5, 1, 18)
        self.start_zoom.set_help(
            _("Set the value for the starting zoom\nDefault: 5"))
        menu.add_option(_("Advanced"), "start_zoom", self.start_zoom)

        # -------------------
        # LIMITS options tab
        # -------------------
        self.enable_limits = BooleanOption(_("Enable map limits"), False)
        self.enable_limits.set_help(
            _("Enabling map limits forces the user to stay in a predefined part"
              " of the map."))
        menu.add_option(_("Limits"), "enable_limits", self.enable_limits)
        self.enable_limits.connect('value-changed', self.update_limit_options)

        self.min_zoom = NumberOption(_("Min. zoom"), 1, 1, 18)
        self.min_zoom.set_help(_("Set minimal zoom value\nDefault: 1"))
        menu.add_option(_("Limits"), "min_zoom", self.min_zoom)

        self.max_zoom = NumberOption(_("Max. zoom"), 18, 1, 18)
        self.max_zoom.set_help(_("Set maximum zoom value.\nDefault: 18"))
        menu.add_option(_("Limits"), "max_zoom", self.max_zoom)

        self.lat1 = StringOption(_("Upper left corner latitude"), "")
        self.lat1.set_help(_("Set latitude for upper left corner map limit."))
        menu.add_option(_("Limits"), "lat1", self.lat1)

        self.lon1 = StringOption(_("Upper left corner longitude"), "")
        self.lon1.set_help(_("Set longitude for upper left corner map limit."))
        menu.add_option(_("Limits"), "lon1", self.lon1)

        self.lat2 = StringOption(_("Lower right corner latitude"), "")
        self.lat2.set_help(_("Set latitude for lower right corner map limit."))
        menu.add_option(_("Limits"), "lat2", self.lat2)

        self.lon2 = StringOption(_("Lower right corner longitude"), "")
        self.lon2.set_help(
            _("Set longitude for lower right corner map limit."))
        menu.add_option(_("Limits"), "lon2", self.lon2)

        self.render_border = BooleanOption(_("Render custom map limit border"),
                                           False)
        self.render_border.set_help(
            _("Enabling will render the map limit border"))
        menu.add_option(_("Limits"), "render_border", self.render_border)

    def update_limit_options(self):
        """Update menu options for limit option tab."""
        self.min_zoom.set_available(False)
        self.max_zoom.set_available(False)
        self.lat1.set_available(False)
        self.lon1.set_available(False)
        self.lat2.set_available(False)
        self.lon2.set_available(False)
        self.render_border.set_available(False)
        value = self.enable_limits.get_value()
        if value:
            self.min_zoom.set_available(True)
            self.max_zoom.set_available(True)
            self.lat1.set_available(True)
            self.lon1.set_available(True)
            self.lat2.set_available(True)
            self.lon2.set_available(True)
            self.render_border.set_available(True)

    def update_start_options(self):
        """Update menu options for start option tab."""
        self.start_zoom.set_available(False)
        self.start_lat.set_available(False)
        self.start_lon.set_available(False)
        value = self.enable_start.get_value()
        if value:
            self.start_zoom.set_available(True)
            self.start_lat.set_available(True)
            self.start_lon.set_available(True)

    @staticmethod
    def get_person_filters(menu):
        """Get menu option filter list of custon and generic filters."""
        custom = CustomFilters.get_filters("Person")
        menu.filter_list = [(0, _("Ancestors of <selected person>")),
                            (1, _("Descendants of <selected person>"))]

        for item in enumerate([x.get_name() for x in custom], start=2):
            menu.filter_list.append(item)

    @staticmethod
    def make_default_style(default_style):
        """Define the default styling."""
        para = ParagraphStyle()
        default_style.add_paragraph_style("Default", para)