def accept(self):
        QDialog.accept(self)

        # save dialog prop
        settings = QSettings()
        settings.setValue("/IdahoLayerPlugin/bucket", self.lineEdit_Bucket.text().strip())
        settings.setValue("/IdahoLayerPlugin/imageid", self.lineEdit_ImageId.text().strip())
    def accept(self):
        utils.addBoundlessRepository()
        if self.leLogin.text() == '' or self.lePassword.text() == '':
            QDialog.accept(self)
            return

        if self.authId == '':
            authConfig = QgsAuthMethodConfig('Basic')
            authId = QgsAuthManager.instance().uniqueConfigId()
            authConfig.setId(authId)
            authConfig.setConfig('username', self.leLogin.text())
            authConfig.setConfig('password', self.lePassword.text())
            authConfig.setName('Boundless Connect Portal')

            settings = QSettings('Boundless', 'BoundlessConnect')
            authConfig.setUri(settings.value('repoUrl', '', unicode))

            if QgsAuthManager.instance().storeAuthenticationConfig(authConfig):
                utils.setRepositoryAuth(authId)
            else:
                QMessageBox.information(self, self.tr('Error!'), self.tr('Unable to save credentials'))
        else:
            authConfig = QgsAuthMethodConfig()
            QgsAuthManager.instance().loadAuthenticationConfig(self.authId, authConfig, True)
            authConfig.setConfig('username', self.leLogin.text())
            authConfig.setConfig('password', self.lePassword.text())
            QgsAuthManager.instance().updateAuthenticationConfig(authConfig)

        QDialog.accept(self)
Example #3
0
 def accept(self):
     #do some stuff first, like save
     if self.input_validated:
         self.config.save()
         QDialog.accept(self)
     else:
         QErrorMessage(self).showMessage("Bad input.. (somewhere?)")
    def accept(self):
        user = self.ui.userTX.text().strip()
        apiKey = self.ui.apiKeyTX.text().strip()
        multiuser = self.ui.multiuserCH.isChecked()

        if any([user == '', apiKey == '']):
            QMessageBox.warning(self, self.tr('Save connection'),
                                self.tr('Both User and Api Key must be provided'))
            return

        if user is not None:
            key = '/CartoDBPlugin/%s' % user
            keyapi = '%s/api' % key
            keymultiuser = '******' % key
            key_orig = '/CartoDBPlugin/%s' % self.user_orig
            # warn if entry was renamed to an existing connection
            if all([self.user_orig != user,
                    self.settings.contains(keyapi)]):
                res = QMessageBox.warning(self, self.tr('Save connection'), self.tr('Overwrite %s?' % user),
                                          QMessageBox.Ok | QMessageBox.Cancel)
                if res == QMessageBox.Cancel:
                    return

            # on rename delete original entry first
            if all([self.user_orig is not None, self.user_orig != user]):
                self.settings.remove(key_orig)

            self.settings.setValue(keyapi, apiKey)
            self.settings.setValue(keymultiuser, multiuser)
            self.settings.setValue('/CartoDBPlugin/selected', user)

            QDialog.accept(self)
Example #5
0
    def accept(self):
        """
    Called when the OK button was pressed. Exports the filtered data
    to a new file, adding a specific header entry containing the
    filtered row numbers.
    """
        fpath, fname = path.split(self.origin_file)
        pre, post = fname.rsplit("_", 1)
        outfile = path.join(fpath, pre + "_filtered_" + post)
        original_lines = open(self.origin_file, "r").readlines()
        output = open(outfile, "w")
        # collect indices of filtered regions
        reg = self.plot_region
        self.filtered_idxs = np.arange(len(self.Qz))[np.logical_not(reg)].tolist()

        for oline in original_lines:
            if oline.startswith("#"):
                if "[Data]" in oline:
                    # insert additional header info for filtering
                    output.write("# [Filtered Indices]")
                    output.write("\n# Original File: %s\n# Filtered Indices: (" % self.origin_file)
                    for idx in self.filtered_idxs:
                        output.write(str(idx) + ", ")
                    output.write(")\n#\n")
                output.write(oline)
            else:
                break
        value = np.array([self.Qz[reg], self.R[reg], self.dR[reg], self.dQz[reg], self.ai[reg]])
        np.savetxt(output, value.T, delimiter="\t", fmt="%-18e")
        output.close()
        QDialog.accept(self)
 def accept(self):
     rows = self.sModel.rowCount()
     cols = self.sModel.columnCount()
     model = self.sModel
     mlqry = dict()
     qry = None
     for r in range(rows):
         record = model.record(r)
         for c in range(1, cols):
             if record.value(c).toString():
                 if not qry:
                     qry = "("
                 elif c > 1 and qry :
                     qry = "%s AND" % qry
                 qry = "%s %s %s" % (qry, record.fieldName(c),
                                 record.value(c).toString())
         if qry :
             mlqry[r] = "%s )" % qry
             qry = ""
     for q in mlqry.keys():
         if not qry:
             qry = mlqry[q]
             continue
         qry = "%s OR %s" % (qry, mlqry[q])
     self.resultFilter = qry
     query = QSqlQuery()
     query.exec_("DROP TABLE filtertable")
     if self.dbi:
         del self.dbi
     QDialog.accept(self)
Example #7
0
    def accept(self):
        """add CSW entry"""

        conn_name = self.leName.text().strip()
        conn_url = self.leURL.text().strip()

        if any([conn_name == '', conn_url == '']):
            QMessageBox.warning(self, self.tr('Save connection'),
                                self.tr('Both Name and URL must be provided'))
            return

        if conn_name is not None:
            key = '/MetaSearch/%s' % conn_name
            keyurl = '%s/url' % key
            key_orig = '/MetaSearch/%s' % self.conn_name_orig

            # warn if entry was renamed to an existing connection
            if all([self.conn_name_orig != conn_name,
                    self.settings.contains(keyurl)]):
                res = QMessageBox.warning(self, self.tr('Save connection'),
                                          self.tr('Overwrite %s?') % conn_name,
                                          QMessageBox.Ok | QMessageBox.Cancel)
                if res == QMessageBox.Cancel:
                    return

            # on rename delete original entry first
            if all([self.conn_name_orig is not None,
                    self.conn_name_orig != conn_name]):
                self.settings.remove(key_orig)

            self.settings.setValue(keyurl, conn_url)
            self.settings.setValue('/MetaSearch/selected', conn_name)

            QDialog.accept(self)
Example #8
0
 def accept(self):
     """ OK """
     args = str(self.ui.txtArgs.toPlainText()).replace("\n", " ")
     self.arglist = args.split(' ')
     self._working_dir = str(self.ui.txtWorkDir.text())
     util.save(args, self._working_dir)
     QDialog.accept(self)
Example #9
0
 def accept(self):
     # The setFocus() call is to force the last edited field to "commit". When the save button
     # is clicked, accept() is called before the last field to have focus has a chance to emit
     # its edition signal.
     self.setFocus()
     self.model.save()
     QDialog.accept(self)
Example #10
0
 def accept(self):
     self.languages = []
     selected = self.selectedListWidget
     for index in xrange(selected.count()):
         item = selected.item(index)
         self.languages.append(item.code)
     QDialog.accept(self)
    def accept(self):
        if self.origCollection:
            if self.origCollection != self.tmpCollection:
                self.tmpCollection._id = random_id()

        self.collection = self.tmpCollection
        QDialog.accept(self)
Example #12
0
        def accept(self):
                s = QSettings( "norBIT", "norGIS-ALKIS-Erweiterung" )
                s.setValue( "service", self.leSERVICE.text() )
                s.setValue( "host", self.leHOST.text() )
                s.setValue( "port", self.lePORT.text() )
                s.setValue( "dbname", self.leDBNAME.text() )
                s.setValue( "uid", self.leUID.text() )
                s.setValue( "pwd", self.lePWD.text() )
                if hasattr(qgis.gui,'QgsAuthConfigSelect'):
                    s.setValue( "authcfg", self.authCfgSelect.configId() )
                s.setValue( "umnpath", self.leUMNPath.text() )
                s.setValue( "umntemplate", self.leUMNTemplate.text() )
                s.setValue( "footnote", self.teFussnote.toPlainText() )

                modelle = []
                if self.twModellarten.isEnabled():
                    for i in range( self.twModellarten.rowCount() ):
                        item = self.twModellarten.item(i,0)
                        if item.checkState() == Qt.Checked:
                            modelle.append( item.text() )

                s.setValue( "modellarten", modelle )
                s.setValue( "signaturkatalog", self.cbxSignaturkatalog.itemData( self.cbxSignaturkatalog.currentIndex() ) )

                QDialog.accept(self)
Example #13
0
 def accept(self):
   if not self.name().isEmpty():
     QDialog.accept(self)
   else:
     box = QMessageBox(QMessageBox.Critical, self.tr("Error"), self.tr("Please, specify a query name"), \
                         QMessageBox.NoButton, self)
     box.exec_()
Example #14
0
    def accept(self):
        Mikibook.settings.setValue('recentNotesNumber', self.recentNotesCount.value())
        Mikibook.setHighlighterColors(self.hltCfg.configToList())

        #then make mikidown use these settings NOW
        self.parent().loadHighlighter()
        QDialog.accept(self)
Example #15
0
 def accept(self):
     #write to settings first
     msettings = self.parent().settings
     nbsettings = msettings.qsettings
     
     nbsettings.setValue('mathJax', self.mjEdit.text())
     extlist = []
     for i in range(self.mdExts.count()):
         item = self.mdExts.item(i)
         if item.checkState() == Qt.Checked:
             extlist.append(item.text())
     writeListToSettings(nbsettings, 'extensions', extlist)
     writeListToSettings(nbsettings, 'attachmentImage', self.attImgEdit.text().split(", "))
     writeListToSettings(nbsettings, 'attachmentDocument', self.attDocEdit.text().split(", "))
     writeDictToSettings(nbsettings, 'extensionsConfig', self.tmpdict)
     
     #then to memory
     msettings.extensions = extlist
     msettings.mathjax = self.mjEdit.text()
     msettings.attachmentDocument = readListFromSettings(nbsettings, 'attachmentDocument')
     msettings.attachmentImage = readListFromSettings(nbsettings, 'attachmentImage')
     msettings.extcfg.update(self.tmpdict)
     msettings.md = markdown.Markdown(msettings.extensions, extension_configs=msettings.extcfg)
     
     #then make mikidown use these settings NOW
     curitem=self.parent().notesTree.currentItem()
     self.parent().currentItemChangedWrapper(curitem, curitem)
     QDialog.accept(self)
 def accept(self):
     self.selectedoptions = []
     model = self.lstLayers.model()
     for i in xrange(model.rowCount()):
         item = model.item(i)
         self.selectedoptions.append(item.text())
     QDialog.accept(self)
 def connect(self):
     # Get tables from CartoDB.
     self.currentUser = self.ui.connectionList.currentText()
     self.currentApiKey = self.settings.value('/CartoDBPlugin/%s/api' % self.currentUser)
     self.currentMultiuser = self.settings.value('/CartoDBPlugin/%s/multiuser' % self.currentUser, False)
     self.settings.setValue('/CartoDBPlugin/selected', self.currentUser)
     QDialog.accept(self)
    def accept(self):
        styles = {}
        for key in self.valueItems.keys():
            styles[key] = unicode(self.valueItems[key].getValue())
        RenderingStyles.addAlgStylesAndSave(self.alg.commandLineName(), styles)

        QDialog.accept(self)
Example #19
0
 def reject(self):
     """
     Use standard dialog to ask whether procedure must stop or not.
     Use the SIGSTOP to stop the conversion process while waiting for user
     to respond and SIGCONT or kill depending on user's answer.
     """
     if not self.files:
         QDialog.accept(self)
         return
     if self._type == 'AudioVideo':
         self.process.send_signal(signal.SIGSTOP)
     self.running = False
     reply = QMessageBox.question(
             self,
             'FF Multi Converter - ' + self.tr('Cancel Conversion'),
             self.tr('Are you sure you want to cancel conversion?'),
             QMessageBox.Yes|QMessageBox.Cancel
             )
     if reply == QMessageBox.Yes:
         if self._type == 'AudioVideo':
             self.process.kill()
         self.running = False
         self.thread.join()
         QDialog.reject(self)
     if reply == QMessageBox.Cancel:
         self.running = True
         if self._type == 'AudioVideo':
             self.process.send_signal(signal.SIGCONT)
         else:
             self.manage_conversions()
    def run(self):
        self.endPointSelection()

        ui = self.ui
        filename = ui.lineEdit_OutputFilename.text()  # ""=Temporary file
        if filename and os.path.exists(filename):
            if (
                QMessageBox.question(
                    self,
                    "Qgis2threejs",
                    "Output file already exists. Overwrite it?",
                    QMessageBox.Ok | QMessageBox.Cancel,
                )
                != QMessageBox.Ok
            ):
                return

        # export to web (three.js)
        canvas = self.iface.mapCanvas()
        export_settings = ExportSettings(self.settings(), canvas, self.pluginManager, self.localBrowsingMode)

        valid, err_msg = export_settings.checkValidity()
        if not valid:
            QMessageBox.warning(self, "Qgis2threejs", err_msg or "Invalid settings")
            return

        ui.pushButton_Run.setEnabled(False)
        ui.toolButton_Settings.setVisible(False)
        self.clearMessageBar()
        self.progress(0)

        if export_settings.exportMode == ExportSettings.PLAIN_MULTI_RES:
            # update quads and point on map canvas
            self.createRubberBands(export_settings.baseExtent, export_settings.quadtree)

        # export
        ret = exportToThreeJS(export_settings, self.iface.legendInterface(), self.objectTypeManager, self.progress)

        self.progress(100)
        ui.pushButton_Run.setEnabled(True)

        if not ret:
            ui.toolButton_Settings.setVisible(True)
            return

        self.clearRubberBands()

        # store last selections
        settings = QSettings()
        settings.setValue("/Qgis2threejs/lastTemplate", export_settings.templateName)
        settings.setValue("/Qgis2threejs/lastControls", export_settings.controls)

        # open web browser
        if not tools.openHTMLFile(export_settings.htmlfilename):
            ui.toolButton_Settings.setVisible(True)
            return

        # close dialog
        QDialog.accept(self)
Example #21
0
        def accept(self):
                if not self.evaluate(False):
                    return

                s = QSettings( "norBIT", "norGIS-ALKIS-Erweiterung" )
                s.setValue( "suchmodus", self.cbxSuchmodus.currentIndex() )

                QDialog.accept(self)
Example #22
0
 def accept(self):
     self.selectedoptions = []
     model = self.lstLayers.model()
     for i in xrange(model.rowCount()):
         item = model.item(i)
         if item.checkState() == Qt.Checked:
             self.selectedoptions.append(i)
     QDialog.accept(self)
Example #23
0
 def accept(self):
     if self.validation():
         self.values = [i.text() for i in self.lineedits]
         if self.categLineEdit.isEnabled():
             self.values.append(self.categLineEdit.text())
         else:
             self.values.append(self.categComboBox.currentText())
         QDialog.accept(self)
Example #24
0
 def accept(self):
     from calibre.gui2.ui import get_gui
     db = get_gui().current_db
     if self.current_search_name:
         self.searches[self.current_search_name] = unicode(self.search_text.toPlainText())
     ss = {name:self.searches[name] for name in self.searches}
     db.saved_search_set_all(ss)
     QDialog.accept(self)
Example #25
0
 def accept(self):
     if self.txtSubject.text().strip() == "":
         QMessageBox.information(self, self.windowTitle(), self.trUtf8("标题不能为空。"))
         return
     if not (self.rdoFinished.isChecked() or self.rdoProcessing.isChecked() or self.rdoUnfinished.isChecked()):
         QMessageBox.information(self, self.windowTitle(), self.trUtf8("请选择完成度。"))
         return
     QDialog.accept(self)
Example #26
0
 def accept(self):
     """Called when OK-button is clicked
     """
     if not self.saveServerlist():
         # DO NOT QUIT
         return
     self.__returnList = self.__serverList
     QDialog.accept(self)
 def on_buttonBox_accepted(self):
     settings = QSettings("PostNAS", "PostNAS-Suche")
     settings.setValue("host", self.leHOST.text())
     settings.setValue("port", self.lePORT.text())
     settings.setValue("dbname", self.leDBNAME.text())
     settings.setValue("user", self.leUID.text())
     settings.setValue("password", self.lePWD.text())
     QDialog.accept(self)
Example #28
0
 def accept(self):
     """Reimplement Qt method"""
     for index in range(self.pages_widget.count()):
         configpage = self.pages_widget.widget(index)
         if not configpage.is_valid():
             return
         configpage.apply_changes()
     QDialog.accept(self)
Example #29
0
 def accept(self):
     if self.current_search_name:
         self.searches[self.current_search_name] = unicode(self.search_text.toPlainText())
     for name in saved_searches().names():
         saved_searches().delete(name)
     for name in self.searches:
         saved_searches().add(name, self.searches[name])
     QDialog.accept(self)
Example #30
0
 def accept(self):
     """Reimplement Qt method"""
     if not self.runconfigoptions.is_valid():
         return
     configurations = _get_run_configurations()
     configurations.insert(0, (self.filename, self.runconfigoptions.get()))
     _set_run_configurations(configurations)
     QDialog.accept(self)
    def on_copy(self):
        select_group_dialog = QDialog(self)
        select_group_dialog.resize(300, 400)
        select_group_dialog.setWindowTitle(self.tr("Choose source group"))
        layout = QVBoxLayout(select_group_dialog)
        select_group_dialog.setLayout(layout)

        groups_list_view = QTableView(self)
        layout.addWidget(groups_list_view)
        groups_list_view.setModel(self.ds_model)
        groups_list_view.setColumnHidden(DSManagerModel.COLUMN_VISIBILITY,
                                         True)
        groups_list_view.horizontalHeader().setResizeMode(
            DSManagerModel.COLUMN_GROUP_DS, QHeaderView.Stretch)
        groups_list_view.setSelectionMode(QTableView.NoSelection)
        groups_list_view.setAlternatingRowColors(True)
        groups_list_view.setShowGrid(False)
        groups_list_view.verticalHeader().setResizeMode(
            QHeaderView.ResizeToContents)
        groups_list_view.verticalHeader().hide()
        groups_list_view.clicked.connect(
            lambda index: select_group_dialog.accept() \
                if self.ds_model.isGroup(index) and \
                    index.column() == DSManagerModel.COLUMN_GROUP_DS \
                else None
        )

        if select_group_dialog.exec_() == QDialog.Accepted:
            group_info = self.ds_model.data(groups_list_view.currentIndex(),
                                            Qt.UserRole)
            group_info.id += "_copy"
            edit_dialog = GroupEditDialog()
            edit_dialog.setWindowTitle(self.tr('Create group from existing'))
            edit_dialog.fill_group_info(group_info)
            if edit_dialog.exec_() == QDialog.Accepted:
                self.feel_list()
                self.ds_model.resetModel()
 def accept(self):
     if self.closeAndControl():
         QDialog.accept(self)
Example #33
0
    def run(self):
        self.endPointSelection()

        ui = self.ui
        filename = ui.lineEdit_OutputFilename.text()  # ""=Temporary file
        if filename and os.path.exists(filename):
            if QMessageBox.question(
                    self, "Qgis2threejs",
                    "Output file already exists. Overwrite it?",
                    QMessageBox.Ok | QMessageBox.Cancel) != QMessageBox.Ok:
                return

        # export to web (three.js)
        export_settings = ExportSettings(self.pluginManager,
                                         self.localBrowsingMode)
        export_settings.loadSettings(self.settings())
        export_settings.setMapCanvas(self.iface.mapCanvas())

        err_msg = export_settings.checkValidity()
        if err_msg is not None:
            QMessageBox.warning(self, "Qgis2threejs", err_msg
                                or "Invalid settings")
            return

        ui.pushButton_Run.setEnabled(False)
        ui.toolButton_Settings.setVisible(False)
        self.clearMessageBar()
        self.progress(0)

        if export_settings.exportMode == ExportSettings.PLAIN_MULTI_RES:
            # update quads and point on map canvas
            self.createRubberBands(export_settings.baseExtent,
                                   export_settings.quadtree())

        # export
        ret = exportToThreeJS(export_settings, self.iface.legendInterface(),
                              self.objectTypeManager, self.progress)

        self.progress(100)
        ui.pushButton_Run.setEnabled(True)

        if not ret:
            ui.toolButton_Settings.setVisible(True)
            return

        self.clearRubberBands()

        # store last selections
        settings = QSettings()
        settings.setValue("/Qgis2threejs/lastTemplate",
                          export_settings.templatePath)
        settings.setValue("/Qgis2threejs/lastControls",
                          export_settings.controls)

        # open web browser
        if not tools.openHTMLFile(export_settings.htmlfilename):
            ui.toolButton_Settings.setVisible(True)
            return

        # close dialog
        QDialog.accept(self)
Example #34
0
 def accept(self):
     """Reimplement Qt method"""
     set_user_env( listdict2envdict(self.get_value()), parent=self )
     QDialog.accept(self)
Example #35
0
 def applyPressed(self):
     self.componentName = unicode(self.ui.compComboBox.currentText())
     self.action = 'APPLY'
     QDialog.accept(self)
Example #36
0
 def storePressed(self):
     self.componentName = unicode(self.ui.compComboBox.currentText())
     self.action = 'STORE'
     QDialog.accept(self)
Example #37
0
 def applyPressed(self):
     self.componentName = unicode(self.ui.cpNameLineEdit.text())
     self.__creator.options.component = self.componentName or None
     self.populateArgs()
     self.action = 'APPLY'
     QDialog.accept(self)
Example #38
0
 def accept(self):
    QDialog.accept(self)
Example #39
0
 def accept(self):
     self.writeSettings(Settings())
     QDialog.accept(self)
 def accept(self):
     if self.validation():
         QDialog.accept(self)
 def accept(self):
     if self.close_and_control():
         QDialog.accept(self)
    def accept(self):
        """
        Called on accept button
        """
        self.selectedFilenames = []
        # save mode
        if self.typeMode == MODE_SAVE:
            filename = unicode(self.filenameLineEdit.text())
            if not filename:
                return

        wItems = self.repo.selectedItems()
        if len(wItems):
            if self.multipleSelection:
                wItemsSelected = wItems
            else:
                wItemsSelected = wItems[0]
        else:
            # select the root item
            wItemsSelected = self.repo.topLevelItem(0)

        if wItemsSelected is None:
            return

        if self.typeMode == MODE_SAVE:
            self.selectedFilename = "%s/%s" % (
                wItemsSelected.getPath(withFolderName=True,
                                       withFileName=False),
                self.filenameLineEdit.text(),
            )
            QDialog.accept(self)
        elif self.typeMode == MODE_OPEN:
            if self.multipleSelection:
                for itm in wItemsSelected:
                    selectedFilename = itm.getPath(withFolderName=False,
                                                   withFileName=True)
                    if EXTENSION_TSX in self.typeFile and selectedFilename.endswith(
                            EXTENSION_TSX):
                        self.selectedFilenames.append(selectedFilename)
                    elif EXTENSION_TPX in self.typeFile and selectedFilename.endswith(
                            EXTENSION_TPX):
                        self.selectedFilenames.append(selectedFilename)
                    elif EXTENSION_TGX in self.typeFile and selectedFilename.endswith(
                            EXTENSION_TGX):
                        self.selectedFilenames.append(selectedFilename)
                    elif EXTENSION_TCX in self.typeFile and selectedFilename.endswith(
                            EXTENSION_TCX):
                        self.selectedFilenames.append(selectedFilename)
                    elif EXTENSION_TDX in self.typeFile and selectedFilename.endswith(
                            EXTENSION_TDX):
                        self.selectedFilenames.append(selectedFilename)
                    elif EXTENSION_TUX in self.typeFile and selectedFilename.endswith(
                            EXTENSION_TUX):
                        self.selectedFilenames.append(selectedFilename)
                    elif EXTENSION_TAX in self.typeFile and selectedFilename.endswith(
                            EXTENSION_TAX):
                        self.selectedFilenames.append(selectedFilename)
                    elif EXTENSION_PNG in self.typeFile and selectedFilename.endswith(
                            EXTENSION_PNG):
                        self.selectedFilenames.append(selectedFilename)
                    else:
                        pass

                if len(self.selectedFilenames):
                    QDialog.accept(self)
            else:
                selectedFilename = wItemsSelected.getPath(withFolderName=False,
                                                          withFileName=True)
                if EXTENSION_TSX in self.typeFile and selectedFilename.endswith(
                        EXTENSION_TSX):
                    self.selectedFilename = selectedFilename
                elif EXTENSION_TPX in self.typeFile and selectedFilename.endswith(
                        EXTENSION_TPX):
                    self.selectedFilename = selectedFilename
                elif EXTENSION_TGX in self.typeFile and selectedFilename.endswith(
                        EXTENSION_TGX):
                    self.selectedFilename = selectedFilename
                elif EXTENSION_TCX in self.typeFile and selectedFilename.endswith(
                        EXTENSION_TCX):
                    self.selectedFilename = selectedFilename
                elif EXTENSION_TDX in self.typeFile and selectedFilename.endswith(
                        EXTENSION_TDX):
                    self.selectedFilename = selectedFilename
                elif EXTENSION_TUX in self.typeFile and selectedFilename.endswith(
                        EXTENSION_TUX):
                    self.selectedFilename = selectedFilename
                elif EXTENSION_TAX in self.typeFile and selectedFilename.endswith(
                        EXTENSION_TAX):
                    self.selectedFilename = selectedFilename
                elif EXTENSION_PNG in self.typeFile and selectedFilename.endswith(
                        EXTENSION_PNG):
                    self.selectedFilename = selectedFilename
                else:
                    pass
                if self.selectedFilename is not None:
                    if len(self.selectedFilename):
                        QDialog.accept(self)
        else:
            raise Exception('local repo mode not supported: %s' %
                            self.typeMode)
Example #43
0
    def accept(self):
        if not self.plugin.initLayers():
            return

        text = self.leSuchbegriff.text()

        if self.cbxSuchmodus.currentIndex() < 2:
            if text <> "":
                text = text.replace("'", "''")
                if self.cbxSuchmodus.currentIndex() == 0:
                    # Teiltreffer
                    text = u"text LIKE '%%%s%%'" % text
                else:
                    # Exakter Treffer
                    text = u"text='%s'" % text

                (db, conninfo) = self.plugin.opendb()
                if db is None:
                    return

                qry = QSqlQuery(db)

                if qry.exec_(u"SELECT find_srid('','po_labels', 'point')"
                             ) and qry.next():
                    crs = qry.value(0)

                    sql = u"SELECT count(*),st_extent( coalesce(point,line) ) FROM po_labels WHERE {0}".format(
                        text)
                    if qry.exec_(sql) and qry.next() and qry.value(0) > 0:
                        self.plugin.zoomToExtent(qry.value(1), crs)
                    else:
                        QMessageBox.information(None, "ALKIS",
                                                u"Keine Treffer gefunden.")
                        return
            else:
                text = "false"

            self.plugin.pointMarkerLayer.setSubsetString(text)
            self.plugin.lineMarkerLayer.setSubsetString(text)

        elif self.cbxSuchmodus.currentIndex() == 2:  # Flurstücksnummer
            m = re.search("(\\d+)(-\\d+)?-(\\d+)(/\\d+)?", text)
            if m:
                g, f, z, n = int(m.group(1)), m.group(2), int(
                    m.group(3)), m.group(4)
                f = int(f[1:]) if f else 0
                n = int(n[1:]) if n else 0

                flsnr = "%06d" % g
                flsnr += "%03d" % f if f > 0 else "___"
                flsnr += "%05d" % z
                flsnr += "%04d" % n if n > 0 else "____"
                flsnr += "%"

                fs = self.plugin.highlight(
                    u"flurstueckskennzeichen LIKE '%s'" % flsnr, True)
                if len(fs) == 0:
                    QMessageBox.information(
                        None, u"Fehler",
                        u"Kein Flurstück %s gefunden." % flsnr)
                    return

        elif self.cbxSuchmodus.currentIndex() == 3:  # Straße und Hausnummer
            m = re.search("^(.*)\s+(\d+[a-zA-Z]?)$", text)
            if m:
                strasse, ha = m.group(1), m.group(2)
                fs = self.plugin.highlight(
                    u"EXISTS (SELECT * FROM ax_lagebezeichnungmithausnummer h JOIN ax_lagebezeichnungkatalogeintrag k ON h.land=k.land AND h.regierungsbezirk=k.regierungsbezirk AND h.kreis=k.kreis AND h.gemeinde=k.gemeinde AND h.lage=k.lage WHERE ARRAY[h.gml_id] <@ ax_flurstueck.weistauf AND k.bezeichnung LIKE '{0}%' AND h.hausnummer='{1}')"
                    .format(strasse, ha.upper()), True)
                if len(fs) == 0:
                    QMessageBox.information(
                        None, u"Fehler",
                        u"Kein Flurstück %s %s gefunden." % (strasse, ha))
                    return

        s = QSettings("norBIT", "norGIS-ALKIS-Erweiterung")
        s.setValue("suchmodus", self.cbxSuchmodus.currentIndex())

        QDialog.accept(self)
Example #44
0
 def accept(self):
     self.stringlist = QStringList()
     for row in range(self.listWidget.count()):
         self.stringlist.append(self.listWidget.item(row).text())
     self.acceptedList.emit(self.stringlist)
     QDialog.accept(self)
Example #45
0
 def accept(self):
     self.saveSettingsData()
     QDialog.accept(self)
Example #46
0
 def accept(self):
     Utils.setGdalBinPath(self.leGdalBinPath.text())
     Utils.setGdalPymodPath(self.leGdalPymodPath.text())
     Utils.setHelpPath(self.leGdalHelpPath.text())
     QDialog.accept(self)
Example #47
0
 def accept(self):
     """Reimplement Qt method"""
     self.set_environ(listdict2envdict(self.get_value()))
     QDialog.accept(self)
Example #48
0
 def accept(self):
     self.selection = self.table.selectedObjects()
     QDialog.accept(self)
Example #49
0
 def accept(self):
     layer = self.layerComboManager.getLayer()
     if LogLayer().checkLayer(layer):
         QDialog.accept(self)
     else:
         self.logLayer.setCurrentIndex(0)
 def accept(self):
     self.save_state()
     return QDialog.accept(self)
Example #51
0
    def accept(self):
        # sanity checks
        if self.editOutputFile.text() == "":
            QMessageBox.information(self, self.tr("Export to file"), self.tr("Output file name is required"))
            return

        if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked():
            try:
                sourceSrid = int(self.editSourceSrid.text())
            except ValueError:
                QMessageBox.information(self, self.tr("Export to file"),
                                        self.tr("Invalid source srid: must be an integer"))
                return

        if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked():
            try:
                targetSrid = int(self.editTargetSrid.text())
            except ValueError:
                QMessageBox.information(self, self.tr("Export to file"),
                                        self.tr("Invalid target srid: must be an integer"))
                return

        # override cursor
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        # store current input layer crs, so I can restore it later
        prevInCrs = self.inLayer.crs()
        try:
            uri = self.editOutputFile.text()
            providerName = "ogr"

            options = {}

            # set the OGR driver will be used
            driverName = self.cboFileFormat.itemData(self.cboFileFormat.currentIndex())
            options['driverName'] = driverName

            # set the output file encoding
            if self.chkEncoding.isEnabled() and self.chkEncoding.isChecked():
                enc = self.cboEncoding.currentText()
                options['fileEncoding'] = enc

            if self.chkDropTable.isChecked():
                options['overwrite'] = True

            outCrs = None
            if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked():
                targetSrid = int(self.editTargetSrid.text())
                outCrs = qgis.core.QgsCoordinateReferenceSystem(targetSrid)

            # update input layer crs
            if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked():
                sourceSrid = int(self.editSourceSrid.text())
                inCrs = qgis.core.QgsCoordinateReferenceSystem(sourceSrid)
                self.inLayer.setCrs(inCrs)

            # do the export!
            ret, errMsg = qgis.core.QgsVectorLayerImport.importLayer(self.inLayer, uri, providerName, outCrs, False,
                                                                     False, options)
        except Exception as e:
            ret = -1
            errMsg = unicode(e)

        finally:
            # restore input layer crs and encoding
            self.inLayer.setCrs(prevInCrs)
            # restore cursor
            QApplication.restoreOverrideCursor()

        if ret != 0:
            QMessageBox.warning(self, self.tr("Export to file"), self.tr("Error %d\n%s") % (ret, errMsg))
            return

        # create spatial index
        # if self.chkSpatialIndex.isEnabled() and self.chkSpatialIndex.isChecked():
        #       self.db.connector.createSpatialIndex( (schema, table), geom )

        QMessageBox.information(self, self.tr("Export to file"), self.tr("Export finished."))
        return QDialog.accept(self)
Example #52
0
 def accept(self):
     
     index = self.taskTreeWidget.tasktree.selectionModel().currentIndex()
     self.selectedTask = self.taskTreeWidget.tasktree.model().getItem(index).data(0)
     QDialog.accept(self)
Example #53
0
 def accept(self):
     """Reimplement Qt method"""
     for index in range(self.stack.count()):
         self.stack.widget(index).accept_changes()
     QDialog.accept(self)
Example #54
0
 def accept(self):
     if not self.running:
         s = QSettings("norBIT", "norGIS-ALKIS-Import")
         s.setValue("geometry", self.saveGeometry())
         QDialog.accept(self)
Example #55
0
 def accept(self):
     self.data = self.formwidget.get()
     QDialog.accept(self)
Example #56
0
    def accept(self):
        if self.printersCombo.count() == 0:
            return
        # get filenames from commandline args, if not then get from file chooser
        filenames = []
        if len(sys.argv) > 1:
            for each in sys.argv[1:]:
                if os.path.exists(each):
                    filenames.append(os.path.abspath(each))
        if filenames == []:
            files = QFileDialog.getOpenFileNames(self, 'Select Files to Print')
            if list(files) == []: return
            for each in files:
                filenames.append(each)

        ext = os.path.splitext(filenames[0])[1].lower()
        image_printing = ext == ".jpg" or ext == ".jpeg"

        # set printer specific options
        printer_name = self.printersCombo.currentText()
        run_command("lpoptions", ["-d", printer_name])
        printer = printer_from_name(printer_name)
        colormode_index = self.colorModeCombo.currentIndex()
        quality_index = self.qualityCombo.currentIndex()
        papertype_index = self.paperTypeCombo.currentIndex()
        papersize_index = self.paperSizeCombo.currentIndex()
        custom_size = [self.widthSpin.value(),
                       self.heightSpin.value()]  # in millimeter
        if not printer.setOptions(colormode_index, quality_index,
                                  papertype_index, papersize_index,
                                  custom_size):
            QMessageBox.critical(self, 'Error !',
                                 'Could not set printer options', 'Close')
            return QDialog.accept(self)
        # get printing options
        lp_args = ['-d', printer_name]

        # General options
        copies = self.copiesSpin.value()
        if copies > 1:
            lp_args += ['-n', str(copies), '-o', 'collate=true']
        lp_args += ['-o', 'brightness=%i' % self.brightnessSpin.value()]
        lp_args += ['-o', 'gamma=%i' % self.gammaSpin.value()]
        # Image printing options
        if image_printing:
            if self.pixelDensityBtn.isChecked():
                lp_args += [
                    '-o',
                    'ppi=%i' % self.ppiSpin.value(), '-o',
                    'natural-scaling=%i' % self.naturalScalingSpin.value()
                ]
            else:
                lp_args += ['-o', 'scaling=%i' % self.scalingSpin.value()]
            # position is always left aligned
            positions = ['top', 'center', 'bottom']
            lp_args += [
                '-o',
                'position=' + positions[self.positionCombo.currentIndex()]
            ]
        else:
            # Document printing options
            if not self.pageSetAll.isChecked():
                page_set = 'odd' if self.pageSetOdd.isChecked() else 'even'
                lp_args += ['-o', 'page-set=' + page_set]
            if self.pagerangeEdit.text() != "":
                lp_args += ['-o', 'page-ranges=' + self.pagerangeEdit.text()]
            # reverse pages so that first page will be on top
            if self.reverseBtn.isChecked() or self.pageSetAll.isChecked(
            ) and self.pagerangeEdit.text() == "":
                lp_args += ["-o", "outputorder=reverse"]
            # scale page to fit inside print margin
            if self.fitToPageBtn.isChecked():
                lp_args += ['-o', 'fit-to-page']
        # call printing command
        print('lp', ' '.join(lp_args))
        ret = QProcess.execute('lp', lp_args + ['--'] + filenames)
        if ret < 0:
            QMessageBox.critical(self, 'Error !',
                                 'Error : Could not execute lp', 'Close')
        self.saveSettings()
        QDialog.accept(self)
Example #57
0
    def accept(self):
        if self.mode == self.ASK_FOR_INPUT_MODE:
            # create the input layer (if not already done) and
            # update available options w/o changing the tablename!
            self.cboTable.blockSignals(True)
            table = self.cboTable.currentText()
            self.updateInputLayer()
            self.cboTable.setEditText(table)
            self.cboTable.blockSignals(False)

        # sanity checks
        if self.inLayer is None:
            QMessageBox.information(
                self, self.tr("Import to database"),
                self.tr("Input layer missing or not valid"))
            return

        if self.cboTable.currentText() == "":
            QMessageBox.information(self, self.tr("Import to database"),
                                    self.tr("Output table name is required"))
            return

        if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked():
            try:
                sourceSrid = self.editSourceSrid.text()
            except ValueError:
                QMessageBox.information(
                    self, self.tr("Import to database"),
                    self.tr("Invalid source srid: must be an integer"))
                return

        if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked():
            try:
                targetSrid = self.editTargetSrid.text()
            except ValueError:
                QMessageBox.information(
                    self, self.tr("Import to database"),
                    self.tr("Invalid target srid: must be an integer"))
                return

        # override cursor
        QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
        # store current input layer crs and encoding, so I can restore it
        prevInCrs = self.inLayer.crs()
        prevInEncoding = self.inLayer.dataProvider().encoding()

        try:
            schema = self.outUri.schema() if not self.cboSchema.isEnabled(
            ) else self.cboSchema.currentText()
            table = self.cboTable.currentText()

            # get pk and geom field names from the source layer or use the
            # ones defined by the user
            pk = self.outUri.keyColumn() if not self.chkPrimaryKey.isChecked(
            ) else self.editPrimaryKey.text()

            if self.inLayer.hasGeometryType() and self.chkGeomColumn.isEnabled(
            ):
                geom = self.outUri.geometryColumn(
                ) if not self.chkGeomColumn.isChecked(
                ) else self.editGeomColumn.text()
                geom = geom if geom != "" else self.default_geom
            else:
                geom = None

            # get output params, update output URI
            self.outUri.setDataSource(schema, table, geom, "", pk)
            uri = self.outUri.uri()

            providerName = self.db.dbplugin().providerName()

            options = {}
            if self.chkDropTable.isChecked():
                options['overwrite'] = True

            if self.chkSinglePart.isEnabled() and self.chkSinglePart.isChecked(
            ):
                options['forceSinglePartGeometryType'] = True

            outCrs = None
            if self.chkTargetSrid.isEnabled() and self.chkTargetSrid.isChecked(
            ):
                targetSrid = int(self.editTargetSrid.text())
                outCrs = qgis.core.QgsCoordinateReferenceSystem(targetSrid)

            # update input layer crs and encoding
            if self.chkSourceSrid.isEnabled() and self.chkSourceSrid.isChecked(
            ):
                sourceSrid = int(self.editSourceSrid.text())
                inCrs = qgis.core.QgsCoordinateReferenceSystem(sourceSrid)
                self.inLayer.setCrs(inCrs)

            if self.chkEncoding.isEnabled() and self.chkEncoding.isChecked():
                enc = self.cboEncoding.currentText()
                self.inLayer.setProviderEncoding(enc)

            # do the import!
            ret, errMsg = qgis.core.QgsVectorLayerImport.importLayer(
                self.inLayer, uri, providerName, outCrs, False, False, options)
        except Exception as e:
            ret = -1
            errMsg = unicode(e)

        finally:
            # restore input layer crs and encoding
            self.inLayer.setCrs(prevInCrs)
            self.inLayer.setProviderEncoding(prevInEncoding)
            # restore cursor
            QApplication.restoreOverrideCursor()

        if ret != 0:
            output = qgis.gui.QgsMessageViewer()
            output.setTitle(self.tr("Import to database"))
            output.setMessageAsPlainText(
                self.tr("Error %d\n%s") % (ret, errMsg))
            output.showMessage()
            return

        # create spatial index
        if self.chkSpatialIndex.isEnabled() and self.chkSpatialIndex.isChecked(
        ):
            self.db.connector.createSpatialIndex((schema, table), geom)

        QMessageBox.information(self, self.tr("Import to database"),
                                self.tr("Import was successful."))
        return QDialog.accept(self)
 def OK(self):
     self.btnApply_clicked()
     QDialog.accept(self)
Example #59
0
        else:
            if self.alg.descriptionFile is not None:
                try:
                    with open(self.alg.descriptionFile + '.help', 'w') as f:
                        json.dump(self.descriptions, f)
                except Exception, e:
                    QMessageBox.warning(
                        self, self.tr('Error saving help file'),
                        self.
                        tr('Help file could not be saved.\n'
                           'Check that you have permission to modify the help\n'
                           'file. You might not have permission if you are \n'
                           'editing an example model or script, since they \n'
                           'are stored on the installation folder'))

        QDialog.accept(self)

    def getHtml(self):
        s = self.tr('<h2>Algorithm description</h2>\n')
        s += '<p>' + self.getDescription(self.ALG_DESC) + '</p>\n'
        s += self.tr('<h2>Input parameters</h2>\n')
        for param in self.alg.parameters:
            s += '<h3>' + param.description + '</h3>\n'
            s += '<p>' + self.getDescription(param.name) + '</p>\n'
        s += self.tr('<h2>Outputs</h2>\n')
        for out in self.alg.outputs:
            s += '<h3>' + out.description + '</h3>\n'
            s += '<p>' + self.getDescription(out.name) + '</p>\n'
        return s

    def fillTree(self):
Example #60
0
 def accept(self):
     dynamic.set(self.cfg_key + '__un', unicode(self.gui_username.text()))
     dynamic.set(self.cfg_key + '__pw', unicode(self.gui_password.text()))
     QDialog.accept(self)