Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/graphicsview/qgraphicsproxywidget.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtGui module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5858#include <QtGui/qstyleoption.h>
    5959#include <QtGui/qgraphicsview.h>
     60#include <QtGui/qlistview.h>
     61#include <QtGui/qlineedit.h>
     62#include <QtGui/qtextedit.h>
    6063
    6164QT_BEGIN_NAMESPACE
     
    6871    a QWidget in a QGraphicsScene.
    6972    \since 4.4
    70     \ingroup multimedia
    7173    \ingroup graphicsview-api
    7274
     
    8890    means that when an embedded QComboBox shows its popup list, a new
    8991    QGraphicsProxyWidget is created automatically, embedding the popup, and
    90     positioning it correctly.
     92    positioning it correctly. This only works if the popup is child of the
     93    embedded widget (for example QToolButton::setMenu() requires the QMenu instance
     94    to be child of the QToolButton).
    9195
    9296    \section1 Embedding a Widget with QGraphicsProxyWidget
     
    178182    in behavior from when it is not embedded.
    179183
     184    \warning This class is provided for convenience when bridging
     185    QWidgets and QGraphicsItems, it should not be used for
     186    high-performance scenarios.
     187
    180188    \sa QGraphicsScene::addWidget(), QGraphicsWidget
    181189*/
    182190
    183191extern bool qt_sendSpontaneousEvent(QObject *, QEvent *);
     192extern bool qt_tab_all_widgets;
    184193
    185194/*!
     
    272281    QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber;
    273282    QApplicationPrivate::sendMouseEvent(receiver, mouseEvent, alienWidget, widget,
    274                                         &embeddedMouseGrabberPtr, lastWidgetUnderMouse);
     283                                        &embeddedMouseGrabberPtr, lastWidgetUnderMouse, event->spontaneous());
    275284    embeddedMouseGrabber = embeddedMouseGrabberPtr;
    276285
     
    367376/*!
    368377    \internal
     378    Some of the logic is shared with QApplicationPrivate::focusNextPrevChild_helper
    369379*/
    370380QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) const
     
    380390        if ((next && child == widget) || (!next && child == widget->d_func()->focus_prev)) {
    381391             return 0;
    382         }
     392        }
    383393    }
    384394
    385395    QWidget *oldChild = child;
     396    uint focus_flag = qt_tab_all_widgets ? Qt::TabFocus : Qt::StrongFocus;
    386397    do {
    387398        if (child->isEnabled()
    388399            && child->isVisibleTo(widget)
    389             && (child->focusPolicy() & Qt::TabFocus)) {
    390             return child;
     400            && ((child->focusPolicy() & focus_flag) == focus_flag)
     401            && !(child->d_func()->extra && child->d_func()->extra->focus_proxy)) {
     402            return child;
    391403        }
    392404        child = next ? child->d_func()->focus_next : child->d_func()->focus_prev;
     
    448460/*!
    449461    \internal
     462*/
     463void QGraphicsProxyWidgetPrivate::updateProxyInputMethodAcceptanceFromWidget()
     464{
     465    Q_Q(QGraphicsProxyWidget);
     466    if (!widget)
     467        return;
     468
     469    QWidget *focusWidget = widget->focusWidget();
     470    if (!focusWidget)
     471        focusWidget = widget;
     472    q->setFlag(QGraphicsItem::ItemAcceptsInputMethod,
     473               focusWidget->testAttribute(Qt::WA_InputMethodEnabled));
     474}
     475
     476/*!
     477    \internal
    450478
    451479    Embeds \a subWin as a subwindow of this proxy widget. \a subWin must be a top-level
     
    457485    QWExtra *extra;
    458486    if (!((extra = subWin->d_func()->extra) && extra->proxyWidget)) {
    459         QGraphicsProxyWidget *subProxy = new QGraphicsProxyWidget(q_func());
     487        QGraphicsProxyWidget *subProxy = new QGraphicsProxyWidget(q_func(), subWin->windowFlags());
    460488        subProxy->d_func()->setWidget_helper(subWin, false);
    461489    }
     
    540568    hidden or disabled after embedding is complete. The class documentation
    541569    has a full overview over the shared state.
     570
     571    QGraphicsProxyWidget's window flags determine whether the widget, after
     572    embedding, will be given window decorations or not.
    542573
    543574    After this function returns, QGraphicsProxyWidget will keep its state
     
    658689        q->setCursor(widget->cursor());
    659690#endif
    660     Qt::WFlags flags = newWidget->windowFlags();
    661     if (newWidget->windowType() == Qt::Window)
    662         flags &= ~Qt::Window;
    663     q->setWindowFlags(flags);
    664691    q->setEnabled(newWidget->isEnabled());
    665692    q->setVisible(newWidget->isVisible());
     
    687714
    688715    updateProxyGeometryFromWidget();
     716
     717    updateProxyInputMethodAcceptanceFromWidget();
    689718
    690719    // Hook up the event filter to keep the state up to date.
     
    837866        // of inputMethodEvent().
    838867        QWidget *focusWidget = d->widget->focusWidget();
    839         if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
     868        if (focusWidget && focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
    840869            QApplication::sendEvent(focusWidget, event);
    841870        break;
     
    954983{
    955984    Q_D(QGraphicsProxyWidget);
    956     if (!event || !d->widget || !d->widget->isVisible())
     985    if (!event || !d->widget || !d->widget->isVisible() || !hasFocus())
    957986        return;
    958987
     
    9741003#endif // QT_NO_CONTEXTMENU
    9751004
     1005#ifndef QT_NO_DRAGANDDROP
    9761006/*!
    9771007    \reimp
     
    10341064            // Try to enter before we leave
    10351065            QDragEnterEvent dragEnter(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
    1036             dragEnter.setDropAction(event->proposedAction());           
     1066            dragEnter.setDropAction(event->proposedAction());
    10371067            QApplication::sendEvent(receiver, &dragEnter);
    10381068            event->setAccepted(dragEnter.isAccepted());
     
    10941124#endif
    10951125}
     1126#endif
    10961127
    10971128/*!
     
    12991330            d->widget->focusWidget()->setFocus(event->reason());
    13001331            return;
    1301         }
    1302         break;
     1332        }
     1333        break;
    13031334    }
    13041335}
     
    14321463  Creates a proxy widget for the given \a child of the widget
    14331464  contained in this proxy.
    1434  
     1465
    14351466  This function makes it possible to aquire proxies for
    14361467  non top-level widgets. For instance, you can embed a dialog,
Note: See TracChangeset for help on using the changeset viewer.