[Kst] branches/work/kst/portto4/kst/src/libkstapp
Adam Treat
treat at kde.org
Thu Jun 7 16:42:13 CEST 2007
SVN commit 672564 by treat:
* All are rect items
M +18 -0 lineitem.cpp
M +9 -2 lineitem.h
--- branches/work/kst/portto4/kst/src/libkstapp/lineitem.cpp #672563:672564
@@ -29,6 +29,24 @@
}
+void LineItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
+ painter->drawLine(_line);
+ QPen p = pen();
+ setPen(Qt::NoPen);
+ QGraphicsRectItem::paint(painter, option, widget);
+ setPen(p);
+}
+
+QLineF LineItem::line() const {
+ return _line;
+}
+
+void LineItem::setLine(const QLineF &line) {
+ _line = line;
+ setRect(QRectF(_line.p1(), _line.p2()));
+}
+
+
void LineItem::creationPolygonChanged(View::CreationEvent event) {
if (event == View::MousePress) {
const QPolygonF poly = mapFromScene(parentView()->creationPolygon(View::MousePress));
--- branches/work/kst/portto4/kst/src/libkstapp/lineitem.h #672563:672564
@@ -14,11 +14,11 @@
#include "viewitem.h"
#include "graphicsfactory.h"
-#include <QGraphicsLineItem>
+#include <QGraphicsRectItem>
namespace Kst {
-class LineItem : public ViewItem, public QGraphicsLineItem
+class LineItem : public ViewItem, public QGraphicsRectItem
{
Q_OBJECT
public:
@@ -26,9 +26,16 @@
virtual ~LineItem();
virtual QGraphicsItem *graphicsItem() { return this; }
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+ QLineF line() const;
+ void setLine(const QLineF &line);
+
private Q_SLOTS:
void creationPolygonChanged(View::CreationEvent event);
+
+private:
+ QLineF _line;
};
class KST_EXPORT CreateLineCommand : public CreateCommand
More information about the Kst
mailing list