[Kst] branches/work/kst/portto4/kst/src

Barth Netterfield netterfield at astro.utoronto.ca
Tue Feb 28 19:58:20 UTC 2012


SVN commit 1282831 by netterfield:

BUG:293247 

Properly escape special characters in file names.

Also, fix a bug in label positions coming out of 'maximize plot' mode.


 M  +5 -0      libkst/labelinfo.cpp  
 M  +1 -0      libkst/labelinfo.h  
 M  +14 -0     libkstapp/labelitem.cpp  
 M  +1 -0      libkstapp/labelitem.h  
 M  +3 -2      libkstapp/legenditem.cpp  
 M  +3 -3      libkstapp/viewitem.h  


--- branches/work/kst/portto4/kst/src/libkst/labelinfo.cpp #1282830:1282831
@@ -47,5 +47,10 @@
   }
 }
 
+QString LabelInfo::escapedFile() {
+  QString escaped_file = file;
+  escaped_file.replace('_', "\\_").replace('^', "\\^").replace('[', "\\[").replace(']', "\\]");
+  return escaped_file;
+}
 
 }
--- branches/work/kst/portto4/kst/src/libkst/labelinfo.h #1282830:1282831
@@ -36,6 +36,7 @@
   QString quantity;
   QString units;
   QString file;
+  QString escapedFile();
   QString singleRenderItemLabel() const;
 };
 
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.cpp #1282830:1282831
@@ -416,6 +416,20 @@
   }
 }
 
+void LabelItem::updateChildGeometry(const QRectF &oldParentRect, const QRectF &newParentRect) {
+  Q_UNUSED(oldParentRect);
+
+  QRectF itemRect = rect();
+
+  QPointF newTopLeft = newParentRect.topLeft() - itemRect.topLeft() +
+      QPointF(newParentRect.width() * _parentRelativePosition.x(),
+              newParentRect.height() * _parentRelativePosition.y());
+
+  setPos(newTopLeft);
+
+  setViewRect(itemRect, true);
 }
 
+}
+
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.h #1282830:1282831
@@ -60,6 +60,7 @@
 
     virtual void updateDataRelativeRect(bool force = false);
     virtual void applyDataLockedDimensions();
+    virtual void updateChildGeometry(const QRectF &oldParentRect, const QRectF &newParentRect);
 
   public Q_SLOTS:
     virtual void edit();
--- branches/work/kst/portto4/kst/src/libkstapp/legenditem.cpp #1282830:1282831
@@ -151,15 +151,16 @@
       } else {
         RelationPtr dup_relation = legendItems.at(i_dup);
         if (!dup_relation->yLabelInfo().file.isEmpty()) {
-          names.replace(i_dup, label + " (" + dup_relation->yLabelInfo().file + ')');
+          names.replace(i_dup, label + " (" + dup_relation->yLabelInfo().escapedFile() + ')');
         }
         if (!relation->yLabelInfo().file.isEmpty()) {
-          names.append(label + " (" + relation->yLabelInfo().file + ')');
+          names.append(label + " (" + relation->yLabelInfo().escapedFile() + ')');
         }
       }
     }
   }
 
+
   QSize legendSize(0, 0);
   QSize titleSize(0,0);
   Label::Parsed *parsed = Label::parse(_title);
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #1282830:1282831
@@ -338,6 +338,9 @@
     void startDragging(QWidget *widget, const QPointF& hotspot);
     ActiveGrip _activeGrip;
     QRectF _dataRelativeRect;
+    QPointF _originalPosition;
+    QPointF _parentRelativeCenter;
+    QPointF _parentRelativePosition;
 
   private:
     GripMode _gripMode;
@@ -358,9 +361,6 @@
     bool _acceptsContextMenuEvents;
     bool _updatingLayout;
     bool _highlighted;
-    QPointF _originalPosition;
-    QPointF _parentRelativeCenter;
-    QPointF _parentRelativePosition;
     QRectF _originalRect;
     QTransform _originalTransform;
     QLineF _normalLine;


More information about the Kst mailing list