def init(self):
        # Memorizzo il valore di TOOLTIPSIZE = dimensione del testo di tooltip.
        var = QadVariables.getVariable(
            QadMsg.translate("Environment variables", "TOOLTIPSIZE"))
        self.edit_size.setText(str(var.value))
        self.edit_size.setValidator(QIntValidator(self.edit_size))
        self.edit_size.installEventFilter(self)
        self.slider_size.setMinimum(var.minNum)
        self.slider_size.setMaximum(var.maxNum)
        self.slider_size.setValue(var.value)

        # Memorizzo il valore di TOOLTIPTRANSPARENCY = Imposta la trasparenza della finestra di input dinamico.
        var = QadVariables.getVariable(
            QadMsg.translate("Environment variables", "TOOLTIPTRANSPARENCY"))
        self.edit_transparency.setText(str(var.value))
        self.edit_transparency.setValidator(
            QIntValidator(self.edit_transparency))
        self.edit_transparency.installEventFilter(self)
        self.slider_transparency.setMinimum(var.minNum)
        self.slider_transparency.setMaximum(var.maxNum)
        self.slider_transparency.setValue(var.value)

        # Memorizzo il valore di DYNTOOLTIPS = Determina su quali tooltip hanno effetto le impostazioni dell'aspetto delle descrizioni.
        dynTooltips = QadVariables.get(
            QadMsg.translate("Environment variables", "DYNTOOLTIPS"))
        if dynTooltips == 0:
            self.radio_for_all_tooltips.setChecked(False)
            self.radio_for_DI_tooltips.setChecked(True)
        elif dynTooltips == 1:
            self.radio_for_all_tooltips.setChecked(True)
            self.radio_for_DI_tooltips.setChecked(False)
 def run(self) -> None:
     """Run the form."""
     self._dlg.checkUseMPI.stateChanged.connect(self.changeUseMPI)
     if os.path.isdir(self.mpiexecDir):
         self._dlg.checkUseMPI.setChecked(True)
     else:
         self._dlg.checkUseMPI.setChecked(False)
     self._dlg.MPIBox.setText(self.mpiexecDir)
     self._dlg.SWATPlusBox.setText(self.SWATPlusDir)
     self._dlg.SWATPlusButton.clicked.connect(self.chooseSWATPlusDir)
     self._dlg.MPIButton.clicked.connect(self.chooseMPIDir)
     self._dlg.cancelButton.clicked.connect(self._dlg.close)
     self._dlg.saveButton.clicked.connect(self.save)
     self._dlg.burninDepth.setValidator(QIntValidator())
     self._dlg.widthMult.setValidator(QDoubleValidator())
     self._dlg.widthExp.setValidator(QDoubleValidator())
     self._dlg.depthMult.setValidator(QDoubleValidator())
     self._dlg.depthExp.setValidator(QDoubleValidator())
     self._dlg.upslopeHRUDrain.setValidator(QIntValidator())
     self.readProj()
     self._dlg.pointSizeBox.valueChanged.connect(self.changeFontSize)
     if not self.isBatch:
         self._dlg.exec_()
     if self._gv:
         self._gv.parametersPos = self._dlg.pos()
Exemple #3
0
    def __init__(self, parent=None):
        super(EditorWidgetTms, self).__init__(parent)
        self.setupUi(self)
        self.tms_validator = LineEditColorValidator(
            self.txtUrl,
            'http[s]?://.+',
            error_tooltip='http{s}://any_text/{z}/{x}/{y}/')
        self.txtCrsId.setValidator(QIntValidator())
        self.txtPostgisCrsId.setValidator(QIntValidator())

        QApplication.instance().focusChanged.connect(self.focus_changed)
Exemple #4
0
    def __init__(self, plugin):
        QDialog.__init__(self)
        self.setupUi(self)
        self.plugin = plugin

        s = QSettings("norBIT", "norGIS-ALKIS-Erweiterung")

        v = QIntValidator()
        v.setBottom(1)
        self.leHighlightThreshold.setValidator(v)
        self.leHighlightThreshold.setText(str(s.value("highlightThreshold", 1000)))

        (db, conninfo) = self.plugin.opendb()
        self.db = db

        qry = QSqlQuery(db)
        if not qry.exec_("SELECT has_table_privilege('eigner', 'SELECT')") or not qry.next() or not qry.value(0):
            self.tabWidget.removeTab(self.tabWidget.indexOf(self.tabEigentuemer))

        self.replaceButton = self.buttonBox.addButton(u"Ersetzen", QDialogButtonBox.ActionRole)
        self.addButton = self.buttonBox.addButton(u"Hinzufügen", QDialogButtonBox.ActionRole)
        self.removeButton = self.buttonBox.addButton(u"Entfernen", QDialogButtonBox.ActionRole)
        self.clearButton = self.buttonBox.addButton(u"Leeren", QDialogButtonBox.ActionRole)

        self.replaceButton.clicked.connect(self.replaceClicked)
        self.addButton.clicked.connect(self.addClicked)
        self.removeButton.clicked.connect(self.removeClicked)
        self.clearButton.clicked.connect(self.clearClicked)

        self.cbxStrassen.setEnabled(False)
        self.cbxHNR.setEnabled(False)

        self.pbLabelSearch.clicked.connect(self.evaluate)
        self.pbOwnerSearch.clicked.connect(self.evaluate)
        self.pbSearchFSK.clicked.connect(self.evaluate)

        self.highlighted = set(self.plugin.highlighted())

        self.lblResult.setText(u"{} Objekte bereits gewählt.".format(len(self.highlighted)) if len(self.highlighted) > 0 else "")

        self.restoreGeometry(QSettings("norBIT", "norGIS-ALKIS-Erweiterung").value("searchgeom", QByteArray(), type=QByteArray))

        self.tabWidget.setCurrentIndex(s.value("suchmodus", 0, type=int))

        self.cbxGemarkung.currentIndexChanged.connect(self.gfzn)
        self.cbxFlur.currentIndexChanged.connect(self.gfzn)
        self.cbxFSZ.currentIndexChanged.connect(self.gfzn)
        self.cbxFSN.currentIndexChanged.connect(self.gfzn)
        self.gfzn()
    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__)
        self.dlg = gen_doc_calvecatDialog(parent=iface.mainWindow())
        # initialize locale
        locale = QSettings().value('locale/userLocale')[0:2]
        locale_path = os.path.join(self.plugin_dir, 'i18n',
                                   'gen_doc_calvecat_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&gen_doc_calvecat')
        self.abrePredio6 = False
        self.directorioAGuardar6 = None
        self.cve_catastral6 = None

        self.canvas = iface.mapCanvas()

        # eventos
        self.dlg.btnBrowse_5.clicked.connect(self.selectDirectory5)
        self.dlg.btnGenerar_5.clicked.connect(self.generarDoc5)
        self.dlg.btnSeleccionar_5.clicked.connect(self.activarSeleccion5)
        self.dlg.exit_signal.connect(self.closeEvent)

        self.dlg.fldCveCat_5.textChanged.connect(self.lineEditToUpper5)

        #validaciones
        rx = QRegExp("[a-zA-Z0-9]{31}")
        val = QRegExpValidator(rx)
        self.dlg.fldCveCat_5.setValidator(val)

        self.onlyInt = QIntValidator()
        self.dlg.fldNomfolio.setValidator(self.onlyInt)
        self.onlyInt = QIntValidator()
        self.dlg.fldCodPostal.setValidator(self.onlyInt)
Exemple #6
0
    def __init__(self, plugin):
        QDialog.__init__(self)
        self.setupUi(self)
        self.plugin = plugin

        s = QSettings("norBIT", "norGIS-ALKIS-Erweiterung")

        v = QIntValidator()
        v.setBottom(1)
        self.leHighlightThreshold.setValidator(v)
        self.leHighlightThreshold.setText(str(s.value("highlightThreshold", 1000)))

        (db, conninfo) = self.plugin.opendb()
        self.db = db

        qry = QSqlQuery(db)
        if not qry.exec_("SELECT has_table_privilege('eigner', 'SELECT')") or not qry.next() or not qry.value(0):
            self.tabWidget.removeTab(self.tabEigentuemer)

        self.replaceButton = self.buttonBox.addButton(u"Ersetzen", QDialogButtonBox.ActionRole)
        self.addButton = self.buttonBox.addButton(u"Hinzufügen", QDialogButtonBox.ActionRole)
        self.removeButton = self.buttonBox.addButton(u"Entfernen", QDialogButtonBox.ActionRole)
        self.clearButton = self.buttonBox.addButton(u"Leeren", QDialogButtonBox.ActionRole)

        self.replaceButton.clicked.connect(self.replaceClicked)
        self.addButton.clicked.connect(self.addClicked)
        self.removeButton.clicked.connect(self.removeClicked)
        self.clearButton.clicked.connect(self.clearClicked)

        self.cbxStrassen.setEnabled(False)
        self.cbxHNR.setEnabled(False)

        self.pbLabelSearch.clicked.connect(self.evaluate)
        self.pbOwnerSearch.clicked.connect(self.evaluate)
        self.pbSearchFSK.clicked.connect(self.evaluate)

        self.highlighted = set(self.plugin.highlighted())

        self.lblResult.setText(u"{} Objekte bereits gewählt.".format(len(self.highlighted)) if len(self.highlighted) > 0 else "")

        self.restoreGeometry(QSettings("norBIT", "norGIS-ALKIS-Erweiterung").value("searchgeom", QByteArray(), type=QByteArray))

        self.tabWidget.setCurrentIndex(s.value("suchmodus", 0, type=int))

        self.cbxGemarkung.currentIndexChanged.connect(self.gfzn)
        self.cbxFlur.currentIndexChanged.connect(self.gfzn)
        self.cbxFSZ.currentIndexChanged.connect(self.gfzn)
        self.cbxFSN.currentIndexChanged.connect(self.gfzn)
        self.gfzn()
Exemple #7
0
    def init_gui(self):
        # Set integer validator for the port number
        int_validator = QIntValidator(1024, 49151)
        self.txtPort.setValidator(int_validator)

        # Load profiles
        self.load_profiles()

        # Set current profile in the combobox
        curr_profile = current_profile()
        if not curr_profile is None:
            setComboCurrentIndexWithText(self.cbo_profiles, curr_profile.name)

        # Load current database connection properties
        self._load_db_conn_properties()

        # Load existing PostgreSQL connections
        self._load_qgis_pg_connections()

        # Load directory paths
        self._load_directory_paths()

        self.edtEntityRecords.setMaximum(MAX_LIMIT)
        self.edtEntityRecords.setValue(get_entity_browser_record_limit())

        # Sorting order
        self.populate_sort_order()
        self.set_current_sort_order(get_entity_sort_order())

        # Debug logging
        lvl = debug_logging()
        if lvl:
            self.chk_logging.setCheckState(Qt.Checked)
        else:
            self.chk_logging.setCheckState(Qt.Unchecked)
    def __init__(self, iface, parent=None):
        """
        Constructor

        @param parent reference to the parent widget
        @type QWidget
        """
        super(SrtmDownloaderDialogBase, self).__init__(parent)
        self.setupUi(self)
        self.iface = iface
        self.username = None
        self.password = None
        self.success = False
        self.cancelled = False
        self.dir = tempfile.gettempdir()
        self.btn_download.setEnabled(False)

        self.int_validator = QIntValidator()
        self.lne_east.setValidator(self.int_validator)
        self.lne_west.setValidator(self.int_validator)
        self.lne_north.setValidator(self.int_validator)
        self.lne_south.setValidator(self.int_validator)

        self.lne_east.textChanged.connect(self.coordinates_valid)
        self.lne_west.textChanged.connect(self.coordinates_valid)
        self.lne_north.textChanged.connect(self.coordinates_valid)
        self.lne_south.textChanged.connect(self.coordinates_valid)

        self.overall_progressBar.setValue(0)
        self.downloader = Download(self, self.iface)
        self.progress_widget_item_list = {}
        self.row_count = 0
        self.tableWidget.setColumnCount(2)
    def open_form(self):

        self.previous_map_tool = self.canvas.mapTool()
        # Get layers of every geom_type
        self.reset_lists()
        self.reset_layers()
        self.geom_type = 'node'
        layer = self.controller.get_layer_by_tablename('v_edit_node')
        if not layer:
            self.last_error = self.tr("Layer not found") + ": v_edit_node"
            return None
        self.layers['node'] = [layer]

        self.visible_layers = self.get_visible_layers()
        self.remove_selection()

        self.dlg_unit = PlaningUnit()
        self.load_settings(self.dlg_unit)
        self.set_icon(self.dlg_unit.btn_insert, "111")
        self.set_icon(self.dlg_unit.btn_delete, "112")
        self.set_icon(self.dlg_unit.btn_snapping, "137")

        validator = QIntValidator(1, 9999999)
        self.dlg_unit.txt_times.setValidator(validator)

        utils_giswater.set_qtv_config(self.dlg_unit.tbl_unit, edit_triggers=QTableView.DoubleClicked)

        sql = "SELECT id, name FROM cat_campaign"
        rows = self.controller.get_rows(sql, log_sql=True)
        utils_giswater.set_item_data(self.dlg_unit.cmb_campaign, rows, 1)
        sql = "SELECT id, name FROM cat_work"
        rows = self.controller.get_rows(sql, add_empty_row=True)
        utils_giswater.set_item_data(self.dlg_unit.cmb_work, rows, 1)
        self.load_default_values()
        table_name = "v_ui_planning_unit"
        self.update_table(self.dlg_unit, self.dlg_unit.tbl_unit, table_name, self.dlg_unit.cmb_campaign, self.dlg_unit.cmb_work)

        # Signals
        self.dlg_unit.cmb_campaign.currentIndexChanged.connect(
            partial(self.update_table, self.dlg_unit, self.dlg_unit.tbl_unit, table_name, self.dlg_unit.cmb_campaign, self.dlg_unit.cmb_work))

        self.dlg_unit.cmb_work.currentIndexChanged.connect(
            partial(self.update_table, self.dlg_unit, self.dlg_unit.tbl_unit, table_name, self.dlg_unit.cmb_campaign, self.dlg_unit.cmb_work))

        completer = QCompleter()
        self.dlg_unit.txt_id.textChanged.connect(
            partial(self.populate_comboline, self.dlg_unit,self.dlg_unit.txt_id, completer))

        self.dlg_unit.btn_close.clicked.connect(partial(self.save_default_values))
        self.dlg_unit.btn_close.clicked.connect(partial(self.close_dialog, self.dlg_unit))
        self.dlg_unit.btn_close.clicked.connect(partial(self.remove_selection))
        self.dlg_unit.rejected.connect(partial(self.save_default_values))
        self.dlg_unit.rejected.connect(partial(self.close_dialog, self.dlg_unit))
        self.dlg_unit.rejected.connect(partial(self.remove_selection))
        self.dlg_unit.btn_snapping.clicked.connect(partial(self.selection_init,  self.dlg_unit.tbl_unit))
        self.dlg_unit.btn_insert.clicked.connect(partial(self.insert_single, self.dlg_unit, self.dlg_unit.txt_id))
        self.dlg_unit.btn_delete.clicked.connect(partial(self.delete_row, self.dlg_unit.tbl_unit, table_name))

        self.open_dialog(self.dlg_unit)
Exemple #10
0
 def __init__(self, gv):
     """Initialise class variables."""
     self._gv = gv
     self._dlg = ElevatioBandsDialog()
     self._dlg.setWindowFlags(self._dlg.windowFlags() & ~Qt.WindowContextHelpButtonHint)
     self._dlg.move(self._gv.elevationBandsPos)
     self._dlg.okButton.clicked.connect(self.setBands)
     self._dlg.cancelButton.clicked.connect(self._dlg.close)
     self._dlg.elevBandsThreshold.setValidator(QIntValidator())
     if self._gv.elevBandsThreshold > 0:
         self._dlg.elevBandsThreshold.setText(str(self._gv.elevBandsThreshold))
         if 2 <= self._gv.numElevBands <= 10:
             self._dlg.numElevBands.setValue(self._gv.numElevBands)
Exemple #11
0
 def __init__(self, contour_tool, parent=None):
     """
     Constructor
     """
     super(ContourValue, self).__init__(parent)
     # Set up the user interface from Designer.
     # After 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)
     self.value_line_edit.setValidator(QIntValidator(0, 1000000))
     self.contour_tool = contour_tool
Exemple #12
0
    def initGui(self):
        '''
        Initialize GUI
        '''
        # Change the name of the OK button to Login
        btnSave = self.btnBox.button(QDialogButtonBox.Ok)
        btnSave.setText(QApplication.translate("DbConnectionDialog", "Save"))

        # Set port integer validator
        intValidator = QIntValidator(1, 60000, self)
        self.txtPort.setValidator(intValidator)

        # Connect slots
        self.btnBox.accepted.connect(self.acceptdlg)
    def __init__(self, iface, CFG=None, UTI = None):
        """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
        locale = QSettings().value('locale/userLocale')[0:2]
        locale_path = os.path.join(
            self.plugin_dir,
            'i18n',
            'busquedaCatastral_{}.qm'.format(locale))

        if os.path.exists(locale_path):
            self.translator = QTranslator()
            self.translator.load(locale_path)
            QCoreApplication.installTranslator(self.translator)

        # Declare instance attributes
        self.actions = []
        self.menu = self.tr(u'&busquedaCatastral')
        self.CFG = CFG
        self.UTI = UTI

        self.pluginIsActive = False
        self.dockwidget = busquedaCatastralDialog(parent=iface.mainWindow())

        #Eventos
        self.dockwidget.btLocalizar.clicked.connect(self.getPredio)
        self.dockwidget.btCerrar.clicked.connect(self.closeIt)
        self.dockwidget.btDetalle.clicked.connect(self.abrirDetallePredio)

        #validaciones QLineEdit
        self.onlyInt = QIntValidator()
        self.dockwidget.leReg.setValidator(self.onlyInt)
        self.dockwidget.leManz.setValidator(self.onlyInt)
        self.dockwidget.leLote.setValidator(self.onlyInt)
        self.dockwidget.leCondo.setValidator(self.onlyInt)


        # Check if plugin was started the first time in current QGIS session
        # Must be set in initGui() to survive plugin reloads
        self.first_start = True
Exemple #14
0
    def init_gui(self):
        """
        Initializes form widgets
        """
        validator = QIntValidator()
        self.edtMinVal.setValidator(validator)
        self.edtMaxVal.setValidator(validator)

        self.edtMinVal.setText(str(self._min_val))
        self.edtMaxVal.setText(str(self._max_val))

        self.edtMinVal.setFocus()

        self.edtMinVal.setEnabled(not self.in_db)
        self.edtMaxVal.setEnabled(not self.in_db)
 def __init__(self, triplestoreconf, prefixes, prefixstore, comboBox):
     super(QDialog, self).__init__()
     self.setupUi(self)
     self.triplestoreconf = triplestoreconf
     self.prefixstore = prefixstore
     self.comboBox = comboBox
     self.prefixes = prefixes
     for item in triplestoreconf:
         self.tripleStoreChooser.addItem(item["name"])
     self.tripleStoreChooser.currentIndexChanged.connect(
         self.loadTripleStoreConfig)
     #self.addTripleStoreButton.clicked.connect(self.addNewSPARQLEndpoint)
     urlregex = QRegExp(
         "http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\(\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+"
     )
     urlvalidator = QRegExpValidator(urlregex, self)
     self.tripleStoreEdit.setValidator(urlvalidator)
     self.tripleStoreEdit.textChanged.connect(self.check_state1)
     self.tripleStoreEdit.textChanged.emit(self.tripleStoreEdit.text())
     self.epsgEdit.setValidator(QIntValidator(1, 100000))
     prefixregex = QRegExp("[a-z]+")
     prefixvalidator = QRegExpValidator(prefixregex, self)
     self.tripleStorePrefixNameEdit.setValidator(prefixvalidator)
     self.addPrefixButton.clicked.connect(self.addPrefixToList)
     self.removePrefixButton.clicked.connect(self.removePrefixFromList)
     self.testConnectButton.clicked.connect(self.testTripleStoreConnection)
     self.deleteTripleStore.clicked.connect(self.deleteTripleStoreFunc)
     self.resetConfiguration.clicked.connect(self.restoreFactory)
     self.newTripleStore.clicked.connect(self.createNewTripleStore)
     #self.exampleQuery.textChanged.connect(self.validateSPARQL)
     self.sparqlhighlighter = SPARQLHighlighter(self.exampleQuery)
     self.tripleStorePrefixEdit.setValidator(urlvalidator)
     self.tripleStorePrefixEdit.textChanged.connect(self.check_state2)
     self.tripleStorePrefixEdit.textChanged.emit(
         self.tripleStorePrefixEdit.text())
     self.tripleStoreApplyButton.clicked.connect(
         self.applyCustomSPARQLEndPoint)
     self.tripleStoreCloseButton.clicked.connect(
         self.closeTripleStoreDialog)
     self.detectConfiguration.clicked.connect(
         self.detectTripleStoreConfiguration)
     s = QSettings()  #getting proxy from qgis options settings
     self.proxyEnabled = s.value("proxy/proxyEnabled")
     self.proxyType = s.value("proxy/proxyType")
     self.proxyHost = s.value("proxy/proxyHost")
     self.proxyPort = s.value("proxy/proxyPort")
     self.proxyUser = s.value("proxy/proxyUser")
     self.proxyPassword = s.value("proxy/proxyPassword")
    def __init__(self, parent=None):
        super(TreeAttributeDialog, self).__init__(parent=parent)

        self.combo_box_tree_type = QComboBox()

        self.combo_box_tree_type.addItem('Ahorn')
        self.combo_box_tree_type.addItem('Apfel')
        self.combo_box_tree_type.addItem('Birke')
        self.combo_box_tree_type.addItem('Buche')
        self.combo_box_tree_type.addItem('Eiche')
        self.combo_box_tree_type.addItem('Eiche')
        self.combo_box_tree_type.addItem('Eiche')
        self.combo_box_tree_type.addItem('Eiche')

        self.combo_box_tree_type.addItem('Eiche')
        self.combo_box_tree_type.addItem('Eiche')
        self.combo_box_tree_type.addItem('Eiche')
        self.combo_box_tree_type.addItem('Pappel')
        self.combo_box_tree_type.addItem('Tanne')
        self.combo_box_tree_type.addItem('Weide')
        self.combo_box_tree_type.addItem('Placeh1')
        self.combo_box_tree_type.addItem('Placeh2')
        self.combo_box_tree_type.addItem('Placeh3')
        self.combo_box_tree_type.addItem('Bestandsbaum')

        self.line_edit_tree_type = QLineEdit()

        self.line_edit_tree_diameter = QLineEdit()

        self.line_edit_tree_diameter.setText('1')
        self.line_edit_tree_diameter.setValidator(QIntValidator(1, 999))

        form = QFormLayout()

        form.addRow(self.tr('Type'), self.line_edit_tree_type)
        form.addRow(self.tr('Diameter'), self.line_edit_tree_diameter)

        buttonBox = QDialogButtonBox(accepted=self.onAccept,  rejected=self.reject)
        buttonBox.setStandardButtons(QDialogButtonBox.Cancel |  QDialogButtonBox.Ok)

        vbox = QVBoxLayout()
        vbox.addLayout(form)
        vbox.addWidget(buttonBox)

        self.setWindowTitle(self.tr('Tree Attribute'))
        self.setModal(True)
        self.setLayout(vbox)
Exemple #17
0
    def __init__(self, iface, parent=None):
        """ Contructor """
        super().__init__(parent)
        self.setupUi(self)
        self.parent = parent
        self.iface = iface

        # Int Validator
        self.onlyInt = QIntValidator()
        self.ln_port.setValidator(self.onlyInt)

        # IP Validator
        v = QRegExpValidator(self)
        rx = QRegExp(
            "((1{0,1}[0-9]{0,2}|2[0-4]{1,1}[0-9]{1,1}|25[0-5]{1,1})\\.){3,3}(1{0,1}[0-9]{0,2}|2[0-4]{1,1}[0-9]{1,1}|25[0-5]{1,1})"
        )
        v.setRegExp(rx)
        self.ln_host.setValidator(v)
Exemple #18
0
    def initGui(self):
        """Create the menu entries and toolbar icons inside the QGIS GUI."""

        # Input
        global last_path_input
        last_path_input = self.dlg.LE_input.text()

        self.dlg.PB_input.clicked.connect(self.select_input_files)
        self.dlg.LE_input.editingFinished.connect(self.check_input_path)

        # Output
        global last_path_output, output_message
        last_path_output = self.dlg.LE_output.text()
        output_message = True

        self.dlg.PB_output.clicked.connect(self.select_output_directory)
        self.dlg.LE_output.editingFinished.connect(self.check_output_path)
        self.dlg.PB_quit.clicked.connect(self.quit_plugin)
        self.dlg.PB_ok.clicked.connect(self.run)
        self.dlg.tabWidget.setCurrentIndex(0)

        # Set current line edit
        self.dlg.LE_input.setFocus()

        # Check validation
        self.dlg.LE_minHeightThres.setValidator(QIntValidator())
        self.dlg.LE_maxHeightThres.setValidator(QIntValidator())
        self.dlg.LE_DRFD.setValidator(QDoubleValidator())
        self.dlg.LE_DRPB.setValidator(QDoubleValidator())
        self.dlg.txt_triangle_peri.setValidator(QDoubleValidator())
        self.dlg.LE_minWidthThres.setValidator(QIntValidator())
        self.dlg.LE_minForSurfThres.setValidator(QIntValidator())
        self.dlg.LE_minClearingSurfThres.setValidator(QIntValidator())
        self.dlg.LE_gradConvDiameter.setValidator(QIntValidator())

        # Set add result to canevas as default
        self.dlg.CB_addLayer.setCheckState(2)

        # set progress bar settings
        self.dlg.progressBar.setMinimum(0)
        self.dlg.progressBar.setValue(0)

        icon_path = ':/plugins/forLim/icon.png'
        self.add_action(icon_path,
                        text=self.tr(u'forLim'),
                        callback=self.run,
                        parent=self.iface.mainWindow())
    def __init__(self, iface, vlayer):
        super().__init__(None)
        self.setupUi(self)

        self.iface = iface
        self.layer = vlayer

        self.setWindowTitle('NavTable - ' + self.layer.name())
        self.exprFilterBT.setIcon(QgsApplication.getThemeIcon('mIconExpressionSelect.svg'))
        self.removeFilterBT.setIcon(QgsApplication.getThemeIcon('mActionDeselectAll.svg'))
        self.orderByBT.setIcon(QgsApplication.getThemeIcon('sort.svg'))

        self.previousDialog = self.widget_form

        self.validator = QIntValidator(1, 1)
        self.currentFeatLB.setValidator(self.validator)

        self.nextBT.clicked.connect(self.next)
        self.previousBT.clicked.connect(self.previous)
        self.lastBT.clicked.connect(self.last)
        self.firstBT.clicked.connect(self.first)
        self.orderByBT.clicked.connect(self.orderBy)
        self.exprFilterBT.clicked.connect(self.filter_by_expression)
        self.removeFilterBT.clicked.connect(self.removeFilter)
        self.deleteBT.clicked.connect(self.deleteFeature)
        self.currentFeatLB.returnPressed.connect(self.manual)

        self.layer.editingStarted.connect(self.activateEdit)
        self.layer.editingStopped.connect(self.deactivateEdit)

        self.allIds = self.layer.allFeatureIds()
        self.currentIndexFid = 0
        self.currentFid = self.allIds[self.currentIndexFid]
        self.currentExpression = ''
        self.update(self.currentFid, self.currentIndexFid)

        self.removeFilterBT.setEnabled(False)
        if self.layer.isEditable():
            self.activateEdit()
    def __init__(self, iface, parent=None):
        """Constructor."""
        super(CatastroV3DockWidget, self).__init__(parent)
        self.setupUi(self)

        self.cir.setValidator(QIntValidator())
        self.chn.setValidator(QIntValidator())
        self.qtn.setValidator(QIntValidator())
        self.frn.setValidator(QIntValidator())
        self.mzn.setValidator(QIntValidator())
        self.pcn.setValidator(QIntValidator())
        validar_cadena = QRegExpValidator(QRegExp('^[0-9a-zA-Z]*$'))
        self.sec.setValidator(validar_cadena)
        self.chl.setValidator(validar_cadena)
        self.qtl.setValidator(validar_cadena)
        self.frl.setValidator(validar_cadena)
        self.mzl.setValidator(validar_cadena)
        self.pcl.setValidator(validar_cadena)

        self.pda.setValidator(QIntValidator())

        self.iface = iface
        self.mode = self.getMode()
        self.utils = Utils(iface)
        self.web = Web(iface, self.utils)
        self.db = Db(iface, self.utils)

        self.path = "MultiPolygon?crs=EPSG:22185&index=yes"
        self.provider = "memory"

        self.baseName = [
            "Resultados Partida Inmobiliaria",
            "Resultados Nomenclatura Catastral"
        ]
        self.qml = ['estilo_pda.qml', 'estilo_nom.qml']

        self._layer1 = self.createLayerDefault(self.baseName[0], self.qml[0],
                                               self.pdo1)
        self._layer2 = self.createLayerDefault(self.baseName[1], self.qml[1],
                                               self.pdo2)

        self.pdopda = ""
        self.result1 = None

        self.nomencla = ""
        self.result2 = None

        self.initSetting()

        #eventos
        self.search1.clicked.connect(self.getPartida)
        self.clean1.clicked.connect(lambda: self.utils.removeLayer(
            self.baseName[0], self.pdo1, self.pda))

        self.search2.clicked.connect(self.getNomencla)
        self.clean2.clicked.connect(lambda: self.utils.removeLayer(
            self.baseName[1], self.pdo2, self.cir, self.sec, self.chn, self.
            chl, self.qtn, self.qtl, self.frn, self.frl, self.mzn, self.mzl,
            self.pcn, self.pcl))

        self.rbNew.toggled.connect(self.toggleButton)
        self.settingOk.clicked.connect(self.setSettings)
 def _set_mask_number(self, lineEdit, lo: int = 0, hi: int = None):
     validator = QIntValidator()
     validator.setBottom(lo)
     if hi:
         validator.setTop(hi)
     lineEdit.setValidator(validator)
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.setValidator(QIntValidator(-99, 99))
Exemple #23
0
    def __init__(self, iface, parent=None):

        super(PreVesperDialog, self).__init__(iface.mainWindow())

        # Set up the user interface from Designer.
        self.setupUi(self)

        # The qgis interface
        self.iface = iface
        self.DISP_TEMP_LAYERS = read_setting(PLUGIN_NAME + '/DISP_TEMP_LAYERS',
                                             bool)
        self.DEBUG = config.get_debug_mode()

        # Catch and redirect python errors directed at the log messages python
        # error tab.
        QgsApplication.messageLog().messageReceived.connect(errorCatcher)

        if not os.path.exists(TEMPDIR):
            os.mkdir(TEMPDIR)

        # Setup for validation messagebar on gui-----------------------------
        self.setWindowIcon(
            QtGui.QIcon(':/plugins/pat/icons/icon_vesperKriging.svg'))

        self.validationLayout = QtWidgets.QFormLayout(self)
        # source: https://nathanw.net/2013/08/02/death-to-the-message-box-use-the-qgis-messagebar/
        # Add the error messages to top of form via a message bar.
        # leave this message bar for bailouts
        self.messageBar = QgsMessageBar(self)

        if isinstance(self.layout(),
                      (QtWidgets.QFormLayout, QtWidgets.QGridLayout)):
            # create a validation layout so multiple messages can be added and
            # cleaned up.
            self.layout().insertRow(0, self.validationLayout)
            self.layout().insertRow(0, self.messageBar)
        else:
            # for use with Vertical/horizontal layout box
            self.layout().insertWidget(0, self.messageBar)

        # Set Class default variables -------------------------------------
        self.vesp_dict = None
        self.dfCSV = None

        # this is a validation flag
        self.OverwriteCtrlFile = False
        self.cboMethod.addItems(
            ['High Density Kriging', 'Low Density Kriging (Advanced)'])

        # To allow only integers for the min number of pts.
        self.onlyInt = QIntValidator()
        self.lneMinPoint.setValidator(self.onlyInt)

        self.vesper_exe = check_vesper_dependency()
        if self.vesper_exe is None or self.vesper_exe == '':
            self.gbRunVesper.setTitle(
                'WARNING:Vesper not found please configure using the about dialog.'
            )
            self.gbRunVesper.setChecked(False)
            self.gbRunVesper.setCheckable(False)
            self.gbRunVesper.setEnabled(False)
    def __init__(self, interface, settings):
        QDialog.__init__(self, interface.mainWindow())

        # Set up the user interface from Designer.
        self.ui = Ui_VoGISProfilToolMain()
        self.ui.setupUi(self)
        self.ui.buttonBox.button(QDialogButtonBox.Ok).setText(
            QApplication.translate("code", "Profil erstellen"))
        self.ui.buttonBox.button(QDialogButtonBox.Cancel).setText(
            QApplication.translate("code", "Schließen"))

        self.ui.grpCadastre.toggled.connect(self._toggleCadastreLayer)
        self.ui.cmbCadastreLayer.currentIndexChanged.connect(
            self._updateCadastreLayer)

        self.settings = settings
        self.iface = interface
        self.selectingVisibleRasters = False
        self.thread = None

        if self.settings.onlyHektoMode is True:
            self.ui.IDC_widRaster.hide()
            self.adjustSize()

        self.ui.IDC_dblspinDistance.setValue(self.settings.equiDistance)
        self.ui.IDC_dblspinVertexCnt.setValue(self.settings.vertexCnt)

        validator = QIntValidator(-32768, 32768, self)
        self.ui.IDC_tbNoDataExport.setValidator(validator)

        self.ui.IDC_tbFromX.setText("-30000")
        self.ui.IDC_tbFromY.setText("240000")
        self.ui.IDC_tbToX.setText("-20000")
        self.ui.IDC_tbToY.setText("230000")

        self.__addRastersToGui()
        self.__addPolygonsToGui()

        for line_lyr in self.settings.mapData.lines.lines():
            self.ui.IDC_cbLineLayers.addItem(line_lyr.name, line_lyr)

        if self.settings.mapData.lines.count() < 1:
            self.ui.IDC_rbDigi.setChecked(True)
            self.ui.IDC_rbShapeLine.setEnabled(False)

        #Einstellungen fuer Linie zeichen
        self.action = QAction(
            QIcon(":/plugins/vogisprofiltoolmain/icons/icon.png"),
            "VoGIS-Profiltool", self.iface.mainWindow())
        self.action.setWhatsThis("VoGIS-Profiltool")

        self.canvas = self.iface.mapCanvas()
        self.tool = ProfiletoolMapTool(self.canvas, self.action)
        self.savedTool = self.canvas.mapTool()
        self.polygon = False

        self.rubberband = QgsRubberBand(self.canvas, self.polygon)
        self.rubberband.setLineStyle(Qt.SolidLine)
        self.rubberband.setWidth(4.0)
        self.rubberband.setColor(QColor(0, 255, 0))
        #http://www.qgis.org/api/classQgsRubberBand.html#a6f7cdabfcf69b65dfc6c164ce2d01fab

        self.pointsToDraw = []
        self.dblclktemp = None
        self.drawnLine = None
Exemple #25
0
    def __init__(self, parameters, is_new):
        QDialog.__init__(self, None)

        self.ui = Ui_MainDialog()
        self.ui.setupUi(self)
        self.ui.layer_list = LayerListWidget(self.ui.labelingGroup)
        self.ui.labelingLayout.addWidget(self.ui.layer_list)

        self.ui.bufferUnits.setValidator(QDoubleValidator())
        self.ui.bufferSegments.setValidator(QIntValidator())
        self.ui.simplifyTolerance.setValidator(QDoubleValidator())

        self.parameters = parameters
        if self.parameters.file_format is None:
            self.parameters.file_format = "ESRI Shapefile"
        self.style = QgsStyle()

        # connect edit style
        self.ui.editStyleBtn.clicked.connect(self.on_style_edit)
        # connect file browser
        self.ui.browseBtn.clicked.connect(self.on_file_browse)
        # add a "tips" button
        self.ui.tipsBtn = QPushButton(self.tr("Tips"), self.ui.buttonBox)
        self.ui.buttonBox.addButton(self.ui.tipsBtn, QDialogButtonBox.ActionRole)
        self.ui.tipsBtn.clicked.connect(self.show_tips)
        # add a "save as defaults" button
        self.ui.saveDefaultsBtn = QPushButton(
            self.tr("Save as defaults"), self.ui.buttonBox
        )
        self.ui.buttonBox.addButton(
            self.ui.saveDefaultsBtn, QDialogButtonBox.ActionRole
        )
        self.ui.saveDefaultsBtn.clicked.connect(self.on_save_defaults)
        # add a "load defaults" button
        self.ui.loadDefaultsBtn = QPushButton(
            self.tr("Load defaults"), self.ui.buttonBox
        )
        self.ui.buttonBox.addButton(
            self.ui.loadDefaultsBtn, QDialogButtonBox.ActionRole
        )
        self.ui.loadDefaultsBtn.clicked.connect(self.load_defaults)
        # connect the "help" button
        self.ui.buttonBox.helpRequested.connect(self.on_help)

        self.ui.layer_list.ui.polygonOperatorCombo.currentIndexChanged[int].connect(
            self.on_polygon_operator_changed
        )

        # connect the "apply" button
        for btn in self.ui.buttonBox.buttons():
            if self.ui.buttonBox.buttonRole(btn) == QDialogButtonBox.ApplyRole:
                btn.clicked.connect(self.on_apply)
                break

        # save current style
        self.save_style_parameters = MaskParameters()
        self.update_parameters_from_style(self.save_style_parameters)
        self.update_parameters_from_style(self.parameters)

        self.is_new = is_new
        if self.is_new:
            self.setWindowTitle(self.tr("Create a mask"))
        else:
            self.setWindowTitle(self.tr("Update the current mask"))
Exemple #26
0
    def initGui(self):
        """
        Initialize the GUI, connect SIGNALS
        """

        self.action = QAction(QIcon(currentPath + "/icon.png"), u"SelvansGeo",
                              self.iface.mainWindow())

        # connect the action to the run method
        self.action.triggered.connect(self.run)

        # Add toolbar button and menu item
        self.iface.addToolBarIcon(self.action)
        self.iface.addPluginToMenu(u"&SelvansGeo", self.action)

        # disable tabs until user is connected to db
        self.switchUiMode(True)
        # self.switchUiMode(False) # ==> switch on production

        # initialize connections to Application Databases - only reading access
        conf = self.conf
        self.pgdb = SitnDB(conf['pg']['dbname'], conf['pg']['host'],
                           conf['pg']['port'], conf['pg']['user'],
                           self.readerPwd, "postgres", self.iface)

        self.dlg.txtPassword.setText(self.readerPwd)

        # Connection to MSSQL
        self.msdb = SitnDB(conf['ms']['dbname'], conf['ms']['host'], "",
                           conf['ms']['user'], conf['ms']['password'], "mssql",
                           self.iface)
        self.qtmsdb, isMSOpened = self.msdb.createQtMSDB()
        # HANDLE MISSING CONNECTION HERE !!!
        # Thematic Analysis tools
        self.thematicanalysis = ThematicAnalysis(self.iface, self.dlg,
                                                 self.pgdb, self.qtmsdb)

        # SelvansGeo navigation tools
        self.tabularNavigation = tabularNavigation(self.dlg, self.pgdb,
                                                   self.canvas, self.iface)

        # Selvans cartographic tools
        self.fillAnalysisCombo()

        # *** Connect signals and slot***

        # Project
        self.dlg.btLoadProject.clicked.connect(self.openSelvansGeoProject)
        self.dlg.btDefineDefaultProject.clicked.connect(
            self.defineDefaultProject)
        self.dlg.btResetDefaultProject.clicked.connect(
            self.resetDefaultProject)

        # Connection
        self.dlg.btConnection.clicked.connect(self.connectionsInit)

        # self.switchUiMode(True)# DEBUG MODE. COMMENT IN PRODUCTION

        self.dlg.cmbConnection.currentIndexChanged.connect(
            self.setConnectionPwdTxt)
        # Help
        self.dlg.btQgisPrintComposerHelp.clicked.connect(
            self.openQgisPrintHelp)
        self.dlg.btQgisHelp.clicked.connect(self.openQgisHelp)
        self.dlg.btSelvansGeoHelp.clicked.connect(self.openSelvansGeoHelp)

        # Navigation tools
        self.dlg.listArr.itemClicked.connect(
            self.tabularNavigation.selectAdministration)
        self.dlg.listAdm.itemClicked.connect(
            self.tabularNavigation.selectDivision)
        self.dlg.listAdm.itemDoubleClicked.connect(
            self.tabularNavigation.zoomToSelectedAdministration)
        self.dlg.listDiv.itemDoubleClicked.connect(
            self.tabularNavigation.zoomToSelectedDivision)

        # Thematic analysis
        self.dlg.btAnalysis.clicked.connect(
            self.thematicanalysis.createAnalysis)
        self.dlg.btAdvancedUserMode.clicked.connect(
            self.analysisAdvancedUserMode)
        self.dlg.cmbAnalysis.currentIndexChanged.connect(
            self.thematicanalysis.getQueryStringFromDb)
        self.dlg.chkSaveAnalysisResult.stateChanged.connect(
            self.thematicanalysis.openFileDialog)
        self.dlg.chkLastSurvey.stateChanged.connect(
            self.thematicanalysis.checkLastSurvey)

        self.dlg.lnYearStart.setValidator(QIntValidator())
        self.dlg.lnYearStart.setMaxLength(4)
        self.dlg.lnYearEnd.setValidator(QIntValidator())
        self.dlg.lnYearEnd.setMaxLength(4)
        self.dlg.lnCoupeType.setValidator(QIntValidator())
        self.analysisAdvancedUserMode()
        self.dlg.frameIcon.setStyleSheet("image: url(" + currentPath +
                                         "/icon.png)")

        # Set default visibility of some GUI items
        self.dlg.lnYearStart.hide()
        self.dlg.lblDateStart.hide()
        self.dlg.chkLastSurvey.hide()
        self.dlg.txtAnalysisName.hide()
        self.dlg.lnCoupeType.hide()
        self.dlg.lblCoupeType.hide()
        self.dlg.lnYearEnd.hide()
        self.dlg.lblDateEnd.hide()
        self.dlg.chkSaveAnalysisResult.show()

        # Set label about project paths
        self.dlg.lblCurrentProject.setText(self.customProjectPath)
class NTMainPanel(BASE, WIDGET):

    def __init__(self, iface, vlayer):
        super().__init__(None)
        self.setupUi(self)

        self.iface = iface
        self.layer = vlayer

        self.setWindowTitle('NavTable - ' + self.layer.name())
        self.exprFilterBT.setIcon(QgsApplication.getThemeIcon('mIconExpressionSelect.svg'))
        self.removeFilterBT.setIcon(QgsApplication.getThemeIcon('mActionDeselectAll.svg'))
        self.orderByBT.setIcon(QgsApplication.getThemeIcon('sort.svg'))

        self.previousDialog = self.widget_form

        self.validator = QIntValidator(1, 1)
        self.currentFeatLB.setValidator(self.validator)

        self.nextBT.clicked.connect(self.next)
        self.previousBT.clicked.connect(self.previous)
        self.lastBT.clicked.connect(self.last)
        self.firstBT.clicked.connect(self.first)
        self.orderByBT.clicked.connect(self.orderBy)
        self.exprFilterBT.clicked.connect(self.filter_by_expression)
        self.removeFilterBT.clicked.connect(self.removeFilter)
        self.deleteBT.clicked.connect(self.deleteFeature)
        self.currentFeatLB.returnPressed.connect(self.manual)

        self.layer.editingStarted.connect(self.activateEdit)
        self.layer.editingStopped.connect(self.deactivateEdit)

        self.allIds = self.layer.allFeatureIds()
        self.currentIndexFid = 0
        self.currentFid = self.allIds[self.currentIndexFid]
        self.currentExpression = ''
        self.update(self.currentFid, self.currentIndexFid)

        self.removeFilterBT.setEnabled(False)
        if self.layer.isEditable():
            self.activateEdit()
        
    def setCounters(self, current, max):
        
        self.currentFeatLB.setText(current)
        self.nFeatLB.setText(max)

        self.validator.setRange(1, int(max))

    def keyPressEvent(self, event):

        if event.key() == Qt.Key_Enter:
            pass
        else:
            super().keyPressEvent(event)

    def next(self):
        newIndex = self.currentIndexFid + 1
        newFid = self.allIds[newIndex]
        self.update(newFid, newIndex)

    def previous(self):
        newIndex = self.currentIndexFid - 1
        newFid = self.allIds[newIndex]
        self.update(newFid, newIndex)

    def last(self):
        newIndex = len(self.allIds) - 1
        newFid = self.allIds[newIndex]
        self.update(newFid, newIndex)

    def first(self):
        newIndex = 0
        newFid = self.allIds[newIndex]
        self.update(newFid, newIndex)

    def manual(self):
        newIndex = int(self.currentFeatLB.text()) - 1
        newFid = self.allIds[newIndex]
        self.update(newFid, newIndex)

    def update(self, newFid, newIndex):
        feat = self.getFeature(newFid)
        if not feat:
            print("Error accesing index.")
            return
        self.currentIndexFid = newIndex
        self.currentFid = newFid
        self.updateNFeatLB()
        self.updateCanvas(feat)
        self.updateDialog(feat)
        self.checkButtons()

    def updateCanvas(self, feat):
        if self.has_to_select():
            self.layer.selectByIds([self.currentFid])

        geom = feat.geometry()
        if self.has_to_zoom():
            self.zoomTo(geom.boundingBox())  # TODO: be careful with crs
        elif self.has_to_pan():
            self.panTo(geom.centroid())  # TODO: be careful with crs

    def zoomTo(self, newExtent):
        '''
        newExtend is bbox
        '''
        self.iface.mapCanvas().setExtent(newExtent)
        self.iface.mapCanvas().refresh()

    def panTo(self, newCenter):
        '''
        newCenter is QgsPoint geometry
        Taked from: http://svn.reprojected.com/qgisplugins/trunk/refmap/refmap.py
        '''
        newCenterPoint = newCenter.asPoint()
        currentExtent = self.iface.mapCanvas().extent()
        currentCenter = currentExtent.center()
        dx = math.fabs(newCenterPoint.x() - currentCenter.x())
        dy = math.fabs(newCenterPoint.y() - currentCenter.y())
        if (newCenterPoint.x() > currentCenter.x()):
            currentExtent.setXMinimum(currentExtent.xMinimum() + dx)
            currentExtent.setXMaximum(currentExtent.xMaximum() + dx)
        else:
            currentExtent.setXMinimum(currentExtent.xMinimum() - dx)
            currentExtent.setXMaximum(currentExtent.xMaximum() - dx)
        if (newCenterPoint.y() > currentCenter.y()):
            currentExtent.setYMaximum(currentExtent.yMaximum() + dy)
            currentExtent.setYMinimum(currentExtent.yMinimum() + dy)
        else:
            currentExtent.setYMaximum(currentExtent.yMaximum() - dy)
            currentExtent.setYMinimum(currentExtent.yMinimum() - dy)
        self.iface.mapCanvas().setExtent(currentExtent)
        self.iface.mapCanvas().refresh()

    def has_to_pan(self):
        return self.panCB.isChecked()

    def has_to_zoom(self):
        return self.zoomCB.isChecked()

    def has_to_select(self):
        return self.selectCB.isChecked()

    def updateNFeatLB(self):
        self.setCounters(str(self.currentIndexFid + 1), str(len(self.allIds)))

    def getFeature(self, fid):
        feat = QgsFeature()
        if self.layer.getFeatures(QgsFeatureRequest().setFilterFid(fid)).nextFeature(feat):
            return feat
        else:
            # return False
            return feat

    def checkButtons(self):

        if self.currentIndexFid == len(self.allIds) - 1:
            self.nextBT.setEnabled(False)
            self.lastBT.setEnabled(False)
        else:
            self.nextBT.setEnabled(True)
            self.lastBT.setEnabled(True)

        if self.currentIndexFid == 0:
            self.previousBT.setEnabled(False)
            self.firstBT.setEnabled(False)
        else:
            self.previousBT.setEnabled(True)
            self.firstBT.setEnabled(True)

    def updateDialog(self, feat):

        if isinstance(self.previousDialog, QgsAttributeDialog):
            self.previousDialog.accept()
        self.currentDialog = QgsAttributeDialog(self.layer, feat, False, showDialogButtons=False)
        self.currentDialog.setWindowFlag(Qt.Widget)

        self.scrollArea.setWidget(self.currentDialog)
        self.previousDialog = self.currentDialog

    def deleteFeature(self):

        self.layer.deleteFeature(self.currentFid)
        self.allIds.remove(self.currentFid)

        if self.currentIndexFid >= len(self.allIds) - 1:
            self.currentIndexFid = self.currentIndexFid - 1
        newFid = self.allIds[self.currentIndexFid]
        self.update(newFid, self.currentIndexFid)

    def activateEdit(self):

        self.deleteBT.setEnabled(True)
        self.deleteBT.setStyleSheet("background-color: red")

    def deactivateEdit(self):

        self.deleteBT.setEnabled(False)
        self.deleteBT.setStyleSheet("")

    def filter_by_expression(self):

        dialog = NTExpressionBuilder(self.layer, self.currentExpression, self.iface)

        if dialog.exec_():
            expression = dialog.expressionBuilder.expressionText()
            self.filter(expression)

    def filter_by_form(self):

        dialog = NTSelectByFormDialog(self.layer, self.iface)

        if dialog.exec_():
            expression = dialog.expression
            self.filter(expression)

    def removeFilter(self):

        self.filter('')
        self.removeFilterBT.setEnabled(False)

    def filter(self, expression):

        self.currentExpression = expression

        if self.currentExpression != '':
            expr = QgsExpression(self.currentExpression)
            selection = self.layer.getFeatures(QgsFeatureRequest(expr))
            self.allIds = [s.id() for s in selection]
            self.setWindowTitle('NavTable - {} ({})'.format(self.layer.name(), self.tr('Filtered')))
            self.removeFilterBT.setEnabled(True)

        if len(self.allIds) == 0 or self.currentExpression == '':
            self.allIds = self.layer.allFeatureIds()
            self.setWindowTitle('NavTable - ' + self.layer.name())

        self.currentIndexFid = 0
        newFid = self.allIds[self.currentIndexFid]
        self.update(newFid, self.currentIndexFid)

    def orderBy(self):

        dialog = NTFieldSelect(self.layer)

        if dialog.exec_():

            featureRequest = dialog.generateFeatureRequest()
            featureRequest.setFilterFids(self.allIds)

            feats = self.layer.getFeatures(featureRequest)
            self.allIds = [f.id() for f in feats]

            self.currentIndexFid = 0
            newFid = self.allIds[self.currentIndexFid]
            self.update(newFid, self.currentIndexFid)
Exemple #28
0
    def __init__(self):
        QDialog.__init__(self)

        self.setWindowTitle(tr('DMS Point Tool'))

        self.lat_D = QLineEdit()
        self.lat_M = QLineEdit()
        self.lat_S = QLineEdit()
        self.lat_DM = QLineEdit()
        self.lon_D = QLineEdit()
        self.lon_M = QLineEdit()
        self.lon_S = QLineEdit()
        self.lon_DM = QLineEdit()

        self.lat_M.textEdited.connect(self.lat_MS_edited)
        self.lat_S.textEdited.connect(self.lat_MS_edited)
        self.lat_DM.textEdited.connect(self.lat_DM_edited)
        self.lon_M.textEdited.connect(self.lon_MS_edited)
        self.lon_S.textEdited.connect(self.lon_MS_edited)
        self.lon_DM.textEdited.connect(self.lon_DM_edited)

        int_val = QIntValidator()
        int_val.setBottom(0)

        float_val = QDoubleValidator()
        float_val.setBottom(0)

        self.lat_D.setValidator(int_val)
        self.lat_M.setValidator(int_val)
        self.lat_S.setValidator(float_val)
        self.lat_DM.setValidator(float_val)

        self.lon_D.setValidator(int_val)
        self.lon_M.setValidator(int_val)
        self.lon_S.setValidator(float_val)
        self.lon_DM.setValidator(float_val)

        self.lat_NS = QComboBox()
        self.lat_NS.addItem("N")
        self.lat_NS.addItem("S")

        self.lon_EW = QComboBox()
        self.lon_EW.addItem("E")
        self.lon_EW.addItem("W")

        buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self)
        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)

        lat_grp = QGroupBox(tr("Latitude"), self)
        lat_grp.setStyleSheet(
            "QGroupBox { font-weight: bold; color: #3c3c3c; } ")
        lat_grid = QGridLayout()
        lat_grid.addWidget(QLabel(tr("Degrees")), 0, 0)
        lat_grid.addWidget(QLabel(tr("Minutes")), 0, 1)
        lat_grid.addWidget(QLabel(tr("Seconds")), 0, 2)
        lat_grid.addWidget(QLabel(tr("Direction")), 0, 3)
        lat_grid.addWidget(self.lat_D, 1, 0)
        lat_grid.addWidget(self.lat_M, 1, 1)
        lat_grid.addWidget(self.lat_S, 1, 2)
        lat_grid.addWidget(self.lat_NS, 1, 3)
        lat_grid.addWidget(QLabel(tr("Decimal minutes")), 2, 1)
        lat_grid.addWidget(self.lat_DM, 3, 1, 1, 2)
        lat_grp.setLayout(lat_grid)

        lon_grp = QGroupBox(tr("Longitude"), self)
        lon_grp.setStyleSheet(
            "QGroupBox { font-weight: bold; color: #3c3c3c; } ")
        lon_grid = QGridLayout()
        lon_grid.addWidget(QLabel(tr("Degrees")), 0, 0)
        lon_grid.addWidget(QLabel(tr("Minutes")), 0, 1)
        lon_grid.addWidget(QLabel(tr("Seconds")), 0, 2)
        lon_grid.addWidget(QLabel(tr("Direction")), 0, 3)
        lon_grid.addWidget(self.lon_D, 1, 0)
        lon_grid.addWidget(self.lon_M, 1, 1)
        lon_grid.addWidget(self.lon_S, 1, 2)
        lon_grid.addWidget(self.lon_EW, 1, 3)
        lon_grid.addWidget(QLabel(tr("Decimal minutes")), 2, 1)
        lon_grid.addWidget(self.lon_DM, 3, 1, 1, 2)
        lon_grp.setLayout(lon_grid)

        vbox = QVBoxLayout()
        vbox.addWidget(lat_grp)
        vbox.addWidget(lon_grp)
        vbox.addWidget(buttons)

        self.setLayout(vbox)
Exemple #29
0
    def __init__(self):
        QDialog.__init__(self)

        self.setWindowTitle(tr('DMS Point Tool'))

        self.lat_D = QLineEdit()
        self.lat_M = QLineEdit()
        self.lat_S = QLineEdit()
        self.lat_DM = QLineEdit()
        self.lon_D = QLineEdit()
        self.lon_M = QLineEdit()
        self.lon_S = QLineEdit()
        self.lon_DM = QLineEdit()

        self.lat_M.textEdited.connect(self.lat_MS_edited)
        self.lat_S.textEdited.connect(self.lat_MS_edited)
        self.lat_DM.textEdited.connect(self.lat_DM_edited)
        self.lon_M.textEdited.connect(self.lon_MS_edited)
        self.lon_S.textEdited.connect(self.lon_MS_edited)
        self.lon_DM.textEdited.connect(self.lon_DM_edited)

        int_val = QIntValidator()
        int_val.setBottom(0)

        float_val = QDoubleValidator()
        float_val.setBottom(0)

        self.lat_D.setValidator(int_val)
        self.lat_M.setValidator(int_val)
        self.lat_S.setValidator(float_val)
        self.lat_DM.setValidator(float_val)

        self.lon_D.setValidator(int_val)
        self.lon_M.setValidator(int_val)
        self.lon_S.setValidator(float_val)
        self.lon_DM.setValidator(float_val)

        self.lat_NS = QComboBox()
        self.lat_NS.addItem("N")
        self.lat_NS.addItem("S")

        self.lon_EW = QComboBox()
        self.lon_EW.addItem("E")
        self.lon_EW.addItem("W")

        buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel, Qt.Horizontal, self)
        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)

        lat_grp = QGroupBox(tr("Latitude"), self)
        lat_grp.setStyleSheet(
            "QGroupBox { font-weight: bold; color: #3c3c3c; } ")
        lat_grid = QGridLayout()
        lat_grid.addWidget(QLabel(tr("Degrees")), 0, 0)
        lat_grid.addWidget(QLabel(tr("Minutes")), 0, 1)
        lat_grid.addWidget(QLabel(tr("Seconds")), 0, 2)
        lat_grid.addWidget(QLabel(tr("Direction")), 0, 3)
        lat_grid.addWidget(self.lat_D, 1, 0)
        lat_grid.addWidget(self.lat_M, 1, 1)
        lat_grid.addWidget(self.lat_S, 1, 2)
        lat_grid.addWidget(self.lat_NS, 1, 3)
        lat_grid.addWidget(QLabel(tr("Decimal minutes")), 2, 1)
        lat_grid.addWidget(self.lat_DM, 3, 1, 1, 2)
        lat_grp.setLayout(lat_grid)

        lon_grp = QGroupBox(tr("Longitude"), self)
        lon_grp.setStyleSheet(
            "QGroupBox { font-weight: bold; color: #3c3c3c; } ")
        lon_grid = QGridLayout()
        lon_grid.addWidget(QLabel(tr("Degrees")), 0, 0)
        lon_grid.addWidget(QLabel(tr("Minutes")), 0, 1)
        lon_grid.addWidget(QLabel(tr("Seconds")), 0, 2)
        lon_grid.addWidget(QLabel(tr("Direction")), 0, 3)
        lon_grid.addWidget(self.lon_D, 1, 0)
        lon_grid.addWidget(self.lon_M, 1, 1)
        lon_grid.addWidget(self.lon_S, 1, 2)
        lon_grid.addWidget(self.lon_EW, 1, 3)
        lon_grid.addWidget(QLabel(tr("Decimal minutes")), 2, 1)
        lon_grid.addWidget(self.lon_DM, 3, 1, 1, 2)
        lon_grp.setLayout(lon_grid)

        vbox = QVBoxLayout()
        vbox.addWidget(lat_grp)
        vbox.addWidget(lon_grp)
        vbox.addWidget(buttons)

        self.setLayout(vbox)