Summary: | Ability to add arbitrary text to a legend | ||
---|---|---|---|
Product: | [Applications] kst | Reporter: | Andrew Walker <arwalker> |
Component: | general | Assignee: | Netterfield <netterfield> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | ||
Priority: | HI | ||
Version: | 1.1.0 | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: | Proposed patch |
Description
Andrew Walker
2005-01-03 19:55:17 UTC
Should be fixed for 1.2.1 release I propose to just add an entry for a legend title. There would be a text entry in the legend dialog. Structurally, tt would add 'legendTitle' and 'parsedLegendTitle' to kstviewlegend. SVN commit 511436 by netterfield: BUG: 96244 Add title text to legends. M +81 -6 kstviewlegend.cpp M +9 -0 kstviewlegend.h M +38 -7 viewlegendwidget.ui This fix doesn't seem to take into account the possible occurences of \n in the title text, in either vertical or horizontal layout. A similar problem exists with the legend text associated with a curve. The remaining problem in the handling of "\\n" seems to be a problem with the label parsing. For the case of legend label objects we do not want "\\n" interpreted as '\n'. The only way to avoid this problem that I can think of is to add a flag to the Label object indicating if we want to interpret "\\n" as a special character. If I don't hear any complaints I'll add the necessary code - making the default the current behaviour. Created attachment 15094 [details]
Proposed patch
SVN commit 518634 by arwalker: BUG:96244 Do not interpret \n in legend M +1 -1 libkstapp/kstviewlegend.cpp M +2 -2 libkstmath/kstbasecurve.cpp M +13 -9 libkstmath/labelparser.cpp M +1 -1 libkstmath/labelparser.h --- trunk/extragear/graphics/kst/src/libkstapp/kstviewlegend.cpp #518633:518634 @@ -517,7 +517,7 @@ void KstViewLegend::reparseTitle() { delete _parsedTitle; - _parsedTitle = Label::parse(_title, true); + _parsedTitle = Label::parse(_title, true, false); setDirty(); } --- trunk/extragear/graphics/kst/src/libkstmath/kstbasecurve.cpp #518633:518634 @@ -56,9 +56,9 @@ void KstBaseCurve::updateParsedLegendTag() { delete _parsedLegendTag; if (_legendText.isEmpty()) { - _parsedLegendTag = Label::parse(tagName(), false); + _parsedLegendTag = Label::parse(tagName(), false, false); } else { - _parsedLegendTag = Label::parse(legendText(), true); + _parsedLegendTag = Label::parse(legendText(), true, false); } } --- trunk/extragear/graphics/kst/src/libkstmath/labelparser.cpp #518633:518634 @@ -120,7 +120,7 @@ break; -inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail) { +inline bool parseOutChar(const QString& txt, uint from, int *skip, Chunk **tail, bool interpretNewLine) { QChar c = txt[from]; bool upper = false; *skip = 1; @@ -243,7 +243,7 @@ *skip = 2; setNormalChar(QChar(0x2260), tail); return true; - } else { + } else if (interpretNewLine) { *skip = 1; if (!*tail || !(*tail)->text.isEmpty() || (*tail)->locked()) { *tail = new Chunk(*tail, Chunk::None, false, true); @@ -251,6 +251,10 @@ (*tail)->linebreak = true; *tail = new Chunk(*tail, Chunk::None, false, true); return true; + } else { + *skip = 1; + setNormalChar(QChar(0x20), tail); + return true; } break; @@ -388,7 +392,7 @@ } -static Chunk *parseInternal(Chunk *ctail, const QString& txt, uint& start, uint cnt) { +static Chunk *parseInternal(Chunk *ctail, const QString& txt, uint& start, uint cnt, bool interpretNewLine) { Chunk *chead = ctail; if (ctail->group) { @@ -422,7 +426,7 @@ setNormalChar('\\', &ctail); } else { int skip = 0; - if (!parseOutChar(txt, i, &skip, &ctail)) { + if (!parseOutChar(txt, i, &skip, &ctail, interpretNewLine)) { setNormalChar(txt[i], &ctail); } else { i += skip - 1; @@ -450,15 +454,15 @@ if (ctail->text.isEmpty() && !ctail->group) { ctail->group = true; dumpattr(ctail, "start group with non-group and empty text"); - ctail = parseInternal(ctail, txt, ++i, cnt); + ctail = parseInternal(ctail, txt, ++i, cnt, interpretNewLine); dumpattr(ctail, "after start group with non-group and empty text"); } else { if (ctail->vOffset == Chunk::None) { dumpattr(ctail, "start group with text or group"); - ctail = parseInternal(new Chunk(ctail, Chunk::None, true, true), txt, ++i, cnt); + ctail = parseInternal(new Chunk(ctail, Chunk::None, true, true), txt, ++i, cnt, interpretNewLine); dumpattr(ctail, "after start group with text or group"); } else { - ctail = parseInternal(new Chunk(ctail->prev, Chunk::None, true, true), txt, ++i, cnt); + ctail = parseInternal(new Chunk(ctail->prev, Chunk::None, true, true), txt, ++i, cnt, interpretNewLine); } } if (!ctail) { @@ -533,7 +537,7 @@ } -Parsed *Label::parse(const QString& txt, bool interpret) { +Parsed *Label::parse(const QString& txt, bool interpret, bool interpretNewLine) { Parsed *parsed = new Parsed; Chunk *ctail = parsed->chunk = new Chunk(0L); if (!interpret) { @@ -543,7 +547,7 @@ uint start = 0; uint cnt = txt.length(); - Chunk *rc = parseInternal(ctail, txt, start, cnt); + Chunk *rc = parseInternal(ctail, txt, start, cnt, interpretNewLine); if (!rc) { // Parse error - how to recover? delete parsed; --- trunk/extragear/graphics/kst/src/libkstmath/labelparser.h #518633:518634 @@ -76,7 +76,7 @@ }; - extern KST_EXPORT Parsed *parse(const QString&, bool interpret = true); + extern KST_EXPORT Parsed *parse(const QString&, bool interpret = true, bool interpretNewLine = true); } #endif |