[Kst] branches/work/kst/portto4/kst/src/libkstapp
Adam Treat
treat at kde.org
Thu Jun 7 16:52:43 CEST 2007
SVN commit 672568 by treat:
* Move to the base class
M +1 -2 boxitem.cpp
M +1 -4 boxitem.h
M +1 -1 document.cpp
M +1 -3 ellipseitem.h
M +1 -4 labelitem.h
M +1 -2 lineitem.cpp
M +1 -3 lineitem.h
M +1 -3 pictureitem.h
M +1 -4 plotitem.h
M +0 -1 svgitem.cpp
M +1 -3 svgitem.h
M +9 -20 viewitem.cpp
M +3 -13 viewitem.h
--- branches/work/kst/portto4/kst/src/libkstapp/boxitem.cpp #672567:672568
@@ -14,7 +14,6 @@
#include <kstdebug.h>
#include <QDebug>
-#include <QGraphicsItem>
#include <QGraphicsScene>
namespace Kst {
@@ -95,7 +94,7 @@
Q_ASSERT(!rc);
rc = new BoxItem(view);
if (parent) {
- rc->graphicsItem()->setParentItem(parent->graphicsItem());
+ rc->setParentItem(parent);
}
QXmlStreamAttributes attrs = xml.attributes();
QStringRef av;
--- branches/work/kst/portto4/kst/src/libkstapp/boxitem.h #672567:672568
@@ -14,19 +14,16 @@
#include "viewitem.h"
#include "graphicsfactory.h"
-#include <QGraphicsRectItem>
namespace Kst {
-class BoxItem : public ViewItem, public QGraphicsRectItem
+class BoxItem : public ViewItem
{
Q_OBJECT
public:
BoxItem(View *parent);
virtual ~BoxItem();
- virtual QGraphicsItem *graphicsItem() { return this; }
-
private Q_SLOTS:
void creationPolygonChanged(View::CreationEvent event);
};
--- branches/work/kst/portto4/kst/src/libkstapp/document.cpp #672567:672568
@@ -168,7 +168,7 @@
{
ViewItem *i = GraphicsFactory::parse(xml, currentView);
if (i) {
- currentView->scene()->addItem(i->graphicsItem());
+ currentView->scene()->addItem(i);
}
}
break;
--- branches/work/kst/portto4/kst/src/libkstapp/ellipseitem.h #672567:672568
@@ -13,18 +13,16 @@
#define ELLIPSEITEM_H
#include "viewitem.h"
-#include <QGraphicsRectItem>
namespace Kst {
-class EllipseItem : public ViewItem, public QGraphicsRectItem
+class EllipseItem : public ViewItem
{
Q_OBJECT
public:
EllipseItem(View *parent);
virtual ~EllipseItem();
- virtual QGraphicsItem *graphicsItem() { return this; }
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
private Q_SLOTS:
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.h #672567:672568
@@ -12,7 +12,6 @@
#ifndef LABELITEM_H
#define LABELITEM_H
-#include <QGraphicsRectItem>
#include "viewitem.h"
namespace Label {
@@ -21,14 +20,12 @@
namespace Kst {
-class LabelItem : public ViewItem, public QGraphicsRectItem {
+class LabelItem : public ViewItem {
Q_OBJECT
public:
LabelItem(View *parent, const QString& labelText);
virtual ~LabelItem();
- virtual QGraphicsItem *graphicsItem() { return this; }
-
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
private Q_SLOTS:
--- branches/work/kst/portto4/kst/src/libkstapp/lineitem.cpp #672567:672568
@@ -14,7 +14,6 @@
#include <kstdebug.h>
#include <QDebug>
-#include <QGraphicsItem>
#include <QGraphicsScene>
namespace Kst {
@@ -112,7 +111,7 @@
Q_ASSERT(!rc);
rc = new LineItem(view);
if (parent) {
- rc->graphicsItem()->setParentItem(parent->graphicsItem());
+ rc->setParentItem(parent);
}
QXmlStreamAttributes attrs = xml.attributes();
QStringRef av;
--- branches/work/kst/portto4/kst/src/libkstapp/lineitem.h #672567:672568
@@ -14,18 +14,16 @@
#include "viewitem.h"
#include "graphicsfactory.h"
-#include <QGraphicsRectItem>
namespace Kst {
-class LineItem : public ViewItem, public QGraphicsRectItem
+class LineItem : public ViewItem
{
Q_OBJECT
public:
LineItem(View *parent);
virtual ~LineItem();
- virtual QGraphicsItem *graphicsItem() { return this; }
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
QLineF line() const;
--- branches/work/kst/portto4/kst/src/libkstapp/pictureitem.h #672567:672568
@@ -13,18 +13,16 @@
#define PICTUREITEM_H
#include "viewitem.h"
-#include <QGraphicsRectItem>
namespace Kst {
-class PictureItem : public ViewItem, public QGraphicsRectItem
+class PictureItem : public ViewItem
{
Q_OBJECT
public:
PictureItem(View *parent, const QImage &image);
~PictureItem();
- QGraphicsItem *graphicsItem() { return this; }
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
private Q_SLOTS:
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #672567:672568
@@ -13,19 +13,16 @@
#define PLOTITEM_H
#include "viewitem.h"
-#include <QGraphicsRectItem>
namespace Kst {
-class PlotItem : public ViewItem, public QGraphicsRectItem
+class PlotItem : public ViewItem
{
Q_OBJECT
public:
PlotItem(View *parent);
virtual ~PlotItem();
- virtual QGraphicsItem *graphicsItem() { return this; }
-
private Q_SLOTS:
void creationPolygonChanged(View::CreationEvent event);
};
--- branches/work/kst/portto4/kst/src/libkstapp/svgitem.cpp #672567:672568
@@ -13,7 +13,6 @@
#include <QDebug>
#include <QFileDialog>
-#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QSvgRenderer>
--- branches/work/kst/portto4/kst/src/libkstapp/svgitem.h #672567:672568
@@ -13,20 +13,18 @@
#define SVGITEM_H
#include "viewitem.h"
-#include <QGraphicsRectItem>
class QSvgRenderer;
namespace Kst {
-class SvgItem : public ViewItem, public QGraphicsRectItem
+class SvgItem : public ViewItem
{
Q_OBJECT
public:
SvgItem(View *parent, const QString &file);
~SvgItem();
- QGraphicsItem *graphicsItem() { return this; }
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
private Q_SLOTS:
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #672567:672568
@@ -14,7 +14,6 @@
#include "tabwidget.h"
#include <QDebug>
-#include <QGraphicsItem>
#include <QGraphicsScene>
namespace Kst {
@@ -23,11 +22,8 @@
: QObject(parent) {
#ifdef DEBUG_GEOMETRY
QColor semiRed(QColor(255, 0, 0, 50));
- _rectItem = new QGraphicsRectItem;
- _rectItem->setZValue(0);
- _rectItem->setPen(semiRed);
- _rectItem->setBrush(semiRed);
- parent->scene()->addItem(_rectItem);
+ setPen(semiRed);
+ setBrush(semiRed);
#endif
connect(parent, SIGNAL(mouseModeChanged()), this, SLOT(mouseModeChanged()));
@@ -45,19 +41,12 @@
void ViewItem::mouseModeChanged() {
if (parentView()->mouseMode() == View::Move)
- _originalPosition = graphicsItem()->pos();
- else if (_originalPosition != graphicsItem()->pos())
- new MoveCommand(this, _originalPosition, graphicsItem()->pos());
+ _originalPosition = pos();
+ else if (_originalPosition != pos())
+ new MoveCommand(this, _originalPosition, pos());
}
-#ifdef DEBUG_GEOMETRY
-void ViewItem::debugGeometry() {
- _rectItem->setRect(graphicsItem()->boundingRect());
-}
-#endif
-
-
ViewItemCommand::ViewItemCommand(const QString &text, bool addToStack, QUndoCommand *parent)
: QUndoCommand(text, parent), _item(kstApp->mainWindow()->tabWidget()->currentView()->currentPlotItem()) {
if (addToStack)
@@ -92,7 +81,7 @@
void CreateCommand::undo() {
if (_item)
- _item->graphicsItem()->hide();
+ _item->hide();
}
@@ -100,7 +89,7 @@
if (!_item)
createItem();
- _item->graphicsItem()->show();
+ _item->show();
}
@@ -110,12 +99,12 @@
void MoveCommand::undo() {
- _item->graphicsItem()->setPos(_originalPos);
+ _item->setPos(_originalPos);
}
void MoveCommand::redo() {
- _item->graphicsItem()->setPos(_newPos);
+ _item->setPos(_newPos);
}
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #672567:672568
@@ -13,17 +13,17 @@
#define VIEWITEM_H
#include <QObject>
+#include <QGraphicsRectItem>
+
#include "kst_export.h"
#include "viewcommand.h"
#include "view.h" //forward declare, but enums??
// #define DEBUG_GEOMETRY 1
-class QGraphicsItem;
-
namespace Kst {
-class KST_EXPORT ViewItem : public QObject
+class KST_EXPORT ViewItem : public QObject, public QGraphicsRectItem
{
Q_OBJECT
public:
@@ -32,8 +32,6 @@
View *parentView() const;
- virtual QGraphicsItem *graphicsItem() = 0;
-
Q_SIGNALS:
void creationComplete();
@@ -42,14 +40,6 @@
private:
QPointF _originalPosition;
-
-#ifdef DEBUG_GEOMETRY
-protected:
- void debugGeometry();
-
-private:
- QGraphicsRectItem *_rectItem;
-#endif
};
class KST_EXPORT ViewItemCommand : public QUndoCommand
More information about the Kst
mailing list