Summary: | Legends are not updated when moved to a different plot | ||
---|---|---|---|
Product: | [Applications] kst | Reporter: | Nicolas Brisset <nicolas.brisset> |
Component: | general | Assignee: | Duncan Hanson <duncan.hanson> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | 1.x | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Solaris | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | Proposed patch. |
Description
Nicolas Brisset
2006-04-05 17:42:39 UTC
Created attachment 16056 [details]
Proposed patch.
Hello All, Here is a small proposed patch for the problem. Are there any glaring problems? Duncan. Quoting Duncan Hanson <duncan.hanson@gmail.com>: > Created an attachment (id=16056) > --> (http://bugs.kde.org/attachment.cgi?id=16056&action=view) > Proposed patch. Looks good. Never mind- I've completely misunderstood the code. Please ignore this patch. On Fri, 2006-05-12 at 23:40 +0000, Duncan Hanson wrote: [bugs.kde.org quoted mail] Hm it might still be a good idea to have a patch that updates the legend when the label is changed in the curve like that. SVN commit 541132 by dhanson: BUG:124986 this should cover all of the ways a curve's legend entry can be modified. M +5 -0 libkstapp/kstviewlegend.cpp M +1 -0 libkstapp/kstviewlegend.h M +7 -0 libkstmath/kstbasecurve.cpp M +6 -2 libkstmath/kstbasecurve.h M +8 -0 libkstmath/kstvcurve.cpp --- trunk/extragear/graphics/kst/src/libkstapp/kstviewlegend.cpp #541131:541132 @@ -485,6 +485,9 @@ setContentsRect(cr); } +void KstViewLegend::modifiedLegendEntry() { + setDirty(); +} bool KstViewLegend::layoutPopupMenu(KPopupMenu *menu, const QPoint& pos, KstViewObjectPtr topLevelParent) { return KstViewObject::layoutPopupMenu(menu, pos, topLevelParent); @@ -524,6 +527,7 @@ void KstViewLegend::addCurve(KstBaseCurvePtr incurve) { if (!_curves.contains(incurve)) { _curves.append(incurve); + connect(incurve, SIGNAL(modifiedLegendEntry()), this, SLOT(modifiedLegendEntry())); setDirty(); } } @@ -532,6 +536,7 @@ void KstViewLegend::removeCurve(KstBaseCurvePtr incurve) { if (_curves.contains(incurve)) { _curves.remove(incurve); + disconnect(incurve,SIGNAL(modifiedLegendEntry()), this, SLOT(modifiedLegendEntry())); setDirty(); } } --- trunk/extragear/graphics/kst/src/libkstapp/kstviewlegend.h #541131:541132 @@ -93,6 +93,7 @@ public slots: void adjustSizeForText(QRect w); + void modifiedLegendEntry(void); protected: KstViewObjectFactoryMethod factory() const; --- trunk/extragear/graphics/kst/src/libkstmath/kstbasecurve.cpp #541131:541132 @@ -68,4 +68,11 @@ } return _parsedLegendTag; } + +void KstBaseCurve::setLegendText(const QString& theValue) { + _legendText = theValue; + updateParsedLegendTag(); + emit modifiedLegendEntry(); +} + // vim: ts=2 sw=2 et --- trunk/extragear/graphics/kst/src/libkstmath/kstbasecurve.h #541131:541132 @@ -46,6 +46,8 @@ enum KstCurveType { KST_VCURVE, KST_HISTOGRAM, KST_IMAGE }; class KST_EXPORT KstBaseCurve : public KstDataObject { + Q_OBJECT + public: KstBaseCurve(); KstBaseCurve(const QDomElement& e); @@ -112,7 +114,7 @@ virtual Label::Parsed *parsedLegendTag(); virtual void updateParsedLegendTag(); - void setLegendText(const QString& theValue) { _legendText = theValue; updateParsedLegendTag(); } + void setLegendText(const QString& theValue); QString legendText() const { return _legendText;} protected: @@ -138,8 +140,10 @@ private: void commonConstructor(); -private: QString _legendText; + + signals: + void modifiedLegendEntry(void); }; --- trunk/extragear/graphics/kst/src/libkstmath/kstvcurve.cpp #541131:541132 @@ -739,48 +739,56 @@ void KstVCurve::setHasPoints(bool in_HasPoints) { HasPoints = in_HasPoints; setDirty(); + emit modifiedLegendEntry(); } void KstVCurve::setHasLines(bool in_HasLines) { HasLines = in_HasLines; setDirty(); + emit modifiedLegendEntry(); } void KstVCurve::setHasBars(bool in_HasBars) { HasBars = in_HasBars; setDirty(); + emit modifiedLegendEntry(); } void KstVCurve::setLineWidth(int in_LineWidth) { LineWidth = in_LineWidth; setDirty(); + emit modifiedLegendEntry(); } void KstVCurve::setLineStyle(int in_LineStyle) { LineStyle = in_LineStyle; setDirty(); + emit modifiedLegendEntry(); } void KstVCurve::setBarStyle(int in_BarStyle) { BarStyle = in_BarStyle; setDirty(); + emit modifiedLegendEntry(); } void KstVCurve::setPointDensity(int in_PointDensity) { PointDensity = in_PointDensity; setDirty(); + emit modifiedLegendEntry(); } void KstVCurve::setColor(const QColor& new_c) { setDirty(); Color = new_c; + emit modifiedLegendEntry(); } There will still be some quirky legend behaviour associated with this bug. For example, when a legend is moved to a different plot, removing the curve from the plot will not remove the corresponding legend entry. I think that this is a tricky problem to fix, because the plot must remove the curve from the legend before the curve is deleted, but we can't expect the plot to know which curves belong to legends in other plots. It would be nice to be able to emit a deletedCurve() signal from the curve destructor, the appropriate legends could catch, but this won't work. The KstSharedPtr in the legend's list of curves keeps the curve from ever destructing. Can anyone think of a solution? not completely fixed. Current behaviour is probably best which is possible (without doing something complicated, like introducing a KstGuardedPtr.) |