[Kst] branches/work/kst/portto4/kst/src/libkst
Nicolas Brisset
nicolas.brisset at eurocopter.com
Sat Feb 5 01:30:44 CET 2011
SVN commit 1218848 by brisset:
Initialize the label correctly and make sure that units get picked up correctly, and always escape special characters.
This is a preparation for the next commit, adding ASCII units.
M +6 -6 datavector.cpp
--- branches/work/kst/portto4/kst/src/libkst/datavector.cpp #1218847:1218848
@@ -303,26 +303,26 @@
QString DataVector::label() const {
- QString label;
-
+ // Initialize label to field name, always
+ QString label = _field;
+ // If there is a meta string named "quantity", override the default label (does that really make sense???)
if (_fieldStrings.contains("quantity")) {
label = _fieldStrings.value("quantity")->value();
}
- if (!label.isEmpty()) {
+ // Now add the unit if found in the metadata
+ // FIXME: the name of the metadata should be configurable!
if (_fieldStrings.contains("units")) {
QString units = _fieldStrings.value("units")->value();
if (!units.isEmpty()) {
label += " \\[" + units + "\\]";
}
}
- } else {
- label = _field;
+
// un-escape escaped special characters so they aren't escaped 2x.
label.replace("\\_", "_").replace("\\^","^").replace("\\[", "[").replace("\\]", "]");
// now escape the special characters.
label.replace('_', "\\_").replace('^', "\\^").replace('[', "\\[").replace(']', "\\]");
- }
return label;
}
More information about the Kst
mailing list