Skip to content

Commit a61b922

Browse files
committedJan 25, 2017
Qt 5.2 has QComboBox::currentData
1 parent 43faf33 commit a61b922

File tree

10 files changed

+28
-29
lines changed

10 files changed

+28
-29
lines changed
 

‎python/plugins/db_manager/dlg_export_vector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def chooseOutputFile(self):
7373
lastUsedDir = settings.value(self.lastUsedVectorDirSettingsKey, ".")
7474

7575
# get selected filter
76-
selectedFilter = self.cboFileFormat.itemData(self.cboFileFormat.currentIndex())
76+
selectedFilter = self.cboFileFormat.currentData()
7777

7878
# ask for a filename
7979
filename, filter = QFileDialog.getSaveFileName(self, self.tr("Choose where to save the file"), lastUsedDir,
@@ -152,7 +152,7 @@ def accept(self):
152152
options = {}
153153

154154
# set the OGR driver will be used
155-
driverName = self.cboFileFormat.itemData(self.cboFileFormat.currentIndex())
155+
driverName = self.cboFileFormat.currentData()
156156
options['driverName'] = driverName
157157

158158
# set the output file encoding

‎python/plugins/processing/algs/qgis/ui/FieldsMappingPanel.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from collections import OrderedDict
3232

3333
from qgis.PyQt import uic
34-
from qgis.PyQt.QtGui import QBrush, QIcon
34+
from qgis.PyQt.QtGui import QBrush
3535
from qgis.PyQt.QtWidgets import QComboBox, QHeaderView, QLineEdit, QSpacerItem, QMessageBox, QSpinBox, QStyledItemDelegate
3636
from qgis.PyQt.QtCore import QItemSelectionModel, QAbstractTableModel, QModelIndex, QVariant, Qt, pyqtSlot
3737

@@ -297,7 +297,7 @@ def setModelData(self, editor, model, index):
297297

298298
fieldType = FieldsMappingModel.columns[column]['type']
299299
if fieldType == QVariant.Type:
300-
value = editor.itemData(editor.currentIndex())
300+
value = editor.currentData()
301301
if value is None:
302302
value = QVariant.Invalid
303303
model.setData(index, value)
@@ -480,7 +480,7 @@ def updateLayerCombo(self):
480480

481481
@pyqtSlot(bool, name='on_loadLayerFieldsButton_clicked')
482482
def on_loadLayerFieldsButton_clicked(self, checked=False):
483-
layer = self.layerCombo.itemData(self.layerCombo.currentIndex())
483+
layer = self.layerCombo.currentData()
484484
if layer is None:
485485
return
486486
self.model.loadLayerFields(layer)

‎python/plugins/processing/gui/wrappers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import os
3535
from functools import cmp_to_key
3636

37-
from qgis.core import QgsCoordinateReferenceSystem, QgsVectorLayer, QgsApplication, QgsWkbTypes, QgsMapLayerProxyModel
37+
from qgis.core import QgsCoordinateReferenceSystem, QgsApplication, QgsWkbTypes, QgsMapLayerProxyModel
3838
from qgis.PyQt.QtWidgets import QCheckBox, QComboBox, QLineEdit, QPlainTextEdit, QWidget, QHBoxLayout, QToolButton, QFileDialog
3939
from qgis.gui import (QgsFieldExpressionWidget,
4040
QgsExpressionLineEdit,
@@ -121,7 +121,7 @@ def comboValue(self, validator=None, combobox=None):
121121
if validator is not None and not validator(v):
122122
raise InvalidParameterValue()
123123
return v
124-
return combobox.itemData(combobox.currentIndex())
124+
return combobox.currentData()
125125

126126
def createWidget(self):
127127
pass
@@ -352,7 +352,7 @@ def value(self):
352352
raise InvalidParameterValue()
353353
return s
354354
else:
355-
return self.widget.itemData(self.widget.currentIndex())
355+
return self.widget.currentData()
356356

357357

358358
class PointWidgetWrapper(WidgetWrapper):
@@ -397,7 +397,7 @@ def value(self):
397397
raise InvalidParameterValue()
398398
return s
399399
else:
400-
return self.widget.itemData(self.widget.currentIndex())
400+
return self.widget.currentData()
401401

402402

403403
class FileWidgetWrapper(WidgetWrapper):

‎python/plugins/processing/modeler/ModelerParameterDefinitionDialog.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
from qgis.PyQt.QtCore import Qt
3434
from qgis.PyQt.QtWidgets import (QDialog,
3535
QVBoxLayout,
36-
QHBoxLayout,
3736
QLabel,
3837
QLineEdit,
3938
QComboBox,
@@ -265,8 +264,8 @@ def setupUi(self):
265264

266265
self.buttonBox = QDialogButtonBox(self)
267266
self.buttonBox.setOrientation(Qt.Horizontal)
268-
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel
269-
| QDialogButtonBox.Ok)
267+
self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel |
268+
QDialogButtonBox.Ok)
270269
self.buttonBox.setObjectName('buttonBox')
271270
self.buttonBox.accepted.connect(self.okPressed)
272271
self.buttonBox.rejected.connect(self.cancelPressed)
@@ -292,17 +291,17 @@ def okPressed(self):
292291
name = safeName.lower() + str(i)
293292
else:
294293
name = self.param.name
295-
if (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN
296-
or isinstance(self.param, ParameterBoolean)):
294+
if (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_BOOLEAN or
295+
isinstance(self.param, ParameterBoolean)):
297296
self.param = ParameterBoolean(name, description, self.state.isChecked())
298-
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD
299-
or isinstance(self.param, ParameterTableField)):
297+
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_TABLE_FIELD or
298+
isinstance(self.param, ParameterTableField)):
300299
if self.parentCombo.currentIndex() < 0:
301300
QMessageBox.warning(self, self.tr('Unable to define parameter'),
302301
self.tr('Wrong or missing parameter values'))
303302
return
304-
parent = self.parentCombo.itemData(self.parentCombo.currentIndex())
305-
datatype = self.datatypeCombo.itemData(self.datatypeCombo.currentIndex())
303+
parent = self.parentCombo.currentData()
304+
datatype = self.datatypeCombo.currentData()
306305
self.param = ParameterTableField(name, description, parent, datatype, multiple=self.multipleCheck.isChecked())
307306
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_RASTER or
308307
isinstance(self.param, ParameterRaster)):
@@ -343,7 +342,7 @@ def okPressed(self):
343342
return
344343
elif (self.paramType == ModelerParameterDefinitionDialog.PARAMETER_EXPRESSION or
345344
isinstance(self.param, ParameterExpression)):
346-
parent = self.parentCombo.itemData(self.parentCombo.currentIndex())
345+
parent = self.parentCombo.currentData()
347346
self.param = ParameterExpression(name, description,
348347
default=str(self.defaultEdit.expression()),
349348
parent_layer=parent)

‎python/plugins/processing/modeler/MultilineTextPanel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def getValue(self):
6161
if self.combo.currentIndex() == 0:
6262
return str(self.textBox.toPlainText())
6363
else:
64-
return self.combo.itemData(self.combo.currentIndex())
64+
return self.combo.currentData()
6565

6666
def setValue(self, value):
6767
items = [self.combo.itemData(i) for i in range(1, self.combo.count())]

‎src/app/qgsfieldcalculator.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ class APP_EXPORT QgsFieldCalculator: public QDialog, private Ui::QgsFieldCalcula
6565
inline QgsField fieldDefinition()
6666
{
6767
return QgsField( mOutputFieldNameLineEdit->text(),
68-
static_cast< QVariant::Type >( mOutputFieldTypeComboBox->itemData( mOutputFieldTypeComboBox->currentIndex(), Qt::UserRole ).toInt() ),
69-
mOutputFieldTypeComboBox->itemData( mOutputFieldTypeComboBox->currentIndex(), Qt::UserRole + 1 ).toString(),
68+
static_cast< QVariant::Type >( mOutputFieldTypeComboBox->currentData( Qt::UserRole ).toInt() ),
69+
mOutputFieldTypeComboBox->currentData( Qt::UserRole + 1 ).toString(),
7070
mOutputFieldWidthSpinBox->value(),
7171
mOutputFieldPrecisionSpinBox->value(),
7272
QString(),
73-
static_cast< QVariant::Type >( mOutputFieldTypeComboBox->itemData( mOutputFieldTypeComboBox->currentIndex(), Qt::UserRole + 6 ).toInt() )
73+
static_cast< QVariant::Type >( mOutputFieldTypeComboBox->currentData( Qt::UserRole + 6 ).toInt() )
7474
);
7575
}
7676

‎src/gui/auth/qgsauthcerttrustpolicycombobox.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ QgsAuthCertTrustPolicyComboBox::QgsAuthCertTrustPolicyComboBox( QWidget *parent,
6060

6161
QgsAuthCertUtils::CertTrustPolicy QgsAuthCertTrustPolicyComboBox::trustPolicy()
6262
{
63-
return ( QgsAuthCertUtils::CertTrustPolicy )itemData( currentIndex() ).toInt();
63+
return ( QgsAuthCertUtils::CertTrustPolicy )currentData().toInt();
6464
}
6565

6666
QgsAuthCertUtils::CertTrustPolicy QgsAuthCertTrustPolicyComboBox::trustPolicyForIndex( int indx )

‎src/gui/effects/qgseffectdrawmodecombobox.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ QgsEffectDrawModeComboBox::QgsEffectDrawModeComboBox( QWidget* parent )
3737

3838
QgsPaintEffect::DrawMode QgsEffectDrawModeComboBox::drawMode() const
3939
{
40-
return ( QgsPaintEffect::DrawMode ) itemData( currentIndex() ).toInt();
40+
return ( QgsPaintEffect::DrawMode ) currentData().toInt();
4141
}
4242

4343
void QgsEffectDrawModeComboBox::setDrawMode( QgsPaintEffect::DrawMode drawMode )

‎src/gui/symbology-ng/qgsbrushstylecombobox.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ QgsBrushStyleComboBox::QgsBrushStyleComboBox( QWidget* parent )
5858

5959
Qt::BrushStyle QgsBrushStyleComboBox::brushStyle() const
6060
{
61-
return ( Qt::BrushStyle ) itemData( currentIndex() ).toInt();
61+
return ( Qt::BrushStyle ) currentData().toInt();
6262
}
6363

6464
void QgsBrushStyleComboBox::setBrushStyle( Qt::BrushStyle style )

‎src/gui/symbology-ng/qgspenstylecombobox.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ QgsPenStyleComboBox::QgsPenStyleComboBox( QWidget* parent )
4646

4747
Qt::PenStyle QgsPenStyleComboBox::penStyle() const
4848
{
49-
return ( Qt::PenStyle ) itemData( currentIndex() ).toInt();
49+
return ( Qt::PenStyle ) currentData().toInt();
5050
}
5151

5252
void QgsPenStyleComboBox::setPenStyle( Qt::PenStyle style )
@@ -87,7 +87,7 @@ QgsPenJoinStyleComboBox::QgsPenJoinStyleComboBox( QWidget* parent )
8787

8888
Qt::PenJoinStyle QgsPenJoinStyleComboBox::penJoinStyle() const
8989
{
90-
return ( Qt::PenJoinStyle ) itemData( currentIndex() ).toInt();
90+
return ( Qt::PenJoinStyle ) currentData().toInt();
9191
}
9292

9393
void QgsPenJoinStyleComboBox::setPenJoinStyle( Qt::PenJoinStyle style )
@@ -111,7 +111,7 @@ QgsPenCapStyleComboBox::QgsPenCapStyleComboBox( QWidget* parent )
111111

112112
Qt::PenCapStyle QgsPenCapStyleComboBox::penCapStyle() const
113113
{
114-
return ( Qt::PenCapStyle ) itemData( currentIndex() ).toInt();
114+
return ( Qt::PenCapStyle ) currentData().toInt();
115115
}
116116

117117
void QgsPenCapStyleComboBox::setPenCapStyle( Qt::PenCapStyle style )

0 commit comments

Comments
 (0)
Please sign in to comment.