| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,270 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <ui version="4.0"> | ||
| <class>FieldsCalculator</class> | ||
| <widget class="QDialog" name="FieldsCalculator"> | ||
| <property name="geometry"> | ||
| <rect> | ||
| <x>0</x> | ||
| <y>0</y> | ||
| <width>681</width> | ||
| <height>681</height> | ||
| </rect> | ||
| </property> | ||
| <property name="windowTitle"> | ||
| <string>Field calculator</string> | ||
| </property> | ||
| <layout class="QGridLayout" name="gridLayout"> | ||
| <item row="2" column="0"> | ||
| <widget class="QGroupBox" name="mNewFieldGroupBox"> | ||
| <property name="sizePolicy"> | ||
| <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> | ||
| <horstretch>0</horstretch> | ||
| <verstretch>0</verstretch> | ||
| </sizepolicy> | ||
| </property> | ||
| <property name="title"> | ||
| <string>Create a new field</string> | ||
| </property> | ||
| <property name="flat"> | ||
| <bool>true</bool> | ||
| </property> | ||
| <property name="checkable"> | ||
| <bool>true</bool> | ||
| </property> | ||
| <property name="checked"> | ||
| <bool>true</bool> | ||
| </property> | ||
| <layout class="QGridLayout"> | ||
| <property name="sizeConstraint"> | ||
| <enum>QLayout::SetMinimumSize</enum> | ||
| </property> | ||
| <property name="leftMargin"> | ||
| <number>3</number> | ||
| </property> | ||
| <property name="topMargin"> | ||
| <number>3</number> | ||
| </property> | ||
| <property name="rightMargin"> | ||
| <number>3</number> | ||
| </property> | ||
| <property name="bottomMargin"> | ||
| <number>0</number> | ||
| </property> | ||
| <property name="verticalSpacing"> | ||
| <number>3</number> | ||
| </property> | ||
| <item row="0" column="0"> | ||
| <widget class="QLabel" name="mFieldNameLabel"> | ||
| <property name="text"> | ||
| <string>Output field name</string> | ||
| </property> | ||
| <property name="buddy"> | ||
| <cstring>mOutputFieldNameLineEdit</cstring> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="0" column="1" colspan="3"> | ||
| <widget class="QLineEdit" name="mOutputFieldNameLineEdit"/> | ||
| </item> | ||
| <item row="1" column="0"> | ||
| <widget class="QLabel" name="mOutputFieldTypeLabel"> | ||
| <property name="text"> | ||
| <string>Output field type</string> | ||
| </property> | ||
| <property name="buddy"> | ||
| <cstring>mOutputFieldTypeComboBox</cstring> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="1" column="1" colspan="3"> | ||
| <widget class="QComboBox" name="mOutputFieldTypeComboBox"/> | ||
| </item> | ||
| <item row="2" column="0"> | ||
| <widget class="QLabel" name="mOutputFieldWidthLabel"> | ||
| <property name="text"> | ||
| <string>Output field width</string> | ||
| </property> | ||
| <property name="buddy"> | ||
| <cstring>mOutputFieldWidthSpinBox</cstring> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="2" column="1"> | ||
| <widget class="QSpinBox" name="mOutputFieldWidthSpinBox"> | ||
| <property name="toolTip"> | ||
| <string>Width of complete output. For example 123,456 means 6 as field width.</string> | ||
| </property> | ||
| <property name="minimum"> | ||
| <number>0</number> | ||
| </property> | ||
| <property name="value"> | ||
| <number>15</number> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="2" column="2"> | ||
| <widget class="QLabel" name="mOutputFieldPrecisionLabel"> | ||
| <property name="text"> | ||
| <string>Precision</string> | ||
| </property> | ||
| <property name="buddy"> | ||
| <cstring>mOutputFieldPrecisionSpinBox</cstring> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="2" column="3"> | ||
| <widget class="QSpinBox" name="mOutputFieldPrecisionSpinBox"> | ||
| <property name="value"> | ||
| <number>2</number> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| </item> | ||
| <item row="5" column="0" colspan="2"> | ||
| <widget class="QDialogButtonBox" name="mButtonBox"> | ||
| <property name="sizePolicy"> | ||
| <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> | ||
| <horstretch>3</horstretch> | ||
| <verstretch>0</verstretch> | ||
| </sizepolicy> | ||
| </property> | ||
| <property name="orientation"> | ||
| <enum>Qt::Horizontal</enum> | ||
| </property> | ||
| <property name="standardButtons"> | ||
| <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="0" column="0" colspan="2"> | ||
| <layout class="QHBoxLayout" name="horizontalLayout"> | ||
| <item> | ||
| <widget class="QLabel" name="label"> | ||
| <property name="text"> | ||
| <string>Input layer</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QComboBox" name="cmbInputLayer"> | ||
| <property name="sizePolicy"> | ||
| <sizepolicy hsizetype="Expanding" vsizetype="Fixed"> | ||
| <horstretch>0</horstretch> | ||
| <verstretch>0</verstretch> | ||
| </sizepolicy> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </item> | ||
| <item row="2" column="1"> | ||
| <widget class="QGroupBox" name="mUpdateExistingGroupBox"> | ||
| <property name="title"> | ||
| <string>Update existing field</string> | ||
| </property> | ||
| <property name="flat"> | ||
| <bool>true</bool> | ||
| </property> | ||
| <property name="checkable"> | ||
| <bool>true</bool> | ||
| </property> | ||
| <property name="checked"> | ||
| <bool>false</bool> | ||
| </property> | ||
| <layout class="QVBoxLayout" name="verticalLayout"> | ||
| <item> | ||
| <widget class="QComboBox" name="mExistingFieldComboBox"/> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| </item> | ||
| <item row="3" column="0" colspan="2"> | ||
| <widget class="QgsExpressionBuilderWidget" name="builder" native="true"> | ||
| <property name="autoFillBackground"> | ||
| <bool>false</bool> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item row="1" column="0" colspan="2"> | ||
| <layout class="QHBoxLayout" name="horizontalLayout_2"> | ||
| <item> | ||
| <widget class="QLabel" name="label_2"> | ||
| <property name="text"> | ||
| <string>Output file</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| <item> | ||
| <widget class="QLineEdit" name="leOutputFile"/> | ||
| </item> | ||
| <item> | ||
| <widget class="QToolButton" name="btnBrowse"> | ||
| <property name="text"> | ||
| <string>...</string> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </item> | ||
| <item row="4" column="0" colspan="2"> | ||
| <widget class="QProgressBar" name="progressBar"> | ||
| <property name="value"> | ||
| <number>0</number> | ||
| </property> | ||
| </widget> | ||
| </item> | ||
| </layout> | ||
| </widget> | ||
| <customwidgets> | ||
| <customwidget> | ||
| <class>QgsExpressionBuilderWidget</class> | ||
| <extends>QWidget</extends> | ||
| <header>qgis.gui</header> | ||
| <container>1</container> | ||
| </customwidget> | ||
| </customwidgets> | ||
| <tabstops> | ||
| <tabstop>mOutputFieldNameLineEdit</tabstop> | ||
| <tabstop>mOutputFieldTypeComboBox</tabstop> | ||
| <tabstop>mOutputFieldWidthSpinBox</tabstop> | ||
| <tabstop>mOutputFieldPrecisionSpinBox</tabstop> | ||
| <tabstop>mButtonBox</tabstop> | ||
| </tabstops> | ||
| <resources/> | ||
| <connections> | ||
| <connection> | ||
| <sender>mButtonBox</sender> | ||
| <signal>accepted()</signal> | ||
| <receiver>FieldsCalculator</receiver> | ||
| <slot>accept()</slot> | ||
| <hints> | ||
| <hint type="sourcelabel"> | ||
| <x>679</x> | ||
| <y>559</y> | ||
| </hint> | ||
| <hint type="destinationlabel"> | ||
| <x>157</x> | ||
| <y>274</y> | ||
| </hint> | ||
| </hints> | ||
| </connection> | ||
| <connection> | ||
| <sender>mButtonBox</sender> | ||
| <signal>rejected()</signal> | ||
| <receiver>FieldsCalculator</receiver> | ||
| <slot>reject()</slot> | ||
| <hints> | ||
| <hint type="sourcelabel"> | ||
| <x>679</x> | ||
| <y>559</y> | ||
| </hint> | ||
| <hint type="destinationlabel"> | ||
| <x>286</x> | ||
| <y>274</y> | ||
| </hint> | ||
| </hints> | ||
| </connection> | ||
| </connections> | ||
| </ui> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,228 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| """ | ||
| *************************************************************************** | ||
| FieldsCalculatorDialog.py | ||
| --------------------- | ||
| Date : October 2013 | ||
| Copyright : (C) 2013 by Alexander Bruy | ||
| Email : alexander dot bruy at gmail dot com | ||
| *************************************************************************** | ||
| * * | ||
| * This program is free software; you can redistribute it and/or modify * | ||
| * it under the terms of the GNU General Public License as published by * | ||
| * the Free Software Foundation; either version 2 of the License, or * | ||
| * (at your option) any later version. * | ||
| * * | ||
| *************************************************************************** | ||
| """ | ||
|
|
||
| __author__ = 'Alexander Bruy' | ||
| __date__ = 'October 2013' | ||
| __copyright__ = '(C) 2013, Alexander Bruy' | ||
|
|
||
| # This will get replaced with a git SHA1 when you do a git archive | ||
|
|
||
| __revision__ = '$Format:%H$' | ||
|
|
||
| import os | ||
| import re | ||
|
|
||
| from PyQt4.QtCore import * | ||
| from PyQt4.QtGui import * | ||
| from qgis.core import * | ||
| from qgis.gui import * | ||
|
|
||
| from processing.core.ProcessingConfig import ProcessingConfig | ||
| from processing.core.ProcessingLog import ProcessingLog | ||
| from processing.core.GeoAlgorithmExecutionException import \ | ||
| GeoAlgorithmExecutionException | ||
| from processing.gui.UnthreadedAlgorithmExecutor import \ | ||
| UnthreadedAlgorithmExecutor | ||
| from processing.gui.Postprocessing import Postprocessing | ||
| from processing.tools import dataobjects | ||
|
|
||
| from ui_DlgFieldsCalculator import Ui_FieldsCalculator | ||
|
|
||
|
|
||
| class FieldsCalculatorDialog(QDialog, Ui_FieldsCalculator): | ||
| def __init__(self, alg): | ||
| QDialog.__init__(self) | ||
| self.setupUi( self ) | ||
|
|
||
| self.executed = False | ||
| self.alg = alg | ||
| self.layer = None | ||
|
|
||
| self.cmbInputLayer.currentIndexChanged.connect(self.updateLayer) | ||
| self.btnBrowse.clicked.connect(self.selectFile) | ||
| self.mNewFieldGroupBox.toggled.connect(self.toggleExistingGroup) | ||
| self.mUpdateExistingGroupBox.toggled.connect(self.toggleNewGroup) | ||
| self.mOutputFieldTypeComboBox.currentIndexChanged.connect( | ||
| self.setupSpinboxes) | ||
|
|
||
| # Default values for field width and precision | ||
| self.mOutputFieldWidthSpinBox.setValue(10) | ||
| self.mOutputFieldPrecisionSpinBox.setValue(3) | ||
|
|
||
| # Output is a shapefile, so limit maximum field name length | ||
| self.mOutputFieldNameLineEdit.setMaxLength(10) | ||
|
|
||
| self.manageGui() | ||
|
|
||
| def manageGui(self): | ||
| self.mOutputFieldTypeComboBox.blockSignals(True) | ||
| for t in self.alg.TYPE_NAMES: | ||
| self.mOutputFieldTypeComboBox.addItem(t) | ||
| self.mOutputFieldTypeComboBox.blockSignals(False) | ||
|
|
||
| self.cmbInputLayer.blockSignals(True) | ||
| layers = dataobjects.getVectorLayers() | ||
| for layer in layers: | ||
| self.cmbInputLayer.addItem(layer.name()) | ||
| self.cmbInputLayer.blockSignals(False) | ||
|
|
||
| self.updateLayer() | ||
|
|
||
| def updateLayer(self): | ||
| self.layer = dataobjects.getObject(self.cmbInputLayer.currentText()) | ||
|
|
||
| self.builder.setLayer(self.layer) | ||
| self.builder.loadFieldNames() | ||
|
|
||
| self.populateFields() | ||
| #populateOutputFieldTypes() | ||
|
|
||
| def setupSpinboxes(self, index): | ||
| if index != 0: | ||
| self.mOutputFieldPrecisionSpinBox.setEnabled(False) | ||
| else: | ||
| self.mOutputFieldPrecisionSpinBox.setEnabled(True) | ||
|
|
||
| if index == 0: | ||
| self.mOutputFieldWidthSpinBox.setRange(1, 20) | ||
| self.mOutputFieldWidthSpinBox.setValue(10) | ||
| self.mOutputFieldPrecisionSpinBox.setRange(0, 15) | ||
| self.mOutputFieldPrecisionSpinBox.setValue(3) | ||
| elif index == 1: | ||
| self.mOutputFieldWidthSpinBox.setRange(1, 10) | ||
| self.mOutputFieldWidthSpinBox.setValue(10) | ||
| elif index == 2: | ||
| self.mOutputFieldWidthSpinBox.setRange(1, 255) | ||
| self.mOutputFieldWidthSpinBox.setValue(80) | ||
| else: | ||
| self.mOutputFieldWidthSpinBox.setEnabled(False) | ||
| self.mOutputFieldPrecisionSpinBox.setEnabled(False) | ||
|
|
||
| def selectFile(self): | ||
| output = self.alg.getOutputFromName('OUTPUT_LAYER') | ||
| fileFilter = output.getFileFilter(self.alg) | ||
|
|
||
| settings = QSettings() | ||
| if settings.contains('/Processing/LastOutputPath'): | ||
| path = settings.value('/Processing/LastOutputPath') | ||
| else: | ||
| path = ProcessingConfig.getSetting(ProcessingConfig.OUTPUT_FOLDER) | ||
| lastEncoding = settings.value('/Processing/encoding', 'System') | ||
| fileDialog = QgsEncodingFileDialog(self, | ||
| self.tr('Save file'), | ||
| path, | ||
| fileFilter, | ||
| lastEncoding) | ||
| fileDialog.setFileMode(QFileDialog.AnyFile) | ||
| fileDialog.setAcceptMode(QFileDialog.AcceptSave) | ||
| fileDialog.setConfirmOverwrite(True) | ||
| if fileDialog.exec_() == QDialog.Accepted: | ||
| files = fileDialog.selectedFiles() | ||
| encoding = unicode(fileDialog.encoding()) | ||
| output.encoding = encoding | ||
| filename = unicode(files[0]) | ||
| selectedFileFilter = unicode(fileDialog.selectedNameFilter()) | ||
| if not filename.lower().endswith( | ||
| tuple(re.findall("\*(\.[a-z]{1,5})", fileFilter))): | ||
| ext = re.search("\*(\.[a-z]{1,5})", selectedFileFilter) | ||
| if ext: | ||
| filename = filename + ext.group(1) | ||
| self.leOutputFile.setText(filename) | ||
| settings.setValue('/Processing/LastOutputPath', | ||
| os.path.dirname(filename)) | ||
| settings.setValue('/Processing/encoding', encoding) | ||
|
|
||
| def toggleExistingGroup(self, toggled): | ||
| self.mUpdateExistingGroupBox.setChecked(not toggled) | ||
|
|
||
| def toggleNewGroup(self, toggled): | ||
| self.mNewFieldGroupBox.setChecked(not toggled) | ||
|
|
||
| def populateFields(self): | ||
| if self.layer is None: | ||
| return | ||
|
|
||
| fields = self.layer.pendingFields() | ||
| for f in fields: | ||
| self.mExistingFieldComboBox.addItem(f.name()) | ||
|
|
||
| def setParamValues(self): | ||
| if self.mUpdateExistingGroupBox.isChecked(): | ||
| fieldName = self.mExistingFieldComboBox.currentText() | ||
| else: | ||
| fieldName = self.mOutputFieldNameLineEdit.text() | ||
|
|
||
| layer = dataobjects.getObjectFromName(self.cmbInputLayer.currentText()) | ||
|
|
||
| self.alg.setParameterValue('INPUT_LAYER', layer) | ||
| self.alg.setParameterValue('FIELD_NAME', fieldName) | ||
| self.alg.setParameterValue('FIELD_TYPE', | ||
| self.mOutputFieldTypeComboBox.currentIndex()) | ||
| self.alg.setParameterValue('FIELD_LENGTH', | ||
| self.mOutputFieldWidthSpinBox.value()) | ||
| self.alg.setParameterValue('FIELD_PRECISION', | ||
| self.mOutputFieldPrecisionSpinBox.value()) | ||
| self.alg.setParameterValue('NEW_FIELD', | ||
| self.mNewFieldGroupBox.isChecked()) | ||
| self.alg.setParameterValue('FORMULA', self.builder.expressionText()) | ||
| self.alg.setOutputValue('OUTPUT_LAYER', | ||
| self.leOutputFile.text()) | ||
| return True | ||
|
|
||
| def accept(self): | ||
| keepOpen = ProcessingConfig.getSetting( | ||
| ProcessingConfig.KEEP_DIALOG_OPEN) | ||
| try: | ||
| if self.setParamValues(): | ||
| QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) | ||
| ProcessingLog.addToLog(ProcessingLog.LOG_ALGORITHM, | ||
| self.alg.getAsCommand()) | ||
| ret = UnthreadedAlgorithmExecutor.runalg(self.alg, self) | ||
| QApplication.restoreOverrideCursor() | ||
| if ret: | ||
| Postprocessing.handleAlgorithmResults(self.alg, | ||
| self, | ||
| not keepOpen) | ||
| self.executed = True | ||
| QDialog.reject(self) | ||
| else: | ||
| QMessageBox.critical(self, | ||
| self.tr('Unable to execute algorithm'), | ||
| self.tr('Wrong or missing parameter ' | ||
| 'values')) | ||
| return | ||
| except GeoAlgorithmExecutionException, e: | ||
| QApplication.restoreOverrideCursor() | ||
| QMessageBox.critical(self, "Error",e.msg) | ||
| ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, e.msg) | ||
| self.executed = False | ||
| QDialog.reject(self) | ||
|
|
||
| def reject(self): | ||
| self.executed = False | ||
| QDialog.reject(self) | ||
|
|
||
| def setPercentage(self, i): | ||
| self.progressBar.setValue(i) | ||
|
|
||
| def setText(self, text): | ||
| pass | ||
|
|
||
| def error(self, text): | ||
| ProcessingLog.addToLog(ProcessingLog.LOG_ERROR, text) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| # -*- coding: utf-8 -*- | ||
|
|
||
| # Form implementation generated from reading ui file 'python/plugins/processing/algs/ui/DlgFieldsCalculator.ui' | ||
| # | ||
| # Created: Thu Oct 24 16:06:48 2013 | ||
| # by: PyQt4 UI code generator 4.9.1 | ||
| # | ||
| # WARNING! All changes made in this file will be lost! | ||
|
|
||
| from PyQt4 import QtCore, QtGui | ||
|
|
||
| try: | ||
| _fromUtf8 = QtCore.QString.fromUtf8 | ||
| except AttributeError: | ||
| _fromUtf8 = lambda s: s | ||
|
|
||
| class Ui_FieldsCalculator(object): | ||
| def setupUi(self, FieldsCalculator): | ||
| FieldsCalculator.setObjectName(_fromUtf8("FieldsCalculator")) | ||
| FieldsCalculator.resize(681, 681) | ||
| self.gridLayout = QtGui.QGridLayout(FieldsCalculator) | ||
| self.gridLayout.setObjectName(_fromUtf8("gridLayout")) | ||
| self.mNewFieldGroupBox = QtGui.QGroupBox(FieldsCalculator) | ||
| sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) | ||
| sizePolicy.setHorizontalStretch(0) | ||
| sizePolicy.setVerticalStretch(0) | ||
| sizePolicy.setHeightForWidth(self.mNewFieldGroupBox.sizePolicy().hasHeightForWidth()) | ||
| self.mNewFieldGroupBox.setSizePolicy(sizePolicy) | ||
| self.mNewFieldGroupBox.setFlat(True) | ||
| self.mNewFieldGroupBox.setCheckable(True) | ||
| self.mNewFieldGroupBox.setChecked(True) | ||
| self.mNewFieldGroupBox.setObjectName(_fromUtf8("mNewFieldGroupBox")) | ||
| self.gridlayout = QtGui.QGridLayout(self.mNewFieldGroupBox) | ||
| self.gridlayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize) | ||
| self.gridlayout.setContentsMargins(3, 3, 3, 0) | ||
| self.gridlayout.setVerticalSpacing(3) | ||
| self.gridlayout.setObjectName(_fromUtf8("gridlayout")) | ||
| self.mFieldNameLabel = QtGui.QLabel(self.mNewFieldGroupBox) | ||
| self.mFieldNameLabel.setObjectName(_fromUtf8("mFieldNameLabel")) | ||
| self.gridlayout.addWidget(self.mFieldNameLabel, 0, 0, 1, 1) | ||
| self.mOutputFieldNameLineEdit = QtGui.QLineEdit(self.mNewFieldGroupBox) | ||
| self.mOutputFieldNameLineEdit.setObjectName(_fromUtf8("mOutputFieldNameLineEdit")) | ||
| self.gridlayout.addWidget(self.mOutputFieldNameLineEdit, 0, 1, 1, 3) | ||
| self.mOutputFieldTypeLabel = QtGui.QLabel(self.mNewFieldGroupBox) | ||
| self.mOutputFieldTypeLabel.setObjectName(_fromUtf8("mOutputFieldTypeLabel")) | ||
| self.gridlayout.addWidget(self.mOutputFieldTypeLabel, 1, 0, 1, 1) | ||
| self.mOutputFieldTypeComboBox = QtGui.QComboBox(self.mNewFieldGroupBox) | ||
| self.mOutputFieldTypeComboBox.setObjectName(_fromUtf8("mOutputFieldTypeComboBox")) | ||
| self.gridlayout.addWidget(self.mOutputFieldTypeComboBox, 1, 1, 1, 3) | ||
| self.mOutputFieldWidthLabel = QtGui.QLabel(self.mNewFieldGroupBox) | ||
| self.mOutputFieldWidthLabel.setObjectName(_fromUtf8("mOutputFieldWidthLabel")) | ||
| self.gridlayout.addWidget(self.mOutputFieldWidthLabel, 2, 0, 1, 1) | ||
| self.mOutputFieldWidthSpinBox = QtGui.QSpinBox(self.mNewFieldGroupBox) | ||
| self.mOutputFieldWidthSpinBox.setMinimum(0) | ||
| self.mOutputFieldWidthSpinBox.setProperty("value", 15) | ||
| self.mOutputFieldWidthSpinBox.setObjectName(_fromUtf8("mOutputFieldWidthSpinBox")) | ||
| self.gridlayout.addWidget(self.mOutputFieldWidthSpinBox, 2, 1, 1, 1) | ||
| self.mOutputFieldPrecisionLabel = QtGui.QLabel(self.mNewFieldGroupBox) | ||
| self.mOutputFieldPrecisionLabel.setObjectName(_fromUtf8("mOutputFieldPrecisionLabel")) | ||
| self.gridlayout.addWidget(self.mOutputFieldPrecisionLabel, 2, 2, 1, 1) | ||
| self.mOutputFieldPrecisionSpinBox = QtGui.QSpinBox(self.mNewFieldGroupBox) | ||
| self.mOutputFieldPrecisionSpinBox.setProperty("value", 2) | ||
| self.mOutputFieldPrecisionSpinBox.setObjectName(_fromUtf8("mOutputFieldPrecisionSpinBox")) | ||
| self.gridlayout.addWidget(self.mOutputFieldPrecisionSpinBox, 2, 3, 1, 1) | ||
| self.gridLayout.addWidget(self.mNewFieldGroupBox, 2, 0, 1, 1) | ||
| self.mButtonBox = QtGui.QDialogButtonBox(FieldsCalculator) | ||
| sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) | ||
| sizePolicy.setHorizontalStretch(3) | ||
| sizePolicy.setVerticalStretch(0) | ||
| sizePolicy.setHeightForWidth(self.mButtonBox.sizePolicy().hasHeightForWidth()) | ||
| self.mButtonBox.setSizePolicy(sizePolicy) | ||
| self.mButtonBox.setOrientation(QtCore.Qt.Horizontal) | ||
| self.mButtonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) | ||
| self.mButtonBox.setObjectName(_fromUtf8("mButtonBox")) | ||
| self.gridLayout.addWidget(self.mButtonBox, 5, 0, 1, 2) | ||
| self.horizontalLayout = QtGui.QHBoxLayout() | ||
| self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) | ||
| self.label = QtGui.QLabel(FieldsCalculator) | ||
| self.label.setObjectName(_fromUtf8("label")) | ||
| self.horizontalLayout.addWidget(self.label) | ||
| self.cmbInputLayer = QtGui.QComboBox(FieldsCalculator) | ||
| sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Fixed) | ||
| sizePolicy.setHorizontalStretch(0) | ||
| sizePolicy.setVerticalStretch(0) | ||
| sizePolicy.setHeightForWidth(self.cmbInputLayer.sizePolicy().hasHeightForWidth()) | ||
| self.cmbInputLayer.setSizePolicy(sizePolicy) | ||
| self.cmbInputLayer.setObjectName(_fromUtf8("cmbInputLayer")) | ||
| self.horizontalLayout.addWidget(self.cmbInputLayer) | ||
| self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 2) | ||
| self.mUpdateExistingGroupBox = QtGui.QGroupBox(FieldsCalculator) | ||
| self.mUpdateExistingGroupBox.setFlat(True) | ||
| self.mUpdateExistingGroupBox.setCheckable(True) | ||
| self.mUpdateExistingGroupBox.setChecked(False) | ||
| self.mUpdateExistingGroupBox.setObjectName(_fromUtf8("mUpdateExistingGroupBox")) | ||
| self.verticalLayout = QtGui.QVBoxLayout(self.mUpdateExistingGroupBox) | ||
| self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) | ||
| self.mExistingFieldComboBox = QtGui.QComboBox(self.mUpdateExistingGroupBox) | ||
| self.mExistingFieldComboBox.setObjectName(_fromUtf8("mExistingFieldComboBox")) | ||
| self.verticalLayout.addWidget(self.mExistingFieldComboBox) | ||
| self.gridLayout.addWidget(self.mUpdateExistingGroupBox, 2, 1, 1, 1) | ||
| self.builder = QgsExpressionBuilderWidget(FieldsCalculator) | ||
| self.builder.setAutoFillBackground(False) | ||
| self.builder.setObjectName(_fromUtf8("builder")) | ||
| self.gridLayout.addWidget(self.builder, 3, 0, 1, 2) | ||
| self.horizontalLayout_2 = QtGui.QHBoxLayout() | ||
| self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) | ||
| self.label_2 = QtGui.QLabel(FieldsCalculator) | ||
| self.label_2.setObjectName(_fromUtf8("label_2")) | ||
| self.horizontalLayout_2.addWidget(self.label_2) | ||
| self.leOutputFile = QtGui.QLineEdit(FieldsCalculator) | ||
| self.leOutputFile.setObjectName(_fromUtf8("leOutputFile")) | ||
| self.horizontalLayout_2.addWidget(self.leOutputFile) | ||
| self.btnBrowse = QtGui.QToolButton(FieldsCalculator) | ||
| self.btnBrowse.setObjectName(_fromUtf8("btnBrowse")) | ||
| self.horizontalLayout_2.addWidget(self.btnBrowse) | ||
| self.gridLayout.addLayout(self.horizontalLayout_2, 1, 0, 1, 2) | ||
| self.progressBar = QtGui.QProgressBar(FieldsCalculator) | ||
| self.progressBar.setProperty("value", 0) | ||
| self.progressBar.setObjectName(_fromUtf8("progressBar")) | ||
| self.gridLayout.addWidget(self.progressBar, 4, 0, 1, 2) | ||
| self.mFieldNameLabel.setBuddy(self.mOutputFieldNameLineEdit) | ||
| self.mOutputFieldTypeLabel.setBuddy(self.mOutputFieldTypeComboBox) | ||
| self.mOutputFieldWidthLabel.setBuddy(self.mOutputFieldWidthSpinBox) | ||
| self.mOutputFieldPrecisionLabel.setBuddy(self.mOutputFieldPrecisionSpinBox) | ||
|
|
||
| self.retranslateUi(FieldsCalculator) | ||
| QtCore.QObject.connect(self.mButtonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), FieldsCalculator.accept) | ||
| QtCore.QObject.connect(self.mButtonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), FieldsCalculator.reject) | ||
| QtCore.QMetaObject.connectSlotsByName(FieldsCalculator) | ||
| FieldsCalculator.setTabOrder(self.mOutputFieldNameLineEdit, self.mOutputFieldTypeComboBox) | ||
| FieldsCalculator.setTabOrder(self.mOutputFieldTypeComboBox, self.mOutputFieldWidthSpinBox) | ||
| FieldsCalculator.setTabOrder(self.mOutputFieldWidthSpinBox, self.mOutputFieldPrecisionSpinBox) | ||
| FieldsCalculator.setTabOrder(self.mOutputFieldPrecisionSpinBox, self.mButtonBox) | ||
|
|
||
| def retranslateUi(self, FieldsCalculator): | ||
| FieldsCalculator.setWindowTitle(QtGui.QApplication.translate("FieldsCalculator", "Field calculator", None, QtGui.QApplication.UnicodeUTF8)) | ||
| self.mNewFieldGroupBox.setTitle(QtGui.QApplication.translate("FieldsCalculator", "Create a new field", None, QtGui.QApplication.UnicodeUTF8)) | ||
| self.mFieldNameLabel.setText(QtGui.QApplication.translate("FieldsCalculator", "Output field name", None, QtGui.QApplication.UnicodeUTF8)) | ||
| self.mOutputFieldTypeLabel.setText(QtGui.QApplication.translate("FieldsCalculator", "Output field type", None, QtGui.QApplication.UnicodeUTF8)) | ||
| self.mOutputFieldWidthLabel.setText(QtGui.QApplication.translate("FieldsCalculator", "Output field width", None, QtGui.QApplication.UnicodeUTF8)) | ||
| self.mOutputFieldWidthSpinBox.setToolTip(QtGui.QApplication.translate("FieldsCalculator", "Width of complete output. For example 123,456 means 6 as field width.", None, QtGui.QApplication.UnicodeUTF8)) | ||
| self.mOutputFieldPrecisionLabel.setText(QtGui.QApplication.translate("FieldsCalculator", "Precision", None, QtGui.QApplication.UnicodeUTF8)) | ||
| self.label.setText(QtGui.QApplication.translate("FieldsCalculator", "Input layer", None, QtGui.QApplication.UnicodeUTF8)) | ||
| self.mUpdateExistingGroupBox.setTitle(QtGui.QApplication.translate("FieldsCalculator", "Update existing field", None, QtGui.QApplication.UnicodeUTF8)) | ||
| self.label_2.setText(QtGui.QApplication.translate("FieldsCalculator", "Output file", None, QtGui.QApplication.UnicodeUTF8)) | ||
| self.btnBrowse.setText(QtGui.QApplication.translate("FieldsCalculator", "...", None, QtGui.QApplication.UnicodeUTF8)) | ||
|
|
||
| from qgis.gui import QgsExpressionBuilderWidget |