def update_from_ui_metadata(self, ui_metadata: QtQml.QJSValue) -> bool: """ Updates all metadata objects managed by this object with new values from ui_metadata :param ui_metadata: Value from QML containing new metadata :return: boolean saying if any WebMetadata have changed their urls a valid value """ webmetadata_url_changed = False for db_name, metadata in ui_metadata.toVariant().items(): for key, value in metadata.items(): if not hasattr(self.get_metadata(MetadataClassMap[db_name]), key): continue if key == "tags": value = Utils.convert_csv_to_list(value) elif key == "url" and isinstance( self.get_metadata( MetadataClassMap[db_name]), WebMetadata ) and value and value != self.get_metadata_value( MetadataClassMap[db_name], "url"): webmetadata_url_changed = True self.update_metadata_value(MetadataClassMap[db_name], key, value) for metadata in list(self.metadata.values()): if isinstance(metadata, WebMetadata) and not metadata.url: self.metadata.pop(metadata.DB_NAME) metadata.delete() return webmetadata_url_changed
def handleAddedLines(self, lines: QJSValue) -> None: lines = lines.toVariant() breakpoints = self._debugger.breakpoints for added_line in lines: breakpoints = set(x if x < added_line else int(x) + 1 for x in breakpoints) self._debugger.breakpoints = breakpoints self.breakpointsChanged.emit(self.breakpoints)
def handleRemovedLines(self, lines: QJSValue) -> None: lines = lines.toVariant() breakpoints = self._debugger.breakpoints for removed_line in lines: if removed_line in breakpoints: breakpoints.remove(removed_line) breakpoints = set(x if x < removed_line else int(x) - 1 for x in breakpoints) self._debugger.breakpoints = breakpoints self.breakpointsChanged.emit(self.breakpoints)
def addHighlightMultiColorRule(self, patterns: List[str], color: QJSValue, fontSettings: QFont) -> None: """ Adds highlight rule to syntax highlighter :param patterns: Regexp pattners to be matched :param color: Foreground color of matched text :param fontSettings: Determinates font weight and italic """ pattern_format = list() self._base_font = fontSettings for single_color in color.toVariant(): pattern_format.append( self._setupFormat(QColor(single_color), fontSettings)) for single_pattern in patterns: self._syntax_highlighter.addHighlightRule( HighlightRule(pattern_format, QRegularExpression(single_pattern)))
def update_from_ui_metadata(self, ui_metadata: QtQml.QJSValue) -> bool: """ Updates all metadata objects managed by this object with new values from ui_metadata :param ui_metadata: Value from QML containing new metadata :return: boolean saying if any WebMetadata have changed their urls a valid value """ webmetadata_url_changed = False for db_name, metadata in ui_metadata.toVariant().items(): for key, value in metadata.items(): if not hasattr(self.get_metadata(MetadataClassMap[db_name]), key): continue if key == "tags": value = Utils.convert_csv_to_list(value) elif key == "url" and isinstance(self.get_metadata(MetadataClassMap[db_name]), WebMetadata) and value and value != self.get_metadata_value(MetadataClassMap[db_name], "url"): webmetadata_url_changed = True self.update_metadata_value(MetadataClassMap[db_name], key, value) for metadata in list(self.metadata.values()): if isinstance(metadata, WebMetadata) and not metadata.url: self.metadata.pop(metadata.DB_NAME) metadata.delete() return webmetadata_url_changed
def classifyImages(self, paths: QJSValue): paths = paths.toVariant() # TODO print(paths) pass
def apply(self, config: QtQml.QJSValue): params = config.toVariant() func_name = params['func_name'] params.pop('func_name') self._image.img = functions[func_name](self.img_src.current, params) self.set_image(self._image)