[Kst] extragear/graphics/kst/kst

Barth Netterfield netterfield at astro.utoronto.ca
Thu Dec 8 00:15:43 CET 2005


SVN commit 486483 by netterfield:

use reasonable legend defaults to plot dialog.

Make the legend dialog work.



 M  +10 -3     kstplotdialog_i.cpp  
 M  +42 -33    kstviewlegend.cpp  
 M  +11 -2     viewlegendwidget.ui  
 A             viewlegendwidget.ui.h   [License: no copyright]


--- trunk/extragear/graphics/kst/kst/kstplotdialog_i.cpp #486482:486483
@@ -301,11 +301,11 @@
 
     double xmin, ymin, xmax, ymax;
     plot->getScale(xmin, ymin, xmax, ymax);
-    
+
     QString xMinExp, xMaxExp, yMinExp, yMaxExp;
     plot->getXScaleExps(xMinExp, xMaxExp);
     plot->getYScaleExps(yMinExp, yMaxExp);
-    
+
     XACRange->setText(QString::number(xmax - xmin, 'g', 16));
     YACRange->setText(QString::number(ymax - ymin, 'g', 16));
 
@@ -461,8 +461,15 @@
       _transparent->setChecked(vl->transparent());
       legendColors->setForeground(vl->foregroundColor());
       legendColors->setBackground(vl->backgroundColor());
-    } else {
+    } else { // plot does not currently have a legend: use defaults.
       ShowLegend->setChecked(false);
+      legendColors->setForeground(KstSettings::globalSettings()->foregroundColor);
+      legendColors->setBackground(KstSettings::globalSettings()->backgroundColor);
+      LegendFontComboBox->setCurrentFont(KstApp::inst()->defaultFont());
+      LegendFontSize->setValue(0);
+      checkBoxVerticalLayout->setChecked(true);
+      _border->setValue(2);
+      _transparent->setChecked(false);
     }
     // initialize the plot color widget
     plotColors->setForeground(plot->foregroundColor());
--- trunk/extragear/graphics/kst/kst/kstviewlegend.cpp #486482:486483
@@ -28,6 +28,7 @@
 #include "kstviewobjectfactory.h"
 #include "labelrenderer.h"
 #include "viewlegendwidget.h"
+#include "plotlistbox.h"
 
 #include <kdatastream.h>
 #include <kglobal.h>
@@ -375,38 +376,7 @@
 void KstViewLegend::readBinary(QDataStream& str) {
 }
 
-/*
-QMap<QString, QVariant> KstViewLegend::widgetHints(const QString& propertyName) const {
-  QMap<QString, QVariant> map = KstBorderedViewObject::widgetHints(propertyName);
-  if (!map.empty()) {
-    return map;
-  }
 
-  if (propertyName == "text") {
-    map.insert(QString("_kst_widgetType"), QString("QLineEdit"));
-    map.insert(QString("_kst_label"), i18n("Text"));
-  } else if (propertyName == "font") {
-    map.insert(QString("_kst_widgetType"), QString("KFontCombo"));
-    map.insert(QString("_kst_label"), i18n("Font"));
-  } else if (propertyName == "foregroundColor") {
-    map.insert(QString("_kst_widgetType"), QString("KColorButton"));
-    map.insert(QString("_kst_label"), i18n("Font color"));
-  } else if (propertyName == "backgroundColor") {
-    map.insert(QString("_kst_widgetType"), QString("KColorButton"));
-    map.insert(QString("_kst_label"), i18n("Background color"));
-  } else if (propertyName == "fontSize") {
-    map.insert(QString("_kst_widgetType"), QString("QSpinBox"));
-    map.insert(QString("_kst_label"), i18n("Font size"));
-    map.insert(QString("minValue"), MIN_FONT_SIZE - (double)KstSettings::globalSettings()->plotFontSize);
-  } else if (propertyName == "transparent") {
-    map.insert(QString("_kst_widgetType"), QString("QCheckBox"));
-    map.insert(QString("_kst_label"), QString::null);
-    map.insert(QString("text"), i18n("Transparent fill"));
-  }
-  return map;
-}*/
-
-
 bool KstViewLegend::transparent() const {
   return KstViewObject::transparent();
 }
@@ -443,6 +413,8 @@
     return false;
   }
 
+  KstBaseCurveList allCurves = kstObjectSubList<KstDataObject, KstBaseCurve>(KST::dataObjectList);
+
   if (Curves.isEmpty()) { // its probably new: set widget to defaults
     widget->_fontSize->setValue(0);
     widget->_fontColor->setColor(KstSettings::globalSettings()->foregroundColor);
@@ -453,6 +425,12 @@
 
     widget->_transparent->setChecked(false);
     widget->_border->setValue(2);
+    
+    for (KstBaseCurveList::iterator it = allCurves.begin(); it != allCurves.end(); ++it) {
+      (*it)->readLock();
+      widget->AvailableCurveList->insertItem((*it)->tagName());
+      (*it)->readUnlock();
+    }
 
   } else { // fill legend properties into widget
     widget->_fontSize->setValue(int(fontSize()));
@@ -463,6 +441,19 @@
     widget->_boxColors->setForeground(borderColor());
     widget->_boxColors->setBackground(backgroundColor());
     widget->_margin->setValue(padding());
+
+    for (KstBaseCurveList::ConstIterator it = Curves.begin(); it != Curves.end(); ++it) {
+      (*it)->readLock();
+      widget->DisplayedCurveList->insertItem((*it)->tagName());
+      (*it)->readUnlock();
+    }
+    for (KstBaseCurveList::iterator it = allCurves.begin(); it != allCurves.end(); ++it) {
+      (*it)->readLock();
+      if (Curves.find(*it) == Curves.end()) {
+        widget->AvailableCurveList->insertItem((*it)->tagName());
+      }
+      (*it)->readUnlock();
+    }
   }
   return false;
 }
@@ -475,8 +466,26 @@
     return false;
   }
 
-  // FIXME
-  return false;
+  setFontSize(widget->_fontSize->value());
+  setForegroundColor(widget->_fontColor->color());
+  setFontName(widget->_font->currentFont());
+
+  setTransparent(widget->_transparent->isChecked());
+  setBorderWidth(widget->_border->value());
+  setBorderColor(widget->_boxColors->foreground());
+  setBackgroundColor(widget->_boxColors->background());
+
+  KstBaseCurveList allCurves = kstObjectSubList<KstDataObject, KstBaseCurve>(KST::dataObjectList);
+  Curves.clear();
+  for (unsigned i = 0; i < widget->DisplayedCurveList->count(); i++) {
+    KstBaseCurveList::Iterator it = allCurves.findTag(widget->DisplayedCurveList->text(i));
+    if (it != allCurves.end()) {
+      Curves.append(*it);
+    }
+  }
+
+  setDirty();
+  return true;
 }
 
 
--- trunk/extragear/graphics/kst/kst/viewlegendwidget.ui #486482:486483
@@ -139,7 +139,7 @@
                         </property>
                         <widget class="QPushButton">
                             <property name="name">
-                                <cstring>CurveUnplot_3</cstring>
+                                <cstring>CurveUnplot</cstring>
                             </property>
                             <property name="enabled">
                                 <bool>false</bool>
@@ -164,7 +164,7 @@
                         </widget>
                         <widget class="QPushButton">
                             <property name="name">
-                                <cstring>CurvePlot_3</cstring>
+                                <cstring>CurvePlot</cstring>
                             </property>
                             <property name="enabled">
                                 <bool>false</bool>
@@ -424,7 +424,16 @@
 <includes>
     <include location="local" impldecl="in implementation">plotlistbox.h</include>
     <include location="global" impldecl="in declaration">kst_export.h</include>
+    <include location="local" impldecl="in implementation">viewlegendwidget.ui.h</include>
 </includes>
+<slots>
+    <slot specifier="non virtual">updateButtons()</slot>
+    <slot specifier="non virtual">removeDisplayedCurve()</slot>
+    <slot specifier="non virtual">addDisplayedCurve()</slot>
+</slots>
+<functions>
+    <function access="private" specifier="non virtual">init()</function>
+</functions>
 <exportmacro>KST_EXPORT</exportmacro>
 <layoutdefaults spacing="6" margin="11"/>
 <includehints>


More information about the Kst mailing list