[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/work/kst/portto4/kst/src/libkstapp
From:       Barth Netterfield <netterfield () astro ! utoronto ! ca>
Date:       2012-06-23 18:54:34
Message-ID: 20120623185435.02D6EAC783 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1302619 by netterfield:

Finish fixing save/reload of lines and arrows.

It turns out that qgraphicsitem_cast doesn't work unless one defiles
type().  Which we don't, except for ViewItem.  Furthermore, it won't
ever work for polymorphic casts, so if we did implement type() for all
viewitems, then a qgraphicsitem_cast to a parent item would not work.

So: use plain old dynamic_cast for run type type ID of anything which
inherits from ViewItem.  OTOH, testing for ViewItem using
qgraphicsitem_cast still works fine and can stay as it is.

Moral: kst uses RTTI, and has to, at least for now.


 M  +1 -1      labeldimensionstab.cpp  
 M  +1 -1      labelitem.cpp  
 M  +2 -0      labelitemdialog.cpp  
 M  +1 -1      lineitem.cpp  
 M  +3 -3      viewitem.cpp  


--- branches/work/kst/portto4/kst/src/libkstapp/labeldimensionstab.cpp #1302618:1302619
@@ -36,7 +36,7 @@
 void LabelDimensionsTab::fillDimensions(bool lock_pos_to_data, bool fix_left) {
 
   if (lock_pos_to_data && _labelItem->dataPosLockable()) {
-    PlotRenderItem *render_item = qgraphicsitem_cast<PlotRenderItem *>(_labelItem->parentViewItem());
+    PlotRenderItem *render_item = dynamic_cast<PlotRenderItem *>(_labelItem->parentViewItem());
     if (render_item) {
       qreal parentWidth = render_item->width();
       qreal parentHeight = render_item->height();
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.cpp #1302618:1302619
@@ -380,7 +380,7 @@
 
 
 void LabelItem::applyDataLockedDimensions() {
-  PlotRenderItem *render_item = qgraphicsitem_cast<PlotRenderItem *>(parentViewItem());
+  PlotRenderItem *render_item = dynamic_cast<PlotRenderItem *>(parentViewItem());
   if (render_item) {
     qreal parentWidth = render_item->width();
     qreal parentHeight = render_item->height();
--- branches/work/kst/portto4/kst/src/libkstapp/labelitemdialog.cpp #1302618:1302619
@@ -77,6 +77,8 @@
   if (_saveAsDefault->isChecked()) {
     _labelItem->saveAsDialogDefaults();
   }
+  kstApp->mainWindow()->document()->setChanged(true);
+
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/lineitem.cpp #1302618:1302619
@@ -244,7 +244,7 @@
 
 
 void LineItem::applyDataLockedDimensions() {
-  PlotRenderItem *render_item = qgraphicsitem_cast<PlotRenderItem *>(parentViewItem());
+  PlotRenderItem *render_item = dynamic_cast<PlotRenderItem *>(parentViewItem());
   if (render_item) {
     qreal parentWidth = render_item->width();
     qreal parentHeight = render_item->height();
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #1302618:1302619
@@ -159,7 +159,7 @@
   // the object will be created in a cartesian render item with no plot
   // borders, and then resized.
   // this keeps line end points in the right place.
-  CartesianRenderItem *cri = qgraphicsitem_cast<CartesianRenderItem *>(parentItem());
+  CartesianRenderItem *cri = dynamic_cast<CartesianRenderItem *>(parentItem());
   QTransform tr;
   double w = _parentRelativeWidth;
   if (cri) {
@@ -302,7 +302,7 @@
 
 
 void ViewItem::applyDataLockedDimensions() {
-  PlotRenderItem *render_item = qgraphicsitem_cast<PlotRenderItem *>(parentViewItem());
+  PlotRenderItem *render_item = dynamic_cast<PlotRenderItem *>(parentViewItem());
   if (render_item) {
     qreal parentWidth = render_item->width();
     qreal parentHeight = render_item->height();
@@ -911,7 +911,7 @@
   painter->setPen(pen());
   painter->setBrush(brush());
   if (_lockPosToData) {
-    PlotRenderItem *render_item = qgraphicsitem_cast<PlotRenderItem *>(parentViewItem());
+    PlotRenderItem *render_item = dynamic_cast<PlotRenderItem *>(parentViewItem());
     if (render_item) {
       QPolygonF PF = mapFromParent(render_item->rect());
       QPainterPath path;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic