[Kst] extragear/graphics/kst/src/libkstapp

George Staikos staikos at kde.org
Mon Jan 22 08:18:23 CET 2007


SVN commit 626110 by staikos:

- partially repair the broken API
- remove unnecessary strlen calls in expression parsing
- de-slot some non-slots
- remove undefined symbol
- minor cleanup


 M  +1 -1      kst2dplot.cpp  
 M  +3 -3      kstborderedviewobject.cpp  
 M  +6 -4      kstborderedviewobject.h  
 M  +6 -6      kstviewlabel.cpp  
 M  +2 -2      kstviewlabel.h  
 M  +4 -4      kstviewlegend.cpp  
 M  +3 -4      kstviewlegend.h  
 M  +1 -1      kstviewpicture.cpp  
 M  +3 -2      labelrenderer.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kst2dplot.cpp #626109:626110
@@ -1952,7 +1952,7 @@
       QString replacedExp = isX ? _xTransformedExp : _yTransformedExp;
       replacedExp.replace(isX ? "x" : "y", QString::number(originalNumber), false);
       bool transformedOK = false;
-      double transformedNumber = Equation::interpret(replacedExp.latin1(), &transformedOK);
+      double transformedNumber = Equation::interpret(replacedExp.latin1(), &transformedOK, replacedExp.length());
       tick_label->setText(QString::number(transformedNumber, 'g', LABEL_PRECISION));
       if (!transformedOK) {
         tick_label->setText("NaN");
--- trunk/extragear/graphics/kst/src/libkstapp/kstborderedviewobject.cpp #626109:626110
@@ -164,7 +164,7 @@
 }
 
 
-QRect KstBorderedViewObject::contentsRectForDevice(const KstPainter& painter) const {
+QRect KstBorderedViewObject::contentsRectForPainter(const KstPainter& painter) const {
   QRect rc;
   const int mpb = (_margin + _padding + _borderWidth) * painter.lineWidthAdjustmentFactor();
   rc.setX(_geom.left() + mpb);
@@ -186,7 +186,7 @@
 }
 
 
-void KstBorderedViewObject::setContentsRectForDevice(const KstPainter& painter, QRect& rect) {
+void KstBorderedViewObject::setContentsRectForPainter(const KstPainter& painter, const QRect& rect) {
   const int mpb = (_margin + _padding + _borderWidth) * painter.lineWidthAdjustmentFactor();
   _geom.setX(rect.left() - mpb);
   _geom.setY(rect.top() - mpb);
@@ -195,7 +195,7 @@
 }
 
 
-void KstBorderedViewObject::setContentsRect(QRect& rect) {
+void KstBorderedViewObject::setContentsRect(const QRect& rect) {
   const int mpb = _margin + _padding + _borderWidth;
   _geom.setX(rect.left() - mpb);
   _geom.setY(rect.top() - mpb);
--- trunk/extragear/graphics/kst/src/libkstapp/kstborderedviewobject.h #626109:626110
@@ -91,7 +91,7 @@
 
     // See above for gross details
     virtual QRect contentsRect() const;
-    virtual void setContentsRect(QRect& rect);
+    virtual void setContentsRect(const QRect& rect);
     
     virtual QMap<QString, QVariant> widgetHints(const QString& propertyName) const;
     
@@ -103,13 +103,15 @@
 
     virtual void paintSelf(KstPainter& p, const QRegion& bounds);
 
-    QRect contentsRectForDevice(const KstPainter& painter) const;
-    virtual void setContentsRectForDevice(const KstPainter& painter, QRect& rect);
-  
   protected:
     virtual void readBinary(QDataStream& str);
     virtual void writeBinary(QDataStream& str);
     void saveAttributesOnly(QTextStream& ts, const QString& indent = QString::null);
+    // Internal, indication of design problem.  Adjusts the contents rect based
+    // on a given line width adjustment factor.
+    QRect contentsRectForPainter(const KstPainter& painter) const;
+    void setContentsRectForPainter(const KstPainter& painter, const QRect& rect);
+  
 
   private:
     QColor _borderColor;
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewlabel.cpp #626109:626110
@@ -382,9 +382,9 @@
   if (p.type() == KstPainter::P_PRINT || p.type() == KstPainter::P_EXPORT) {
     int absFontSizeOld = _absFontSize;
     
-    QRect cr(contentsRectForDevice(p));
+    QRect cr(contentsRectForPainter(p));
     cr.setSize(sizeForText(_parent->geometry()));
-    setContentsRectForDevice(p, cr);    
+    setContentsRectForPainter(p, cr);    
     KstBorderedViewObject::paintSelf(p, bounds);
     
     p.translate(cr.left(), cr.top());
@@ -461,14 +461,14 @@
 }
 
 
-void KstViewLabel::adjustSizeForText(QRect w) {
+void KstViewLabel::adjustSizeForText(const QRect& w) {
   QRect cr(contentsRect());
   cr.setSize(sizeForText(w));
   setContentsRect(cr);
 }
 
 
-QSize KstViewLabel::sizeForText(QRect w) {
+QSize KstViewLabel::sizeForText(const QRect& w) {
   double x_s, y_s;
   
   x_s = y_s = _fontSize + (double)KstSettings::globalSettings()->plotFontSize;
@@ -831,7 +831,7 @@
       case DataRef::DRExpression:
         {
           bool ok = false;
-          const double val = Equation::interpret((*i).name.latin1(), &ok);
+          const double val = Equation::interpret((*i).name.latin1(), &ok, (*i).name.length());
           if (QVariant(val) != (*i).value) {
             valid = false;
           }
@@ -840,7 +840,7 @@
       case DataRef::DRVector:
         {
           bool ok = false;
-          const double idx = Equation::interpret((*i).index.latin1(), &ok);
+          const double idx = Equation::interpret((*i).index.latin1(), &ok, (*i).index.length());
           if (idx != (*i).indexValue) {
             valid = false;
             break;
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewlabel.h #626109:626110
@@ -99,10 +99,10 @@
     void connectConfigWidget(QWidget *parent, QWidget *w) const;
     
     KstObject::UpdateType update(int counter);
+    void adjustSizeForText(const QRect& w);
+    QSize sizeForText(const QRect& w);
 
   public slots:
-    void adjustSizeForText(QRect w);
-    QSize sizeForText(QRect w);
     void reparse();
 
   protected:
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewlegend.cpp #626109:626110
@@ -363,9 +363,9 @@
 void KstViewLegend::paintSelf(KstPainter& p, const QRegion& bounds) {
   if (p.type() == KstPainter::P_PRINT || p.type() == KstPainter::P_EXPORT) {
     p.save();
-    QRect cr(contentsRectForDevice(p));
+    QRect cr(contentsRectForPainter(p));
     cr.setSize(sizeForText(_parent->geometry()));
-    setContentsRectForDevice(p, cr);    
+    setContentsRectForPainter(p, cr);    
     KstBorderedViewObject::paintSelf(p, bounds);
     
     p.translate(cr.left(), cr.top());
@@ -442,14 +442,14 @@
 }
 
 
-void KstViewLegend::adjustSizeForText(QRect w) {
+void KstViewLegend::adjustSizeForText(const QRect& w) {
   QRect cr(contentsRect());
   cr.setSize(sizeForText(w));
   setContentsRect(cr);
 }
 
 
-QSize KstViewLegend::sizeForText(QRect w) {
+QSize KstViewLegend::sizeForText(const QRect& w) {
   double x_s, y_s;
 
   x_s = y_s = _fontSize + (double)KstSettings::globalSettings()->plotFontSize;
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewlegend.h #626109:626110
@@ -98,11 +98,11 @@
     void invalidateClipRegion();
     bool trackContents() const;
     void setTrackContents(bool track);
+    void adjustSizeForText(const QRect& w);
+    QSize sizeForText(const QRect& w);
 
   public slots:
-    void adjustSizeForText(QRect w);
-    QSize sizeForText(QRect w);
-    void modifiedLegendEntry(void);
+    void modifiedLegendEntry();
 
   protected:
     KstViewObjectFactoryMethod factory() const;
@@ -113,7 +113,6 @@
   private:
     void drawToBuffer();
     void drawToPainter(KstPainter& p);
-    void tmpDrawToPainter(KstPainter& p);
     void computeTextSize();
 
     double _rotation;
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewpicture.cpp #626109:626110
@@ -139,7 +139,7 @@
     KstBorderedViewObject::paintSelf(p, bounds);
   }
 
-  const QRect cr(contentsRectForDevice(p));
+  const QRect cr(contentsRectForPainter(p));
   if (_image.isNull()) {
     // fill with X
     p.setBrush(QBrush(Qt::gray, Qt::SolidPattern));
--- trunk/extragear/graphics/kst/src/libkstapp/labelrenderer.cpp #626109:626110
@@ -81,7 +81,8 @@
       if (!fi->text.isEmpty() && fi->text[0] == '=') {
         // Parse and evaluate as an equation
         bool ok = false;
-        const double eqResult(Equation::interpret(fi->text.mid(1).latin1(), &ok));
+        const QString s = fi->text.mid(1);
+        const double eqResult(Equation::interpret(s.latin1(), &ok, s.length()));
         txt = QString::number(eqResult, 'g', rc.precision);
         if (rc._cache) {
           rc._cache->append(DataRef(DataRef::DRExpression, fi->text, QString::null, 0.0, QVariant(eqResult)));
@@ -162,7 +163,7 @@
           // Parse and evaluate as an equation
           bool ok = false;
           // FIXME: make more efficient: cache the parsed equation
-          const double idx = Equation::interpret(fi->expression.latin1(), &ok);
+          const double idx = Equation::interpret(fi->expression.latin1(), &ok, fi->expression.length());
           if (ok) {
             vp->readLock();
             const double vVal(vp->value()[int(idx)]);


More information about the Kst mailing list