def validate(self) -> str: upstream = super().validate() if upstream: return upstream layer = self.layer.currentLayer() wfs_layers_list = QgsProject.instance().readListEntry('WFSLayers', '')[0] for wfs_layer in wfs_layers_list: if layer.id() == wfs_layer: break else: msg = tr( 'The layers you have chosen for this tool must be checked in the "WFS Capabilities"\n' ' option of the QGIS Server tab in the "Project Properties" dialog.' ) return msg index = self.type.currentIndex() data = self.type.itemData(index) if data == 'date': if not self.min_date.currentField(): return tr('Field min date is mandatory.') elif data in ['text', 'uniquevalues', 'numeric']: if not self.field.currentField(): return tr('Field is mandatory.') else: raise Exception('Unknown option')
def validate(self): y_field = self.y_field.currentField() if y_field == '': return tr('Y field is required.') if y_field in self.uniques: return tr('This Y field is already existing.') return
def validate(self): if self.unicity: for key in self.unicity: for k, layer_config in self.config.layer_config.items(): if key == k: if layer_config['type'] == InputType.Layer: if layer_config['widget'].currentLayer().id( ) in self.unicity[key]: msg = tr( 'A duplicated "{}"="{}" is already in the table.' .format( key, layer_config['widget']. currentLayer().name())) return msg else: raise Exception( 'InputType "{}" not implemented'.format( layer_config['type'])) for k, layer_config in self.config.layer_config.items(): if layer_config['type'] == InputType.Field: widget = layer_config['widget'] if not widget.allowEmptyFieldName(): if widget.currentField() == '': names = re.findall('.[^A-Z]*', k) names = [n.lower() for n in names] msg = tr('The field "{}" is mandatory.'.format( ' '.join(names))) return msg return None
class Theme(Enum): Dark = { 'data': 'dark', 'label': tr('Dark'), } Light = { 'data': 'light', 'label': tr('Light'), }
def request_finished(self, row): """ Dispatch the answer to update the GUI. """ cell = QTableWidgetItem() reply = self.fetchers[row].reply() if not reply: cell.setText(tr('Error')) self.display_action(row, Qgis.Warning, 'Temporary not available') if reply.error() != QNetworkReply.NoError: if reply.error() == QNetworkReply.HostNotFoundError: self.display_action( row, Qgis.Warning, 'Host can not be found. Is-it an intranet server ?') if reply.error() == QNetworkReply.ContentNotFoundError: self.display_action( row, Qgis.Critical, 'Not a valid Lizmap URL or this version is already not maintained < 3.2' ) else: self.display_action(row, Qgis.Critical, reply.errorString()) cell.setText(tr('Error')) else: content = self.fetchers[row].contentAsString() if not content: self.display_action(row, Qgis.Critical, 'Not a valid Lizmap URL') return try: content = json.loads(content) except json.JSONDecodeError: self.display_action(row, Qgis.Critical, 'Not a JSON document.') return info = content.get('info') if not info: self.display_action(row, Qgis.Critical, 'No "info" in the JSON document') return version = info.get('version') if not info: self.display_action(row, Qgis.Critical, 'No "version" in the JSON document') return cell.setText(version) self.update_action_version(version, row) self.table.setItem(row, 1, cell)
class ZoomItems(Enum): Nothing = { 'data': '', 'label': '', } Center = { 'data': 'center', 'label': tr('Center'), } Zoom = { 'data': 'zoom', 'label': tr('Zoom'), }
def update_lwc_selector(self, released_versions: dict): """ Update LWC selector showing outdated versions. """ for i, json_version in enumerate(released_versions): if not json_version['maintained']: index = self.dialog.combo_lwc_version.findData(LwcVersions(json_version['branch'])) text = self.dialog.combo_lwc_version.itemText(index) if i == 0: # If it's the first item in the list AND not maintained, then it's the next LWC version new_text = text + ' - ' + tr('Next') else: new_text = text + ' - ' + tr('Not maintained') self.dialog.combo_lwc_version.setItemText(index, new_text)
def update_action_version(self, server_version, row): """ When we know the version, we can check the latest release from LWC with the file in cache. """ version_file = os.path.join(lizmap_user_folder(), 'released_versions.json') if not os.path.exists(version_file): return with open(version_file, 'r') as json_file: json_content = json.loads(json_file.read()) split_version = server_version.split('.') if len(split_version) != 3: QgsMessageLog.logMessage( "The version '{}' is not correct.".format(server_version), "Lizmap", Qgis.Critical) branch = '{}.{}'.format(split_version[0], split_version[1]) full_version = '{}.{}'.format(branch, split_version[2].split('-')[0]) messages = [] level = Qgis.Warning for i, version in enumerate(json_content): if version['branch'] == branch: if not version['maintained']: if i == 0: messages.append(tr('A dev version, warrior !') + ' 👍') level = Qgis.Success else: messages.append( tr('Version {version} not maintained anymore'). format(version=branch)) level = Qgis.Critical bugfix = int(split_version[2].split('-')[0]) latest_bugfix = int( version['latest_release_version'].split('.')[2]) if version['latest_release_version'] != full_version: if bugfix > latest_bugfix: messages.append( tr('Higher than a public release') + ' 👍') elif bugfix < latest_bugfix: messages.append(tr('Not latest bugfix release')) self.display_action(row, level, ', '.join(messages)) break else: self.display_action( row, Qgis.Critical, f"Version {branch} has not been detected has a known version.")
def __init__(self): super().__init__() self._layer_config['layerId'] = { 'type': InputType.Layer, 'header': tr('Layer'), 'default': None, 'tooltip': tr('The vector layer for filtering by login.') } self._layer_config['filterAttribute'] = { 'type': InputType.Field, 'header': tr('Field'), 'default': None, 'tooltip': tr('The field to use for filtering.') } self._layer_config['filterPrivate'] = { 'type': InputType.CheckBox, 'header': tr('Filter by user'), 'default': False, 'tooltip': tr('If Lizmap should use the group or the username for filtering data.' ) } self._layer_config['edition_only'] = { 'type': InputType.CheckBox, 'header': tr('Edition only'), 'default': False, 'tooltip': tr('If this filter is used for edition capabilities only.'), 'version': LwcVersions.Lizmap_3_4, }
def __init__(self): super().__init__() self._layer_config['layerId'] = { 'type': InputType.Layer, 'header': tr('Layer'), 'default': None, 'tooltip': tr('The vector layer for the tooltip.') } self._layer_config['fields'] = { 'type': InputType.Fields, 'header': tr('Fields'), 'default': None, 'tooltip': tr('Fields to display in the tooltip.') } self._layer_config['displayGeom'] = { 'type': InputType.CheckBox, 'header': tr('Display geometry'), 'default': False, 'tooltip': tr('If you want to display geometry with the tooltip.') } self._layer_config['colorGeom'] = { 'type': InputType.Color, 'header': tr('Color'), 'default': '', 'tooltip': tr('The color to use for displaying the geometry.') }
def __init__(self): super().__init__() self._layer_config['layerId'] = { 'type': InputType.Layer, 'header': tr('Layer'), 'default': None, 'tooltip': tr('Layer with the date/time.') } self._layer_config['startAttribute'] = { 'type': InputType.Field, 'header': tr('Start'), 'default': None, 'tooltip': tr('Column with the date/time.') } self._layer_config['label'] = { 'type': InputType.Field, 'header': tr('Hover label'), 'default': '', 'tooltip': tr('A field to display as a label when hovering with the mouse over the object' ) } self._layer_config['group'] = { 'type': InputType.Text, 'header': tr('Group ID'), 'default': '', 'tooltip': tr('Optional, an ID and a title for groups of objects.') } self._layer_config['groupTitle'] = { 'type': InputType.Text, 'header': tr('Group title'), 'default': '', 'tooltip': tr('Optional, an ID and a title for groups of objects.') } self._general_config['inTimeFrameSize'] = { 'type': InputType.SpinBox, 'default': 10, } self._general_config['tmTimeFrameType'] = { 'type': InputType.List, 'default': 'seconds', } self._general_config['tmAnimationFrameLength'] = { 'type': InputType.SpinBox, 'default': 1000, }
def add_row(self): """ Add a new row in the table, asking the URL to the user. """ server_url, result = QInputDialog.getText( self.parent, tr("New Lizmap Server"), tr("URL"), QLineEdit.Normal, ) if not result: return row = self.table.rowCount() self.table.setRowCount(row + 1) self._edit_row(row, server_url) self.save_table() self.check_display_warning_no_server()
def validate(self) -> str: upstream = super().validate() if upstream: return upstream if not self.field.currentField(): return tr('Field is mandatory.')
def add_new_row(self): # noinspection PyCallingNonCallable row = self.table.rowCount() if row >= 1 and self.definitions.key() == 'atlas' and version( ) not in ['master', 'dev']: message = tr('The multi-atlas is coming soon in Lizmap 3.4.') QMessageBox.warning(self.parent, tr('Lizmap'), message, QMessageBox.Ok) return dialog = self.edition(self.parent, self._primary_keys()) result = dialog.exec_() if result == QDialog.Accepted: data = dialog.save_form() row = self.table.rowCount() self.table.setRowCount(row + 1) self._edit_row(row, data)
class TimeUnits(Enum): Seconds = { 'data': 'seconds', 'label': tr('Seconds'), } Minutes = { 'data': 'minutes', 'label': tr('Minutes'), } Hours = { 'data': 'hours', 'label': tr('Hours'), } Days = { 'data': 'days', 'label': tr('Days'), } Weeks = { 'data': 'weeks', 'label': tr('Weeks'), } Months = { 'data': 'months', 'label': tr('Months'), } Years = { 'data': 'years', 'label': tr('Years'), }
def validate(self) -> str: upstream = super().validate() if upstream: return upstream layer = self.layer.currentLayer() wfs_layers_list = QgsProject.instance().readListEntry('WFSLayers', '')[0] for wfs_layer in wfs_layers_list: if layer.id() == wfs_layer: break else: msg = tr( 'The layers you have chosen for this tool must be checked in the "WFS Capabilities"\n' ' option of the QGIS Server tab in the "Project Properties" dialog.') return msg if not self.fields.selection(): return tr('At least one field is mandatory.')
def __init__(self, parent, layer, graph, uniques): super().__init__(parent) self.config = DatavizDefinitions() self._graph = graph self._layer = layer self.uniques = uniques self.setupUi(self) self.setWindowTitle(tr('Dataviz Trace')) self.y_field.setLayer(self._layer) self.color_field.setLayer(self._layer) self.z_field.setLayer(self._layer) self.config.add_layer_widget('y_field', self.y_field) self.config.add_layer_widget('colorfield', self.color_field) self.config.add_layer_widget('color', self.color) self.config.add_layer_widget('z_field', self.z_field) self.config.add_layer_label('y_field', self.label_y_field) self.config.add_layer_label('colorfield', self.label_color) self.config.add_layer_label('z_field', self.label_z_field) self.y_field.setAllowEmptyFieldName(False) self.z_field.setAllowEmptyFieldName(True) self.color_field.setAllowEmptyFieldName(True) self.button_box.button(QDialogButtonBox.Cancel).clicked.connect( self.close) self.button_box.button(QDialogButtonBox.Ok).clicked.connect( self.accept) self.error.setVisible(False) color_definition = self.config.layer_config['color'] self.color.setDefaultColor(QColor(color_definition['default'])) self.color.setToDefaultColor() self.color_field.setAllowEmptyFieldName(True) self.color_field.currentTextChanged.connect(self.check_y_color_field) self.check_y_color_field() # Z Field if self._graph == GraphType.Sunburst: self.label_z_field.setVisible(True) self.z_field.setVisible(True) self.z_field.setAllowEmptyFieldName(False) else: self.label_z_field.setVisible(False) self.z_field.setVisible(False) self.z_field.setAllowEmptyFieldName(True) self.z_field.setCurrentIndex(0) # Color field histo_2d = self._graph == GraphType.Histogram2D self.label_color.setVisible(not histo_2d) self.color_field.setVisible(not histo_2d) self.color.setVisible(not histo_2d)
class AggregationType(Enum): Sum = { 'data': 'sum', 'label': tr('Sum'), } Count = { 'data': 'count', 'label': tr('Count'), } Avg = { 'data': 'avg', 'label': tr('Average'), } Median = { 'data': 'median', 'label': tr('Median'), } Stddev = { 'data': 'stddev', 'label': tr('Standard deviation'), } Min = { 'data': 'min', 'label': tr('Min'), } Max = { 'data': 'max', 'label': tr('Max'), } First = { 'data': 'first', 'label': tr('First'), } Last = { 'data': 'last', 'label': tr('Last'), } No = { 'data': 'no', 'label': tr('No'), }
class GraphType(Enum): Scatter = { 'data': 'scatter', 'label': tr('Scatter'), 'icon': resources_path('icons', 'plots', 'scatterplot.svg'), } Box = { 'data': 'box', 'label': tr('Box'), 'icon': resources_path('icons', 'plots', 'boxplot.svg'), } Bar = { 'data': 'bar', 'label': tr('Bar'), 'icon': resources_path('icons', 'plots', 'barplot.svg'), } Histogram = { 'data': 'histogram', 'label': tr('Histogram'), 'icon': resources_path('icons', 'plots', 'histogram.svg'), } Pie = { 'data': 'pie', 'label': tr('Pie'), 'icon': resources_path('icons', 'plots', 'pie.svg'), } Histogram2D = { 'data': 'histogram2d', 'label': tr('Histogram 2D'), 'icon': resources_path('icons', 'plots', '2dhistogram.svg'), } Polar = { 'data': 'polar', 'label': tr('Polar'), 'icon': resources_path('icons', 'plots', 'polar.svg'), } Sunburst = { 'data': 'sunburst', 'label': tr('Sunburst'), 'icon': resources_path('icons', 'plots', 'sunburst.svg'), } HtmlTemplate = { 'data': 'html', 'label': tr('HTML Template'), 'icon': resources_path('icons', 'plots', 'html_template.png'), }
def validate(self) -> str: upstream = super().validate() if upstream: return upstream layer = self.layer.currentLayer() wfs_layers_list = QgsProject.instance().readListEntry('WFSLayers', '')[0] for wfs_layer in wfs_layers_list: if layer.id() == wfs_layer: break else: msg = tr( 'The layers you have chosen for this tool must be checked in the "WFS Capabilities"\n' ' option of the QGIS Server tab in the "Project Properties" dialog.' ) return msg if self.traces.rowCount() == 0: return tr('At least one Y field is required.') graph = self.type_graph.currentData() for item_enum in GraphType: if item_enum.value['data'] == graph: graph = item_enum break if graph == GraphType.HtmlTemplate: html = self.html_template.text() if html == '': return tr('HTML template is mandatory.') layout = self.json_layout.text() if layout: import json try: data = json.loads(layout) except json.decoder.JSONDecodeError as e: return tr('JSON layout is not valid : {}').format(str(e)) if not isinstance(data, dict): return tr('The JSON layout must be a dictionary.')
def __init__(self): super().__init__() self._layer_config['layerId'] = { 'type': InputType.Layer, 'header': tr('Layer'), 'default': None, 'tooltip': tr('The vector layer for filtering by login.') } self._layer_config['filterAttribute'] = { 'type': InputType.Field, 'header': tr('Field'), 'default': None, 'tooltip': tr('The field to use for filtering.') } self._layer_config['filterPrivate'] = { 'type': InputType.CheckBox, 'header': tr('Filter by user'), 'default': False, 'tooltip': tr('If Lizmap should use the group or the username for filtering data.' ) }
def edit_row(self): """ Edit the selected row in the table. """ selection = self.table.selectedIndexes() if len(selection) <= 0: return row = selection[0].row() item = self.table.item(row, 0) url = item.data(Qt.UserRole) server_url, result = QInputDialog.getText(self.parent, tr("Update Lizmap Server"), tr("URL"), QLineEdit.Normal, text=url) if not result: return self._edit_row(row, server_url) self.save_table() self.check_display_warning_no_server()
def validate(self) -> str: layer = self.layer.currentLayer() if not layer: return tr('A layer is mandatory.') upstream = super().validate() if upstream: return upstream wfs_layers_list = QgsProject.instance().readListEntry('WFSLayers', '')[0] for wfs_layer in wfs_layers_list: if layer.id() == wfs_layer: break else: msg = tr( 'The layers you have chosen for this tool must be checked in the "WFS Capabilities"\n' ' option of the QGIS Server tab in the "Project Properties" dialog.') return msg create_feature = self.create_feature.isChecked() modify_attribute = self.edit_attributes.isChecked() modify_geometry = self.edit_geometry.isChecked() delete_feature = self.delete_feature.isChecked() if not create_feature and not modify_attribute and not modify_geometry and not delete_feature: return tr('At least one action is mandatory.') # Check Z or M values which will be lost when editing geometry_type = layer.wkbType() # noinspection PyArgumentList has_m_values = QgsWkbTypes.hasM(geometry_type) # noinspection PyArgumentList has_z_values = QgsWkbTypes.hasZ(geometry_type) if has_z_values or has_m_values: QMessageBox.warning( self, tr('Editing Z/M Values'), tr('Be careful, editing this layer with Lizmap will set the Z and M to 0.'), )
def validate(self) -> str: upstream = super().validate() if upstream: return upstream layer = self.layer.currentLayer() wfs_layers_list = QgsProject.instance().readListEntry('WFSLayers', '')[0] for wfs_layer in wfs_layers_list: if layer.id() == wfs_layer: break else: msg = tr( 'The layers you have chosen for this tool must be checked in the "WFS Capabilities"\n' ' option of the QGIS Server tab in the "Project Properties" dialog.') return msg if not self.start_field.currentField(): return tr('Start attribute is mandatory.') msg = tr('The min/max values must be computed.') if self.edit_min_value.isVisible(): if self.edit_min_value.text() == '' or self.edit_max_value.text() == '': return msg
def __init__(self, parent=None, unicity=None): super().__init__(parent, unicity) self.setupUi(self) self.config = FilterByFormDefinitions() self.config.add_layer_widget('layerId', self.layer) self.config.add_layer_widget('title', self.title) self.config.add_layer_widget('type', self.type) self.config.add_layer_widget('field', self.field) self.config.add_layer_widget('min_date', self.min_date) self.config.add_layer_widget('max_date', self.max_date) self.config.add_layer_widget('format', self.filter_format) self.config.add_layer_widget('splitter', self.splitter) self.config.add_layer_label('layerId', self.label_layer) self.config.add_layer_label('title', self.label_title) self.config.add_layer_label('type', self.label_type) self.config.add_layer_label('field', self.label_field) self.config.add_layer_label('min_date', self.label_min_date) self.config.add_layer_label('max_date', self.label_max_date) self.config.add_layer_label('format', self.label_format) self.config.add_layer_label('splitter', self.label_splitter) self.type.addItem(tr('Text'), 'text') self.type.addItem(tr('Unique values'), 'uniquevalues') self.type.addItem(tr('Numeric'), 'numeric') self.type.addItem(tr('Date'), 'date') self.filter_format.addItem(tr('Checkboxes'), 'checkboxes') self.filter_format.addItem(tr('Combobox'), 'select') self.layer.setFilters(QgsMapLayerProxyModel.VectorLayer) self.layer.layerChanged.connect(self.field.setLayer) self.layer.layerChanged.connect(self.min_date.setLayer) self.layer.layerChanged.connect(self.max_date.setLayer) self.field.setLayer(self.layer.currentLayer()) self.min_date.setLayer(self.layer.currentLayer()) self.max_date.setLayer(self.layer.currentLayer()) self.field.setAllowEmptyFieldName(False) self.min_date.setAllowEmptyFieldName(False) self.max_date.setAllowEmptyFieldName(True) block_list = [] for layer in QgsProject().instance().mapLayers().values(): if layer.providerType() not in ('ogr', 'postgres', 'spatialite'): block_list.append(layer) if layer.providerType() == 'ogr': if '|layername=' not in layer.dataProvider().dataSourceUri(): block_list.append(layer) self.layer.setExceptedLayerList(block_list) self.setup_ui() self.update_visibility() self.type.currentIndexChanged.connect(self.update_visibility)
def _edit_row(self, row, server_url): """ Internal function to edit a row. """ # URL cell = QTableWidgetItem() cell.setText(server_url) cell.setData(Qt.UserRole, server_url) self.table.setItem(row, 0, cell) # Version cell = QTableWidgetItem() cell.setText(tr('')) cell.setData(Qt.UserRole, None) self.table.setItem(row, 1, cell) # Action cell = QTableWidgetItem() cell.setText('') cell.setData(Qt.UserRole, '') self.table.setItem(row, 2, cell) self.table.clearSelection() self.fetch(server_url, row)
class GraphType(Enum): Scatter = { 'data': 'scatter', 'label': tr('Scatter'), 'icon': resources_path('icons', 'plots', 'scatterplot.svg'), } Box = { 'data': 'box', 'label': tr('Box'), 'icon': resources_path('icons', 'plots', 'boxplot.svg'), } Bar = { 'data': 'bar', 'label': tr('Bar'), 'icon': resources_path('icons', 'plots', 'barplot.svg'), } Histogram = { 'data': 'histogram', 'label': tr('Histogram'), 'icon': resources_path('icons', 'plots', 'histogram.svg'), } Pie = { 'data': 'pie', 'label': tr('Pie'), 'icon': resources_path('icons', 'plots', 'pie.svg'), } Histogram2D = { 'data': 'histogram2d', 'label': tr('Histogram 2D'), 'icon': resources_path('icons', 'plots', '2dhistogram.svg'), } Polar = { 'data': 'polar', 'label': tr('Polar'), 'icon': resources_path('icons', 'plots', 'polar.svg'), }
def __init__(self, parent, table, add_button, remove_button, edit_button, refresh_button, label_no_server, up_button, down_button): self.parent = parent self.table = table self.add_button = add_button self.remove_button = remove_button self.edit_button = edit_button self.refresh_button = refresh_button self.up_button = up_button self.down_button = down_button self.label_no_server = label_no_server # Network self.fetchers = {} # Icons and tooltips self.remove_button.setIcon( QIcon(QgsApplication.iconPath('symbologyRemove.svg'))) self.remove_button.setText('') self.remove_button.setToolTip( tr('Remove the selected server from the list')) self.add_button.setIcon( QIcon(QgsApplication.iconPath('symbologyAdd.svg'))) self.add_button.setText('') self.add_button.setToolTip(tr('Add a new server in the list')) self.edit_button.setIcon( QIcon(QgsApplication.iconPath('symbologyEdit.svg'))) self.edit_button.setText('') self.edit_button.setToolTip(tr('Edit the selected server in the list')) self.refresh_button.setIcon( QIcon(QgsApplication.iconPath('mActionRefresh.svg'))) self.refresh_button.setText('') self.refresh_button.setToolTip(tr('Refresh all servers')) self.up_button.setIcon( QIcon(QgsApplication.iconPath('mActionArrowUp.svg'))) self.up_button.setText('') self.up_button.setToolTip(tr('Move the server up')) self.down_button.setIcon( QIcon(QgsApplication.iconPath('mActionArrowDown.svg'))) self.down_button.setText('') self.down_button.setToolTip(tr('Move the server down')) # Table self.table.setColumnCount(3) self.table.setSelectionMode(QAbstractItemView.SingleSelection) self.table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.table.setSelectionBehavior(QAbstractItemView.SelectRows) self.table.setAlternatingRowColors(True) self.table.cellDoubleClicked.connect(self.edit_row) # Headers header = self.table.horizontalHeader() header.setSectionResizeMode(QHeaderView.ResizeToContents) item = QTableWidgetItem(tr('URL')) item.setToolTip(tr('URL of the server.')) self.table.setHorizontalHeaderItem(0, item) item = QTableWidgetItem(tr('Version')) item.setToolTip(tr('Version detected on the server')) self.table.setHorizontalHeaderItem(1, item) item = QTableWidgetItem(tr('Action')) item.setToolTip(tr('If there is any action to do on the server')) self.table.setHorizontalHeaderItem(2, item) # Connect self.add_button.clicked.connect(self.add_row) self.remove_button.clicked.connect(self.remove_row) self.edit_button.clicked.connect(self.edit_row) self.refresh_button.clicked.connect(self.refresh_table) self.up_button.clicked.connect(self.move_server_up) self.down_button.clicked.connect(self.move_server_down) # Actions self.load_table()
def __init__(self, parent=None, unicity=None): super().__init__(parent, unicity) self.setupUi(self) self.parent = parent self.config = DatavizDefinitions() self.config.add_layer_widget('title', self.title) self.config.add_layer_widget('type', self.type_graph) self.config.add_layer_widget('description', self.text_description) self.config.add_layer_widget('layerId', self.layer) self.config.add_layer_widget('x_field', self.x_field) self.config.add_layer_widget('aggregation', self.aggregation) self.config.add_layer_widget('traces', self.traces) self.config.add_layer_widget('html_template', self.html_template) self.config.add_layer_widget('layout', self.json_layout) self.config.add_layer_widget('horizontal', self.horizontal) self.config.add_layer_widget('stacked', self.stacked) self.config.add_layer_widget('popup_display_child_plot', self.popup_display_child_plot) self.config.add_layer_widget('only_show_child', self.only_show_child) self.config.add_layer_widget('display_legend', self.display_legend) self.config.add_layer_widget('display_when_layer_visible', self.display_when_layer_visible) self.config.add_layer_label('title', self.label_title) self.config.add_layer_label('type', self.label_type) self.config.add_layer_label('description', self.label_description) self.config.add_layer_label('layerId', self.label_layer) self.config.add_layer_label('x_field', self.label_x_field) self.config.add_layer_label('aggregation', self.label_aggregation) self.config.add_layer_label('traces', self.label_traces) self.config.add_layer_label('html_template', self.label_html_template) self.config.add_layer_label('html_template', self.label_layout) # noinspection PyCallByClass,PyArgumentList self.add_trace.setText('') self.add_trace.setIcon( QIcon(QgsApplication.iconPath('symbologyAdd.svg'))) self.add_trace.setToolTip(tr('Add a new trace to the chart.')) self.remove_trace.setText('') self.remove_trace.setIcon( QIcon(QgsApplication.iconPath('symbologyRemove.svg'))) self.remove_trace.setToolTip( tr('Remove the selected trace from the chart.')) # Set traces table items = self.config.layer_config['traces']['items'] self.traces.setColumnCount(len(items)) for i, item in enumerate(items): sub_definition = self.config.layer_config[item] column = QTableWidgetItem(sub_definition['header']) column.setToolTip(sub_definition['tooltip']) self.traces.setHorizontalHeaderItem(i, column) header = self.traces.horizontalHeader() header.setSectionResizeMode(QHeaderView.ResizeToContents) header.setSectionResizeMode(0, QHeaderView.Stretch) self.traces.setSelectionMode(QAbstractItemView.SingleSelection) self.traces.setEditTriggers(QAbstractItemView.NoEditTriggers) self.traces.setSelectionBehavior(QAbstractItemView.SelectRows) self.traces.setAlternatingRowColors(True) self.layer.setFilters(QgsMapLayerProxyModel.VectorLayer) self.layer.layerChanged.connect(self.current_layer_changed) self.x_field.setLayer(self.layer.currentLayer()) self.type_graph.currentTextChanged.connect(self.check_form_graph_type) self.add_trace.clicked.connect(self.add_new_trace) self.remove_trace.clicked.connect(self.remove_selection) self.lwc_versions[LwcVersions.Lizmap_3_4] = [self.label_graph_34] self.setup_ui() self.check_form_graph_type()
def __init__(self): super().__init__() self._layer_config['layerId'] = { 'type': InputType.Layer, 'header': tr('Layer'), 'default': None, 'tooltip': tr('The vector layer for the attribute table.') } self._layer_config['primaryKey'] = { 'type': InputType.Field, 'header': tr('Primary key'), 'default': None, 'tooltip': tr('Primary key of the layer.') } self._layer_config['hiddenFields'] = { 'type': InputType.Fields, 'header': tr('Fields to hide'), 'default': '', 'tooltip': tr('List of fields to hide in the attribute table.') } self._layer_config['pivot'] = { 'type': InputType.CheckBox, 'header': tr('Pivot table'), 'default': False, 'tooltip': tr('If the table is a pivot, used in a many-to-many relationship.') } self._layer_config['hideAsChild'] = { 'type': InputType.CheckBox, 'header': tr('Hide in child subpanels'), 'default': False, 'tooltip': tr('Do not display the layer in a relation when the layer is a child.' ) } self._layer_config['hideLayer'] = { 'type': InputType.CheckBox, 'header': tr('Hide layer in list'), 'default': False, 'tooltip': tr('No button "Detail" will be shown in Lizmap to open the attribute table, but related ' 'features such as selection and filter will be available.'), } self._layer_config['custom_config'] = { 'type': InputType.CheckBox, 'header': tr('Custom configuration'), 'default': layer_has_custom_attribute_table, 'tooltip': tr('If the attribute table has a custom order. Read only field.'), 'read_only': True, } self._general_config['limitDataToBbox'] = { 'type': InputType.CheckBox, 'default': False, }