summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicswidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/graphicsview/qgraphicswidget.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp69
1 files changed, 41 insertions, 28 deletions
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 157fbe5..224f50b 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtGui module of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -168,6 +168,8 @@ QT_BEGIN_NAMESPACE
\sa QGraphicsProxyWidget, QGraphicsItem, {Widgets and Layouts}
*/
+bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
+
/*!
Constructs a QGraphicsWidget instance. The optional \a parent argument is
passed to QGraphicsItem's constructor. The optional \a wFlags argument
@@ -379,6 +381,8 @@ void QGraphicsWidget::setGeometry(const QRectF &rect)
QSizeF oldSize = size();
QGraphicsLayoutItem::setGeometry(newGeom);
+ wd->invalidateCachedClipPathRecursively();
+
// Send resize event
bool resized = newGeom.size() != oldSize;
if (resized) {
@@ -683,11 +687,13 @@ QSizeF QGraphicsWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c
Q_D(const QGraphicsWidget);
QSizeF sh;
if (d->layout) {
- sh = d->layout->effectiveSizeHint(which, constraint);
+ QSizeF marginSize(0,0);
if (d->margins) {
- sh += QSizeF(d->margins[d->Left] + d->margins[d->Right],
+ marginSize = QSizeF(d->margins[d->Left] + d->margins[d->Right],
d->margins[d->Top] + d->margins[d->Bottom]);
}
+ sh = d->layout->effectiveSizeHint(which, constraint - marginSize);
+ sh += marginSize;
} else {
switch (which) {
case Qt::MinimumSize:
@@ -1097,7 +1103,11 @@ QVariant QGraphicsWidget::propertyChange(const QString &propertyName, const QVar
*/
bool QGraphicsWidget::sceneEvent(QEvent *event)
{
- return QCoreApplication::sendEvent(this, event) || QGraphicsItem::sceneEvent(event);
+ bool spont = event->spontaneous();
+ if (spont ? qt_sendSpontaneousEvent(this, event) : QApplication::sendEvent(this, event))
+ return true;
+ event->spont = spont;
+ return QGraphicsItem::sceneEvent(event);
}
/*!
@@ -1277,10 +1287,6 @@ bool QGraphicsWidget::event(QEvent *event)
case QEvent::WindowActivate:
case QEvent::WindowDeactivate:
update();
- foreach (QGraphicsItem *child, childItems()) {
- if (child->isWidget())
- QApplication::sendEvent(static_cast<QGraphicsWidget *>(child), event);
- }
break;
// Taken from QWidget::event
case QEvent::ActivationChange:
@@ -1590,6 +1596,8 @@ void QGraphicsWidget::ungrabKeyboardEvent(QEvent *event)
/*!
Returns the widgets window type.
+
+ \sa windowFlags(), isWindow(), isPanel()
*/
Qt::WindowType QGraphicsWidget::windowType() const
{
@@ -1605,6 +1613,13 @@ Qt::WindowType QGraphicsWidget::windowType() const
is platform-dependent.
By default, this property contains no window flags.
+
+ Windows are panels. If you set the Qt::Window flag, the ItemIsPanel flag
+ will be set automatically. If you clear the Qt::Window flag, the
+ ItemIsPanel flag is also cleared. Note that the ItemIsPanel flag can be
+ set independently of Qt::Window.
+
+ \sa isWindow(), isPanel()
*/
Qt::WindowFlags QGraphicsWidget::windowFlags() const
{
@@ -1623,6 +1638,8 @@ void QGraphicsWidget::setWindowFlags(Qt::WindowFlags wFlags)
if (!d->setWindowFrameMargins)
unsetWindowFrameMargins();
+ setFlag(ItemIsPanel, d->windowFlags & Qt::Window);
+
bool isPopup = (d->windowFlags & Qt::WindowType_Mask) == Qt::Popup;
if (d->scene && isVisible() && wasPopup != isPopup) {
// Popup state changed; update implicit mouse grab.
@@ -1646,15 +1663,11 @@ void QGraphicsWidget::setWindowFlags(Qt::WindowFlags wFlags)
The active window is the window that either contains a child widget that
currently has input focus, or that itself has input focus.
- \sa QGraphicsScene::activeWindow(), QGraphicsScene::setActiveWindow()
+ \sa QGraphicsScene::activeWindow(), QGraphicsScene::setActiveWindow(), isActive()
*/
bool QGraphicsWidget::isActiveWindow() const
{
- Q_D(const QGraphicsWidget);
- if (!d->scene)
- return false;
- const QGraphicsWidget *w = window();
- return (!w && d->scene->d_func()->activationRefCount) || (w && d->scene->activeWindow() == w);
+ return isActive();
}
/*!