def setOptions(self, options): model = self.lstItems.model() for i in options: item = QStandardItem(i) item.setCheckable(True) item.setDropEnabled(False) item.setData(Qt.Unchecked) model.appendRow(item)
def addItem(self): model = self.lstItems.model() item = QStandardItem('new item') item.setCheckable(True) item.setDropEnabled(False) item.setData(Qt.Unchecked) model.appendRow(item)
def setColumnCombos(self, cols, quotedCols): # get sensible default columns. do this before sorting in case there's hints in the column order (e.g., id is more likely to be first) try: defaultGeomCol = next(col for col in cols if col in ['geom', 'geometry', 'the_geom', 'way']) except: defaultGeomCol = None try: defaultUniqueCol = [col for col in cols if 'id' in col][0] except: defaultUniqueCol = None colNames = sorted(zip(cols, quotedCols)) newItems = [] uniqueIsFilled = False for (col, quotedCol) in colNames: item = QStandardItem(col) item.setData(quotedCol) item.setEnabled(True) item.setCheckable(self.allowMultiColumnPk) item.setSelectable(not self.allowMultiColumnPk) if self.allowMultiColumnPk: matchingItems = self.uniqueModel.findItems(col) if matchingItems: item.setCheckState(matchingItems[0].checkState()) uniqueIsFilled = uniqueIsFilled or matchingItems[0].checkState() == Qt.Checked else: item.setCheckState(Qt.Unchecked) newItems.append(item) if self.allowMultiColumnPk: self.uniqueModel.clear() self.uniqueModel.appendColumn(newItems) self.uniqueChanged() else: previousUniqueColumn = self.uniqueCombo.currentText() self.uniqueModel.clear() self.uniqueModel.appendColumn(newItems) if self.uniqueModel.findItems(previousUniqueColumn): self.uniqueCombo.setEditText(previousUniqueColumn) uniqueIsFilled = True oldGeometryColumn = self.geomCombo.currentText() self.geomCombo.clear() self.geomCombo.addItems(cols) self.geomCombo.setCurrentIndex(self.geomCombo.findText(oldGeometryColumn, Qt.MatchExactly)) # set sensible default columns if the columns are not already set try: if self.geomCombo.currentIndex() == -1: self.geomCombo.setCurrentIndex(cols.index(defaultGeomCol)) except: pass items = self.uniqueModel.findItems(defaultUniqueCol) if items and not uniqueIsFilled: if self.allowMultiColumnPk: items[0].setCheckState(Qt.Checked) else: self.uniqueCombo.setEditText(defaultUniqueCol)
def setOptions(self, options): model = self.lstItems.model() for i in options: item = QStandardItem(i) item.setCheckable(True) item.setDropEnabled(False) item.setData(Qt.Unchecked) model.appendRow(item)
def populateList(self): model = QStandardItemModel() for i, option in enumerate(self.options): item = QStandardItem(option) item.setCheckState(Qt.Checked if i in self.selectedoptions else Qt.Unchecked) item.setCheckable(True) model.appendRow(item) self.lstLayers.setModel(model)
def addItem(self): model = self.lstItems.model() item = QStandardItem('new item') item.setCheckable(True) item.setDropEnabled(False) item.setData(Qt.Unchecked) model.appendRow(item)
def setColumnCombos(self, cols, quotedCols): # get sensible default columns. do this before sorting in case there's hints in the column order (e.g., id is more likely to be first) try: defaultGeomCol = next(col for col in cols if col in ['geom', 'geometry', 'the_geom', 'way']) except: defaultGeomCol = None try: defaultUniqueCol = [col for col in cols if 'id' in col][0] except: defaultUniqueCol = None colNames = sorted(zip(cols, quotedCols)) newItems = [] uniqueIsFilled = False for (col, quotedCol) in colNames: item = QStandardItem(col) item.setData(quotedCol) item.setEnabled(True) item.setCheckable(self.allowMultiColumnPk) item.setSelectable(not self.allowMultiColumnPk) if self.allowMultiColumnPk: matchingItems = self.uniqueModel.findItems(col) if matchingItems: item.setCheckState(matchingItems[0].checkState()) uniqueIsFilled = uniqueIsFilled or matchingItems[0].checkState() == Qt.Checked else: item.setCheckState(Qt.Unchecked) newItems.append(item) if self.allowMultiColumnPk: self.uniqueModel.clear() self.uniqueModel.appendColumn(newItems) self.uniqueChanged() else: previousUniqueColumn = self.uniqueCombo.currentText() self.uniqueModel.clear() self.uniqueModel.appendColumn(newItems) if self.uniqueModel.findItems(previousUniqueColumn): self.uniqueCombo.setEditText(previousUniqueColumn) uniqueIsFilled = True oldGeometryColumn = self.geomCombo.currentText() self.geomCombo.clear() self.geomCombo.addItems(cols) self.geomCombo.setCurrentIndex(self.geomCombo.findText(oldGeometryColumn, Qt.MatchExactly)) # set sensible default columns if the columns are not already set try: if self.geomCombo.currentIndex() == -1: self.geomCombo.setCurrentIndex(cols.index(defaultGeomCol)) except: pass items = self.uniqueModel.findItems(defaultUniqueCol) if items and not uniqueIsFilled: if self.allowMultiColumnPk: items[0].setCheckState(Qt.Checked) else: self.uniqueCombo.setEditText(defaultUniqueCol)
def build_list_positionable_class(self): model = QStandardItemModel() for obj in self.data.getClassName(): item = QStandardItem(obj) item.setCheckState(Qt.Checked) item.setCheckable(True) model.appendRow(item) model.itemChanged.connect(self.on_positionable_class_list_changed) self.dlg.positionableClass.setModel(model)
def _load_item(self, values, checked_values): """Load item list""" for v in values: item = QStandardItem(str(v)) if v in checked_values: item.setCheckState(Qt.Checked) else: item.setCheckState(Qt.Unchecked) item.setCheckable(True) self.m_sim.appendRow(item)
def populateList(self): model = QStandardItemModel() for value, text in self.options: item = QStandardItem(text) item.setData(value, Qt.UserRole) item.setCheckState(Qt.Checked if value in self.selectedoptions else Qt.Unchecked) item.setCheckable(True) model.appendRow(item) self.lstLayers.setModel(model)
def _add_entity(self, entity): # Add entity item to view item = QStandardItem( GuiUtils.get_icon('table.png'), entity.short_name ) item.setCheckable(True) item.setCheckState(Qt.Unchecked) self._model.appendRow(item)
def populateList(self): model = QStandardItemModel() for i, option in enumerate(self.options): item = QStandardItem(option) item.setCheckState(Qt.Checked if i in self.selectedoptions else Qt.Unchecked) item.setCheckable(True) model.appendRow(item) self.lstLayers.setModel(model)
def populateList(self): model = QStandardItemModel() for value, text in self.options: item = QStandardItem(text) item.setData(value, Qt.UserRole) item.setCheckState(Qt.Checked if value in self.selectedoptions else Qt.Unchecked) item.setCheckable(True) model.appendRow(item) self.lstLayers.setModel(model)
def initModel(self): self.model = QStandardItemModel(self.listView) state = self.checkBox.isChecked() for key in list(self.feat.keys()): if state == False or self.feat[key] > 0: item = QStandardItem() item.setText(key) item.setCheckable(True) item.setSelectable(False) self.model.appendRow(item) self.listView.setModel(self.model) self.listView.show()
def populate_column_listview(self, columns): """ Populates list view with columns used in selecting display columns for foreign key param columns: A list of column names type columns: list """ self.column_model.clear() for column in columns: item = QStandardItem(column) item.setCheckable(True) self.column_model.appendRow(item)
def _createNewUserMapping(self, username): ''' Adds a new user to the list of user mappings ''' # Set icon icon = QIcon() icon.addPixmap(GuiUtils.get_icon_pixmap("user.png"), QIcon.Normal, QIcon.Off) userItem = QStandardItem(icon, username) userItem.setCheckable(True) userItem.setCheckState(Qt.Unchecked) return userItem
def __init__(self, parent=None): """Constructor.""" super(BDTopoImporterDialog, self).__init__(parent) # Set up the user interface from Designer through FORM_CLASS. # After self.setupUi() you can access any designer object by doing # self.<objectname>, and you can use autoconnect slots - see # http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html # #widgets-and-dialogs-with-auto-connect self.setupUi(self) # load db connections self.dbselect = QgsProviderConnectionComboBox('postgres', self) self.horizontalLayout_4.addWidget(self.dbselect) self.schemaselect = QgsDatabaseSchemaComboBox('postgres', self.dbselect.currentConnection(), self) self.dbselect.connectionChanged.connect(self.schemaselect.setConnectionName) self.horizontalLayout_5.addWidget(self.schemaselect) # load layer list data_path = os.path.join(os.path.dirname(__file__), 'data.json') with open(data_path, 'r') as f: json_data = json.load(f) layer_data = json_data['themes'] model = QStandardItemModel() root = model.invisibleRootItem() for theme in layer_data: item = QStandardItem(theme['title']) item.setData(theme['pathname']) root.appendRow(item) for layer in theme['layers']: layeritem = QStandardItem(layer['name']) layeritem.setCheckable(True) # layeritem.setCheckState(Qt.Checked) layeritem.setData(layer['filename']) item.appendRow(layeritem) self.treeView_layers.setModel(model) self.treeView_layers.expandAll() # extract parameter dialog self.settings_dlg = ExtractorSettingsDialog(self) # file access buttons self.pushButton_folder_select.clicked.connect(self.onFolderSelectClicked) self.pushButton_file_select.clicked.connect(self.onFileSelectClicked) # check/uncheck all buttons self.pushButton_checkall.clicked.connect(self.onCheckAllClicked) self.pushButton_uncheckall.clicked.connect(self.onUncheckAllClicked) # settings button self.toolButton_extract_parameters.clicked.connect(self.onExtractParametersClicked)
def update_import_models(self): self.clear_messages() error_msg = None if not self.xtf_file_line_edit.text().strip(): color = '#ffd356' # Light orange self.import_models_qmodel = QStandardItemModel() self.import_models_list_view.setModel(self.import_models_qmodel) else: if os.path.isfile(self.xtf_file_line_edit.text().strip()): color = '#fff' # White self.import_models_qmodel = QStandardItemModel() model_names = get_models_from_xtf( self.xtf_file_line_edit.text().strip()) for model in self.__ladmcol_models.supported_models(): if not model.hidden() and model.full_name() in model_names: item = QStandardItem(model.full_alias()) item.setData(model.full_name(), Qt.UserRole) item.setCheckable(False) item.setEditable(False) self.import_models_qmodel.appendRow(item) if self.import_models_qmodel.rowCount() > 0: self.import_models_list_view.setModel( self.import_models_qmodel) else: error_msg = QCoreApplication.translate( "DialogImportData", "No models were found in the XTF. Is it a valid file?") color = '#ffd356' # Light orange self.import_models_qmodel = QStandardItemModel() self.import_models_list_view.setModel( self.import_models_qmodel) else: error_msg = QCoreApplication.translate( "DialogImportData", "Please set a valid XTF file") color = '#ffd356' # Light orange self.import_models_qmodel = QStandardItemModel() self.import_models_list_view.setModel( self.import_models_qmodel) self.xtf_file_line_edit.setStyleSheet( 'QLineEdit {{ background-color: {} }}'.format(color)) if error_msg: self.txtStdout.setText(error_msg) self.show_message(error_msg, Qgis.Warning) self.import_models_list_view.setFocus() return
def change_positionable_class(self, state): model = QStandardItemModel() for className in self.data.getClassName(): self.data.setSelected(className, state) item = QStandardItem(className) item.setCheckable(True) if state: self.data.setIds(className, "all") item.setCheckState(Qt.Checked) else: item.setCheckState(Qt.Unchecked) model.appendRow(item) model.itemChanged.connect(self.on_positionable_class_list_changed) self.dlg.positionableClass.setModel(model)
def _createNewRoleItem(self, rolename): ''' Creates a custom role item for use in a QStandardItemModel ''' # Set icon icon = QIcon() icon.addPixmap(GuiUtils.get_icon_pixmap("roles.png"), QIcon.Normal, QIcon.Off) roleItem = QStandardItem(icon, rolename) roleItem.setCheckable(True) roleItem.setCheckState(Qt.Unchecked) return roleItem
def update_model_names(self): self.export_models_qmodel = QStandardItemModel() model_names = self.db.get_models() if model_names: for model_name in model_names: if model_name not in LADMNames.DEFAULT_HIDDEN_MODELS: item = QStandardItem(model_name) item.setCheckable(False) item.setEditable(False) self.export_models_qmodel.appendRow(item) self.export_models_list_view.setModel(self.export_models_qmodel)
def update_import_models(self): message_error = None if not self.xtf_file_line_edit.text().strip(): color = '#ffd356' # Light orange self.import_models_qmodel = QStandardItemModel() self.import_models_list_view.setModel(self.import_models_qmodel) else: if os.path.isfile(self.xtf_file_line_edit.text().strip()): color = '#fff' # White self.import_models_qmodel = QStandardItemModel() models_name = self.find_models_xtf( self.xtf_file_line_edit.text().strip()) for model_name in models_name: if not model_name in DEFAULT_HIDDEN_MODELS: item = QStandardItem(model_name) item.setCheckable(False) item.setEditable(False) self.import_models_qmodel.appendRow(item) if self.import_models_qmodel.rowCount() > 0: self.import_models_list_view.setModel( self.import_models_qmodel) else: message_error = QCoreApplication.translate( "DialogImportData", "No models were found in the XTF. Is it a valid file?") color = '#ffd356' # Light orange self.import_models_qmodel = QStandardItemModel() self.import_models_list_view.setModel( self.import_models_qmodel) else: message_error = QCoreApplication.translate( "DialogImportData", "Please set a valid XTF file") color = '#ffd356' # Light orange self.import_models_qmodel = QStandardItemModel() self.import_models_list_view.setModel( self.import_models_qmodel) self.xtf_file_line_edit.setStyleSheet( 'QLineEdit {{ background-color: {} }}'.format(color)) if message_error: self.txtStdout.setText(message_error) self.show_message(message_error, Qgis.Warning) self.import_models_list_view.setFocus() return
def _add_item(self, id, value): """ Adds a row corresponding to id and corresponding value from a lookup table. :param id: Primary key of a lookup record. :type id: int :param value: Lookup value :type value: str """ value_item = QStandardItem(value) value_item.setCheckable(True) id_item = QStandardItem(str(id)) self._item_model.appendRow([value_item, id_item])
def build_list_positionable(self): model = QStandardItemModel() lu = 25 / len(self.loadedPositionable) completed = 75 for pos in self.loadedPositionable: name = Utils.build_row_name_positionable(pos) item = QStandardItem(name) item.setCheckable(True) item.setCheckState(Qt.Checked) model.appendRow(item) completed = completed + lu self.dlg.progressBar.setValue(completed) model.itemChanged.connect(self.on_positionable_list_changed) self.dlg.positionable.setModel(model) self.dlg.progressBar.setValue(0)
def update_model_names(self): self.export_models_qmodel = QStandardItemModel() model_names = self.db.get_models() if model_names: for model in LADMColModelRegistry().supported_models(): if not model.hidden() and model.full_name() in model_names: item = QStandardItem(model.full_alias()) item.setData(model.full_name(), Qt.UserRole) item.setCheckable(False) item.setEditable(False) self.export_models_qmodel.appendRow(item) self.export_models_list_view.setModel(self.export_models_qmodel)
def change_positionable(self, state): model = QStandardItemModel() for className in self.data.getClassName(): for id in self.data.getIds(className): self.data.setIdValue(className, id, state) for pos in self.loadedPositionable: name = Utils.build_row_name_positionable(pos) item = QStandardItem(name) item.setCheckable(True) if state: item.setCheckState(Qt.Checked) else: item.setCheckState(Qt.Unchecked) model.appendRow(item) model.itemChanged.connect(self.on_positionable_list_changed) self.dlg.positionable.setModel(model)
def update_model_names(self): self.export_models_qmodel = QStandardItemModel() db_models = None db_models = self.db.get_models() if db_models: for db_model in db_models: regex = re.compile(r'(?:\{[^\}]*\}|\s)') for modelname in regex.split(db_model['modelname']): if modelname and modelname not in DEFAULT_HIDDEN_MODELS: item = QStandardItem(modelname.strip()) item.setCheckable(False) item.setEditable(False) self.export_models_qmodel.appendRow(item) self.export_models_list_view.setModel(self.export_models_qmodel)
def build_list_attribute(self): model = QStandardItemModel() for attr in self.data.getAttributes(self.currentPositionableClass): item = QStandardItem(attr) if attr in self.alwaysSelectedAttribute: item.setCheckable(False) item.setCheckState(Qt.Checked) else: item.setCheckable(True) if self.data.getAttributes( self.currentPositionableClass)[attr]: item.setCheckState(Qt.Checked) else: item.setCheckState(Qt.Unchecked) model.appendRow(item) model.itemChanged.connect(self.on_attribute_list_changed) self.dlg.attribute.setModel(model)
def addFiles(self): filter = self.getFileFilter(self.datatype) settings = QgsSettings() path = str(settings.value('/Processing/LastInputPath')) ret, selected_filter = QFileDialog.getOpenFileNames(self, self.tr('Select file(s)'), path, filter) if ret: files = list(ret) settings.setValue('/Processing/LastInputPath', os.path.dirname(str(files[0]))) for filename in files: item = QStandardItem(filename) item.setData(filename, Qt.UserRole) item.setCheckState(Qt.Checked) item.setCheckable(True) self.model.appendRow(item)
def addFiles(self): filter = self.getFileFilter(self.datatype) settings = QgsSettings() path = str(settings.value('/Processing/LastInputPath')) ret, selected_filter = QFileDialog.getOpenFileNames(self, self.tr('Select file(s)'), path, filter) if ret: files = list(ret) settings.setValue('/Processing/LastInputPath', os.path.dirname(str(files[0]))) for filename in files: item = QStandardItem(filename) item.setData(filename, Qt.UserRole) item.setCheckState(Qt.Checked) item.setCheckable(True) self.model.appendRow(item)
def __init__(self, parent=None, widget=0): QDialog.__init__(self, parent) tdir = os.path.dirname(os.path.realpath(__file__)) uif = os.path.join(tdir, "ui", "ui_settings.ui") self.ui = uic.loadUi(uif, self) self.ui.optionsList.setCurrentRow(widget) self.rgis = parent self.rdb = parent.rdb if not self.rgis.dtms: self.rgis.dtmModel = QStandardItemModel() self.ui.buttonBox.accepted.connect(self.acceptDialog) self.ui.buttonBox.rejected.connect(self.reject) self.ui.dtm_selectAllChbox.toggled.connect(self.dtm_selectAllToggled) # layerIds of rasters already in the model modelDtmLids = [] for row in range(self.rgis.dtmModel.rowCount()): modelDtmLids.append(self.rgis.dtmModel.item(row).data()[1]) for layerId, layer in sorted( QgsProject.instance().mapLayers().items()): if layer.type() == 1: # it's a raster # skip the raster if already in the model if layerId in modelDtmLids: continue item = QStandardItem('{0}'.format(layer.name())) #layerId check = Qt.Unchecked item.setCheckState(check) item.setCheckable(True) item.setData([layer.name(), layerId]) self.rgis.dtmModel.appendRow(item) self.ui.dtm_listView.setModel(self.rgis.dtmModel) # set UI according to current variable values # General self.ui.open_lastChbox.setChecked(self.rgis.open_last_conn) self.ui.debugModeChbox.setChecked(self.rgis.DEBUG) self.ui.rgisAlwaysOnTopChbox.setChecked(self.rgis.always_on_top) # DB self.ui.db_loadAllChbox.setChecked(self.rgis.rdb.LOAD_ALL)
def __init__(self, parent=None): QWidget.__init__(self, parent) layerList = QgsProject.instance().layerTreeRoot().findLayers() self.iface = iface """for layer in layerList: print(layer.name())""" self.selectedLayers = [] layout = QVBoxLayout() self.model = QStandardItemModel() self.select_all_cb = QCheckBox('Check All') self.select_all_cb.setChecked(True) self.select_all_cb.setStyleSheet('margin-left: 5px; font: bold') #self.select_all_cb.stateChanged.connect(lambda: selectAllCheckChanged(select_all_cb, model)) layout.addWidget(self.select_all_cb) self.view = QListView() self.view.setEditTriggers(QAbstractItemView.NoEditTriggers) self.view.setSelectionMode(QAbstractItemView.NoSelection) self.view.setSelectionRectVisible(False) for layer in layerList: item = QStandardItem(layer.name()) # item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) # item.setData(QVariant(Qt.Checked), Qt.CheckStateRole) item.setCheckable(True) item.setSelectable(False) item.setCheckState(QtCore.Qt.Checked) self.model.appendRow(item) self.selectedLayers.append(item) self.view.setModel(self.model) #view.clicked.connect(lambda: listviewCheckChanged(item, model, select_all_cb)) layout.addWidget(self.view) self.setLayout(layout) """if parent:
def update_model_names(self, dbschema): self.export_models_qmodel = QStandardItemModel() db_models = None if self.type_combo_box.currentData() == 'gpkg': db_models = self.db.get_models() elif self.type_combo_box.currentData() == 'pg': db_models = self.db.get_models(dbschema) if dbschema else None if db_models: for db_model in db_models: regex = re.compile(r'(?:\{[^\}]*\}|\s)') for modelname in regex.split(db_model['modelname']): if modelname and modelname not in DEFAULT_HIDDEN_MODELS: item = QStandardItem(modelname.strip()) item.setCheckable(False) item.setEditable(False) self.export_models_qmodel.appendRow(item) self.export_models_list_view.setModel(self.export_models_qmodel)
def populate_columns_list(self): """ Populate the columns view. :return: :rtype: """ options = {} options['type'] = 'combobox' delegate = GenericDelegate(self.separators, options, self.column_code_view) # Set delegate to add widget self.column_code_view.setItemDelegate(delegate) self.column_code_view.setItemDelegateForColumn(1, delegate) model = QStandardItemModel(2, 2) i = 0 for row, col in enumerate(self._columns): column_item = QStandardItem(self._entity.columns[col].header()) column_item.setCheckable(True) model.setItem(i, 0, column_item) column_item.setData(col) self.column_code_view.setModel(model) i = i + 1 for col in self._entity.columns.values(): if col.name == 'id': continue if col.name not in self._columns: # Correct row by reducing by one due to removal of id column_item = QStandardItem(col.header()) column_item.setCheckable(True) model.setItem(i, 0, column_item) column_item.setData(col.name) self.column_code_view.setModel(model) i = i + 1
def populateList(self): self.model = QStandardItemModel() for value, text in self.options: item = QStandardItem(text) item.setData(value, Qt.UserRole) item.setCheckState(Qt.Checked if value in self.selectedoptions else Qt.Unchecked) item.setCheckable(True) self.model.appendRow(item) # add extra options (e.g. manually added layers) for t in [o for o in self.selectedoptions if not isinstance(o, int)]: if isinstance(t, QgsProcessingModelChildParameterSource): item = QStandardItem(t.staticValue()) else: item = QStandardItem(t) item.setData(item.text(), Qt.UserRole) item.setCheckState(Qt.Checked) item.setCheckable(True) self.model.appendRow(item) self.lstLayers.setModel(self.model)
def populateList(self): self.model = QStandardItemModel() for value, text in self.options: item = QStandardItem(text) item.setData(value, Qt.UserRole) item.setCheckState(Qt.Checked if value in self.selectedoptions else Qt.Unchecked) item.setCheckable(True) self.model.appendRow(item) # add extra options (e.g. manually added layers) for t in [o for o in self.selectedoptions if not isinstance(o, int)]: if isinstance(t, QgsProcessingModelChildParameterSource): item = QStandardItem(t.staticValue()) else: item = QStandardItem(t) item.setData(item.text(), Qt.UserRole) item.setCheckState(Qt.Checked) item.setCheckable(True) self.model.appendRow(item) self.lstLayers.setModel(self.model)
def _loadAttrs(self, attrMapping, sort=False): """ Loads display mapping into the list view. Specify to sort display names in ascending order once items have been added to the model. """ self._attrModel.clear() self._attrModel.setColumnCount(2) for attrName, displayName in attrMapping.items(): # Exclude row ID in the list, other unique identifier attributes in the model can be used if attrName != "id": displayNameItem = QStandardItem(displayName) displayNameItem.setCheckable(True) attrNameItem = QStandardItem(attrName) self._attrModel.appendRow([displayNameItem, attrNameItem]) self.setModel(self._attrModel) if sort: self._attrModel.sort(0)
def addDirectory(self): settings = QgsSettings() path = str(settings.value('/Processing/LastInputPath')) ret = QFileDialog.getExistingDirectory(self, self.tr('Select File(s)'), path) if ret: exts = [] if self.datatype == QgsProcessing.TypeVector: exts = QgsVectorFileWriter.supportedFormatExtensions() elif self.datatype == QgsProcessing.TypeRaster: for t in QgsProviderRegistry.instance().fileRasterFilters().split(';;')[1:]: for e in t[t.index('(') + 1:-1].split(' '): if e != "*.*" and e.startswith("*."): exts.append(e[2:]) files = [] for pp in Path(ret).rglob("*"): if not pp.is_file(): continue if exts and pp.suffix[1:] not in exts: continue p = pp.as_posix() files.append(p) settings.setValue('/Processing/LastInputPath', ret) for filename in files: item = QStandardItem(filename) item.setData(filename, Qt.UserRole) item.setCheckState(Qt.Checked) item.setCheckable(True) item.setDropEnabled(False) self.model.appendRow(item)