@@ -103,6 +103,8 @@ static const char *const mSupportedRasterFormats[] =
103
103
};
104
104
105
105
106
+ // Constant that signals property not used.
107
+ const QString QgsRasterLayer::QSTRING_NOT_SET = QString(" Not Set" );
106
108
107
109
/* *
108
110
Builds the list of file filter strings to later be used by
@@ -598,8 +600,8 @@ bool QgsRasterLayer::readFile( QString const & fileName )
598
600
mRedBandName = " Red" ; // sensible default
599
601
mGreenBandName = " Green" ; // sensible default
600
602
mBlueBandName = " Blue" ;// sensible default
601
- mTransparencyBandName = tr (" Not Set " ); // sensible default
602
- mGrayBandName = tr (" Not Set " ); // sensible default
603
+ mTransparencyBandName = tr (QSTRING_NOT_SET ); // sensible default
604
+ mGrayBandName = tr (QSTRING_NOT_SET ); // sensible default
603
605
drawingStyle = PALETTED_MULTI_BAND_COLOR; // sensible default
604
606
}
605
607
else if (rasterLayerType == MULTIBAND)
@@ -614,7 +616,7 @@ bool QgsRasterLayer::readFile( QString const & fileName )
614
616
}
615
617
else
616
618
{
617
- mBlueBandName = tr (" Not Set " ); // sensible default
619
+ mBlueBandName = tr (QSTRING_NOT_SET ); // sensible default
618
620
}
619
621
620
622
// Beacuse the transparent band can be set from a different layer defaulting to the fourth
@@ -624,18 +626,18 @@ bool QgsRasterLayer::readFile( QString const & fileName )
624
626
mTransparencyBandName = getRasterBandName(4);
625
627
else
626
628
*/
627
- mTransparencyBandName = tr (" Not Set " );
629
+ mTransparencyBandName = tr (QSTRING_NOT_SET );
628
630
629
- mGrayBandName = tr (" Not Set " ); // sensible default
631
+ mGrayBandName = tr (QSTRING_NOT_SET ); // sensible default
630
632
drawingStyle = MULTI_BAND_COLOR; // sensible default
631
633
}
632
634
else // GRAY_OR_UNDEFINED
633
635
{
634
636
getRasterBandStats (1 );
635
- mRedBandName = tr (" Not Set " ); // sensible default
636
- mGreenBandName = tr (" Not Set " ); // sensible default
637
- mBlueBandName = tr (" Not Set " ); // sensible default
638
- mTransparencyBandName = tr (" Not Set " ); // sensible default
637
+ mRedBandName = tr (QSTRING_NOT_SET ); // sensible default
638
+ mGreenBandName = tr (QSTRING_NOT_SET ); // sensible default
639
+ mBlueBandName = tr (QSTRING_NOT_SET ); // sensible default
640
+ mTransparencyBandName = tr (QSTRING_NOT_SET ); // sensible default
639
641
drawingStyle = SINGLE_BAND_GRAY; // sensible default
640
642
mGrayBandName = getRasterBandName (1 ); // usually gdal will return gray or undefined
641
643
}
@@ -1291,7 +1293,7 @@ void QgsRasterLayer::draw (QPainter * theQPainter,
1291
1293
// a "Gray" or "Undefined" layer drawn as a range of gray colors
1292
1294
case SINGLE_BAND_GRAY:
1293
1295
// check the band is set!
1294
- if (mGrayBandName == tr (" Not Set " ))
1296
+ if (mGrayBandName == tr (QSTRING_NOT_SET ))
1295
1297
{
1296
1298
break ;
1297
1299
}
@@ -1304,7 +1306,7 @@ void QgsRasterLayer::draw (QPainter * theQPainter,
1304
1306
// a "Gray" or "Undefined" layer drawn using a pseudocolor algorithm
1305
1307
case SINGLE_BAND_PSEUDO_COLOR:
1306
1308
// check the band is set!
1307
- if (mGrayBandName == tr (" Not Set " ))
1309
+ if (mGrayBandName == tr (QSTRING_NOT_SET ))
1308
1310
{
1309
1311
break ;
1310
1312
}
@@ -1317,7 +1319,7 @@ void QgsRasterLayer::draw (QPainter * theQPainter,
1317
1319
// a "Palette" layer drawn in gray scale (using only one of the color components)
1318
1320
case PALETTED_SINGLE_BAND_GRAY:
1319
1321
// check the band is set!
1320
- if (mGrayBandName == tr (" Not Set " ))
1322
+ if (mGrayBandName == tr (QSTRING_NOT_SET ))
1321
1323
{
1322
1324
break ;
1323
1325
}
@@ -1334,7 +1336,7 @@ void QgsRasterLayer::draw (QPainter * theQPainter,
1334
1336
// a "Palette" layer having only one of its color components rendered as psuedo color
1335
1337
case PALETTED_SINGLE_BAND_PSEUDO_COLOR:
1336
1338
// check the band is set!
1337
- if (mGrayBandName == tr (" Not Set " ))
1339
+ if (mGrayBandName == tr (QSTRING_NOT_SET ))
1338
1340
{
1339
1341
break ;
1340
1342
}
@@ -1355,7 +1357,7 @@ void QgsRasterLayer::draw (QPainter * theQPainter,
1355
1357
case MULTI_BAND_SINGLE_BAND_GRAY:
1356
1358
QgsDebugMsg (" MULTI_BAND_SINGLE_BAND_GRAY drawing type detected..." );
1357
1359
// check the band is set!
1358
- if (mGrayBandName == tr (" Not Set " ))
1360
+ if (mGrayBandName == tr (QSTRING_NOT_SET ))
1359
1361
{
1360
1362
QgsDebugMsg (" MULTI_BAND_SINGLE_BAND_GRAY Not Set detected..." + mGrayBandName );
1361
1363
break ;
@@ -1371,7 +1373,7 @@ void QgsRasterLayer::draw (QPainter * theQPainter,
1371
1373
// a layer containing 2 or more bands, but using only one band to produce a pseudocolor image
1372
1374
case MULTI_BAND_SINGLE_BAND_PSEUDO_COLOR:
1373
1375
// check the band is set!
1374
- if (mGrayBandName == tr (" Not Set " ))
1376
+ if (mGrayBandName == tr (QSTRING_NOT_SET ))
1375
1377
{
1376
1378
break ;
1377
1379
}
@@ -1386,9 +1388,9 @@ void QgsRasterLayer::draw (QPainter * theQPainter,
1386
1388
// In the case of a multiband with only two bands,
1387
1389
// one band will have to be mapped to more than one color
1388
1390
case MULTI_BAND_COLOR:
1389
- if (mRedBandName == tr (" Not Set " ) ||
1390
- mGreenBandName == tr (" Not Set " ) ||
1391
- mBlueBandName == tr (" Not Set " ))
1391
+ if (mRedBandName == tr (QSTRING_NOT_SET ) ||
1392
+ mGreenBandName == tr (QSTRING_NOT_SET ) ||
1393
+ mBlueBandName == tr (QSTRING_NOT_SET ))
1392
1394
{
1393
1395
break ;
1394
1396
}
@@ -2621,9 +2623,10 @@ void QgsRasterLayer::setRedBandName(QString const & theBandNameQString)
2621
2623
{
2622
2624
QgsDebugMsg (" setRedBandName : " + theBandNameQString);
2623
2625
// check if the band is unset
2624
- if (theBandNameQString == tr (" Not Set " ) )
2626
+ if (theBandNameQString == tr (QSTRING_NOT_SET) || theBandNameQString == QSTRING_NOT_SET )
2625
2627
{
2626
- mRedBandName = theBandNameQString;
2628
+ // Use translated name internally
2629
+ mRedBandName = tr (QSTRING_NOT_SET);
2627
2630
return ;
2628
2631
}
2629
2632
// check if the image is paletted
@@ -2646,7 +2649,7 @@ void QgsRasterLayer::setRedBandName(QString const & theBandNameQString)
2646
2649
}
2647
2650
2648
2651
// if no matches were found default to not set
2649
- mRedBandName = tr (" Not Set " );
2652
+ mRedBandName = tr (QSTRING_NOT_SET );
2650
2653
return ;
2651
2654
}
2652
2655
@@ -2656,9 +2659,10 @@ void QgsRasterLayer::setRedBandName(QString const & theBandNameQString)
2656
2659
void QgsRasterLayer::setGreenBandName (QString const & theBandNameQString)
2657
2660
{
2658
2661
// check if the band is unset
2659
- if (theBandNameQString == tr (" Not Set " ) )
2662
+ if (theBandNameQString == tr (QSTRING_NOT_SET) || theBandNameQString == QSTRING_NOT_SET )
2660
2663
{
2661
- mGreenBandName = theBandNameQString;
2664
+ // Use translated name internally
2665
+ mGreenBandName = tr (QSTRING_NOT_SET);
2662
2666
return ;
2663
2667
}
2664
2668
// check if the image is paletted
@@ -2681,17 +2685,18 @@ void QgsRasterLayer::setGreenBandName(QString const & theBandNameQString)
2681
2685
}
2682
2686
2683
2687
// if no matches were found default to not set
2684
- mGreenBandName = tr (" Not Set " );
2688
+ mGreenBandName = tr (QSTRING_NOT_SET );
2685
2689
return ;
2686
2690
}
2687
2691
2688
2692
// mutator for blue band name
2689
2693
void QgsRasterLayer::setBlueBandName (QString const & theBandNameQString)
2690
2694
{
2691
2695
// check if the band is unset
2692
- if (theBandNameQString == tr (" Not Set " ) )
2696
+ if (theBandNameQString == tr (QSTRING_NOT_SET) || theBandNameQString == QSTRING_NOT_SET )
2693
2697
{
2694
- mBlueBandName = theBandNameQString;
2698
+ // Use translated name internally
2699
+ mBlueBandName = tr (QSTRING_NOT_SET);
2695
2700
return ;
2696
2701
}
2697
2702
// check if the image is paletted
@@ -2714,15 +2719,15 @@ void QgsRasterLayer::setBlueBandName(QString const & theBandNameQString)
2714
2719
}
2715
2720
2716
2721
// if no matches were found default to not set
2717
- mBlueBandName = tr (" Not Set " );
2722
+ mBlueBandName = tr (QSTRING_NOT_SET );
2718
2723
return ;
2719
2724
}
2720
2725
2721
2726
// mutator for transparent band name
2722
2727
void QgsRasterLayer::setTransparentBandName (QString const & theBandNameQString)
2723
2728
{
2724
2729
// check if the band is unset
2725
- if (theBandNameQString == tr (" Not Set " ))
2730
+ if (theBandNameQString == tr (QSTRING_NOT_SET ))
2726
2731
{
2727
2732
mTransparencyBandName = theBandNameQString;
2728
2733
return ;
@@ -2747,7 +2752,7 @@ void QgsRasterLayer::setTransparentBandName(QString const & theBandNameQString)
2747
2752
}
2748
2753
2749
2754
// if no matches were found default to not set
2750
- mTransparencyBandName = tr (" Not Set " );
2755
+ mTransparencyBandName = tr (QSTRING_NOT_SET );
2751
2756
return ;
2752
2757
}
2753
2758
@@ -2756,9 +2761,10 @@ void QgsRasterLayer::setTransparentBandName(QString const & theBandNameQString)
2756
2761
void QgsRasterLayer::setGrayBandName (QString const & theBandNameQString)
2757
2762
{
2758
2763
// check if the band is unset
2759
- if (theBandNameQString == tr (" Not Set " ) )
2764
+ if (theBandNameQString == tr (QSTRING_NOT_SET) || theBandNameQString == QSTRING_NOT_SET )
2760
2765
{
2761
- mGrayBandName = theBandNameQString;
2766
+ // Use translated name internally
2767
+ mGrayBandName = tr (QSTRING_NOT_SET);
2762
2768
return ;
2763
2769
}
2764
2770
// check if the image is paletted
@@ -2783,7 +2789,7 @@ void QgsRasterLayer::setGrayBandName(QString const & theBandNameQString)
2783
2789
}
2784
2790
2785
2791
// if no matches were found default to not set
2786
- mGrayBandName = tr (" Not Set " );
2792
+ mGrayBandName = tr (QSTRING_NOT_SET );
2787
2793
return ;
2788
2794
}
2789
2795
@@ -4253,8 +4259,9 @@ bool QgsRasterLayer::readXML_( QDomNode & layer_node )
4253
4259
snode = mnl.namedItem (" mNoDataValue" );
4254
4260
myElement = snode.toElement ();
4255
4261
setNoDataValue (myElement.text ().toDouble ());
4256
- if (myElement.attribute (" mValidNoDataValue" , " false" ) != " true" )
4262
+ if ( myElement.attribute (" mValidNoDataValue" , " false" ). compare ( " true" ) )
4257
4263
{
4264
+ // If flag element is not true, set to false.
4258
4265
mValidNoDataValue = false ;
4259
4266
}
4260
4267
@@ -4496,7 +4503,13 @@ bool QgsRasterLayer::readXML_( QDomNode & layer_node )
4496
4503
4497
4504
// <mRedBandName>
4498
4505
QDomElement mRedBandNameElement = document.createElement ( " mRedBandName" );
4499
- QDomText mRedBandNameText = document.createTextNode ( getRedBandName () );
4506
+ QString writtenRedBandName = getRedBandName ();
4507
+ if ( writtenRedBandName == tr (QSTRING_NOT_SET) )
4508
+ {
4509
+ // Write english "not set" only.
4510
+ writtenRedBandName = QSTRING_NOT_SET;
4511
+ }
4512
+ QDomText mRedBandNameText = document.createTextNode ( writtenRedBandName );
4500
4513
4501
4514
mRedBandNameElement .appendChild ( mRedBandNameText );
4502
4515
@@ -4505,7 +4518,13 @@ bool QgsRasterLayer::readXML_( QDomNode & layer_node )
4505
4518
4506
4519
// <mGreenBandName>
4507
4520
QDomElement mGreenBandNameElement = document.createElement ( " mGreenBandName" );
4508
- QDomText mGreenBandNameText = document.createTextNode ( getGreenBandName () );
4521
+ QString writtenGreenBandName = getGreenBandName ();
4522
+ if ( writtenGreenBandName == tr (QSTRING_NOT_SET) )
4523
+ {
4524
+ // Write english "not set" only.
4525
+ writtenGreenBandName = QSTRING_NOT_SET;
4526
+ }
4527
+ QDomText mGreenBandNameText = document.createTextNode ( writtenGreenBandName );
4509
4528
4510
4529
mGreenBandNameElement .appendChild ( mGreenBandNameText );
4511
4530
@@ -4514,7 +4533,13 @@ bool QgsRasterLayer::readXML_( QDomNode & layer_node )
4514
4533
4515
4534
// <mBlueBandName>
4516
4535
QDomElement mBlueBandNameElement = document.createElement ( " mBlueBandName" );
4517
- QDomText mBlueBandNameText = document.createTextNode ( getBlueBandName () );
4536
+ QString writtenBlueBandName = getBlueBandName ();
4537
+ if ( writtenBlueBandName == tr (QSTRING_NOT_SET) )
4538
+ {
4539
+ // Write english "not set" only.
4540
+ writtenBlueBandName = QSTRING_NOT_SET;
4541
+ }
4542
+ QDomText mBlueBandNameText = document.createTextNode ( writtenBlueBandName );
4518
4543
4519
4544
mBlueBandNameElement .appendChild ( mBlueBandNameText );
4520
4545
@@ -4523,7 +4548,13 @@ bool QgsRasterLayer::readXML_( QDomNode & layer_node )
4523
4548
4524
4549
// <mGrayBandName>
4525
4550
QDomElement mGrayBandNameElement = document.createElement ( " mGrayBandName" );
4526
- QDomText mGrayBandNameText = document.createTextNode ( getGrayBandName () );
4551
+ QString writtenGrayBandName = getGrayBandName ();
4552
+ if ( writtenGrayBandName == tr (QSTRING_NOT_SET) )
4553
+ {
4554
+ // Write english "not set" only.
4555
+ writtenGrayBandName = QSTRING_NOT_SET;
4556
+ }
4557
+ QDomText mGrayBandNameText = document.createTextNode ( writtenGrayBandName );
4527
4558
4528
4559
mGrayBandNameElement .appendChild ( mGrayBandNameText );
4529
4560
rasterPropertiesElement.appendChild ( mGrayBandNameElement );
0 commit comments