Exemple #1
0
    def create_fakom_item(self,
                          parent: Union[KnechtItem, None],
                          model,
                          model_desc,
                          color,
                          sib,
                          vos,
                          lum,
                          sib_text,
                          vos_text,
                          lum_text,
                          fakom_type,
                          preset_wizard: bool = False):
        name = f'{model_desc} {color}-{sib}-{vos}-{lum}'
        if preset_wizard:
            name = f'{color}-{sib}-{vos}-{lum}'

        order = 0
        if parent:
            order = parent.childCount()

        data = (f'{order:03d}', f'{name}', model, fakom_type, '',
                self.id_gen.create_id())

        # Create FaKom item
        fa_item = KnechtItem(parent, data)

        if preset_wizard:
            fa_item.fixed_userType = Kg.dialog_item
            if parent:
                parent.append_item_child(fa_item)
            return

        # Create FaKom item content
        color_item = KnechtItem(fa_item, ('000', color, 'on'))
        sib_item = KnechtItem(fa_item,
                              ('001', sib, 'on', 'SIB', '', '', sib_text))
        vos_item = KnechtItem(fa_item,
                              ('002', vos, 'on', 'VOS', '', '', vos_text))
        lum_item = KnechtItem(fa_item,
                              ('003', lum, 'on', 'LUM', '', '', lum_text))

        for i in (color_item, sib_item, vos_item, lum_item):
            fa_item.append_item_child(i)

        return fa_item
Exemple #2
0
    def initializePage(self):
        data = self.wizard.session.data.import_data
        item_creator = KnechtDataToModel(data)

        # -- Populate Preset Tree --
        for trim in data.models:
            if trim.model not in data.selected_models:
                continue

            item_data = (f'{item_creator.root_item.childCount():03d}', trim.model_text, trim.model, 'trim_setup')
            trim_item = KnechtItem(item_creator.root_item, item_data)
            trim_item.fixed_userType = Kg.group_item
            item_creator.create_fakom(trim, is_preset_wizard=True, parent_item=trim_item)
            item_creator.root_item.append_item_child(trim_item)

        fakom_model = KnechtModel(item_creator.root_item)
        for column in (Kg.VALUE, Kg.DESC, Kg.TYPE, Kg.REF, Kg.ID):
            self.fakom_tree.hideColumn(column)
        UpdateModel(self.fakom_tree).update(fakom_model)

        QTimer.singleShot(50, self.load_fakom_selection)

        LOGGER.info('FaKom Wizard Page initialized.')
Exemple #3
0
    def create_fakom(self,
                     trim: KnTrim,
                     is_preset_wizard: bool = False,
                     parent_item: KnechtItem = None):
        model_short_desc = shorten_model_name(trim.model_text)

        # Create lists of List[KnPr] for SIB/VOS/LUM families
        sib_pr_ls = [
            pr for pr in trim.iterate_available_pr()
            if pr.family.casefold() == 'sib'
        ]
        sib_pr_codes = [pr.name for pr in sib_pr_ls]
        lum_pr_ls = [
            pr for pr in trim.iterate_available_pr()
            if pr.family.casefold() == 'lum'
        ]
        vos_pr_ls = [
            pr for pr in trim.iterate_available_pr()
            if pr.family.casefold() == 'vos'
        ]

        if not parent_item:
            parent_item = self.root_item

        for color, sib_set in self.data.fakom.iterate_colors():
            valid_sib_set = sib_set.intersection(sib_pr_codes)
            if not valid_sib_set:
                continue

            fa_parent, grp_item = parent_item, parent_item

            if is_preset_wizard:
                grp_item = KnechtItem(parent_item,
                                      (f'{parent_item.childCount():03d}',
                                       color, '', 'fakom_option'))
                grp_item.fixed_userType = Kg.group_item
                parent_item.append_item_child(grp_item)

            # --- Iterate SIB Codes ---
            for sib_pr in sib_pr_ls:
                if sib_pr.name not in valid_sib_set:
                    # Skip seat covers not matching
                    continue

                if is_preset_wizard:
                    sib_grp_item = KnechtItem(grp_item,
                                              (f'{grp_item.childCount():03d}',
                                               sib_pr.name, '', 'options'))
                    sib_grp_item.fixed_userType = Kg.group_item
                    grp_item.append_item_child(sib_grp_item)
                    fa_parent = sib_grp_item

                # --- Iterate VOS Codes ---
                for vos_pr in vos_pr_ls:

                    # --- Iterate LUM Codes ---
                    for lum_pr in lum_pr_ls:

                        # Determine if all options belong to standard equipment L
                        fakom_type = 'fakom_option'
                        if not {sib_pr.value, vos_pr.value, lum_pr.value
                                }.difference('L'):
                            fakom_type = 'fakom_setup'

                        fa_item = self.create_fakom_item(
                            fa_parent, trim.model, model_short_desc, color,
                            sib_pr.name, vos_pr.name, lum_pr.name, sib_pr.desc,
                            vos_pr.desc, lum_pr.desc, fakom_type,
                            is_preset_wizard)
                        if is_preset_wizard:
                            continue
                        fa_parent.append_item_child(fa_item)