Skip to content
Permalink
Browse files

Using QString.replace instead of .arg to ensure that %1 and %2 are un…

…ambiguously replaced with lower and upper value. Also moving legend template to more sensible location, and adding tooltip for legend template
  • Loading branch information
ccrook committed Sep 30, 2014
1 parent 834c1d0 commit 465219a12a29d346e67b5bc0e22c463d17ddd61d
@@ -223,7 +223,9 @@ QString QgsRendererRangeV2LabelFormat::labelForRange( double lower, double upper
if ( upperStr.contains( '.' ) ) upperStr = upperStr.replace( mReTrailingZeroes, "" );
}

return mFormat.arg( lowerStr, upperStr );
QString legend(mFormat);

return legend.replace( "%1",lowerStr).replace("%2",upperStr );
}

void QgsRendererRangeV2LabelFormat::setFromDomElement( QDomElement &element )
@@ -19,7 +19,48 @@
<property name="rightMargin">
<number>6</number>
</property>
<item row="6" column="2">
<item row="6" column="3">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QSpinBox" name="spinDecimalPlaces">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>4</number>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbxTrimTrailingZeroes">
<property name="text">
<string>Trim</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="6" column="1">
<widget class="QLineEdit" name="txtFormat">
<property name="toolTip">
<string>Template for the legend text associated with each classification.
Use &quot;%1&quot; for the lower bound of the classification, and &quot;%2&quot; for the upper bound.</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Mode</string>
@@ -32,7 +73,7 @@
</property>
</widget>
</item>
<item row="6" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Color ramp</string>
@@ -42,7 +83,7 @@
</property>
</widget>
</item>
<item row="6" column="3">
<item row="5" column="3">
<widget class="QComboBox" name="cboGraduatedMode">
<item>
<property name="text">
@@ -71,7 +112,7 @@
</item>
</widget>
</item>
<item row="5" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Symbol</string>
@@ -81,7 +122,7 @@
</property>
</widget>
</item>
<item row="5" column="1">
<item row="4" column="1">
<widget class="QPushButton" name="btnChangeGraduatedSymbol">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@@ -94,7 +135,7 @@
</property>
</widget>
</item>
<item row="5" column="3">
<item row="4" column="3">
<widget class="QSpinBox" name="spinGraduatedClasses">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@@ -113,7 +154,7 @@
</property>
</widget>
</item>
<item row="5" column="2">
<item row="4" column="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Classes</string>
@@ -126,7 +167,7 @@
</property>
</widget>
</item>
<item row="6" column="1">
<item row="5" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QgsColorRampComboBox" name="cboGraduatedColorRamp"/>
@@ -183,7 +224,7 @@
</item>
</layout>
</item>
<item row="3" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Label Format</string>
@@ -196,51 +237,7 @@
</property>
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="txtFormat">
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="3">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QSpinBox" name="spinDecimalPlaces">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>10</number>
</property>
<property name="value">
<number>4</number>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbxTrimTrailingZeroes">
<property name="text">
<string>Trim</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="2">
<item row="6" column="2">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Decimal places</string>
@@ -358,14 +355,14 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>txtFormat</tabstop>
<tabstop>spinDecimalPlaces</tabstop>
<tabstop>cbxTrimTrailingZeroes</tabstop>
<tabstop>btnChangeGraduatedSymbol</tabstop>
<tabstop>spinGraduatedClasses</tabstop>
<tabstop>cboGraduatedColorRamp</tabstop>
<tabstop>cbxInvertedColorRamp</tabstop>
<tabstop>cboGraduatedMode</tabstop>
<tabstop>txtFormat</tabstop>
<tabstop>spinDecimalPlaces</tabstop>
<tabstop>cbxTrimTrailingZeroes</tabstop>
<tabstop>viewGraduated</tabstop>
<tabstop>btnGraduatedClassify</tabstop>
<tabstop>btnGraduatedAdd</tabstop>

0 comments on commit 465219a

Please sign in to comment.
You can’t perform that action at this time.