[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Wed Dec 7 07:16:33 CET 2005


SVN commit 486234 by staikos:

some cleanups including checking the result of the dynamic cast, not the
argument to it


 M  +2 -2      kstviewlabel.cpp  
 M  +41 -29    kstviewlegend.cpp  


--- trunk/extragear/graphics/kst/kst/kstviewlabel.cpp #486233:486234
@@ -541,7 +541,7 @@
 
 bool KstViewLabel::fillConfigWidget(QWidget *w) const {
   ViewLabelWidget *widget = dynamic_cast<ViewLabelWidget*>(w);
-  if (!w) {
+  if (!widget) {
     return false;
   }
   
@@ -598,7 +598,7 @@
 
 bool KstViewLabel::readConfigWidget(QWidget *w) {
   ViewLabelWidget *widget = dynamic_cast<ViewLabelWidget*>(w);
-  if (!w) {
+  if (!widget) {
     return false;
   }
 
--- trunk/extragear/graphics/kst/kst/kstviewlegend.cpp #486233:486234
@@ -160,7 +160,7 @@
   RenderContext rc(_fontName, _absFontSize, &p);
 
   if (_vertical) {
-    unsigned i=0;
+    unsigned i = 0;
     for (KstBaseCurveList::Iterator it = Curves.begin(); it != Curves.end(); ++it) {
       p.save();
       if ((*it)->parsedLegendTag()) {
@@ -187,7 +187,7 @@
                           QSize(16*_ascent/4, rc.fontHeight()));
         (*it)->paintLegendSymbol(&p, symbolBound);
         p.translate(9*_ascent/2, 0);
-        rc.x = 0;//Curves[i]->legendLabelSize().width() / 2;
+        rc.x = 0;//(*it)->legendLabelSize().width() / 2;
         rc.y = _ascent;
         rc.xStart = rc.x;
         renderLabel(rc, (*it)->parsedLegendTag()->chunk);
@@ -206,14 +206,18 @@
   _ascent = 0;
   _textHeight = 0;
 
-  for(KstBaseCurveList::iterator it = Curves.begin(); it != Curves.end(); it++) {
+  for (KstBaseCurveList::Iterator it = Curves.begin(); it != Curves.end(); it++) {
     if ((*it)->parsedLegendTag()) {
       RenderContext rc(_fontName, _absFontSize, 0L);
       renderLabel(rc, (*it)->parsedLegendTag()->chunk);
       if (_vertical) {
-        if (rc.xMax>_textWidth) _textWidth = rc.xMax;
+        if (rc.xMax>_textWidth) {
+          _textWidth = rc.xMax;
+        }
       } else {
-        if (rc.fontHeight()>_textHeight) _textHeight = rc.fontHeight();
+        if (rc.fontHeight() > _textHeight) {
+          _textHeight = rc.fontHeight();
+        }
         _textWidth += rc.xMax;
       }
       (*it)->setLegendLabelSize(QSize(rc.xMax, rc.fontHeight()));
@@ -342,8 +346,7 @@
 
 
 bool KstViewLegend::layoutPopupMenu(KPopupMenu *menu, const QPoint& pos, KstViewObjectPtr topLevelParent) {
-  KstViewObject::layoutPopupMenu(menu, pos, topLevelParent);
-  return true;
+  return KstViewObject::layoutPopupMenu(menu, pos, topLevelParent);
 }
 
 
@@ -409,8 +412,10 @@
 
 
 void KstViewLegend::addCurve(KstBaseCurvePtr incurve) {
-  Curves.append(incurve);
-  setDirty();
+  if (!Curves.contains(incurve)) {
+    Curves.append(incurve);
+    setDirty();
+  }
 }
 
 
@@ -428,30 +433,32 @@
 /** fill the custom widget with current properties */
 bool KstViewLegend::fillConfigWidget(QWidget *w) const {
   ViewLegendWidget *widget = dynamic_cast<ViewLegendWidget*>(w);
-  if (!w) {
+  if (!widget) {
     return false;
   }
 
-  if (Curves.count()<1) { // its empty so probably new: set widget to defaults
-    // widget->_fontSize->setValue(0);
-    // widget->_fontColor->setColor(KstSettings::globalSettings()->foregroundColor);
-    // widget->_font->setCurrentFont(KstApp::inst()->defaultFont());
-    // widget->_margin->setValue(5);
-    // widget->_boxColors->setForeground(KstSettings::globalSettings()->foregroundColor);
-    // widget->_boxColors->setBackground(KstSettings::globalSettings()->backgroundColor);
-
-    // widget->_transparent->setChecked(false);
-    // widget->_border->setValue(2);
-
+  if (Curves.isEmpty()) { // its probably new: set widget to defaults
+#if 0
+    widget->_fontSize->setValue(0);
+    widget->_fontColor->setColor(KstSettings::globalSettings()->foregroundColor);
+    widget->_font->setCurrentFont(KstApp::inst()->defaultFont());
+    widget->_margin->setValue(5);
+    widget->_boxColors->setForeground(KstSettings::globalSettings()->foregroundColor);
+    widget->_boxColors->setBackground(KstSettings::globalSettings()->backgroundColor);
+    widget->_transparent->setChecked(false);
+    widget->_border->setValue(2);
+#endif
   } else { // fill legend properties into widget
-    // widget->_fontSize->setValue(int(fontSize()));
-    // widget->_fontColor->setColor(foregroundColor());
-    // widget->_font->setCurrentFont(fontName());
-    // widget->_transparent->setChecked(transparent());
-    // widget->_border->setValue(borderWidth());
-    // widget->_boxColors->setForeground(borderColor());
-    // widget->_boxColors->setBackground(backgroundColor());
-    // widget->_margin->setValue(padding());
+#if 0
+    widget->_fontSize->setValue(int(fontSize()));
+    widget->_fontColor->setColor(foregroundColor());
+    widget->_font->setCurrentFont(fontName());
+    widget->_transparent->setChecked(transparent());
+    widget->_border->setValue(borderWidth());
+    widget->_boxColors->setForeground(borderColor());
+    widget->_boxColors->setBackground(backgroundColor());
+    widget->_margin->setValue(padding());
+#endif
   }
   return false;
 }
@@ -459,6 +466,11 @@
 
 /** apply properties in the custom config widget to this */
 bool KstViewLegend::readConfigWidget(QWidget *w) {
+  ViewLegendWidget *widget = dynamic_cast<ViewLegendWidget*>(w);
+  if (!widget) {
+    return false;
+  }
+
   // FIXME
   return false;
 }


More information about the Kst mailing list