def add_authentication(self):
        """Slot for when the add auth button is clicked."""
        if qgis_version() >= 21200:
            from qgis.gui import QgsAuthConfigSelect

            dlg = QDialog(self)
            dlg.setWindowTitle(self.tr("Select Authentication"))
            layout = QVBoxLayout(dlg)

            acs = QgsAuthConfigSelect(dlg)
            if self.line_edit_auth_id.text():
                acs.setConfigId(self.line_edit_auth_id.text())
            layout.addWidget(acs)

            button_box = QDialogButtonBox(
                QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
                Qt.Horizontal,
                dlg)
            layout.addWidget(button_box)
            button_box.accepted.connect(dlg.accept)
            button_box.rejected.connect(dlg.close)

            dlg.setLayout(layout)
            dlg.setWindowModality(Qt.WindowModal)
            if dlg.exec_():
                self.line_edit_auth_id.setText(acs.configId())
            del dlg
Exemplo n.º 2
0
    def __init__(self, parent, server_type):
        super().__init__(parent, server_type)
        self.setupUi(self)

        self.postgisAuth = QgsAuthConfigSelect()
        self.postgisAuth.selectedConfigIdChanged.connect(self.setDirty)
        self.addAuthWidget()

        self.txtPostgisName.textChanged.connect(self.setDirty)
        self.txtPostgisServerAddress.textChanged.connect(self.setDirty)
        self.txtPostgisPort.textChanged.connect(self.setDirty)
        self.txtPostgisSchema.textChanged.connect(self.setDirty)
        self.txtPostgisDatabase.textChanged.connect(self.setDirty)
Exemplo n.º 3
0
 def editAuthCfgId(self):
     dlg = QDialog(self)
     dlg.setWindowModality(Qt.WindowModal)
     layout = QVBoxLayout()
     selector = QgsAuthConfigSelect(self)
     if self.editAuthCfg.text():
         selector.setConfigId(self.editAuthCfg.text())
     layout.addWidget(selector)
     buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Close)
     buttonBox.accepted.connect(dlg.accept)
     buttonBox.rejected.connect(dlg.reject)
     layout.addWidget(buttonBox)
     dlg.setLayout(layout)
     if dlg.exec_():
         self.editAuthCfg.setText(selector.configId())
     del dlg
Exemplo n.º 4
0
    def __init__(self, parent, server_type):
        super().__init__(parent, server_type)
        self.setupUi(self)

        self.geonetworkAuth = QgsAuthConfigSelect()
        self.geonetworkAuth.selectedConfigIdChanged.connect(self.setDirty)
        self.addAuthWidget()

        self.txtGeonetworkName.textChanged.connect(self.setDirty)
        self.txtGeonetworkNode.textChanged.connect(self.setDirty)
        self.txtGeonetworkUrl.textChanged.connect(self.setDirty)

        self.populateProfileCombo()
        self.comboMetadataProfile.currentIndexChanged.connect(self.setDirty)

        # TODO: implement profile stuff
        self.comboMetadataProfile.setVisible(False)
        self.labelMetadataProfile.setVisible(False)
Exemplo n.º 5
0
    def __init__(self, parent, server_type):
        super().__init__(parent, server_type)
        self.setupUi(self)

        self.mapserverAuth = QgsAuthConfigSelect()
        self.mapserverAuth.selectedConfigIdChanged.connect(self.setDirty)
        self.addAuthWidget()

        self.radioLocalPath.toggled.connect(self.showLocalStorageFields)
        self.fileMapserver.setStorageMode(self.fileMapserver.GetDirectory)

        self.txtMapserverName.textChanged.connect(self.setDirty)
        self.txtMapserverUrl.textChanged.connect(self.setDirty)
        self.txtMapserverHost.textChanged.connect(self.setDirty)
        self.txtMapserverPort.textChanged.connect(self.setDirty)
        self.txtMapserverUrl.textChanged.connect(self.setDirty)
        self.txtMapServicesPath.textChanged.connect(self.setDirty)
        self.txtProjFolder.textChanged.connect(self.setDirty)
Exemplo n.º 6
0
 def addAuthWidgets(self):
     self.geoserverAuth = QgsAuthConfigSelect()
     self.geoserverAuth.selectedConfigIdChanged.connect(
         self._setCurrentServerHasChanges)
     layout = QHBoxLayout()
     layout.setMargin(0)
     layout.addWidget(self.geoserverAuth)
     self.geoserverAuthWidget.setLayout(layout)
     self.geoserverAuthWidget.setFixedHeight(self.txtGeoserverUrl.height())
     self.mapserverAuth = QgsAuthConfigSelect()
     self.mapserverAuth.selectedConfigIdChanged.connect(
         self._setCurrentServerHasChanges)
     layout = QHBoxLayout()
     layout.setMargin(0)
     layout.addWidget(self.mapserverAuth)
     self.mapserverAuthWidget.setLayout(layout)
     self.mapserverAuthWidget.setFixedHeight(self.txtGeoserverUrl.height())
     self.postgisAuth = QgsAuthConfigSelect()
     self.postgisAuth.selectedConfigIdChanged.connect(
         self._setCurrentServerHasChanges)
     layout = QHBoxLayout()
     layout.setMargin(0)
     layout.addWidget(self.postgisAuth)
     self.postgisAuthWidget.setLayout(layout)
     self.postgisAuthWidget.setFixedHeight(self.txtGeoserverUrl.height())
     self.cswAuth = QgsAuthConfigSelect()
     self.cswAuth.selectedConfigIdChanged.connect(
         self._setCurrentServerHasChanges)
     layout = QHBoxLayout()
     layout.setMargin(0)
     layout.addWidget(self.cswAuth)
     self.cswAuthWidget.setLayout(layout)
     self.cswAuthWidget.setFixedHeight(self.txtGeoserverUrl.height())
     self.geocatLiveGeoserverAuth = QgsAuthConfigSelect()
     self.geocatLiveGeoserverAuth.selectedConfigIdChanged.connect(
         self._setCurrentServerHasChanges)
     layout = QHBoxLayout()
     layout.setMargin(0)
     layout.addWidget(self.geocatLiveGeoserverAuth)
     self.geocatLiveGeoserverAuthWidget.setLayout(layout)
     self.geocatLiveGeoserverAuthWidget.setFixedHeight(
         self.txtGeoserverUrl.height())
     self.geocatLiveGeonetworkAuth = QgsAuthConfigSelect()
     self.geocatLiveGeonetworkAuth.selectedConfigIdChanged.connect(
         self._setCurrentServerHasChanges)
     layout = QHBoxLayout()
     layout.setMargin(0)
     layout.addWidget(self.geocatLiveGeonetworkAuth)
     self.geocatLiveGeonetworkAuthWidget.setLayout(layout)
     self.geocatLiveGeonetworkAuthWidget.setFixedHeight(
         self.txtGeoserverUrl.height())
Exemplo n.º 7
0
    def __init__(self, parent, server_type):
        super().__init__(parent, server_type)
        self.setupUi(self)

        self.geoserverAuth = QgsAuthConfigSelect()
        self.geoserverAuth.selectedConfigIdChanged.connect(self.setDirty)
        self.addAuthWidget()

        self.populateStorageCombo()
        self.comboStorageType.currentIndexChanged.connect(self.datastoreChanged)
        self.btnRefreshDatabases.clicked.connect(partial(self.updateDbServersCombo, True))
        self.btnAddDatastore.clicked.connect(self.addPostgisDatastore)
        self.txtGeoserverName.textChanged.connect(self.setDirty)
        self.txtGeoserverUrl.textChanged.connect(self.setDirty)
        self.chkUseOriginalDataSource.stateChanged.connect(self.setDirty)
        self.chkUseVectorTiles.stateChanged.connect(self.setDirty)
        self.comboGeoserverDatabase.currentIndexChanged.connect(self.setDirty)

        # Declare progress dialog
        self._pgdialog = None
Exemplo n.º 8
0
    def __init__(self, parent=None, authcfg=None, provider=None):
        super(AuthConfigSelectDialog, self).__init__(parent)

        self.authcfg = authcfg

        #self.resize(600, 350)
        self.setWindowFlags(self.windowFlags() | Qt.WindowSystemMenuHint
                            | Qt.WindowMinMaxButtonsHint)
        self.setWindowTitle("Authentication config ID selector")

        layout = QVBoxLayout()
        buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                     | QDialogButtonBox.Cancel)
        self.editor = QgsAuthConfigSelect(self, dataprovider=provider)
        self.editor.setConfigId(authcfg)
        layout.addWidget(self.editor)
        layout.addWidget(buttonBox)
        self.setLayout(layout)

        buttonBox.accepted.connect(self.okPressed)
        buttonBox.rejected.connect(self.cancelPressed)
Exemplo n.º 9
0
    def __init__(self, plugin):
        QDialog.__init__(self)
        self.setupUi(self)

        self.plugin = plugin
        self.settings = plugin.settings
        self.settings.loadSettings()

        self.leSERVICE.setText(self.settings.service)
        self.leHOST.setText(self.settings.host)
        self.lePORT.setText(self.settings.port)
        self.leDBNAME.setText(self.settings.dbname)
        self.leSCHEMA.setText(self.settings.schema)
        self.leUID.setText(self.settings.uid)
        self.lePWD.setText(self.settings.pwd)
        self.cbxSignaturkatalog.setEnabled(False)

        if hasattr(qgis.gui, 'QgsAuthConfigSelect'):
            self.authCfgSelect = QgsAuthConfigSelect(self, "postgres")
            self.tabWidget.insertTab(1, self.authCfgSelect, "Konfigurationen")

            authcfg = self.settings.authcfg
            if authcfg:
                self.tabWidget.setCurrentIndex(1)
                self.authCfgSelect.setConfigId(authcfg)

        self.leUMNPath.setText(self.settings.umnpath)
        self.pbUMNBrowse.clicked.connect(self.browseUMNPath)
        self.leUMNTemplate.setText(self.settings.umntemplate)
        self.teFussnote.setPlainText(self.settings.footnote)

        self.loadModels(False)

        self.bb.accepted.connect(self.accept)
        self.bb.rejected.connect(self.reject)
        self.bb.addButton("Modelle laden", QDialogButtonBox.ActionRole).clicked.connect(self.loadModels)
        self.bb.addButton("Layer einbinden", QDialogButtonBox.ActionRole).clicked.connect(self.loadLayers)

        self.restoreGeometry(QSettings("norBIT", "norGIS-ALKIS-Erweiterung").value("confgeom", QByteArray(), type=QByteArray))
Exemplo n.º 10
0
    def authcfg_edit(self):
        dlg = QDialog(None)
        dlg.setWindowTitle(self.util.tr("Select Authentication"))
        layout = QVBoxLayout(dlg)

        acs = QgsAuthConfigSelect(dlg)
        if self.IDC_leAuthCfg.text():
            acs.setConfigId(self.IDC_leAuthCfg.text())
        layout.addWidget(acs)

        buttonbox = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, dlg)

        layout.addWidget(buttonbox)
        buttonbox.accepted.connect(dlg.accept)
        buttonbox.rejected.connect(dlg.close)

        dlg.setLayout(layout)
        dlg.setWindowModality(Qt.WindowModal)

        if dlg.exec_():
            self.IDC_leAuthCfg.setText(acs.configId())
            self.cc.auth_cfg = acs.configId()
# coding: utf-8
from qgis.gui import QgsAuthConfigSelect

auth_config_select = QgsAuthConfigSelect()

auth_config_select.show()
Exemplo n.º 12
0
    def __init__(self, parent=None):  # pylint: disable=too-many-statements
        super().__init__(parent)

        self.setWindowTitle(self.tr('Redistrict Plugin | Settings'))
        layout = QVBoxLayout()
        self.auth_label = QLabel(self.tr('Authentication configuration'))
        layout.addWidget(self.auth_label)
        self.auth_value = QgsAuthConfigSelect()
        layout.addWidget(self.auth_value)
        auth_id = get_auth_config_id()
        if auth_id:
            self.auth_value.setConfigId(auth_id)

        layout.addWidget(QLabel(self.tr('API base URL')))
        self.base_url_edit = QLineEdit()
        self.base_url_edit.setText(QgsSettings().value('redistrict/base_url', '', str, QgsSettings.Plugins))
        layout.addWidget(self.base_url_edit)

        h_layout = QHBoxLayout()
        h_layout.addWidget(QLabel(self.tr('Check for completed requests every')))
        self.check_every_spin = QSpinBox()
        self.check_every_spin.setMinimum(10)
        self.check_every_spin.setMaximum(600)
        self.check_every_spin.setSuffix(' ' + self.tr('s'))
        self.check_every_spin.setValue(QgsSettings().value('redistrict/check_every', '30', int, QgsSettings.Plugins))

        h_layout.addWidget(self.check_every_spin)
        layout.addLayout(h_layout)

        self.use_mock_checkbox = QCheckBox(self.tr('Use mock Statistics NZ API'))
        self.use_mock_checkbox.setChecked(get_use_mock_api())
        layout.addWidget(self.use_mock_checkbox)

        self.test_button = QPushButton(self.tr('Test API connection'))
        self.test_button.clicked.connect(self.test_api)
        layout.addWidget(self.test_button)

        self.use_overlays_checkbox = QCheckBox(self.tr('Show updated populations during interactive redistricting'))
        self.use_overlays_checkbox.setChecked(
            QgsSettings().value('redistrict/show_overlays', False, bool, QgsSettings.Plugins))
        layout.addWidget(self.use_overlays_checkbox)

        self.use_sound_group_box = QGroupBox(self.tr('Use audio feedback'))
        self.use_sound_group_box.setCheckable(True)
        self.use_sound_group_box.setChecked(
            QgsSettings().value('redistrict/use_audio_feedback', False, bool, QgsSettings.Plugins))

        sound_layout = QGridLayout()
        sound_layout.addWidget(QLabel(self.tr('When meshblock redistricted')), 0, 0)
        self.on_redistrict_file_widget = QgsFileWidget()
        self.on_redistrict_file_widget.setDialogTitle(self.tr('Select Audio File'))
        self.on_redistrict_file_widget.setStorageMode(QgsFileWidget.GetFile)
        self.on_redistrict_file_widget.setFilePath(
            QgsSettings().value('redistrict/on_redistrict', '', str, QgsSettings.Plugins))
        self.on_redistrict_file_widget.setFilter(self.tr('Wave files (*.wav *.WAV)'))
        sound_layout.addWidget(self.on_redistrict_file_widget, 0, 1)
        self.play_on_redistrict_sound_button = QPushButton(self.tr('Test'))
        self.play_on_redistrict_sound_button.clicked.connect(self.play_on_redistrict_sound)
        sound_layout.addWidget(self.play_on_redistrict_sound_button, 0, 2)

        self.use_sound_group_box.setLayout(sound_layout)
        layout.addWidget(self.use_sound_group_box)

        button_box = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
        layout.addWidget(button_box)
        button_box.rejected.connect(self.reject)
        button_box.accepted.connect(self.accept)

        self.setLayout(layout)
Exemplo n.º 13
0
    def __init__(self, iface):
        """Constructor.

        :param iface: An interface instance that will be passed to this class
            which provides the hook by which you can manipulate the QGIS
            application at run time.
        :type iface: QgsInterface
        """
        # Save reference to the QGIS interface
        self.iface = iface
        # initialize plugin directory
        self.plugin_dir = os.path.dirname(__file__)
        # initialize locale
        self.MSG_TITLE = self.tr('DHIS2 datafetcher')
        locale = QSettings().value('locale/userLocale')[0:2]
        self.info('Locale: "{}"'.format(locale))
        locale_path = os.path.join(
            self.plugin_dir,
            'i18n',
            '{}.qm'.format(locale))
        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)
        else:
            self.info('Locale niet gevonden: "{}"'.format(locale_path))

        # start a group/dir for all settings
        self.SETTINGS_GROUP = self.tr('dhis2datafetcher')
        QgsSettings().beginGroup(self.SETTINGS_GROUP, QgsSettings.Plugins)

        # Create the dialog (after translation) and keep reference
        self.dlg = DHIS2DataFetcherDialog(self.iface.mainWindow())

        self.dlg.cb_ou.currentIndexChanged.connect(self.cb_ou_changed)
        self.dlg.cb_pe.currentIndexChanged.connect(self.cb_pe_changed)
        self.dlg.cb_dx.currentIndexChanged.connect(self.cb_dx_changed)
        self.dlg.cb_level.currentIndexChanged.connect(self.cb_level_changed)

        self.dlg.btn_load_geodata.clicked.connect(self.load_geodata_in_layer)
        self.dlg.btn_new_dataset.clicked.connect(self.new_dataset)

        # Replace the placeholder in the dialog with a QgsAuthConfigSelect widget
        self.dlg.cmb_profile_select.close()  # this apparently also removes the widget??
        self.dlg.cmb_profile_select = QgsAuthConfigSelect()
        self.dlg.gridLayout.addWidget(self.dlg.cmb_profile_select, 0, 1, 1, 1)  # row, col, #rows, #cols
        self.dlg.cmb_profile_select.selectedConfigIdChanged.connect(self.selectAuthConfig)

        # Declare instance attributes
        self.actions = []
        self.menu = QMenu(self.tr(u'KIT - DHIS2 Data Fetcher'))
        self.iface.pluginMenu().addMenu(self.menu)
        self.menu.setIcon(QIcon(':/plugins/DHIS2DataFetcher/icon_kit.png'))

        self.toolbar = self.iface.addToolBar(u'DHIS2DataFetcher')
        self.toolbar.setObjectName(u'DHIS2DataFetcher')

        self.api_url = None  # url as defined by user in authorisation profile
        self.auth_id = None  # authorisation id to be used in nam creation AND vectorlayer creation uri

        self.gui_inited = False
        self.nam = None  # created in gui during authorisation profile choice

        self.ou_items = []
        self.pe_items = []
        self.dx_items = []

        # current demo site
        self.analytics_url = 'https://play.dhis2.org/2.28/api/'
        self.username = '******'
        self.password = '******'
        self.level = 2

        # connect to the iface.projectRead signal to be able to refresh data in a project with a dhis2 layer
        self.iface.projectRead.connect(self.update_dhis2_project)