[Kst] branches/work/kst/portto4/kst/src/libkstapp
Adam Treat
treat at kde.org
Thu Jun 7 17:48:16 CEST 2007
SVN commit 672591 by treat:
* Move most of this into base class
M +0 -31 boxitem.cpp
M +0 -3 boxitem.h
M +0 -31 ellipseitem.cpp
M +0 -3 ellipseitem.h
M +0 -32 labelitem.cpp
M +0 -4 labelitem.h
M +0 -4 lineitem.cpp
M +2 -2 lineitem.h
M +0 -31 pictureitem.cpp
M +0 -3 pictureitem.h
M +0 -31 plotitem.cpp
M +8 -10 plotitem.h
M +0 -31 svgitem.cpp
M +0 -3 svgitem.h
M +31 -0 viewitem.cpp
M +4 -1 viewitem.h
--- branches/work/kst/portto4/kst/src/libkstapp/boxitem.cpp #672590:672591
@@ -27,37 +27,6 @@
}
-void BoxItem::creationPolygonChanged(View::CreationEvent event) {
- if (event == View::MousePress) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MousePress));
- setRect(poly.first().x(), poly.first().y(), poly.last().x() - poly.first().x(), poly.last().y() - poly.first().y());
- parentView()->scene()->addItem(this);
- setZValue(1);
- return;
- }
-
- if (event == View::MouseMove) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseMove));
- setRect(rect().x(), rect().y(), poly.last().x() - rect().x(), poly.last().y() - rect().y());
- return;
- }
-
- if (event == View::MouseRelease) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseRelease));
- setRect(rect().x(), rect().y(), poly.last().x() - rect().x(), poly.last().y() - rect().y());
-
-#ifdef DEBUG_GEOMETRY
- debugGeometry();
-#endif
-
- parentView()->disconnect(this, SLOT(deleteLater())); //Don't delete ourself
- parentView()->disconnect(this, SLOT(creationPolygonChanged(View::CreationEvent)));
- parentView()->setMouseMode(View::Default);
- emit creationComplete();
- return;
- }
-}
-
void CreateBoxCommand::createItem() {
_item = new BoxItem(_view);
_view->setMouseMode(View::Create);
--- branches/work/kst/portto4/kst/src/libkstapp/boxitem.h #672590:672591
@@ -23,9 +23,6 @@
public:
BoxItem(View *parent);
virtual ~BoxItem();
-
-private Q_SLOTS:
- void creationPolygonChanged(View::CreationEvent event);
};
class KST_EXPORT CreateBoxCommand : public CreateCommand
--- branches/work/kst/portto4/kst/src/libkstapp/ellipseitem.cpp #672590:672591
@@ -36,37 +36,6 @@
}
-void EllipseItem::creationPolygonChanged(View::CreationEvent event) {
- if (event == View::MousePress) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MousePress));
- setRect(poly.first().x(), poly.first().y(), poly.last().x() - poly.first().x(), poly.last().y() - poly.first().y());
- parentView()->scene()->addItem(this);
- setZValue(1);
- return;
- }
-
- if (event == View::MouseMove) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseMove));
- setRect(rect().x(), rect().y(), poly.last().x() - rect().x(), poly.last().y() - rect().y());
- return;
- }
-
- if (event == View::MouseRelease) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseRelease));
- setRect(rect().x(), rect().y(), poly.last().x() - rect().x(), poly.last().y() - rect().y());
-
-#ifdef DEBUG_GEOMETRY
- debugGeometry();
-#endif
-
- parentView()->disconnect(this, SLOT(deleteLater())); //Don't delete ourself
- parentView()->disconnect(this, SLOT(creationPolygonChanged(View::CreationEvent)));
- parentView()->setMouseMode(View::Default);
- emit creationComplete();
- return;
- }
-}
-
void CreateEllipseCommand::createItem() {
_item = new EllipseItem(_view);
_view->setMouseMode(View::Create);
--- branches/work/kst/portto4/kst/src/libkstapp/ellipseitem.h #672590:672591
@@ -24,9 +24,6 @@
virtual ~EllipseItem();
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
-
-private Q_SLOTS:
- void creationPolygonChanged(View::CreationEvent event);
};
class KST_EXPORT CreateEllipseCommand : public CreateCommand
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.cpp #672590:672591
@@ -61,38 +61,6 @@
}
-void LabelItem::creationPolygonChanged(View::CreationEvent event) {
- if (event == View::MousePress) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MousePress));
- setRect(poly.first().x(), poly.first().y(), poly.last().x() - poly.first().x(), poly.last().y() - poly.first().y());
- parentView()->scene()->addItem(this);
- setZValue(1);
- return;
- }
-
- if (event == View::MouseMove) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseMove));
- setRect(rect().x(), rect().y(), poly.last().x() - rect().x(), poly.last().y() - rect().y());
- return;
- }
-
- if (event == View::MouseRelease) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseRelease));
- setRect(rect().x(), rect().y(), poly.last().x() - rect().x(), poly.last().y() - rect().y());
-
-#ifdef DEBUG_GEOMETRY
- debugGeometry();
-#endif
-
- parentView()->disconnect(this, SLOT(deleteLater())); //Don't delete ourself
- parentView()->disconnect(this, SLOT(creationPolygonChanged(View::CreationEvent)));
- parentView()->setMouseMode(View::Default);
- emit creationComplete();
- return;
- }
-}
-
-
void CreateLabelCommand::createItem() {
bool ok;
QString text = QInputDialog::getText(_view, tr("Kst: Create Label"), tr("Label:"), QLineEdit::Normal, QString::null, &ok);
--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.h #672590:672591
@@ -28,11 +28,7 @@
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
- private Q_SLOTS:
- void creationPolygonChanged(View::CreationEvent event);
-
private:
- QPointF _originalPos;
Label::Parsed *_parsed;
QString _text;
};
--- branches/work/kst/portto4/kst/src/libkstapp/lineitem.cpp #672590:672591
@@ -64,10 +64,6 @@
const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseRelease));
setLine(QLineF(line().p1(), poly.last())); //start and end
-#ifdef DEBUG_GEOMETRY
- debugGeometry();
-#endif
-
parentView()->disconnect(this, SLOT(deleteLater())); //Don't delete ourself
parentView()->disconnect(this, SLOT(creationPolygonChanged(View::CreationEvent)));
parentView()->setMouseMode(View::Default);
--- branches/work/kst/portto4/kst/src/libkstapp/lineitem.h #672590:672591
@@ -29,8 +29,8 @@
QLineF line() const;
void setLine(const QLineF &line);
-private Q_SLOTS:
- void creationPolygonChanged(View::CreationEvent event);
+protected Q_SLOTS:
+ virtual void creationPolygonChanged(View::CreationEvent event);
private:
QLineF _line;
--- branches/work/kst/portto4/kst/src/libkstapp/pictureitem.cpp #672590:672591
@@ -41,37 +41,6 @@
}
-void PictureItem::creationPolygonChanged(View::CreationEvent event) {
- if (event == View::MousePress) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MousePress));
- setRect(poly.first().x(), poly.first().y(), poly.last().x() - poly.first().x(), poly.last().y() - poly.first().y());
- parentView()->scene()->addItem(this);
- setZValue(1);
- return;
- }
-
- if (event == View::MouseMove) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseMove));
- setRect(rect().x(), rect().y(), poly.last().x() - rect().x(), poly.last().y() - rect().y());
- return;
- }
-
- if (event == View::MouseRelease) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseRelease));
- setRect(rect().x(), rect().y(), poly.last().x() - rect().x(), poly.last().y() - rect().y());
-
-#ifdef DEBUG_GEOMETRY
- debugGeometry();
-#endif
-
- parentView()->disconnect(this, SLOT(deleteLater())); //Don't delete ourself
- parentView()->disconnect(this, SLOT(creationPolygonChanged(View::CreationEvent)));
- parentView()->setMouseMode(View::Default);
- emit creationComplete();
- return;
- }
-}
-
void CreatePictureCommand::createItem() {
QString file = QFileDialog::getOpenFileName(_view, tr("Kst: Open Image"));
if (file.isEmpty())
--- branches/work/kst/portto4/kst/src/libkstapp/pictureitem.h #672590:672591
@@ -25,9 +25,6 @@
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
- private Q_SLOTS:
- void creationPolygonChanged(View::CreationEvent event);
-
private:
QPixmap _image;
};
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #672590:672591
@@ -27,37 +27,6 @@
}
-void PlotItem::creationPolygonChanged(View::CreationEvent event) {
- if (event == View::MousePress) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MousePress));
- setRect(poly.first().x(), poly.first().y(), poly.last().x() - poly.first().x(), poly.last().y() - poly.first().y());
- parentView()->scene()->addItem(this);
- setZValue(1);
- return;
- }
-
- if (event == View::MouseMove) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseMove));
- setRect(rect().x(), rect().y(), poly.last().x() - rect().x(), poly.last().y() - rect().y());
- return;
- }
-
- if (event == View::MouseRelease) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseRelease));
- setRect(rect().x(), rect().y(), poly.last().x() - rect().x(), poly.last().y() - rect().y());
-
-#ifdef DEBUG_GEOMETRY
- debugGeometry();
-#endif
-
- parentView()->disconnect(this, SLOT(deleteLater())); //Don't delete ourself
- parentView()->disconnect(this, SLOT(creationPolygonChanged(View::CreationEvent)));
- parentView()->setMouseMode(View::Default);
- emit creationComplete();
- return;
- }
-}
-
void CreatePlotCommand::createItem() {
_item = new PlotItem(_view);
_view->setMouseMode(View::Create);
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #672590:672591
@@ -19,21 +19,19 @@
class PlotItem : public ViewItem
{
Q_OBJECT
-public:
- PlotItem(View *parent);
- virtual ~PlotItem();
+ public:
+ PlotItem(View *parent);
+ virtual ~PlotItem();
-private Q_SLOTS:
- void creationPolygonChanged(View::CreationEvent event);
};
class KST_EXPORT CreatePlotCommand : public CreateCommand
{
-public:
- CreatePlotCommand() : CreateCommand(QObject::tr("Create Plot")) {}
- CreatePlotCommand(View *view) : CreateCommand(view, QObject::tr("Create Plot")) {}
- virtual ~CreatePlotCommand() {}
- virtual void createItem();
+ public:
+ CreatePlotCommand() : CreateCommand(QObject::tr("Create Plot")) {}
+ CreatePlotCommand(View *view) : CreateCommand(view, QObject::tr("Create Plot")) {}
+ virtual ~CreatePlotCommand() {}
+ virtual void createItem();
};
}
--- branches/work/kst/portto4/kst/src/libkstapp/svgitem.cpp #672590:672591
@@ -41,37 +41,6 @@
}
-void SvgItem::creationPolygonChanged(View::CreationEvent event) {
- if (event == View::MousePress) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MousePress));
- setRect(poly.first().x(), poly.first().y(), poly.last().x() - poly.first().x(), poly.last().y() - poly.first().y());
- parentView()->scene()->addItem(this);
- setZValue(1);
- return;
- }
-
- if (event == View::MouseMove) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseMove));
- setRect(rect().x(), rect().y(), poly.last().x() - rect().x(), poly.last().y() - rect().y());
- return;
- }
-
- if (event == View::MouseRelease) {
- const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseRelease));
- setRect(rect().x(), rect().y(), poly.last().x() - rect().x(), poly.last().y() - rect().y());
-
-#ifdef DEBUG_GEOMETRY
- debugGeometry();
-#endif
-
- parentView()->disconnect(this, SLOT(deleteLater())); //Don't delete ourself
- parentView()->disconnect(this, SLOT(creationPolygonChanged(View::CreationEvent)));
- parentView()->setMouseMode(View::Default);
- emit creationComplete();
- return;
- }
-}
-
void CreateSvgCommand::createItem() {
QString file = QFileDialog::getOpenFileName(_view, tr("Kst: Open Svg Image"));
if (file.isEmpty())
--- branches/work/kst/portto4/kst/src/libkstapp/svgitem.h #672590:672591
@@ -27,9 +27,6 @@
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
- private Q_SLOTS:
- void creationPolygonChanged(View::CreationEvent event);
-
private:
QSvgRenderer *_svg;
};
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #672590:672591
@@ -40,6 +40,37 @@
}
+void ViewItem::creationPolygonChanged(View::CreationEvent event) {
+ if (event == View::MousePress) {
+ const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MousePress));
+ setRect(poly.first().x(), poly.first().y(),
+ poly.last().x() - poly.first().x(), poly.last().y() - poly.first().y());
+ parentView()->scene()->addItem(this);
+ setZValue(1);
+ return;
+ }
+
+ if (event == View::MouseMove) {
+ const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseMove));
+ setRect(rect().x(), rect().y(),
+ poly.last().x() - rect().x(), poly.last().y() - rect().y());
+ return;
+ }
+
+ if (event == View::MouseRelease) {
+ const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MouseRelease));
+ setRect(rect().x(), rect().y(),
+ poly.last().x() - rect().x(), poly.last().y() - rect().y());
+
+ parentView()->disconnect(this, SLOT(deleteLater())); //Don't delete ourself
+ parentView()->disconnect(this, SLOT(creationPolygonChanged(View::CreationEvent)));
+ parentView()->setMouseMode(View::Default);
+ emit creationComplete();
+ return;
+ }
+}
+
+
void ViewItem::mouseModeChanged() {
if (parentView()->mouseMode() == View::Move)
_originalPosition = pos();
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #672590:672591
@@ -19,7 +19,7 @@
#include "viewcommand.h"
#include "view.h" //forward declare, but enums??
-// #define DEBUG_GEOMETRY 1
+#define DEBUG_GEOMETRY 1
namespace Kst {
@@ -35,6 +35,9 @@
Q_SIGNALS:
void creationComplete();
+protected Q_SLOTS:
+ virtual void creationPolygonChanged(View::CreationEvent event);
+
private Q_SLOTS:
void mouseModeChanged();
More information about the Kst
mailing list