def _on_add_token(self, *args): """ Creates a new token and add it to the Naming Manager :return: None """ load_token = True if len(args) == 0: load_token = False token = None if not load_token: token = self._naming_lib.get_token_unique_name(name='New_Token') elif load_token and len(args) == 1: token = args[0].name if token: # Create a new item based on the token name and add it item = QListWidgetItem(token) item.setFlags(item.flags() | Qt.ItemIsEditable) self.tokens_list.addItem(item) # Add the data of the token to our JSON data file if len(args) == 0: self._naming_lib.add_token(token) # Update necessary UI wigdets if not load_token: self.tokens_list.setCurrentItem(item)
def _on_add_template_token(self, *args): """ Creates a new template token :param args: :return: """ load_template_token = True if len(args) == 0: load_template_token = False template_token = None if not load_template_token: template_token = self._naming_lib.get_template_token_unique_name( 'New_Template_Token') elif load_template_token and len(args) == 1: template_token = args[0].name if template_token is not None: item = QListWidgetItem(template_token) item.setFlags(item.flags() | Qt.ItemIsEditable) self.template_tokens_list.addItem(item) if len(args) == 0: self._naming_lib.add_template_token(template_token) if not load_template_token: self.template_tokens_list.setCurrentItem(item)
def _on_add_rule(self, *args): """ Creates a new standard rule and add it to the Naming Manager :return: """ load_rule = True if len(args) == 0: load_rule = False self.description_rule_text.blockSignals(True) rule = None if not load_rule: rule = self._naming_lib.get_rule_unique_name(name='New_Rule') elif load_rule and len(args) == 1: rule = args[0].name if rule is not None: # Create a new item based on the rule name and add it item = QListWidgetItem(rule) item.setFlags(item.flags() | Qt.ItemIsEditable) self.rules_list.addItem(item) # Add the data of the rule to our JSON data file if len(args) == 0: self._naming_lib.add_rule(rule) # Update necessary UI Widgets if not load_rule: self.rules_list.setCurrentItem(item) self.update_expression_menu() self.update_rules_properties_state() self.description_rule_text.blockSignals(False)
def _on_add_template(self, *args): """ Creates a new template and add it to the Naming Manager :return: """ load_template = True if len(args) == 0: load_template = False template = None if not load_template: template = self._naming_lib.get_template_unique_name( 'New_Template') elif load_template and len(args) == 1: template = args[0].name if template is not None: item = QListWidgetItem(template) item.setFlags(item.flags() | Qt.ItemIsEditable) self.templates_list.addItem(item) if len(args) == 0: self._naming_lib.add_template(template) if not load_template: self.templates_list.setCurrentItem(item)