def suggest(self):
     self.dlg.ui.lookupinfo.setHtml('')
     search_text = self.dlg.geocoderSearch.text()
     if len(search_text) <= 1:
         # QMessageBox.warning(self.iface.mainWindow(), "PDOK plugin", ( \
         #     "meer input aub: {}".format(search_text)
         #     ), QMessageBox.Ok, QMessageBox.Ok)
         return
     # QMessageBox.warning(self.iface.mainWindow(), "PDOK plugin", ( \
     #     "zoeken: {}".format(search_text)
     # ), QMessageBox.Ok, QMessageBox.Ok)
     results = self.pdokgeocoder.suggest(search_text, self.createfq())
     if len(results) == 0:
         # ignore, as we are suggesting, maybe more characters will reveal something...
         return
     for result in results:
         #print address
         adrestekst = QStandardItem("%s" % (result["adrestekst"]))
         adrestekst.setData(result, Qt.UserRole)
         type = QStandardItem("%s" % (result["type"]))
         id = QStandardItem("%s" % (result["id"]))
         score = QStandardItem("%s" % (result["score"]))
         adrestekst.setData(result, Qt.UserRole)
         self.geocoderSourceModel.appendRow([adrestekst, type])
     self.geocoderSourceModel.setHeaderData(0, Qt.Horizontal, "Resultaat")
     self.geocoderSourceModel.setHeaderData(1, Qt.Horizontal, "Type")
     self.geocoderSourceModel.horizontalHeaderItem(0).setTextAlignment(Qt.AlignLeft)
     self.dlg.geocoderResultView.resizeColumnsToContents()
     self.dlg.geocoderResultView.horizontalHeader().setStretchLastSection(True)
Exemplo n.º 2
0
    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)
Exemplo n.º 3
0
    def addItem(self):
        model = self.lstItems.model()

        item = QStandardItem('new item')
        item.setCheckable(True)
        item.setDropEnabled(False)
        item.setData(Qt.Unchecked)

        model.appendRow(item)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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 populateList(self):
        model = QStandardItemModel()
        for i, option in enumerate(self.options):
            item = QStandardItem(option)
            item.setData(i, Qt.UserRole)
            item.setCheckState(Qt.Checked if i in self.selectedoptions else Qt.Unchecked)
            item.setCheckable(True)
            item.setDropEnabled(False)
            model.appendRow(item)

        self.lstLayers.setModel(model)
Exemplo n.º 7
0
    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)
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
    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 add_source(self, name, type, path, origin_info, checked, enabled):
     item = QStandardItem()
     self._checked_models[(name, path)] = checked
     item.setFlags(Qt.ItemIsSelectable
                   | Qt.ItemIsEnabled if enabled else Qt.NoItemFlags)
     item.setData(name, int(Qt.DisplayRole))
     item.setData(name, int(SourceModel.Roles.NAME))
     item.setData(type, int(SourceModel.Roles.TYPE))
     item.setData(path, int(SourceModel.Roles.PATH))
     item.setData(origin_info, int(SourceModel.Roles.ORIGIN_INFO))
     self.appendRow(item)
Exemplo n.º 11
0
 def new_time(self):
     self.filling_tab = True
     model = self.ui.tab_laws.model()
     r = model.rowCount()
     model.insertRow(r)
     itm = QStandardItem()
     if r == 0:
         val = 0.0
     elif r == 1:
         val = model.item(r - 1).data(0) + 1
     else:
         val = 2 * model.item(r - 1).data(0) - model.item(r - 2).data(0)
     itm.setData(val, 0)
     model.setItem(r, 0, itm)
     for c in range(4, model.columnCount()):
         model.setItem(r, c, QStandardItem())
     self.ui.tab_laws.scrollToBottom()
     self.filling_tab = False
     self.update_courbe("all")
 def refresh(self):
     self.beginResetModel()
     self.clear()
     for schema_identificator in self.schema_baskets.keys():
         for basket in self.schema_baskets[schema_identificator]:
             item = QStandardItem()
             item.setData(basket["datasetname"], int(Qt.DisplayRole))
             item.setData(basket["datasetname"],
                          int(BasketSourceModel.Roles.DATASETNAME))
             item.setData(basket["topic"],
                          int(BasketSourceModel.Roles.MODEL_TOPIC))
             item.setData(basket["basket_t_id"],
                          int(BasketSourceModel.Roles.BASKET_TID))
             item.setData(
                 f"{schema_identificator}_{slugify(basket['topic'])}",
                 int(BasketSourceModel.Roles.SCHEMA_TOPIC_IDENTIFICATOR),
             )
             self.appendRow(item)
     self.endResetModel()
Exemplo n.º 13
0
    def import_csv(self):
        """ import CSV """
        # TODO not good format
        # +2 (bief , abscissa)
        nb_col = len(self.list_trac) + 2
        f = QFileDialog.getOpenFileName(None, 'File Selection',
                                        self.mgis.repProject,
                                        "File (*.txt *.csv)")
        if f[0] != '':
            error = False
            self.filling_tab = True
            model = self.create_tab_model()
            r = 0
            with open(f[0], "r", encoding="utf-8") as filein:
                for num_ligne, ligne in enumerate(filein):
                    if ligne[0] != '#':
                        liste = ligne.split(";")
                        if len(liste) == nb_col:
                            model.insertRow(r)
                            for c, val in enumerate(liste):
                                itm = QStandardItem()
                                if c == 0:
                                    itm.setData(data_to_int(val), 0)
                                else:
                                    itm.setData(data_to_float(val), 0)
                                model.setItem(r, c, itm)

                            r += 1
                        else:
                            error = True
                            break

            self.filling_tab = False

            if not error:
                self.ui.tab_laws.setModel(model)
                self.update_cb_bief()
                self.update_courbe("all")
            else:
                if self.mgis.DEBUG:
                    self.mgis.add_info(
                        "Import failed ({}) because the colone number of file isn't agree."
                        .format(f[0]))
Exemplo n.º 14
0
    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.non_hidden_and_supported_models():
                    if 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
Exemplo n.º 15
0
 def fetch_3di_models(self):
     """Fetching 3Di models list."""
     try:
         tc = ThreediCalls(self.threedi_api)
         offset = (self.page_sbox.value() - 1) * self.TABLE_LIMIT
         text = self.search_le.text()
         threedi_models, models_count = tc.fetch_3di_models_with_count(
             limit=self.TABLE_LIMIT, offset=offset, name_contains=text)
         pages_nr = ceil(models_count / self.TABLE_LIMIT) or 1
         self.page_sbox.setMaximum(pages_nr)
         self.page_sbox.setSuffix(f" / {pages_nr}")
         self.models_model.clear()
         header = [
             "ID", "Model", "Schematisation", "Revision", "Last updated",
             "Updated by"
         ]
         self.models_model.setHorizontalHeaderLabels(header)
         for sim_model in sorted(threedi_models,
                                 key=attrgetter("revision_commit_date"),
                                 reverse=True):
             id_item = QStandardItem(str(sim_model.id))
             name_item = QStandardItem(sim_model.name)
             name_item.setData(sim_model, role=Qt.UserRole)
             schema_item = QStandardItem(sim_model.schematisation_name)
             rev_item = QStandardItem(sim_model.revision_number)
             last_updated_day = sim_model.revision_commit_date.split("T")[0]
             lu_datetime = QDateTime.fromString(last_updated_day,
                                                "yyyy-MM-dd")
             lu_item = QStandardItem(lu_datetime.toString("dd-MMMM-yyyy"))
             ub_item = QStandardItem(sim_model.user)
             self.models_model.appendRow([
                 id_item, name_item, schema_item, rev_item, lu_item, ub_item
             ])
         self.threedi_models = threedi_models
     except ApiException as e:
         self.close()
         error_msg = extract_error_message(e)
         self.communication.show_error(error_msg)
     except Exception as e:
         self.close()
         error_msg = f"Error: {e}"
         self.communication.show_error(error_msg)
Exemplo n.º 16
0
    def set_columns(self):
        """
        Check columns from the configuration.
        :return:
        :rtype:
        .. versionadded:: 1.7.5
        """
        model = self.column_code_view.model()

        for row in range(model.rowCount()):
            col_item = model.item(row, 0)

            if col_item.data() in self._columns:
                col_idx = self._columns.index(col_item.data())
                separator = self._column_separators[col_idx]
                separator_item = QStandardItem(self.separators[separator])
                model.setItem(row, 1, separator_item)
                separator_item.setData(separator)

                col_item.setCheckState(Qt.Checked)
Exemplo n.º 17
0
    def setModelData(self, editor, model, index):
        """
        Gets data from the editor widget and stores
        it in the specified model at the item index.
        :param editor: combobox
        :type editor: QComboBox
        :param model: QModel
        :type model: QModel
        :param index: The index of the data
        to be inserted.
        :type index: QModelIndex
        """
        if self.options['type'] == 'combobox':
            value = editor.currentIndex()
            data = editor.itemData(editor.currentIndex())

            separator_item = QStandardItem(value)
            model.setItem(index.row(), index.column(), separator_item)
            separator_item.setData(data)
            model.setData(index, editor.itemData(value, Qt.DisplayRole))
Exemplo n.º 18
0
    def loadwidgettypes(self):
        """
        Load all supported widgets into the combobox for the form designer.
        :return:
        """
        self.useablewidgets.blockSignals(True)
        for widgettype in roam.editorwidgets.core.supportedwidgets():
            try:
                configclass = configmanager.editorwidgets.widgetconfigs[widgettype]
            except KeyError:
                continue

            configwidget = configclass()
            item = QStandardItem(widgettype)
            item.setData(configwidget, Qt.UserRole)
            item.setData(widgettype, Qt.UserRole + 1)
            item.setIcon(widgeticon(widgettype))
            self.useablewidgets.model().appendRow(item)
            self.widgetstack.addWidget(configwidget)
        self.useablewidgets.blockSignals(False)
Exemplo n.º 19
0
    def set_layer(self, layer):
        self.model.clear()

        if not layer:
            return
        if layer.type() != QgsMapLayer.VectorLayer:
            return

        self.layer = layer

        for i, field in enumerate(self.layer.fields()):
            alias = field.alias()
            if alias:
                name = "{} ({})".format(field.name(), alias)
            else:
                name = field.name()
            item = QStandardItem(name)
            item.setData(field.name())
            item.setIcon(self.layer.fields().iconForField(i))
            self.append_row(item)
Exemplo n.º 20
0
    def geocode(self, search_text):
        self.dlg.ui.lookupinfo.setHtml('')
        addresses = self.pdokgeocoder.search(search_text)
        if len(addresses) == 0:
            QMessageBox.warning(self.iface.mainWindow(), "PDOK plugin", ( \
                "Niets gevonden. Probeer een andere spelling of alleen postcode/huisnummer."
                ), QMessageBox.Ok, QMessageBox.Ok)
            return
        for address in addresses:
            #print address
            adrestekst = QStandardItem("%s" % (address["adrestekst"]))
            adrestekst.setData(address, Qt.UserRole)
            straat = QStandardItem("%s" % (address["straat"]))
            nummer = QStandardItem("%s" % (address["nummer"]))
            postcode = QStandardItem("%s" % (address["postcode"]))
            plaats = QStandardItem("%s" % (address["plaats"]))
            gemeente = QStandardItem("%s" % (address["gemeente"]))
            provincie = QStandardItem("%s" % (address["provincie"]))
            self.geocoderSourceModel.appendRow([adrestekst, straat, nummer, postcode, plaats, gemeente, provincie])

        self.dlg.geocoderResultView.selectRow(0)
        self.zoomToAddress()

        self.geocoderSourceModel.setHeaderData(0, Qt.Horizontal, "Resultaat")
        self.geocoderSourceModel.setHeaderData(1, Qt.Horizontal, "Straat")
        self.geocoderSourceModel.setHeaderData(2, Qt.Horizontal, "Nr")
        self.geocoderSourceModel.setHeaderData(3, Qt.Horizontal, "Postcode")
        self.geocoderSourceModel.setHeaderData(4, Qt.Horizontal, "Plaats")
        self.geocoderSourceModel.setHeaderData(5, Qt.Horizontal, "Gemeente")
        self.geocoderSourceModel.setHeaderData(6, Qt.Horizontal, "Provincie")

        self.geocoderSourceModel.horizontalHeaderItem(0).setTextAlignment(Qt.AlignLeft)
        self.geocoderSourceModel.horizontalHeaderItem(1).setTextAlignment(Qt.AlignLeft)
        self.geocoderSourceModel.horizontalHeaderItem(2).setTextAlignment(Qt.AlignLeft)
        self.geocoderSourceModel.horizontalHeaderItem(3).setTextAlignment(Qt.AlignLeft)
        self.geocoderSourceModel.horizontalHeaderItem(4).setTextAlignment(Qt.AlignLeft)
        self.geocoderSourceModel.horizontalHeaderItem(5).setTextAlignment(Qt.AlignLeft)
        self.geocoderSourceModel.horizontalHeaderItem(6).setTextAlignment(Qt.AlignLeft)

        self.dlg.geocoderResultView.resizeColumnsToContents()
        self.dlg.geocoderResultView.horizontalHeader().setStretchLastSection(True)
Exemplo n.º 21
0
    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
Exemplo n.º 22
0
 def fetch_3di_models(self):
     """Fetching 3Di models list."""
     try:
         tc = ThreediCalls(self.threedi_api)
         threedi_models, models_count = tc.fetch_3di_models_with_count(
             limit=tc.FETCH_LIMIT,
             schematisation_name=self.local_schematisation.name,
             show_invalid=True)
         self.models_model.clear()
         if models_count < self.parent_widget.MAX_SCHEMATISATION_MODELS:
             self.accept()
         header = [
             "ID", "Model", "Schematisation", "Revision", "Last updated",
             "Updated by"
         ]
         self.models_model.setHorizontalHeaderLabels(header)
         for sim_model in sorted(threedi_models,
                                 key=attrgetter("revision_commit_date"),
                                 reverse=True):
             if sim_model.schematisation_id != self.local_schematisation.id:
                 continue
             id_item = QStandardItem(str(sim_model.id))
             name_item = QStandardItem(sim_model.name)
             name_item.setData(sim_model, role=Qt.UserRole)
             schema_item = QStandardItem(sim_model.schematisation_name)
             rev_item = QStandardItem(sim_model.revision_number)
             last_updated_day = sim_model.revision_commit_date.split("T")[0]
             lu_datetime = QDateTime.fromString(last_updated_day,
                                                "yyyy-MM-dd")
             lu_item = QStandardItem(lu_datetime.toString("dd-MMMM-yyyy"))
             ub_item = QStandardItem(sim_model.user)
             self.models_model.appendRow([
                 id_item, name_item, schema_item, rev_item, lu_item, ub_item
             ])
         self.threedi_models = threedi_models
     except ApiException as e:
         error_msg = extract_error_message(e)
         self.communication.show_error(error_msg)
     except Exception as e:
         error_msg = f"Error: {e}"
         self.communication.show_error(error_msg)
Exemplo n.º 23
0
    def _buildfromlist(self, widget, listconfig):
        items = listconfig['items']
        for item in items:
            parts = item.split(';')
            data = parts[0]
            try:
                desc = parts[1]
            except IndexError:
                desc = data

            try:
                path = parts[2]
                path = path.strip()
                icon = QIcon(path)
            except:
                icon = QIcon()

            item = QStandardItem(desc)
            item.setData(data, Qt.UserRole)
            item.setIcon(icon)
            self.listmodel.appendRow(item)
Exemplo n.º 24
0
    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)
Exemplo n.º 25
0
    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)
Exemplo n.º 26
0
    def init_ui(self):
        model = QStandardItemModel()
        model.insertColumns(0, 4)
        model.setHeaderData(0, 1, 'ID', 0)
        model.setHeaderData(1, 1, 'Sigle', 0)
        model.setHeaderData(2, 1, 'Parameter', 0)
        model.setHeaderData(3, 1, 'Value', 0)

        sql = "SELECT id, sigle, text, value FROM {0}.tracer_physic WHERE type = '{1}' ORDER BY id".format(
            self.mdb.SCHEMA, self.cur_wq_mod)
        rows = self.mdb.run_query(sql, fetch=True)
        model.insertRows(0, len(rows))
        for r, row in enumerate(rows):
            for c, val in enumerate(row):
                itm = QStandardItem()
                itm.setData(val, 0)
                if c == 3:
                    itm.setData(data_to_float(val), 0)
                    itm.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled
                                 | Qt.ItemIsEditable)
                    itm.setTextAlignment(Qt.AlignRight | Qt.AlignVCenter)
                else:
                    itm.setData(val, 0)
                    itm.setFlags(Qt.ItemIsEnabled)
                model.setItem(r, c, itm)

        self.ui.tab_param.setModel(model)
        self.ui.tab_param.hide()
        self.ui.tab_param.resizeColumnsToContents()
        self.ui.tab_param.resizeRowsToContents()
        self.ui.tab_param.setColumnHidden(0, True)
        self.ui.ui.tab_param.show()
Exemplo n.º 27
0
    def new_val(self):
        self.filling_tab = True
        model = self.ui.tab_laws.model()
        r = model.rowCount()
        model.insertRow(r)

        itm = QStandardItem()
        if r == 0:
            cur_bief = 1
        else:
            cur_bief = model.item(r - 1).data(0)
        itm.setData(cur_bief, 0)
        model.setItem(r, 0, itm)

        itm = QStandardItem()
        valabs = 0.0
        if r == 0:
            valabs = 0.0
        else:
            if model.item(r - 1, 0).data(0) != cur_bief:
                valabs = 0.0
            else:
                try:
                    if model.item(r - 2, 0).data(0) != cur_bief:
                        valabs = model.item(r - 1, 1).data(0) + 1.
                    else:
                        valabs = 2 * model.item(r - 1, 1).data(0) - model.item(
                            r - 2, 1).data(0)
                except AttributeError:
                    valabs = valabs + 1
        itm.setData(valabs, 0)
        model.setItem(r, 1, itm)

        for c in range(2, model.columnCount()):
            model.setItem(r, c, QStandardItem())
        self.ui.tab_laws.scrollToBottom()
        self.filling_tab = False

        self.update_cb_bief()
        self.update_courbe("all")
Exemplo n.º 28
0
    def load(self):
        """
        Parse the XML and return any basemaps you find
        """
        self.regions = {}

        # Maybe the basemaps file isn't synced yet
        if not os.path.isfile(BASEMAPS_XML_PATH):
            return

        # Parse the XML
        try:
            for region in lxml.etree.parse(BASEMAPS_XML_PATH).getroot().findall('Region'):
                q_region = QStandardItem(QIcon(':/plugins/qrave_toolbar/BrowseFolder.png'), 'Basemaps')
                q_region.setData(ProjectTreeData(QRaveTreeTypes.BASEMAP_ROOT), Qt.UserRole),
                self.regions[region.attrib['name']] = q_region

                for group_layer in region.findall('GroupLayer'):
                    q_group_layer = QStandardItem(QIcon(':/plugins/qrave_toolbar/BrowseFolder.png'), group_layer.attrib['name'])
                    q_group_layer.setData(ProjectTreeData(QRaveTreeTypes.BASEMAP_SUPER_FOLDER), Qt.UserRole),
                    q_region.appendRow(q_group_layer)

                    for layer in group_layer.findall('Layer'):
                        layer_label = layer.attrib['name']
                        # TODO: Need to go a little backward compatible. We can remove this logic after July 1, 2021
                        tile_type = layer.attrib['type'] if 'type' in layer.attrib else 'wms'
                        layer_url = layer.attrib['url']

                        q_layer = QStandardItem(QIcon(':/plugins/qrave_toolbar/RaveAddIn_16px.png'), layer_label)

                        meta = {meta.attrib['name']: meta.text for meta in layer.findall('Metadata/Meta')}

                        basemap_obj = QRaveBaseMap(q_layer, layer_url, tile_type, meta)

                        if tile_type == 'wms':
                            pt_data = basemap_obj
                        else:
                            encoded_url = urllib.parse.quote_plus(layer_url)
                            url_with_params = 'type=xyz&url={}'.format(encoded_url)
                            pt_data = QRaveMapLayer(
                                layer_label,
                                QRaveMapLayer.LayerTypes.WEBTILE,
                                tile_type=tile_type,
                                layer_uri=url_with_params,
                                meta=meta
                            )

                        # WMS is complicated because it needs a lookup
                        q_layer.setData(
                            ProjectTreeData(QRaveTreeTypes.LEAF, None, pt_data),
                            Qt.UserRole
                        )

                        # We set the data to be Basemaps to help us load this stuff later
                        q_group_layer.appendRow(q_layer)
        except Exception as e:
            settings = Settings()
            settings.msg_bar("Error loading basemaps", "Exception: {}".format(e),
                             Qgis.Critical)
Exemplo n.º 29
0
    def _build_views(self):
        if self.business_logic is None:
            return

        views = self.business_logic.find('Views')
        if views is None or 'default' not in views.attrib:
            self.settings.log('Default view could not be located',
                              Qgis.Warning)
            return

        self.default_view = views.attrib['default']
        self.views = {}

        curr_item = QStandardItem(
            QIcon(':/plugins/qrave_toolbar/BrowseFolder.png'), "Project Views")
        curr_item.setData(
            ProjectTreeData(QRaveTreeTypes.PROJECT_VIEW_FOLDER, project=self),
            Qt.UserRole)

        for view in self.business_logic.findall('Views/View'):
            name = view.attrib['name']
            view_id = view.attrib['id'] if 'id' in view.attrib else None

            if name is None or view_id is None:
                continue

            view_item = QStandardItem(
                QIcon(':/plugins/qrave_toolbar/project_view.png'), name)
            view_layer_ids = [
                layer.attrib['id'] for layer in view.findall('Layers/Layer')
            ]
            self.views[view_id] = view_layer_ids
            view_item.setData(
                ProjectTreeData(QRaveTreeTypes.PROJECT_VIEW,
                                project=self,
                                data=view_layer_ids), Qt.UserRole)
            curr_item.appendRow(view_item)

        self.qproject.appendRow(curr_item)
 def addSourceRow(self, serviceLayer):
     # you can attache different "data's" to to an QStandarditem
     # default one is the visible one:
     itemType = QStandardItem("%s" % (serviceLayer["type"].upper()) )
     # userrole is a free form one:
     # only attach the data to the first item
     # service layer = a dict/object with all props of the layer
     itemType.setData( serviceLayer, Qt.UserRole )
     itemType.setToolTip("%s - %s" % (serviceLayer["type"].upper() ,serviceLayer["title"] ))
     # only wms services have styles (sometimes)
     layername = serviceLayer["title"]
     if 'style' in serviceLayer:
         itemLayername = QStandardItem("%s [%s]" % (serviceLayer["title"], serviceLayer["style"]) )
         layername = "%s [%s]" % (serviceLayer["title"], serviceLayer["style"])
     else:
         itemLayername = QStandardItem("%s" % (serviceLayer["title"]))
     itemLayername.setToolTip("%s - %s" % (serviceLayer["type"].upper() ,serviceLayer["servicetitle"] ))
     # itemFilter is the item used to search filter in. That is why layername is a combi of layername + filter here
     itemFilter = QStandardItem("%s %s %s %s" % (serviceLayer["type"], layername, serviceLayer["servicetitle"], serviceLayer["abstract"]) )
     itemServicetitle = QStandardItem("%s" % (serviceLayer["servicetitle"]))
     itemServicetitle.setToolTip("%s - %s" % (serviceLayer["type"].upper() ,serviceLayer["title"] ))
     self.sourceModel.appendRow( [ itemLayername, itemType, itemServicetitle, itemFilter ] )
 def addSourceRow(self, serviceLayer):
     # you can attache different "data's" to to an QStandarditem
     # default one is the visible one:
     itemType = QStandardItem("%s" % (serviceLayer["type"].upper()) )
     # userrole is a free form one:
     # only attach the data to the first item
     # service layer = a dict/object with all props of the layer
     itemType.setData( serviceLayer, Qt.UserRole )
     itemType.setToolTip("%s - %s" % (serviceLayer["type"].upper() ,serviceLayer["title"] ))
     # only wms services have styles (sometimes)
     layername = serviceLayer["title"]
     if 'style' in serviceLayer:
         itemLayername = QStandardItem("%s [%s]" % (serviceLayer["title"], serviceLayer["style"]) )
         layername = "%s [%s]" % (serviceLayer["title"], serviceLayer["style"])
     else:
         itemLayername = QStandardItem("%s" % (serviceLayer["title"]))
     itemLayername.setToolTip("%s - %s" % (serviceLayer["type"].upper() ,serviceLayer["servicetitle"] ))
     # itemFilter is the item used to search filter in. That is why layername is a combi of layername + filter here
     itemFilter = QStandardItem("%s %s %s %s" % (serviceLayer["type"], layername, serviceLayer["servicetitle"], serviceLayer["abstract"]) )
     itemServicetitle = QStandardItem("%s" % (serviceLayer["servicetitle"]))
     itemServicetitle.setToolTip("%s - %s" % (serviceLayer["type"].upper() ,serviceLayer["title"] ))
     self.sourceModel.appendRow( [ itemLayername, itemType, itemServicetitle, itemFilter ] )
Exemplo n.º 32
0
    def _buildfromlayer(self, widget, layerconfig):
        layername = layerconfig['layer']
        keyfield = layerconfig['key']
        valuefield = layerconfig['value']
        filterexp = layerconfig.get('filter', None)

        try:
            layer = utils.layer_by_name(layername)
        except IndexError:
            roam.utils.warning(
                "Can't find layer {} in project".format(layername))
            return

        keyfieldindex = layer.fields().lookupField(keyfield)
        valuefieldindex = layer.fields().lookupField(valuefield)
        if keyfieldindex == -1 or valuefieldindex == -1:
            roam.utils.warning(f"Can't find key or value column for widget"
                               f"Id: {self.id} "
                               f"Key: {keyfield} - {keyfieldindex} "
                               f"Value: {valuefield} - {valuefieldindex} ")
            return

        if self.allownulls:
            item = QStandardItem('(no selection)')
            item.setData(None, Qt.UserRole)
            self.listmodel.appendRow(item)

        fields = [keyfield, valuefield]
        iconfieldindex = layer.fields().lookupField('icon')
        if iconfieldindex > -1:
            fields.append("icon")

        if not filterexp and valuefieldindex == keyfieldindex and iconfieldindex == -1:
            values = layer.uniqueValues(keyfieldindex)
            for value in values:
                value = nullconvert(value)
                item = QStandardItem(value)
                item.setData(value, Qt.UserRole)
                self.listmodel.appendRow(item)
            return

        features = roam.api.utils.search_layer(layer,
                                               filterexp,
                                               fields,
                                               with_geometry=False)
        for feature in features:
            keyvalue = nullconvert(feature[keyfieldindex])
            valuvalue = nullconvert(feature[valuefield])
            try:
                path = feature["icon"]
                icon = QIcon(path)
            except KeyError:
                icon = QIcon()

            item = QStandardItem(keyvalue)
            item.setData(str(valuvalue), Qt.UserRole)
            item.setIcon(icon)
            self.listmodel.appendRow(item)
    def add_source(self, name, type, path, origin_info=None):
        if self._source_in_model(name, type, path):
            return False

        item = QStandardItem()
        item.setData(name, int(Qt.DisplayRole))
        item.setData(name, int(SourceModel.Roles.NAME))
        item.setData(type, int(SourceModel.Roles.TYPE))
        item.setData(path, int(SourceModel.Roles.PATH))
        item.setData(origin_info, int(SourceModel.Roles.ORIGIN_INFO))
        self.appendRow([item, QStandardItem()])

        self.print_info.emit(
            self.tr("Add source {} ({}) {}").format(
                name, path if path else "repository", origin_info))
        return True
Exemplo n.º 34
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)
Exemplo n.º 35
0
    def update_cbb_keywords(self,
                            tags_keywords: dict = {},
                            selected_keywords: list = []):
        """Keywords combobox is specific because items are checkable.
        See: https://github.com/isogeo/isogeo-plugin-qgis/issues/159

        :param dict tags_keywords: keywords found in search tags.
        :param list selected_keywords: keywords (codes) already checked.
        """
        selected_keywords_lbls = self.cbb_chck_kw.checkedItems()  # for tooltip
        logger.debug(
            "Updating keywords combobox with {} items, including {} selected.".
            format(len(tags_keywords), len(selected_keywords_lbls)))

        # shortcut
        model = self.cbb_chck_kw.model()

        # disconnect the widget before updating
        try:
            model.itemChanged.disconnect()
        except TypeError:
            pass

        # clear the the combobox content
        model.clear()

        # parse keywords and check selected
        i = 0  # row index
        for tag_label, tag_code in sorted(tags_keywords.items()):
            item = QStandardItem(tag_label)
            item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled)
            item.setData(tag_code, 32)
            if len(selected_keywords
                   ) == 0 or tag_code not in selected_keywords:
                item.setData(Qt.Unchecked, Qt.CheckStateRole)
                model.setItem(i, 0, item)
            elif tag_code in selected_keywords:
                item.setData(Qt.Checked, Qt.CheckStateRole)
                model.insertRow(0, item)
            else:
                pass
            i += 1

        # connect keyword selected -> launch search
        model.itemChanged.connect(self.kw_sig.emit)

        # add tooltip with selected keywords. see: #107#issuecomment-341742142
        if selected_keywords:
            tooltip = "{}\n - {}".format(
                self.tr("Selected keywords:", context=__class__.__name__),
                "\n - ".join(selected_keywords_lbls),
            )
        else:
            tooltip = self.tr("No keyword selected",
                              context=__class__.__name__)
        self.cbb_chck_kw.setToolTip(tooltip)
 def refresh_model(self, db_connector=None):
     self.beginResetModel()
     self.clear()
     if db_connector:
         datasets_info = db_connector.get_datasets_info()
         for record in datasets_info:
             if record["datasetname"] == CATALOGUE_DATASETNAME:
                 continue
             item = QStandardItem()
             item.setData(record["datasetname"], int(Qt.DisplayRole))
             item.setData(record["datasetname"],
                          int(DatasetModel.Roles.DATASETNAME))
             item.setData(record["t_id"], int(DatasetModel.Roles.TID))
             self.appendRow(item)
     self.endResetModel()
Exemplo n.º 37
0
    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)
        try:
            pass
        except:
            pass
 def endpointselectaction(self):
     endpointIndex = self.dlg.comboBox.currentIndex()
     self.dlg.queryTemplates.clear()
     print("changing endpoint")
     conceptlist = []
     self.dlg.geoClassListModel.clear()
     self.dlg.savedQueries.clear()
     if "endpoint" in self.triplestoreconf[
             endpointIndex] and self.triplestoreconf[endpointIndex][
                 "endpoint"] in self.savedQueriesJSON:
         for item in self.savedQueriesJSON[
                 self.triplestoreconf[endpointIndex]["endpoint"]]:
             self.dlg.savedQueries.addItem(item["label"])
     if "endpoint" in self.triplestoreconf[
             endpointIndex] and self.triplestoreconf[endpointIndex][
                 "endpoint"] != "" and (
                     not "staticconcepts"
                     in self.triplestoreconf[endpointIndex] or
                     "staticconcepts" in self.triplestoreconf[endpointIndex]
                     and
                     self.triplestoreconf[endpointIndex]["staticconcepts"]
                     == []) and "geoconceptquery" in self.triplestoreconf[
                         endpointIndex] and self.triplestoreconf[
                             endpointIndex]["geoconceptquery"] != "":
         item = QStandardItem()
         item.setText("Loading...")
         self.dlg.geoClassListModel.appendRow(item)
         if "examplequery" in self.triplestoreconf[endpointIndex]:
             conceptlist = self.getGeoConcepts(
                 self.triplestoreconf[endpointIndex]["endpoint"],
                 self.triplestoreconf[endpointIndex]["geoconceptquery"],
                 "class", None, True,
                 self.triplestoreconf[endpointIndex]["examplequery"])
         else:
             conceptlist = self.getGeoConcepts(
                 self.triplestoreconf[endpointIndex]["endpoint"],
                 self.triplestoreconf[endpointIndex]["geoconceptquery"],
                 "class", None, True, None)
     elif "staticconcepts" in self.triplestoreconf[
             endpointIndex] and self.triplestoreconf[endpointIndex][
                 "staticconcepts"] != []:
         conceptlist = self.triplestoreconf[endpointIndex]["staticconcepts"]
         self.dlg.autocomplete["completerClassList"] = {}
         for concept in conceptlist:
             item = QStandardItem()
             item.setData(concept, 1)
             item.setText(concept[concept.rfind('/') + 1:])
             self.dlg.autocomplete["completerClassList"][
                 concept[concept.rfind('/') + 1:]] = "<" + concept + ">"
             self.dlg.geoClassListModel.appendRow(item)
         self.dlg.inp_sparql2.updateNewClassList()
         if len(conceptlist) > 0:
             self.dlg.geoClassList.selectionModel().setCurrentIndex(
                 self.dlg.geoClassList.model().index(0, 0),
                 QItemSelectionModel.SelectCurrent)
         if "examplequery" in self.triplestoreconf[endpointIndex]:
             self.dlg.inp_sparql2.setPlainText(
                 self.triplestoreconf[endpointIndex]["examplequery"])
             self.dlg.inp_sparql2.columnvars = {}
     if "areaconcepts" in self.triplestoreconf[
             endpointIndex] and self.triplestoreconf[endpointIndex][
                 "areaconcepts"]:
         conceptlist2 = self.triplestoreconf[endpointIndex]["areaconcepts"]
         for concept in conceptlist2:
             self.dlg.areaconcepts.addItem(concept["concept"])
     if "querytemplate" in self.triplestoreconf[endpointIndex]:
         for concept in self.triplestoreconf[endpointIndex][
                 "querytemplate"]:
             self.dlg.queryTemplates.addItem(concept["label"])
 def reload_collections_model(self):
     """Reload the collections model with the current collections."""
     self.collections_model.clear()
     installed_collections = \
         self.collection_manager.get_installed_collections()
     for id in config.COLLECTIONS:
         collection_name = config.COLLECTIONS[id]['name']
         collection_author = config.COLLECTIONS[id]['author']
         collection_tags = config.COLLECTIONS[id]['tags']
         collection_description = config.COLLECTIONS[id]['description']
         collection_status = config.COLLECTIONS[id]['status']
         repository_name = ''
         if 'repository_name' in config.COLLECTIONS[id].keys():
             repository_name = config.COLLECTIONS[id]['repository_name']
         item = QStandardItem(collection_name + ' (' + repository_name +
                              ')')
         item.setEditable(False)
         item.setData(id, COLLECTION_ID_ROLE)
         item.setData(collection_name, COLLECTION_NAME_ROLE)
         item.setData(collection_description, COLLECTION_DESCRIPTION_ROLE)
         item.setData(collection_author, COLLECTION_AUTHOR_ROLE)
         item.setData(collection_tags, COLLECTION_TAGS_ROLE)
         item.setData(collection_status, COLLECTION_STATUS_ROLE)
         # Make installed collections stand out
         if installed_collections and id in installed_collections.keys():
             collectionFont = QFont()
             collectionFont.setWeight(60)
             item.setFont(collectionFont)
         self.collections_model.appendRow(item)
     self.collections_model.sort(0, Qt.AscendingOrder)
 def reload_collections_model(self):
     """Reload the collections model with the current collections."""
     self.collections_model.clear()
     for id in config.COLLECTIONS:
         collection_name = config.COLLECTIONS[id]['name']
         collection_author = config.COLLECTIONS[id]['author']
         collection_tags = config.COLLECTIONS[id]['tags']
         collection_description = config.COLLECTIONS[id]['description']
         collection_status = config.COLLECTIONS[id]['status']
         item = QStandardItem(collection_name)
         item.setEditable(False)
         item.setData(id, COLLECTION_ID_ROLE)
         item.setData(collection_name, COLLECTION_NAME_ROLE)
         item.setData(collection_description, COLLECTION_DESCRIPTION_ROLE)
         item.setData(collection_author, COLLECTION_AUTHOR_ROLE)
         item.setData(collection_tags, COLLECTION_TAGS_ROLE)
         item.setData(collection_status, COLLECTION_STATUS_ROLE)
         self.collections_model.appendRow(item)
     self.collections_model.sort(0, Qt.AscendingOrder)