[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Sun Nov 20 19:38:49 CET 2005


SVN commit 481822 by staikos:

- update the plots when the timezone changes
- small cleanups and use const iterators where possible in the legend code
BUG: 116453


 M  +13 -2     kst2dplot.cpp  
 M  +2 -0      kst2dplot.h  
 M  +21 -13    kstviewlegend.cpp  


--- trunk/extragear/graphics/kst/kst/kst2dplot.cpp #481821:481822
@@ -505,6 +505,7 @@
                                 double ymax_in,
                                 bool x_log,
                                 bool y_log) {
+  connect(KstApp::inst(), SIGNAL(timezoneChanged(const QString&, int)), this, SLOT(timezoneChanged(const QString&, int)));
   _xLabel = new KstPlotLabel;
   _yLabel = new KstPlotLabel(270);
   _topLabel = new KstPlotLabel;
@@ -6456,13 +6457,23 @@
     appendChild(KstViewObjectPtr(vl), true);
     vl->resizeFromAspect(0.1, 0.1, 0.2, 0.1);
     for (KstBaseCurveList::Iterator it = Curves.begin(); it != Curves.end(); ++it) {
-      vl->addCurve((*it));
+      vl->addCurve(*it);
     }
   }
   return vl;
 }
 
-QRect Kst2DPlot::contentsRect() const{
+
+void Kst2DPlot::timezoneChanged(const QString& tz, int utcOffset) {
+  Q_UNUSED(tz)
+  Q_UNUSED(utcOffset)
+  setDirty();
+  KstViewWidget *view = KstApp::inst()->activeView()->widget();
+  static_cast<KstViewWidget*>(view)->paint();
+}
+
+
+QRect Kst2DPlot::contentsRect() const {
   return QRect(PlotRegion.left() + geometry().left(), 
                PlotRegion.top() + geometry().top(),
                PlotRegion.width(),
--- trunk/extragear/graphics/kst/kst/kst2dplot.h #481821:481822
@@ -391,6 +391,8 @@
   void menuNextMarker();
   void menuPrevMarker();
 
+  void timezoneChanged(const QString& tz, int utcOffset);
+
 protected:
   virtual KstViewObjectFactoryMethod factory() const;
 
--- trunk/extragear/graphics/kst/kst/kstviewlegend.cpp #481821:481822
@@ -35,6 +35,7 @@
 
 #include <qapplication.h>
 #include <qbitmap.h>
+#include <qdeepcopy.h>
 #include <qmetaobject.h>
 #include <qptrstack.h>
 #include <qstylesheet.h>
@@ -87,9 +88,10 @@
   }
 
   KstBaseCurveList l = kstObjectSubList<KstDataObject,KstBaseCurve>(KST::dataObjectList);
-  for (QStringList::iterator str = ctaglist.begin(); str!=ctaglist.end(); ++str) {
-    KstBaseCurveList::Iterator it = l.findTag(*str);
-    if (it != l.end()) {
+  KstBaseCurveList::ConstIterator end = l.end();
+  for (QStringList::ConstIterator str = ctaglist.begin(); str != ctaglist.end(); ++str) {
+    KstBaseCurveList::ConstIterator it = l.findTag(*str);
+    if (it != end) {
       addCurve(*it);
     }
   }
@@ -99,6 +101,7 @@
 KstViewLegend::~KstViewLegend() {
 }
 
+
 void KstViewLegend::resize(const QSize& size) {
   KstBorderedViewObject::resize(size);
   drawToBuffer();
@@ -122,11 +125,12 @@
   return _fontName;
 }
 
+
 void KstViewLegend::save(QTextStream &ts, const QString& indent) {
   ts << indent << "<" << type() << ">" << endl;
   KstBorderedViewObject::save(ts, indent + "  ");
   
-  for (KstBaseCurveList::Iterator j = Curves.begin(); j != Curves.end(); ++j) {
+  for (KstBaseCurveList::ConstIterator j = Curves.begin(); j != Curves.end(); ++j) {
     (*j)->readLock();
     ts << indent+"  " << "<curvetag>" << QStyleSheet::escape((*j)->tagName()) << "</curvetag>" << endl;
     (*j)->readUnlock();
@@ -135,6 +139,7 @@
   ts << indent << "</" << type() << ">" << endl;
 }
 
+
 void KstViewLegend::drawToBuffer() {
   setDirty(false);
 
@@ -192,6 +197,7 @@
   QApplication::syncX();
 }
 
+
 void KstViewLegend::computeTextSize() {
   _textWidth = 0;
   _ascent = 0;
@@ -219,9 +225,9 @@
   } else {
     _textWidth += Curves.count()*_ascent;
   }
-
 }
 
+
 void KstViewLegend::paint(KstPaintType type, QPainter& p, const QRegion& bounds) {
   if (type == P_PRINT) {
     p.save();
@@ -336,6 +342,7 @@
   return true;
 }
 
+
 KstViewObjectPtr create_KstViewLegend() {
   return KstViewObjectPtr(new KstViewLegend());
 }
@@ -386,30 +393,31 @@
   return map;
 }
 
+
+bool KstViewLegend::transparent() const {
+  return KstViewObject::transparent();
+}
+
+
 void KstViewLegend::setTransparent(bool transparent) {
   KstViewObject::setTransparent(transparent);
 }
 
 
-bool KstViewLegend::transparent() const {
-  return KstViewObject::transparent();
-}
-
 void KstViewLegend::addCurve(KstBaseCurvePtr incurve) {
   Curves.append(incurve);
   setDirty();
 }
 
+
 void KstViewLegend::removeCurve(KstBaseCurvePtr incurve) {
   Curves.remove(incurve);
   setDirty();
 }
 
+
 void KstViewLegend::setCurveList(Kst2DPlot *pl) {
-  Curves.clear();
-  for (KstBaseCurveList::Iterator i = pl->Curves.begin(); i != pl->Curves.end(); ++i) {
-    Curves.append(*i);
-  }
+  Curves = QDeepCopy<KstBaseCurveList>(pl->Curves);
 }
 
 #include "kstviewlegend.moc"


More information about the Kst mailing list