[Kst] branches/work/kst/portto4/kst/src/libkstapp
Adam Treat
treat at kde.org
Fri Sep 21 20:19:29 CEST 2007
SVN commit 715285 by treat:
* Do not use dynamic_cast any longer for viewitems.
* From now on, items that subclass viewitem must not
reimplement the QGraphicsItem::type() method.
M +2 -2 layoutboxitem.cpp
M +2 -2 mainwindow.cpp
M +2 -2 plotitem.cpp
M +0 -3 plotitem.h
M +1 -1 plotrenderitem.cpp
M +2 -2 view.cpp
M +1 -1 viewgridlayout.cpp
M +3 -3 viewitem.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/layoutboxitem.cpp #715284:715285
@@ -58,7 +58,7 @@
if (enabled) {
QList<QGraphicsItem*> list = parentView()->items();
foreach (QGraphicsItem *item, list) {
- ViewItem *viewItem = dynamic_cast<ViewItem*>(item);
+ ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(item);
if (!viewItem || viewItem->parentItem() || !viewItem->isVisible() || viewItem == this)
continue;
@@ -71,7 +71,7 @@
} else {
QList<QGraphicsItem*> list = QGraphicsItem::children();
foreach (QGraphicsItem *item, list) {
- ViewItem *viewItem = dynamic_cast<ViewItem*>(item);
+ ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(item);
if (!viewItem)
continue;
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #715284:715285
@@ -336,7 +336,7 @@
View *view = tabWidget()->currentView();
QList<QGraphicsItem*> selectedItems = view->scene()->selectedItems();
if (!selectedItems.isEmpty()) {
- ViewItem *viewItem = dynamic_cast<ViewItem*>(selectedItems.first());
+ ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(selectedItems.first());
Q_ASSERT(viewItem);
viewItem->createLayout();
} else {
@@ -349,7 +349,7 @@
View *view = tabWidget()->currentView();
QList<QGraphicsItem*> selectedItems = view->scene()->selectedItems();
if (!selectedItems.isEmpty()) {
- ViewItem *viewItem = dynamic_cast<ViewItem*>(selectedItems.first());
+ ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(selectedItems.first());
Q_ASSERT(viewItem);
viewItem->breakLayout();
}
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #715284:715285
@@ -193,7 +193,7 @@
qreal PlotItem::marginWidth() const {
- ViewItem *viewItem = dynamic_cast<ViewItem*>(parentItem());
+ ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(parentItem());
if (viewItem && viewItem->layout()) {
return viewItem->layout()->plotMarginWidth(this);
} else {
@@ -203,7 +203,7 @@
qreal PlotItem::marginHeight() const {
- ViewItem *viewItem = dynamic_cast<ViewItem*>(parentItem());
+ ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(parentItem());
if (viewItem && viewItem->layout()) {
return viewItem->layout()->plotMarginHeight(this);
} else {
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #715284:715285
@@ -31,9 +31,6 @@
PlotItem(View *parent);
virtual ~PlotItem();
- enum { Type = UserType + 2 };
- int type() const { return Type; }
-
virtual void paint(QPainter *painter);
qreal marginWidth() const;
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #715284:715285
@@ -29,7 +29,7 @@
PlotItem *PlotRenderItem::plotItem() const {
- return qgraphicsitem_cast<PlotItem*>(parentItem());
+ return qobject_cast<PlotItem*>(qgraphicsitem_cast<ViewItem*>(parentItem()));
}
--- branches/work/kst/portto4/kst/src/libkstapp/view.cpp #715284:715285
@@ -226,7 +226,7 @@
if (item->parentItem())
continue;
- ViewItem *viewItem = dynamic_cast<ViewItem*>(item);
+ ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(item);
Q_ASSERT(viewItem);
ViewItem::updateChildGeometry(viewItem, oldSceneRect, sceneRect());
@@ -292,7 +292,7 @@
if (item->parentItem())
continue;
- ViewItem *viewItem = dynamic_cast<ViewItem*>(item);
+ ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(item);
Q_ASSERT(viewItem);
ViewItem::updateChildGeometry(viewItem, oldSceneRect, sceneRect());
--- branches/work/kst/portto4/kst/src/libkstapp/viewgridlayout.cpp #715284:715285
@@ -184,7 +184,7 @@
_plotMarginWidth.clear();
_plotMarginHeight.clear();
foreach (LayoutItem item, _items) {
- PlotItem *plotItem = dynamic_cast<PlotItem*>(item.viewItem);
+ PlotItem *plotItem = qgraphicsitem_cast<PlotItem*>(item.viewItem);
if (!plotItem)
continue;
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #715284:715285
@@ -138,7 +138,7 @@
if (item->parentItem() != this)
continue;
- ViewItem *viewItem = dynamic_cast<ViewItem*>(item);
+ ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(item);
if (!viewItem)
continue;
@@ -1047,7 +1047,7 @@
//Look for collisions that completely contain us
foreach (QGraphicsItem *item, collisions) {
- ViewItem *viewItem = dynamic_cast<ViewItem*>(item);
+ ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(item);
if (!viewItem) /*bah*/
continue;
@@ -1495,7 +1495,7 @@
return; //not added to undostack
foreach (QGraphicsItem *item, list) {
- ViewItem *viewItem = dynamic_cast<ViewItem*>(item);
+ ViewItem *viewItem = qgraphicsitem_cast<ViewItem*>(item);
if (!viewItem || viewItem->parentItem() != _item)
continue;
viewItems.append(viewItem);
More information about the Kst
mailing list