@@ -36,20 +36,20 @@ QgsLabelPropertyDialog::~QgsLabelPropertyDialog()
36
36
37
37
void QgsLabelPropertyDialog::init ( const QString& layerId, int featureId )
38
38
{
39
- if ( !mMapRenderer )
39
+ if ( !mMapRenderer )
40
40
{
41
41
return ;
42
42
}
43
43
44
44
// get feature attributes
45
45
QgsVectorLayer* vlayer = dynamic_cast <QgsVectorLayer*>( QgsMapLayerRegistry::instance ()->mapLayer ( layerId ) );
46
- if ( !vlayer )
46
+ if ( !vlayer )
47
47
{
48
48
return ;
49
49
}
50
50
51
51
QgsFeature f;
52
- if ( !vlayer->featureAtId ( featureId, f, false , true ) )
52
+ if ( !vlayer->featureAtId ( featureId, f, false , true ) )
53
53
{
54
54
return ;
55
55
}
@@ -58,7 +58,7 @@ void QgsLabelPropertyDialog::init( const QString& layerId, int featureId )
58
58
59
59
// get layerproperties. Problem: only for pallabeling...
60
60
QgsPalLabeling* lbl = dynamic_cast <QgsPalLabeling*>( mMapRenderer ->labelingEngine () );
61
- if ( !lbl )
61
+ if ( !lbl )
62
62
{
63
63
return ;
64
64
}
@@ -67,12 +67,12 @@ void QgsLabelPropertyDialog::init( const QString& layerId, int featureId )
67
67
68
68
// get label field and fill line edit
69
69
QString labelFieldName = vlayer->customProperty ( " labeling/fieldName" ).toString ();
70
- if ( !labelFieldName.isEmpty () )
70
+ if ( !labelFieldName.isEmpty () )
71
71
{
72
72
mCurrentLabelField = vlayer->fieldNameIndex ( labelFieldName );
73
73
mLabelTextLineEdit ->setText ( attributeValues[mCurrentLabelField ].toString () );
74
74
const QgsFieldMap& layerFields = vlayer->pendingFields ();
75
- switch ( layerFields[mCurrentLabelField ].type () )
75
+ switch ( layerFields[mCurrentLabelField ].type () )
76
76
{
77
77
case QVariant::Double:
78
78
mLabelTextLineEdit ->setValidator ( new QDoubleValidator ( this ) );
@@ -82,6 +82,8 @@ void QgsLabelPropertyDialog::init( const QString& layerId, int featureId )
82
82
case QVariant::LongLong:
83
83
mLabelTextLineEdit ->setValidator ( new QIntValidator ( this ) );
84
84
break ;
85
+ default :
86
+ break ;
85
87
}
86
88
}
87
89
@@ -94,17 +96,17 @@ void QgsLabelPropertyDialog::init( const QString& layerId, int featureId )
94
96
mBufferColorButton ->setColor ( layerSettings.textColor );
95
97
mLabelDistanceSpinBox ->setValue ( layerSettings.dist );
96
98
mBufferSizeSpinBox ->setValue ( layerSettings.bufferSize );
97
- mHaliComboBox ->setCurrentIndex ( mHaliComboBox ->findText (" Left" ) );
98
- mValiComboBox ->setCurrentIndex ( mValiComboBox ->findText (" Bottom" ) );
99
+ mHaliComboBox ->setCurrentIndex ( mHaliComboBox ->findText ( " Left" ) );
100
+ mValiComboBox ->setCurrentIndex ( mValiComboBox ->findText ( " Bottom" ) );
99
101
100
102
disableGuiElements ();
101
103
102
104
mDataDefinedProperties = layerSettings.dataDefinedProperties ;
103
105
QMap< QgsPalLayerSettings::DataDefinedProperties, int >::const_iterator propIt = mDataDefinedProperties .constBegin ();
104
106
105
- for ( ; propIt != mDataDefinedProperties .constEnd (); ++propIt )
107
+ for ( ; propIt != mDataDefinedProperties .constEnd (); ++propIt )
106
108
{
107
- switch ( propIt.key () )
109
+ switch ( propIt.key () )
108
110
{
109
111
case QgsPalLayerSettings::Size:
110
112
mFontSizeSpinBox ->setEnabled ( true );
@@ -148,7 +150,7 @@ void QgsLabelPropertyDialog::init( const QString& layerId, int featureId )
148
150
mRotationSpinBox ->setValue ( attributeValues[propIt.value ()].toDouble () );
149
151
break ;
150
152
151
- // font related properties
153
+ // font related properties
152
154
case QgsPalLayerSettings::Bold:
153
155
mLabelFont .setBold ( attributeValues[propIt.value ()].toBool () );
154
156
break ;
@@ -247,8 +249,8 @@ void QgsLabelPropertyDialog::on_mRotationSpinBox_valueChanged( double d )
247
249
void QgsLabelPropertyDialog::on_mFontPushButton_clicked ()
248
250
{
249
251
bool ok;
250
- mLabelFont = QFontDialog::getFont ( &ok, mLabelFont , 0 , tr (" Label font" ) );
251
- if ( ok )
252
+ mLabelFont = QFontDialog::getFont ( &ok, mLabelFont , 0 , tr ( " Label font" ) );
253
+ if ( ok )
252
254
{
253
255
insertChangedValue ( QgsPalLayerSettings::Size, mLabelFont .pointSizeF () );
254
256
insertChangedValue ( QgsPalLayerSettings::Bold, mLabelFont .bold () );
@@ -259,8 +261,12 @@ void QgsLabelPropertyDialog::on_mFontPushButton_clicked()
259
261
260
262
void QgsLabelPropertyDialog::on_mFontColorButton_clicked ()
261
263
{
262
- QColor c = QColorDialog::getColor ( mFontColorButton ->color (), 0 , tr (" Font color" ), QColorDialog::ShowAlphaChannel );
263
- if ( c.isValid () )
264
+ #if QT_VERSION >= 0x040500
265
+ QColor c = QColorDialog::getColor ( mFontColorButton ->color (), 0 , tr ( " Font color" ), QColorDialog::ShowAlphaChannel );
266
+ #else
267
+ QColor c = QColorDialog::getColor ( mFontColorButton ->color () );
268
+ #endif
269
+ if ( c.isValid () )
264
270
{
265
271
mFontColorButton ->setColor ( c );
266
272
insertChangedValue ( QgsPalLayerSettings::Color, c.name () );
@@ -269,8 +275,12 @@ void QgsLabelPropertyDialog::on_mFontColorButton_clicked()
269
275
270
276
void QgsLabelPropertyDialog::on_mBufferColorButton_clicked ()
271
277
{
272
- QColor c = QColorDialog::getColor ( mBufferColorButton ->color (), 0 , tr (" Buffer color" ), QColorDialog::ShowAlphaChannel );
273
- if ( c.isValid () )
278
+ #if QT_VERSION >= 0x040500
279
+ QColor c = QColorDialog::getColor ( mBufferColorButton ->color (), 0 , tr ( " Buffer color" ), QColorDialog::ShowAlphaChannel );
280
+ #else
281
+ QColor c = QColorDialog::getColor ( mBufferColorButton ->color () );
282
+ #endif
283
+ if ( c.isValid () )
274
284
{
275
285
mFontColorButton ->setColor ( c );
276
286
insertChangedValue ( QgsPalLayerSettings::BufferColor, c.name () );
@@ -287,18 +297,18 @@ void QgsLabelPropertyDialog::on_mValiComboBox_currentIndexChanged( const QString
287
297
insertChangedValue ( QgsPalLayerSettings::Vali, text );
288
298
}
289
299
290
- void QgsLabelPropertyDialog::on_mLabelTextLineEdit_textChanged ( const QString& text )
300
+ void QgsLabelPropertyDialog::on_mLabelTextLineEdit_textChanged ( const QString& text )
291
301
{
292
- if ( mCurrentLabelField != -1 )
302
+ if ( mCurrentLabelField != -1 )
293
303
{
294
304
mChangedProperties .insert ( mCurrentLabelField , text );
295
305
}
296
306
}
297
307
298
308
void QgsLabelPropertyDialog::insertChangedValue ( QgsPalLayerSettings::DataDefinedProperties p, QVariant value )
299
309
{
300
- QMap< QgsPalLayerSettings::DataDefinedProperties, int >::const_iterator ddIt = mDataDefinedProperties .find ( p );
301
- if ( ddIt != mDataDefinedProperties .constEnd () )
310
+ QMap< QgsPalLayerSettings::DataDefinedProperties, int >::const_iterator ddIt = mDataDefinedProperties .find ( p );
311
+ if ( ddIt != mDataDefinedProperties .constEnd () )
302
312
{
303
313
mChangedProperties .insert ( ddIt.value (), value );
304
314
}
0 commit comments