diff options
author | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-08-26 09:02:33 (GMT) |
---|---|---|
committer | Andreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com> | 2009-08-26 14:18:45 (GMT) |
commit | da5033d8b48b24580e3b6faf7b4e2a8fe2cec254 (patch) | |
tree | 5870b468e418a29a8269bd462e93e54bb0ee5b7b /src/gui/graphicsview/qgraphicswidget.cpp | |
parent | 7e30c92186878beb300a13093c3668ae8a10f2be (diff) | |
download | Qt-da5033d8b48b24580e3b6faf7b4e2a8fe2cec254.zip Qt-da5033d8b48b24580e3b6faf7b4e2a8fe2cec254.tar.gz Qt-da5033d8b48b24580e3b6faf7b4e2a8fe2cec254.tar.bz2 |
Introduce QGraphicsItem::ItemIsPanel, light-weight window.
ItemIsPanel allows items that act like windows. They can be
activated and deactivated just like windows and focus is handled
just like with windows. The main difference is that panels are
more light-weight. There's less built-in functionality (e.g.,
clicking a panel doesn't automatically activate nor raise it).
This patch also introduces QGraphicsItem::panel(),
QGraphicsItem::isPanel(), and QGraphicsItem::isActive(),
as well as QGraphicsScene::activePanel(),
QGraphicsScene::setActivePanel(). and QGraphicsScene::isActive().
Regular windows (QGraphicsWidgets with Qt::Window set) are
also panels, with added functionality. The ItemIsPanel flag is
set automatically for windows.
Reviewed-by: brad
Diffstat (limited to 'src/gui/graphicsview/qgraphicswidget.cpp')
-rw-r--r-- | src/gui/graphicsview/qgraphicswidget.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index 7f9fe65..40addf6 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -1285,10 +1285,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: @@ -1598,6 +1594,8 @@ void QGraphicsWidget::ungrabKeyboardEvent(QEvent *event) /*! Returns the widgets window type. + + \sa windowFlags(), isWindow(), isPanel() */ Qt::WindowType QGraphicsWidget::windowType() const { @@ -1613,6 +1611,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 { @@ -1631,6 +1636,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. @@ -1654,7 +1661,7 @@ 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 { @@ -1662,7 +1669,7 @@ bool QGraphicsWidget::isActiveWindow() const if (!d->scene) return false; const QGraphicsWidget *w = window(); - return (!w && d->scene->d_func()->activationRefCount) || (w && d->scene->activeWindow() == w); + return (!w && d->scene->isActive()) || (w && d->scene->activeWindow() == w); } /*! |