[Kst] kdeextragear-2/kst/kst

Barth Netterfield netterfield at astro.utoronto.ca
Wed Nov 3 16:38:58 CET 2004


CVS commit by netterfield: 

BUG:

As pointing out a while ago by Andrew, a change I made to allow empty *Labels 
to take up no room if they are empty also changed the way labels are handled 
in terms of what the correct justification should be. Since, up to now, the 
Justification of these otherwise fixed labels is stored in data file, this 
change meant that old files (August and earlier) request the wrong 
justification for the labels.

This patch does 2 things to the way that [X|Y|Tick]*Labels are handled.
1) it assumes that the position of these labels is fixed, and overwrites 
whatever justification might have been in the file.
2) it assumes that since neither the position nor the justification for these 
labels is going to be listened to, it shouldn't write them to the file.

It means that kst files written by new versions of kst will not work on old 
ksts, but old kst files will work on new ksts.


  M +10 -8     kst2dplot.cpp   1.299
  M +6 -4      kstlabel.cpp   1.48
  M +2 -1      kstlabel.h   1.32


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.298:1.299
@@ -207,5 +207,4 @@ Kst2DPlot::Kst2DPlot(QDomElement& e)
         in_xticklabel = new KstLabel(" ");
         in_xticklabel->read(el);
-        in_xticklabel->setJustification(CxTy);
         in_yticklabel = new KstLabel(" ");
         in_yticklabel->read(el);
@@ -319,4 +318,5 @@ Kst2DPlot::Kst2DPlot(QDomElement& e)
     delete XLabel;
     XLabel = in_xlabel;
+    XLabel->setJustification(CxBy);
   }
 
@@ -324,4 +324,5 @@ Kst2DPlot::Kst2DPlot(QDomElement& e)
     delete YLabel;
     YLabel = in_ylabel;
+    YLabel->setJustification(CxTy);
   }
 
@@ -329,4 +330,5 @@ Kst2DPlot::Kst2DPlot(QDomElement& e)
     delete XTickLabel;
     XTickLabel = in_xticklabel;
+    XTickLabel->setJustification(CxTy);
     XTickLabel->setDoScalarReplacement(false);
   }
@@ -335,4 +337,5 @@ Kst2DPlot::Kst2DPlot(QDomElement& e)
     delete YTickLabel;
     YTickLabel = in_yticklabel;
+    YTickLabel->setJustification(RxCy);
     YTickLabel->setDoScalarReplacement(false);
   }
@@ -2192,25 +2195,25 @@ void Kst2DPlot::save(QTextStream& ts, co
 
   ts << indent << "<xlabel>" << endl;
-  XLabel->save(ts, l2);
+  XLabel->save(ts, l2, false);
   ts << indent << "</xlabel>" << endl;
 
   ts << indent << "<ylabel>" << endl;
-  YLabel->save(ts, l2);
+  YLabel->save(ts, l2, false);
   ts << indent << "</ylabel>" << endl;
 
   ts << indent << "<xticklabel>" << endl;
-  XTickLabel->save(ts, l2);
+  XTickLabel->save(ts, l2, false);
   ts << indent << "</xticklabel>" << endl;
 
   ts << indent << "<yticklabel>" << endl;
-  YTickLabel->save(ts, l2);
+  YTickLabel->save(ts, l2, false);
   ts << indent << "</yticklabel>" << endl;
 
   ts << indent << "<xfullticklabel>" << endl;
-  XFullTickLabel->save(ts, l2);
+  XFullTickLabel->save(ts, l2, false);
   ts << indent << "</xfullticklabel>" << endl;
 
   ts << indent << "<yfullticklabel>" << endl;
-  YFullTickLabel->save(ts, l2);
+  YFullTickLabel->save(ts, l2, false);
   ts << indent << "</yfullticklabel>" << endl;
 
@@ -5698,5 +5701,4 @@ void Kst2DPlot::plotAxes(QPainter& p, QR
   // x axis numbers
   //
-  //genAxisTickLabels(p, tpx, x_min, x_max, _xLog, XTickLabel, true);
   if (tpx.delta && tpx.labels.count() > 0) {
     XFullTickLabel->setText(tpx.labels[0]);

--- kdeextragear-2/kst/kst/kstlabel.cpp  #1.47:1.48
@@ -632,5 +632,5 @@ void KstLabel::draw(QPainter &p, int px,
 
 
-void KstLabel::save(QTextStream &ts, const QString& indent) {
+void KstLabel::save(QTextStream &ts, const QString& indent, bool save_pos) {
   QString l2 = indent + "  ";
   ts << indent << "<text>" << QStyleSheet::escape(Text) << "</text>" << endl;
@@ -638,8 +638,10 @@ void KstLabel::save(QTextStream &ts, con
     ts << indent << "<interpret/>" << endl;
   }
-  ts << indent << "<justify>" << _justification << "</justify>" << endl;
   ts << indent << "<rotation>" << Rotation << "</rotation>" << endl;
+  if (save_pos) {
+    ts << indent << "<justify>" << _justification << "</justify>" << endl;
   ts << indent << "<xpos>" << _x << "</xpos>" << endl;
   ts << indent << "<ypos>" << _y << "</ypos>" << endl;
+  }
   ts << indent << "<fontfamily>" << QStyleSheet::escape(FontName) << "</fontfamily>" << endl;
   ts << indent << "<symbolfontfamily>" << QStyleSheet::escape(SymbolFontName) << "</symbolfontfamily>" << endl;

--- kdeextragear-2/kst/kst/kstlabel.h  #1.31:1.32
@@ -74,5 +74,6 @@ class KstLabel {
     int size() const;
 
-    void save(QTextStream& ts, const QString& indent = QString::null);
+    void save(QTextStream& ts, const QString& indent = QString::null,
+              bool save_pos=true);
     void read(QDomElement& e);
 





More information about the Kst mailing list