mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-25 00:03:06 -04:00
Qt 5.2 has QComboBox::currentData
This commit is contained in:
parent
43faf338f3
commit
a61b9222de
@ -73,7 +73,7 @@ class DlgExportVector(QDialog, Ui_Dialog):
|
|||||||
lastUsedDir = settings.value(self.lastUsedVectorDirSettingsKey, ".")
|
lastUsedDir = settings.value(self.lastUsedVectorDirSettingsKey, ".")
|
||||||
|
|
||||||
# get selected filter
|
# get selected filter
|
||||||
selectedFilter = self.cboFileFormat.itemData(self.cboFileFormat.currentIndex())
|
selectedFilter = self.cboFileFormat.currentData()
|
||||||
|
|
||||||
# ask for a filename
|
# ask for a filename
|
||||||
filename, filter = QFileDialog.getSaveFileName(self, self.tr("Choose where to save the file"), lastUsedDir,
|
filename, filter = QFileDialog.getSaveFileName(self, self.tr("Choose where to save the file"), lastUsedDir,
|
||||||
@ -152,7 +152,7 @@ class DlgExportVector(QDialog, Ui_Dialog):
|
|||||||
options = {}
|
options = {}
|
||||||
|
|
||||||
# set the OGR driver will be used
|
# set the OGR driver will be used
|
||||||
driverName = self.cboFileFormat.itemData(self.cboFileFormat.currentIndex())
|
driverName = self.cboFileFormat.currentData()
|
||||||
options['driverName'] = driverName
|
options['driverName'] = driverName
|
||||||
|
|
||||||
# set the output file encoding
|
# set the output file encoding
|
||||||
|
@ -31,7 +31,7 @@ import os
|
|||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
|
||||||
from qgis.PyQt import uic
|
from qgis.PyQt import uic
|
||||||
from qgis.PyQt.QtGui import QBrush, QIcon
|
from qgis.PyQt.QtGui import QBrush
|
||||||
from qgis.PyQt.QtWidgets import QComboBox, QHeaderView, QLineEdit, QSpacerItem, QMessageBox, QSpinBox, QStyledItemDelegate
|
from qgis.PyQt.QtWidgets import QComboBox, QHeaderView, QLineEdit, QSpacerItem, QMessageBox, QSpinBox, QStyledItemDelegate
|
||||||
from qgis.PyQt.QtCore import QItemSelectionModel, QAbstractTableModel, QModelIndex, QVariant, Qt, pyqtSlot
|
from qgis.PyQt.QtCore import QItemSelectionModel, QAbstractTableModel, QModelIndex, QVariant, Qt, pyqtSlot
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ class FieldDelegate(QStyledItemDelegate):
|
|||||||
|
|
||||||
fieldType = FieldsMappingModel.columns[column]['type']
|
fieldType = FieldsMappingModel.columns[column]['type']
|
||||||
if fieldType == QVariant.Type:
|
if fieldType == QVariant.Type:
|
||||||
value = editor.itemData(editor.currentIndex())
|
value = editor.currentData()
|
||||||
if value is None:
|
if value is None:
|
||||||
value = QVariant.Invalid
|
value = QVariant.Invalid
|
||||||
model.setData(index, value)
|
model.setData(index, value)
|
||||||
@ -480,7 +480,7 @@ class FieldsMappingPanel(BASE, WIDGET):
|
|||||||
|
|
||||||
@pyqtSlot(bool, name='on_loadLayerFieldsButton_clicked')
|
@pyqtSlot(bool, name='on_loadLayerFieldsButton_clicked')
|
||||||
def on_loadLayerFieldsButton_clicked(self, checked=False):
|
def on_loadLayerFieldsButton_clicked(self, checked=False):
|
||||||
layer = self.layerCombo.itemData(self.layerCombo.currentIndex())
|
layer = self.layerCombo.currentData()
|
||||||
if layer is None:
|
if layer is None:
|
||||||
return
|
return
|
||||||
self.model.loadLayerFields(layer)
|
self.model.loadLayerFields(layer)
|
||||||
|
@ -34,7 +34,7 @@ import locale
|
|||||||
import os
|
import os
|
||||||
from functools import cmp_to_key
|
from functools import cmp_to_key
|
||||||
|
|
||||||
from qgis.core import QgsCoordinateReferenceSystem, QgsVectorLayer, QgsApplication, QgsWkbTypes, QgsMapLayerProxyModel
|
from qgis.core import QgsCoordinateReferenceSystem, QgsApplication, QgsWkbTypes, QgsMapLayerProxyModel
|
||||||
from qgis.PyQt.QtWidgets import QCheckBox, QComboBox, QLineEdit, QPlainTextEdit, QWidget, QHBoxLayout, QToolButton, QFileDialog
|
from qgis.PyQt.QtWidgets import QCheckBox, QComboBox, QLineEdit, QPlainTextEdit, QWidget, QHBoxLayout, QToolButton, QFileDialog
|
||||||
from qgis.gui import (QgsFieldExpressionWidget,
|
from qgis.gui import (QgsFieldExpressionWidget,
|
||||||
QgsExpressionLineEdit,
|
QgsExpressionLineEdit,
|
||||||
@ -121,7 +121,7 @@ class WidgetWrapper(QObject):
|
|||||||
if validator is not None and not validator(v):
|
if validator is not None and not validator(v):
|
||||||
raise InvalidParameterValue()
|
raise InvalidParameterValue()
|
||||||
return v
|
return v
|
||||||
return combobox.itemData(combobox.currentIndex())
|
return combobox.currentData()
|
||||||
|
|
||||||
def createWidget(self):
|
def createWidget(self):
|
||||||
pass
|
pass
|
||||||
@ -352,7 +352,7 @@ class ExtentWidgetWrapper(WidgetWrapper):
|
|||||||
raise InvalidParameterValue()
|
raise InvalidParameterValue()
|
||||||
return s
|
return s
|
||||||
else:
|
else:
|
||||||
return self.widget.itemData(self.widget.currentIndex())
|
return self.widget.currentData()
|
||||||
|
|
||||||
|
|
||||||
class PointWidgetWrapper(WidgetWrapper):
|
class PointWidgetWrapper(WidgetWrapper):
|
||||||
@ -397,7 +397,7 @@ class PointWidgetWrapper(WidgetWrapper):
|
|||||||
raise InvalidParameterValue()
|
raise InvalidParameterValue()
|
||||||
return s
|
return s
|
||||||
else:
|
else:
|
||||||
return self.widget.itemData(self.widget.currentIndex())
|
return self.widget.currentData()
|
||||||
|
|
||||||
|
|
||||||
class FileWidgetWrapper(WidgetWrapper):
|
class FileWidgetWrapper(WidgetWrapper):
|
||||||
|
@ -33,7 +33,6 @@ from qgis.core import QgsCoordinateReferenceSystem
|
|||||||
from qgis.PyQt.QtCore import Qt
|
from qgis.PyQt.QtCore import Qt
|
||||||
from qgis.PyQt.QtWidgets import (QDialog,
|
from qgis.PyQt.QtWidgets import (QDialog,
|
||||||
QVBoxLayout,
|
QVBoxLayout,
|
||||||
QHBoxLayout,
|
|
||||||
QLabel,
|
QLabel,
|
||||||
QLineEdit,
|
QLineEdit,
|
||||||
QComboBox,
|
QComboBox,
|
||||||
@ -265,8 +264,8 @@ class ModelerParameterDefinitionDialog(QDialog):
|
|||||||
|
|
||||||
self.buttonBox = QDialogButtonBox(self)
|
self.buttonBox = QDialogButtonBox(self)
|
||||||
self.buttonBox.setOrientation(Qt.Horizontal)
|
self.buttonBox.setOrientation(Qt.Horizontal)
|
||||||
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel
|
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel |
|
||||||
| QDialogButtonBox.Ok)
|
QDialogButtonBox.Ok)
|
||||||
self.buttonBox.setObjectName('buttonBox')
|
self.buttonBox.setObjectName('buttonBox')
|
||||||
self.buttonBox.accepted.connect(self.okPressed)
|
self.buttonBox.accepted.connect(self.okPressed)
|
||||||
self.buttonBox.rejected.connect(self.cancelPressed)
|
self.buttonBox.rejected.connect(self.cancelPressed)
|
||||||
@ -292,17 +291,17 @@ class ModelerParameterDefinitionDialog(QDialog):
|
|||||||
name = safeName.lower() + str(i)
|
name = safeName.lower() + str(i)
|
||||||
else:
|
else:
|
||||||
name = self.param.name
|
name = self.param.name
|
||||||
if (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN
|
if (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN or
|
||||||
or isinstance(self.param, ParameterBoolean)):
|
isinstance(self.param, ParameterBoolean)):
|
||||||
self.param = ParameterBoolean(name, description, self.state.isChecked())
|
self.param = ParameterBoolean(name, description, self.state.isChecked())
|
||||||
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD
|
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD or
|
||||||
or isinstance(self.param, ParameterTableField)):
|
isinstance(self.param, ParameterTableField)):
|
||||||
if self.parentCombo.currentIndex() < 0:
|
if self.parentCombo.currentIndex() < 0:
|
||||||
QMessageBox.warning(self, self.tr('Unable to define parameter'),
|
QMessageBox.warning(self, self.tr('Unable to define parameter'),
|
||||||
self.tr('Wrong or missing parameter values'))
|
self.tr('Wrong or missing parameter values'))
|
||||||
return
|
return
|
||||||
parent = self.parentCombo.itemData(self.parentCombo.currentIndex())
|
parent = self.parentCombo.currentData()
|
||||||
datatype = self.datatypeCombo.itemData(self.datatypeCombo.currentIndex())
|
datatype = self.datatypeCombo.currentData()
|
||||||
self.param = ParameterTableField(name, description, parent, datatype, multiple=self.multipleCheck.isChecked())
|
self.param = ParameterTableField(name, description, parent, datatype, multiple=self.multipleCheck.isChecked())
|
||||||
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_RASTER or
|
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_RASTER or
|
||||||
isinstance(self.param, ParameterRaster)):
|
isinstance(self.param, ParameterRaster)):
|
||||||
@ -343,7 +342,7 @@ class ModelerParameterDefinitionDialog(QDialog):
|
|||||||
return
|
return
|
||||||
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_EXPRESSION or
|
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_EXPRESSION or
|
||||||
isinstance(self.param, ParameterExpression)):
|
isinstance(self.param, ParameterExpression)):
|
||||||
parent = self.parentCombo.itemData(self.parentCombo.currentIndex())
|
parent = self.parentCombo.currentData()
|
||||||
self.param = ParameterExpression(name, description,
|
self.param = ParameterExpression(name, description,
|
||||||
default=str(self.defaultEdit.expression()),
|
default=str(self.defaultEdit.expression()),
|
||||||
parent_layer=parent)
|
parent_layer=parent)
|
||||||
|
@ -61,7 +61,7 @@ class MultilineTextPanel(QWidget):
|
|||||||
if self.combo.currentIndex() == 0:
|
if self.combo.currentIndex() == 0:
|
||||||
return str(self.textBox.toPlainText())
|
return str(self.textBox.toPlainText())
|
||||||
else:
|
else:
|
||||||
return self.combo.itemData(self.combo.currentIndex())
|
return self.combo.currentData()
|
||||||
|
|
||||||
def setValue(self, value):
|
def setValue(self, value):
|
||||||
items = [self.combo.itemData(i) for i in range(1, self.combo.count())]
|
items = [self.combo.itemData(i) for i in range(1, self.combo.count())]
|
||||||
|
@ -65,12 +65,12 @@ class APP_EXPORT QgsFieldCalculator: public QDialog, private Ui::QgsFieldCalcula
|
|||||||
inline QgsField fieldDefinition()
|
inline QgsField fieldDefinition()
|
||||||
{
|
{
|
||||||
return QgsField( mOutputFieldNameLineEdit->text(),
|
return QgsField( mOutputFieldNameLineEdit->text(),
|
||||||
static_cast< QVariant::Type >( mOutputFieldTypeComboBox->itemData( mOutputFieldTypeComboBox->currentIndex(), Qt::UserRole ).toInt() ),
|
static_cast< QVariant::Type >( mOutputFieldTypeComboBox->currentData( Qt::UserRole ).toInt() ),
|
||||||
mOutputFieldTypeComboBox->itemData( mOutputFieldTypeComboBox->currentIndex(), Qt::UserRole + 1 ).toString(),
|
mOutputFieldTypeComboBox->currentData( Qt::UserRole + 1 ).toString(),
|
||||||
mOutputFieldWidthSpinBox->value(),
|
mOutputFieldWidthSpinBox->value(),
|
||||||
mOutputFieldPrecisionSpinBox->value(),
|
mOutputFieldPrecisionSpinBox->value(),
|
||||||
QString(),
|
QString(),
|
||||||
static_cast< QVariant::Type >( mOutputFieldTypeComboBox->itemData( mOutputFieldTypeComboBox->currentIndex(), Qt::UserRole + 6 ).toInt() )
|
static_cast< QVariant::Type >( mOutputFieldTypeComboBox->currentData( Qt::UserRole + 6 ).toInt() )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ QgsAuthCertTrustPolicyComboBox::QgsAuthCertTrustPolicyComboBox( QWidget *parent,
|
|||||||
|
|
||||||
QgsAuthCertUtils::CertTrustPolicy QgsAuthCertTrustPolicyComboBox::trustPolicy()
|
QgsAuthCertUtils::CertTrustPolicy QgsAuthCertTrustPolicyComboBox::trustPolicy()
|
||||||
{
|
{
|
||||||
return ( QgsAuthCertUtils::CertTrustPolicy )itemData( currentIndex() ).toInt();
|
return ( QgsAuthCertUtils::CertTrustPolicy )currentData().toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
QgsAuthCertUtils::CertTrustPolicy QgsAuthCertTrustPolicyComboBox::trustPolicyForIndex( int indx )
|
QgsAuthCertUtils::CertTrustPolicy QgsAuthCertTrustPolicyComboBox::trustPolicyForIndex( int indx )
|
||||||
|
@ -37,7 +37,7 @@ QgsEffectDrawModeComboBox::QgsEffectDrawModeComboBox( QWidget* parent )
|
|||||||
|
|
||||||
QgsPaintEffect::DrawMode QgsEffectDrawModeComboBox::drawMode() const
|
QgsPaintEffect::DrawMode QgsEffectDrawModeComboBox::drawMode() const
|
||||||
{
|
{
|
||||||
return ( QgsPaintEffect::DrawMode ) itemData( currentIndex() ).toInt();
|
return ( QgsPaintEffect::DrawMode ) currentData().toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsEffectDrawModeComboBox::setDrawMode( QgsPaintEffect::DrawMode drawMode )
|
void QgsEffectDrawModeComboBox::setDrawMode( QgsPaintEffect::DrawMode drawMode )
|
||||||
|
@ -58,7 +58,7 @@ QgsBrushStyleComboBox::QgsBrushStyleComboBox( QWidget* parent )
|
|||||||
|
|
||||||
Qt::BrushStyle QgsBrushStyleComboBox::brushStyle() const
|
Qt::BrushStyle QgsBrushStyleComboBox::brushStyle() const
|
||||||
{
|
{
|
||||||
return ( Qt::BrushStyle ) itemData( currentIndex() ).toInt();
|
return ( Qt::BrushStyle ) currentData().toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsBrushStyleComboBox::setBrushStyle( Qt::BrushStyle style )
|
void QgsBrushStyleComboBox::setBrushStyle( Qt::BrushStyle style )
|
||||||
|
@ -46,7 +46,7 @@ QgsPenStyleComboBox::QgsPenStyleComboBox( QWidget* parent )
|
|||||||
|
|
||||||
Qt::PenStyle QgsPenStyleComboBox::penStyle() const
|
Qt::PenStyle QgsPenStyleComboBox::penStyle() const
|
||||||
{
|
{
|
||||||
return ( Qt::PenStyle ) itemData( currentIndex() ).toInt();
|
return ( Qt::PenStyle ) currentData().toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsPenStyleComboBox::setPenStyle( Qt::PenStyle style )
|
void QgsPenStyleComboBox::setPenStyle( Qt::PenStyle style )
|
||||||
@ -87,7 +87,7 @@ QgsPenJoinStyleComboBox::QgsPenJoinStyleComboBox( QWidget* parent )
|
|||||||
|
|
||||||
Qt::PenJoinStyle QgsPenJoinStyleComboBox::penJoinStyle() const
|
Qt::PenJoinStyle QgsPenJoinStyleComboBox::penJoinStyle() const
|
||||||
{
|
{
|
||||||
return ( Qt::PenJoinStyle ) itemData( currentIndex() ).toInt();
|
return ( Qt::PenJoinStyle ) currentData().toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsPenJoinStyleComboBox::setPenJoinStyle( Qt::PenJoinStyle style )
|
void QgsPenJoinStyleComboBox::setPenJoinStyle( Qt::PenJoinStyle style )
|
||||||
@ -111,7 +111,7 @@ QgsPenCapStyleComboBox::QgsPenCapStyleComboBox( QWidget* parent )
|
|||||||
|
|
||||||
Qt::PenCapStyle QgsPenCapStyleComboBox::penCapStyle() const
|
Qt::PenCapStyle QgsPenCapStyleComboBox::penCapStyle() const
|
||||||
{
|
{
|
||||||
return ( Qt::PenCapStyle ) itemData( currentIndex() ).toInt();
|
return ( Qt::PenCapStyle ) currentData().toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QgsPenCapStyleComboBox::setPenCapStyle( Qt::PenCapStyle style )
|
void QgsPenCapStyleComboBox::setPenCapStyle( Qt::PenCapStyle style )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user