- make it possible to instantiate a Plasma::Widget itself (implement all pure virtuals from QGraphicsItem)
- allow parenting it to a QGraphicsItem svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=687019
This commit is contained in:
parent
ac35242c5d
commit
b82624429e
@ -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<Widget *> childList;
|
||||
};
|
||||
|
||||
|
||||
Widget::Widget(Widget *parent)
|
||||
Widget::Widget(QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent),
|
||||
d(new Private)
|
||||
{
|
||||
d->parent = parent;
|
||||
d->layout = 0;
|
||||
d->parent = dynamic_cast<Widget*>(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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user