コード例 #1
0
    def get_html(self, collection_id):
        """Return the details of a collection as HTML, given its id.

        :param collection_id: The id of the collection
        :type collection_id: str
        """
        html = ""
        resource_types = 0
        for type_, desc in SUPPORTED_RESOURCES_MAP.items():
            if type_ in config.COLLECTIONS[collection_id].keys():
                if resource_types > 0:
                    html += ", "
                html += f"{config.COLLECTIONS[collection_id][type_]} {desc}"
                if config.COLLECTIONS[collection_id][type_] > 1:
                    html += "s"
                resource_types += 1
        html = html + ".<br><i>Reinstall</i> to update"
        if resource_types == 0:
            html = "<i>No standard resources found</i>."
        if config.COLLECTIONS[collection_id]["status"] != COLLECTION_INSTALLED_STATUS:
            html = "<i>Unknown before installation</i>"

        config.COLLECTIONS[collection_id]["resources_html"] = html
        context = {
            "resources_path": str(resources_path()),
            "collection": config.COLLECTIONS[collection_id],
        }
        return render_template("collection_details.html", context)
コード例 #2
0
    def get_html(self, collection_id):
        """Return the details of a collection as HTML, given its id.

        :param collection_id: The id of the collection
        :type collection_id: str
        """
        html = ''
        resource_types = 0
        for type_, desc in SUPPORTED_RESOURCES_MAP.items():
            if type_ in config.COLLECTIONS[collection_id].keys():
                if resource_types > 0:
                    html += ', '
                html += f'{config.COLLECTIONS[collection_id][type_]} {desc}'
                if config.COLLECTIONS[collection_id][type_] > 1:
                    html += 's'
                resource_types += 1
        html = html + '.<br><i>Reinstall</i> to update'
        if resource_types == 0:
            html = '<i>No standard resources found</i>.'
        if (config.COLLECTIONS[collection_id]['status'] !=
                COLLECTION_INSTALLED_STATUS):
            html = '<i>Unknown before installation</i>'

        config.COLLECTIONS[collection_id]['resources_html'] = html
        context = {
            'resources_path': str(resources_path()),
            'collection': config.COLLECTIONS[collection_id]
        }
        return render_template('collection_details.html', context)
コード例 #3
0
    def get_html(self, collection_id):
        """Return the detail of a collection in HTML form given the id.

        :param collection_id: The id of the collection
        :type collection_id: str
        """
        context = {
            'resources_path': resources_path(),
            'collection': config.COLLECTIONS[collection_id]
        }
        return render_template('collection_details.html', context)
コード例 #4
0
    def get_html(self, collection_id):
        """Return the detail of a collection in HTML form given the id.

        :param collection_id: The id of the collection
        :type collection_id: str
        """
        context = {
            'resources_path': resources_path(),
            'collection': config.COLLECTIONS[collection_id]
        }
        return render_template('collection_details.html', context)
コード例 #5
0
    def set_current_tab(self, index):
        """Set stacked widget based on the active tab.

        :param index: The index of the active widget (in the list widget).
        :type index: int
        """
        # Clear message bar
        self.message_bar.clearWidgets()
        if index == (self.menu_list_widget.count() - 1):
            # Last menu entry - Settings
            self.stacked_menu_widget.setCurrentIndex(1)
        else:
            # Not settings, must be Collections (all or installed)
            if index == 1:
                # Installed collections
                self.collection_proxy.accepted_status = \
                    COLLECTION_INSTALLED_STATUS
                # Set the web view
                title = self.tr('Installed Collections')
                description = self.tr(
                    'On the left you see the list of all the '
                    'installed collections.')
            else:
                # All collections (0)
                self.collection_proxy.accepted_status = COLLECTION_ALL_STATUS
                # Set the web view
                title = self.tr('All Collections')
                description = self.tr(
                    'On the left you see a list of all the collections '
                    'that are available from the registered repositories.<br> '
                    'Installed collections are emphasized (in <b>bold</b>).')

            context = {
                'resources_path': str(resources_path()),
                'title': title,
                'description': description
            }
            self.web_view_details.setHtml(
                render_template('tab_description.html', context))
            self.stacked_menu_widget.setCurrentIndex(0)
コード例 #6
0
    def set_current_tab(self, index):
        """Set stacked widget based on active tab.

        :param index: The index of the active list widget item.
        :type index: int
        """
        # Clear message bar first
        self.message_bar.clearWidgets()
        if index == (self.menu_list_widget.count() - 1):
            # Switch to settings tab
            self.stacked_menu_widget.setCurrentIndex(1)
        else:
            # Switch to plugins tab
            if index == 1:
                # Installed
                self.collection_proxy.accepted_status = \
                    COLLECTION_INSTALLED_STATUS
                # Set the web view
                title = self.tr('Installed Collections')
                description = self.tr(
                    'On the left you see the list of all collections '
                    'installed on your QGIS')
            else:
                # All
                self.collection_proxy.accepted_status = COLLECTION_ALL_STATUS
                # Set the web view
                title = self.tr('All Collections')
                description = self.tr(
                    'On the left you see the list of all collections '
                    'available from the repositories registered in the '
                    'settings.')

            context = {
                'resources_path': resources_path(),
                'title': title,
                'description': description
            }
            self.web_view_details.setHtml(
                render_template('tab_description.html', context))
            self.stacked_menu_widget.setCurrentIndex(0)
コード例 #7
0
    def __init__(self, parent=None, iface=None):
        """Constructor.

        :param parent: Optional widget to use as parent
        :type parent: QWidget

        :param iface: An instance of QGisInterface
        :type iface: QGisInterface
        """
        super(ResourceSharingDialog, self).__init__(parent)
        self.setupUi(self)
        self.iface = iface

        # Reconfigure UI
        self.setModal(True)
        self.button_edit.setEnabled(False)
        self.button_delete.setEnabled(False)
        self.button_install.setEnabled(False)
        self.button_open.setEnabled(False)
        self.button_uninstall.setEnabled(False)

        # Set up the "main menu" - QListWidgetItem
        # All collections
        icon_all = QIcon()
        icon_all.addFile(str(resources_path('img', 'plugin.svg')), QSize(),
                         QIcon.Normal, QIcon.Off)
        item_all = QListWidgetItem()
        item_all.setIcon(icon_all)
        item_all.setText(self.tr('All collections'))
        # Installed collections
        icon_installed = QIcon()
        icon_installed.addFile(
            str(resources_path('img', 'plugin-installed.svg')), QSize(),
            QIcon.Normal, QIcon.Off)
        item_installed = QListWidgetItem()
        item_installed.setIcon(icon_installed)
        item_installed.setText(self.tr('Installed collections'))
        item_all.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
        # Settings / repositories
        icon_settings = QIcon()
        icon_settings.addFile(str(resources_path('img', 'settings.svg')),
                              QSize(), QIcon.Normal, QIcon.Off)
        item_settings = QListWidgetItem()
        item_settings.setIcon(icon_settings)
        item_settings.setText(self.tr('Settings'))
        item_all.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        # Add the items to the list widget
        self.menu_list_widget.addItem(item_all)
        self.menu_list_widget.addItem(item_installed)
        self.menu_list_widget.addItem(item_settings)

        # Init the message bar
        self.message_bar = QgsMessageBar(self)
        self.message_bar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
        self.vlayoutRightColumn.insertWidget(0, self.message_bar)

        # Progress dialog for long running processes
        self.progress_dialog = None

        # Init the repository manager dialog
        self.repository_manager = RepositoryManager()
        self.collection_manager = CollectionManager()
        # Collections list view
        self.collections_model = QStandardItemModel(0, 1)
        self.collections_model.sort(0, Qt.AscendingOrder)
        self.collection_proxy = CustomSortFilterProxyModel(self)
        self.collection_proxy.setSourceModel(self.collections_model)
        self.list_view_collections.setModel(self.collection_proxy)
        # Active selected collection
        self._selected_collection_id = None

        # Slots
        self.button_add.clicked.connect(self.add_repository)
        self.button_edit.clicked.connect(self.edit_repository)
        self.button_delete.clicked.connect(self.delete_repository)
        self.button_reload.clicked.connect(self.reload_repositories)
        self.menu_list_widget.currentRowChanged.connect(self.set_current_tab)
        self.list_view_collections.selectionModel().currentChanged.connect(
            self.on_list_view_collections_clicked)
        self.line_edit_filter.textChanged.connect(self.filter_collections)
        self.button_install.clicked.connect(self.install_collection)
        self.button_open.clicked.connect(self.open_collection)
        self.button_uninstall.clicked.connect(self.uninstall_collection)
        self.button_box.button(QDialogButtonBox.Help).clicked.connect(
            self.open_help)

        # Populate the repositories widget and collections list view
        self.populate_repositories_widget()
        self.reload_collections_model()
コード例 #8
0
    def get_html(self, collection_id):
        """Return the details of a collection as HTML, given its id.

        :param collection_id: The id of the collection
        :type collection_id: str
        """
        html = ''
        resource_types = 0
        if 'svg' in config.COLLECTIONS[collection_id].keys():
            html = html + str(
                config.COLLECTIONS[collection_id]['svg']) + ' SVG'
            if config.COLLECTIONS[collection_id]['svg'] > 1:
                html = html + 's'
            resource_types = resource_types + 1
        if 'style' in config.COLLECTIONS[collection_id].keys():
            if resource_types > 0:
                html = html + ', '
            html = html + str(config.COLLECTIONS[collection_id]
                              ['style']) + ' Layer style (QML) file'
            if config.COLLECTIONS[collection_id]['style'] > 1:
                html = html + 's'
            resource_types = resource_types + 1
        if 'symbol' in config.COLLECTIONS[collection_id].keys():
            if resource_types > 0:
                html = html + ', '
            html = html + str(config.COLLECTIONS[collection_id]
                              ['symbol']) + ' Symbol (XML) file'
            if config.COLLECTIONS[collection_id]['symbol'] > 1:
                html = html + 's'
            resource_types = resource_types + 1
        if 'models' in config.COLLECTIONS[collection_id].keys():
            if resource_types > 0:
                html = html + ', '
            html = html + str(config.COLLECTIONS[collection_id]
                              ['models']) + ' Processing model'
            if config.COLLECTIONS[collection_id]['models'] > 1:
                html = html + 's'
            resource_types = resource_types + 1
        if 'expressions' in config.COLLECTIONS[collection_id].keys():
            if resource_types > 0:
                html = html + ', '
            html = html + str(config.COLLECTIONS[collection_id]
                              ['expressions']) + ' Expression (JSON) file'
            if config.COLLECTIONS[collection_id]['expressions'] > 1:
                html = html + 's'
            resource_types = resource_types + 1
        if 'processing' in config.COLLECTIONS[collection_id].keys():
            if resource_types > 0:
                html = html + ', '
            html = html + str(config.COLLECTIONS[collection_id]
                              ['processing']) + ' Processing script'
            if config.COLLECTIONS[collection_id]['processing'] > 1:
                html = html + 's'
            resource_types = resource_types + 1
        if 'rscripts' in config.COLLECTIONS[collection_id].keys():
            if resource_types > 0:
                html = html + ', '
            html = html + str(
                config.COLLECTIONS[collection_id]['rscripts']) + ' R script'
            if config.COLLECTIONS[collection_id]['rscripts'] > 1:
                html = html + 's'
            resource_types = resource_types + 1
        html = html + '.<br><i>Reinstall</i> to update'
        if resource_types == 0:
            html = '<i>No standard resources found</i>.'
        if config.COLLECTIONS[collection_id][
                'status'] != COLLECTION_INSTALLED_STATUS:
            html = '<i>Unknown before installation</i>'

        config.COLLECTIONS[collection_id]['resources_html'] = html
        context = {
            'resources_path': str(resources_path()),
            'collection': config.COLLECTIONS[collection_id]
        }
        return render_template('collection_details.html', context)
コード例 #9
0
    def __init__(self, parent=None, iface=None):
        """Constructor.

        :param parent: Optional widget to use as parent
        :type parent: QWidget

        :param iface: An instance of QGisInterface
        :type iface: QGisInterface
        """
        super(ResourceSharingDialog, self).__init__(parent)
        self.setupUi(self)
        self.iface = iface

        # Reconfigure UI
        self.setModal(True)
        self.button_edit.setEnabled(False)
        self.button_delete.setEnabled(False)
        self.button_install.setEnabled(False)
        self.button_open.setEnabled(False)
        self.button_uninstall.setEnabled(False)

        # Set QListWidgetItem
        # All
        icon_all = QIcon()
        icon_all.addFile(
            resources_path('img', 'plugin.svg'),
            QSize(),
            QIcon.Normal,
            QIcon.Off)
        item_all = QListWidgetItem()
        item_all.setIcon(icon_all)
        item_all.setText(self.tr('All'))
        # Installed
        icon_installed = QIcon()
        icon_installed.addFile(
            resources_path('img', 'plugin-installed.svg'),
            QSize(),
            QIcon.Normal,
            QIcon.Off)
        item_installed = QListWidgetItem()
        item_installed.setIcon(icon_installed)
        item_installed.setText(self.tr('Installed'))
        item_all.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
        # Settings
        icon_settings = QIcon()
        icon_settings.addFile(
            resources_path('img', 'settings.svg'),
            QSize(),
            QIcon.Normal,
            QIcon.Off)
        item_settings = QListWidgetItem()
        item_settings.setIcon(icon_settings)
        item_settings.setText(self.tr('Settings'))
        item_all.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)

        # Add the list widget item to the widget
        self.menu_list_widget.addItem(item_all)
        self.menu_list_widget.addItem(item_installed)
        self.menu_list_widget.addItem(item_settings)

        # Init the message bar
        self.message_bar = QgsMessageBar(self)
        self.message_bar.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed)
        self.vlayoutRightColumn.insertWidget(0, self.message_bar)

        # Progress dialog for any long running process
        self.progress_dialog = None

        # Init repository manager
        self.repository_manager = RepositoryManager()
        self.collection_manager = CollectionManager()
        # Collections list view
        self.collections_model = QStandardItemModel(0, 1)
        self.collections_model.sort(0, Qt.AscendingOrder)
        self.collection_proxy = CustomSortFilterProxyModel(self)
        self.collection_proxy.setSourceModel(self.collections_model)
        self.list_view_collections.setModel(self.collection_proxy)
        # Active selected collection
        self._selected_collection_id = None

        # Slots
        self.button_add.clicked.connect(self.add_repository)
        self.button_edit.clicked.connect(self.edit_repository)
        self.button_delete.clicked.connect(self.delete_repository)
        self.button_reload.clicked.connect(self.reload_repositories)
        self.menu_list_widget.currentRowChanged.connect(self.set_current_tab)
        self.list_view_collections.selectionModel().currentChanged.connect(
            self.on_list_view_collections_clicked)
        self.line_edit_filter.textChanged.connect(self.filter_collections)
        self.button_install.clicked.connect(self.install_collection)
        self.button_open.clicked.connect(self.open_collection)
        self.button_uninstall.clicked.connect(self.uninstall_collection)
        self.button_box.button(QDialogButtonBox.Help).clicked.connect(
            self.open_help)

        # Populate repositories widget and collections list view
        self.populate_repositories_widget()
        self.reload_collections_model()