delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / runtime / phonon / tests / guitest / widgetrectitem.cpp
blobe93539694d852697b2707031cc47c3206932a7ad
1 /* This file is part of the KDE project
2 Copyright (C) 2007 Matthias Kretz <kretz@kde.org>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
20 #include "widgetrectitem.h"
21 #include <QtCore/QEvent>
22 #include <QtGui/QGraphicsProxyWidget>
23 #include "pathitem.h"
25 //X WidgetRectItem::WidgetRectItem(QGraphicsItem *parent)
26 //X : QGraphicsRectItem(parent)
27 //X {
28 //X }
30 WidgetRectItem::WidgetRectItem(const QPointF &pos, const QColor &brush, const QString &title)
31 : m_title(title)
33 setFlag(QGraphicsItem::ItemIsMovable);
34 setPos(pos);
35 setBrush(brush);
38 WidgetRectItem::~WidgetRectItem()
42 void WidgetRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
44 QSizeF size;
45 QGraphicsProxyWidget *proxy = 0;
46 if (childItems().size() == 1) {
47 proxy = qgraphicsitem_cast<QGraphicsProxyWidget *>(
48 childItems().first());
49 QWidget *w = proxy->widget();
50 if (w) {
51 size = w->sizeHint();
54 if (!size.isValid()) {
55 size = childrenBoundingRect().size();
57 setRect(0.0, 0.0, size.width() + 32.0, size.height() + 30.0);
58 QGraphicsRectItem::paint(painter, option, widget);
59 painter->drawText(rect(), Qt::AlignTop | Qt::AlignHCenter, m_title);
61 if (size != m_lastSize) {
62 if (proxy) {
63 proxy->resize(size);
65 m_lastSize = size;
66 foreach (PathItem *p, m_paths) {
67 p->endPointMoved(this);
71 //X const QPoint mapped = m_view->mapFromScene(pos());
72 //X const QRectF frameGeometry(mapped.x() + 18, mapped.y() + 17, size.width(), size.height());
73 //X if (childrenBoundingRect() != frameGeometry) {
74 //X PathItem *pathItem = qgraphicsitem_cast<PathItem *>(parentItem());
75 //X if (pathItem) {
76 //X pathItem->updateChildrenPositions();
77 //X }
78 //X }
81 QVariant WidgetRectItem::itemChange(GraphicsItemChange change, const QVariant &value)
83 if (change == ItemPositionHasChanged) {
84 foreach (PathItem *p, m_paths) {
85 p->endPointMoved(this);
88 return QGraphicsItem::itemChange(change, value);
91 void WidgetRectItem::addPath(PathItem *p)
93 m_paths.append(p);
96 void WidgetRectItem::removePath(PathItem *p)
98 m_paths.removeAll(p);