Esempio n. 1
0
    def add_item(self, item: KnechtItem, children: Union[None, List] = None, create_id: bool = False):
        # Create a unique copy
        item = item.copy(True, None)

        # Update Name
        if item.data(Kg.TYPE) == Kg.type_keys[Kg.separator]:
            item.setData(Kg.NAME, '')
        else:
            item.setData(Kg.NAME, f'{item.data(Kg.NAME)}_{self.item_count:03d}')
            self.item_count += 1

        # Create unique item id
        if create_id:
            item.setData(Kg.ID, Kid.create_id())

        # Add children
        for child_item in children or []:
            child_item.setData(Kg.ORDER, f'{item.childCount():03d}', Qt.DisplayRole)
            item.append_item_child(child_item)

        # Get order data
        current_src_index, _ = self.editor.get_current_selection()
        order = self.editor.util.get_order_data(current_src_index)

        self.editor.create_top_level_rows([item], at_row=order)
        return item
Esempio n. 2
0
 def _add_variant(item: KnechtItem, variants: KnechtVariantList, src_model: KnechtModel) -> None:
     if item.userType == Kg.variant:
         index = src_model.get_index_from_item(item)
         variants.add(index, item.data(Kg.NAME), item.data(Kg.VALUE), item.data(Kg.TYPE))
     elif item.userType == Kg.output_item:
         variants.output_path = item.data(Kg.VALUE)
         LOGGER.debug('Collected output path: %s', item.data(Kg.VALUE))
     elif item.userType == Kg.plmxml_item:
         variants.plm_xml_path = item.data(Kg.VALUE)
         LOGGER.debug('Collected PlmXml path: %s', item.data(Kg.VALUE))