[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Fri Feb 27 19:22:38 CET 2009
SVN commit 932985 by fenton:
Fix qgraphicsitem_cast related bugs.
M +1 -1 labelitem.cpp
M +20 -19 plotitem.cpp
M +5 -1 plotitem.h
M +5 -7 plotrenderitem.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.cpp #932984:932985
@@ -175,7 +175,7 @@
}
_item = new LabelItem(_view, text);
- LabelItem *label = qgraphicsitem_cast<LabelItem*>(_item);
+ LabelItem *label = qobject_cast<LabelItem*>(_item);
label->setLabelScale(dialog.labelScale());
label->setLabelColor(dialog.labelColor());
label->setLabelFont(dialog.labelFont());
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #932984:932985
@@ -85,7 +85,8 @@
_legend(0),
_zoomMenu(0),
_filterMenu(0),
- _fitMenu(0)
+ _fitMenu(0),
+ _sharedBox(0)
{
setName("Plot");
@@ -407,14 +408,12 @@
void PlotItem::addToMenuForContextEvent(QMenu &menu) {
- if (parentItem()) {
- if (SharedAxisBoxItem *sharedBox = qgraphicsitem_cast<SharedAxisBoxItem*>(parentItem())) {
- if (parentView()->viewMode() == View::Data) {
- QAction *breakSharedBox = new QAction(tr("Break Shared Axis Box"), this);
- breakSharedBox->setShortcut(Qt::Key_B);
- connect(breakSharedBox, SIGNAL(triggered()), sharedBox, SLOT(breakShare()));
- menu.addAction(breakSharedBox);
- }
+ if (parentItem() && isInSharedAxisBox() && _sharedBox) {
+ if (parentView()->viewMode() == View::Data) {
+ QAction *breakSharedBox = new QAction(tr("Break Shared Axis Box"), this);
+ breakSharedBox->setShortcut(Qt::Key_B);
+ connect(breakSharedBox, SIGNAL(triggered()), _sharedBox, SLOT(breakShare()));
+ menu.addAction(breakSharedBox);
}
}
@@ -506,10 +505,8 @@
void PlotItem::marginsUpdated() {
//ViewGridLayout::standardizePlotMargins(this);
//qDebug() << "---Margins updated called";
- if (isInSharedAxisBox() && parentItem()) {
- if (SharedAxisBoxItem *sharedBox = qgraphicsitem_cast<SharedAxisBoxItem*>(parentItem())) {
- sharedBox->sharePlots();
- }
+ if (isInSharedAxisBox() && parentItem() && _sharedBox) {
+ _sharedBox->sharePlots();
}
}
@@ -1034,7 +1031,12 @@
}
-void PlotItem::setSharedAxisBox(ViewItem* parent) {
+SharedAxisBoxItem* PlotItem::sharedAxisBox() {
+ return _sharedBox;
+}
+
+
+void PlotItem::setSharedAxisBox(SharedAxisBoxItem* parent) {
if (parent) {
if (_isTiedZoom) {
setTiedZoom(false);
@@ -1053,6 +1055,7 @@
setParent(0);
setBrush(Qt::white);
}
+ _sharedBox = parent;
}
@@ -2354,11 +2357,9 @@
void PlotItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
- if (isInSharedAxisBox()) {
- if (SharedAxisBoxItem *sharedBox = qgraphicsitem_cast<SharedAxisBoxItem*>(parentItem())) {
- if (sharedBox->tryMousePressEvent(this, event)) {
- return;
- }
+ if (isInSharedAxisBox() && _sharedBox) {
+ if (_sharedBox->tryMousePressEvent(this, event)) {
+ return;
}
}
if (event->button() == Qt::LeftButton) {
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #932984:932985
@@ -28,6 +28,7 @@
#include "plotaxis.h"
#include "legenditem.h"
#include "curveplacement.h"
+#include "sharedaxisboxitem.h"
namespace Kst {
@@ -83,7 +84,8 @@
bool isInSharedAxisBox() const;
void setInSharedAxisBox(bool inSharedBox);
- void setSharedAxisBox(ViewItem* parent);
+ SharedAxisBoxItem* sharedAxisBox();
+ void setSharedAxisBox(SharedAxisBoxItem* parent);
qreal leftMarginSize() const;
void setLeftPadding(const qreal);
@@ -459,6 +461,8 @@
QMenu *_fitMenu;
QAction *_fitAction;
+ SharedAxisBoxItem * _sharedBox;
+
QUndoStack *_undoStack;
friend class ZoomCommand;
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #932984:932985
@@ -73,7 +73,7 @@
PlotItem *PlotRenderItem::plotItem() const {
- return qobject_cast<PlotItem*>(qgraphicsitem_cast<ViewItem*>(parentItem()));
+ return static_cast<PlotItem*>(parentItem());
}
@@ -890,12 +890,10 @@
void PlotRenderItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) {
- if (plotItem() && plotItem()->parentItem()) {
- if (SharedAxisBoxItem *sharedBox = qgraphicsitem_cast<SharedAxisBoxItem*>(plotItem()->parentItem())) {
- if (plotItem()->parentView()->viewMode() == View::Layout) {
- sharedBox->triggerContextEvent(event);
- return;
- }
+ if (plotItem() && plotItem()->parentItem() && plotItem()->isInSharedAxisBox()) {
+ if (plotItem()->parentView()->viewMode() == View::Layout) {
+ plotItem()->sharedAxisBox()->triggerContextEvent(event);
+ return;
}
}
ViewItem::contextMenuEvent(event);
More information about the Kst
mailing list