[Kst] extragear/graphics/kst/kst
Barth Netterfield
netterfield at astro.utoronto.ca
Thu Nov 17 21:26:22 CET 2005
SVN commit 481083 by netterfield:
Arbitrary text for curve legend entries, and changes to the curve dialog
to support this.
Not yet supported in the other dialogs.
M +14 -0 kstbasecurve.cpp
M +8 -3 kstbasecurve.h
M +20 -0 kstcurvedialog_i.cpp
M +0 -8 kstvcurve.cpp
M +0 -2 kstvcurve.h
--- trunk/extragear/graphics/kst/kst/kstbasecurve.cpp #481082:481083
@@ -53,5 +53,19 @@
_ignoreAutoScale = ignoreAutoScale;
}
+void KstBaseCurve::updateParsedLegendTag() {
+ delete _parsedLegendTag;
+ if (_legendText.isEmpty()) {
+ _parsedLegendTag = Label::parse(tagName(), true);
+ } else {
+ _parsedLegendTag = Label::parse(legendText(), true);
+ }
+}
+Label::Parsed *KstBaseCurve::parsedLegendTag() {
+ if (!_parsedLegendTag) {
+ updateParsedLegendTag();
+ }
+ return _parsedLegendTag;
+}
// vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/kstbasecurve.h #481082:481083
@@ -99,14 +99,19 @@
// render the legend symbol for this curve
virtual void paintLegendSymbol(QPainter *p, const QRect& bound) = 0;
- // return the parsed legend tag
- virtual Label::Parsed *parsedLegendTag() {return NULL;}
// just store the size of the legend tag here. The viewLegend actually uses and calculates it.
virtual QSize legendLabelSize() const {return _legendLabelSize;}
virtual void setLegendLabelSize(QSize ls) {_legendLabelSize = ls;}
- void setLegendText(const QString& theValue) { _legendText = theValue; }
+ // Deal with the legend tag.
+ // The actual text is always stored in the base class.
+ // If _legendText == QString("") then the tagname should be used as the legend text.
+ // The label is parsed every time the legnend text is changed.
+ virtual Label::Parsed *parsedLegendTag();
+ virtual void updateParsedLegendTag();
+
+ void setLegendText(const QString& theValue) { _legendText = theValue; updateParsedLegendTag(); }
QString legendText() const { return _legendText;}
protected:
--- trunk/extragear/graphics/kst/kst/kstcurvedialog_i.cpp #481082:481083
@@ -126,6 +126,11 @@
cp->readLock();
_tagName->setText(cp->tagName());
+ if (cp->legendText() == "") {
+ _legendText->setText(defaultTag);
+ } else {
+ _legendText->setText(cp->legendText());
+ }
_w->_xVector->setSelection(cp->xVTag());
_w->_yVector->setSelection(cp->yVTag());
@@ -167,6 +172,7 @@
KstVCurveList curves = kstObjectSubList<KstDataObject, KstVCurve>(KST::dataObjectList);
_tagName->setText(defaultTag);
+ _legendText->setText(defaultTag);
_w->_curvePlacement->update();
// for some reason the lower widget needs to be shown first to prevent overlapping?
@@ -271,6 +277,14 @@
haveExMinus ? *EXMinus : KstVectorPtr(0L),
haveEyMinus ? *EYMinus : KstVectorPtr(0L),
_w->_curveAppearance->color());
+
+ QString legend_text = _legendText->text();
+ if (legend_text == defaultTag) {
+ curve->setLegendText(QString(""));
+ } else {
+ curve->setLegendText(legend_text);
+ }
+
KST::vectorList.lock().readUnlock();
curve->setHasPoints(_w->_curveAppearance->showPoints());
@@ -483,6 +497,12 @@
cp->writeLock();
cp->setTagName(tag_name);
+ QString legend_text = _legendText->text();
+ if (legend_text==defaultTag) {
+ cp->setLegendText(QString(""));
+ } else {
+ cp->setLegendText(legend_text);
+ }
cp->writeUnlock();
// then edit the object
--- trunk/extragear/graphics/kst/kst/kstvcurve.cpp #481082:481083
@@ -1553,13 +1553,5 @@
p->restore();
}
-Label::Parsed *KstVCurve::parsedLegendTag(){
- //FIXME: massive optimization needed, but this will get us going for now.
- delete _parsedLegendTag;
- _parsedLegendTag = Label::parse(tagName(), true);
- return _parsedLegendTag;
-}
-
-
// vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/kstvcurve.h #481082:481083
@@ -148,8 +148,6 @@
// see KstBaseCurve::providerDataObject
virtual KstDataObjectPtr providerDataObject() const;
- virtual Label::Parsed *parsedLegendTag();
-
private:
inline void commonConstructor(const QString& in_tag, const QColor& in_color);
More information about the Kst
mailing list