diff --git a/widgets/widget.cpp b/widgets/widget.cpp index b4c067f80..e57b26511 100644 --- a/widgets/widget.cpp +++ b/widgets/widget.cpp @@ -30,7 +30,10 @@ namespace Plasma class Widget::Private { public: - Private() : parent(0) { } + Private() + : parent(0), + layout(0) + { } ~Private() { } QRectF geometry; @@ -40,17 +43,15 @@ class Widget::Private QList childList; }; - -Widget::Widget(Widget *parent) +Widget::Widget(QGraphicsItem *parent) : QGraphicsItem(parent), d(new Private) { - d->parent = parent; - d->layout = 0; + d->parent = dynamic_cast(parent); - if (parent) { - parent->addChild(this); - parent->setGeometry(QRectF(QPointF(0.0, 0.0), parent->size())); + if (d->parent) { + d->parent->addChild(this); + d->parent->setGeometry(QRectF(QPointF(0.0, 0.0), d->parent->size())); } } @@ -186,6 +187,15 @@ void Widget::addChild(Widget *w) } } +void Widget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + Q_UNUSED(painter) + Q_UNUSED(option) + Q_UNUSED(widget) + // do nothing, but we need to reimp so we can create Widget items as this method + // is pure virtual in QGraphicsItem +} + void Widget::reparent(Widget *w) { d->parent = w; diff --git a/widgets/widget.h b/widgets/widget.h index cb13343f9..0e6dd1d97 100644 --- a/widgets/widget.h +++ b/widgets/widget.h @@ -39,7 +39,7 @@ class Layout; class PLASMA_EXPORT Widget : public QGraphicsItem, public LayoutItem { public: - Widget(Widget *parent = 0); + explicit Widget(QGraphicsItem *parent = 0); virtual ~Widget(); virtual Qt::Orientations expandingDirections() const; @@ -54,7 +54,7 @@ public: virtual qreal widthForHeight(qreal h) const; QRectF geometry() const; - void setGeometry(const QRectF& geometry); + void setGeometry(const QRectF &geometry); void updateGeometry(); @@ -66,7 +66,7 @@ public: virtual QRectF boundingRect() const; - void resize(const QSizeF& size); + void resize(const QSizeF &size); void resize(qreal w, qreal h); void setLayout(Layout *l); @@ -76,6 +76,7 @@ public: void reparent(Widget *w); void addChild(Widget *w); + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); private: class Private;