44 #ifndef QT_NO_GRAPHICSVIEW 48 #include "private/qgraphicsproxywidget_p.h" 49 #include "private/qwidget_p.h" 50 #include "private/qapplication_p.h" 52 #include <QtCore/qdebug.h> 53 #include <QtGui/qevent.h> 54 #include <QtGui/qgraphicsscene.h> 55 #include <QtGui/qgraphicssceneevent.h> 56 #include <QtGui/qlayout.h> 57 #include <QtGui/qpainter.h> 58 #include <QtGui/qstyleoption.h> 59 #include <QtGui/qgraphicsview.h> 60 #include <QtGui/qlistview.h> 61 #include <QtGui/qlineedit.h> 62 #include <QtGui/qtextedit.h> 199 q->setAcceptDrops(
true);
236 switch (event->
type()) {
262 Q_ASSERT_X(
false,
"QGraphicsProxyWidget",
"internal error");
277 event->buttons(),
event->modifiers());
288 if (q->rect().contains(event->
pos()) && q->acceptsHoverEvents())
294 embeddedMouseGrabber = 0;
357 QPointF focusWidgetPos = q->subWidgetRect(focusWidget).topLeft();
390 child = next ? child->d_func()->focus_next : child->d_func()->focus_prev;
391 if ((next && child ==
widget) || (!next && child ==
widget->d_func()->focus_prev)) {
401 && ((child->
focusPolicy() & focus_flag) == focus_flag)
402 && !(child->d_func()->extra && child->d_func()->extra->focus_proxy)) {
405 child = next ? child->d_func()->focus_next : child->d_func()->focus_prev;
406 }
while (child != oldChild && !(next && child ==
widget) && !(!next && child ==
widget->d_func()->focus_prev));
440 if (parentWidget && (proxyParent = qobject_cast<QGraphicsProxyWidget *>(q->parentWidget()))) {
456 q->setGeometry(widgetGeometry);
490 if (!((extra = subWin->d_func()->extra) && extra->
proxyWidget)) {
492 subProxy->d_func()->setWidget_helper(subWin,
false);
510 if (
QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(static_cast<QGraphicsWidget *>(child))) {
511 if (proxy->widget() == subWin) {
535 while (receiver && receiver !=
widget) {
537 receiver = receiver->parentWidget();
600 d->setWidget_helper(widget,
true);
612 widget->d_func()->extra->proxyWidget = 0;
613 resolveFont(inheritedFontResolveMask);
614 resolvePalette(inheritedPaletteResolveMask);
637 q->setAcceptHoverEvents(
false);
646 qWarning(
"QGraphicsProxyWidget::setWidget: cannot embed widget %p " 647 "which is not a toplevel widget, and is not a child of an embedded widget", newWidget);
654 QWExtra *extra = newWidget->d_func()->extra;
656 newWidget->d_func()->createExtra();
657 extra = newWidget->d_func()->extra;
661 if (*proxyWidget != q) {
662 qWarning(
"QGraphicsProxyWidget::setWidget: cannot embed widget %p" 663 "; already embedded", newWidget);
674 q->setAcceptHoverEvents(
true);
704 resolveFont(inheritedFontResolveMask);
705 resolvePalette(inheritedPaletteResolveMask);
712 q->setContentsMargins(left, top, right, bottom);
722 updateProxyGeometryFromWidget();
724 updateProxyInputMethodAcceptanceFromWidget();
760 if (!widget || !
d->widget)
762 if (
d->widget == widget ||
d->widget->isAncestorOf(widget))
773 bool proxyResizesWidget = !
d->posChangeMode && !
d->sizeChangeMode;
774 if (proxyResizesWidget) {
779 if (proxyResizesWidget) {
798 if (!
d->posChangeMode)
810 if (!
d->visibleChangeMode)
820 if (!
d->enabledChangeMode)
844 switch (event->
type()) {
847 if (!
d->styleChangeMode) {
849 d->widget->setStyle(
style());
856 int mask =
d->font.resolve() |
d->inheritedFontResolveMask;
864 int mask =
d->palette.resolve() |
d->inheritedPaletteResolveMask;
881 while (focusWidget) {
894 while (focusWidget) {
907 #ifndef QT_NO_TOOLTIP 910 if (
d->lastWidgetUnderMouse) {
915 event->setAccepted(e.isAccepted());
916 return e.isAccepted();
922 if (!
d->tooltipChangeMode) {
943 if (
object ==
d->widget) {
944 switch (event->
type()) {
951 if (!
d->sizeChangeMode)
952 d->updateProxyGeometryFromWidget();
957 if (!
d->posChangeMode)
958 d->updateProxyGeometryFromWidget();
963 if (!
d->visibleChangeMode) {
971 if (!
d->enabledChangeMode) {
979 if (!
d->styleChangeMode) {
985 #ifndef QT_NO_TOOLTIP 988 if (!
d->tooltipChangeMode) {
1018 #ifndef QT_NO_CONTEXTMENU 1025 if (!event || !
d->widget || !
d->widget->isVisible() || !
hasFocus())
1034 pos =
d->mapToReceiver(pos, receiver);
1047 pos.
toPoint(), globalPos,
event->modifiers());
1052 #endif // QT_NO_CONTEXTMENU 1054 #ifndef QT_NO_DRAGANDDROP 1060 #ifdef QT_NO_DRAGANDDROP 1067 QDragEnterEvent proxyDragEnter(event->
pos().
toPoint(),
event->dropAction(),
event->mimeData(),
event->buttons(),
event->modifiers());
1070 event->setAccepted(proxyDragEnter.isAccepted());
1071 if (proxyDragEnter.isAccepted())
1081 #ifndef QT_NO_DRAGANDDROP 1083 if (!
d->widget || !
d->dragDropWidget)
1087 d->dragDropWidget = 0;
1096 #ifdef QT_NO_DRAGANDDROP 1106 bool eventDelivered =
false;
1107 for (; receiver; receiver = receiver->
parentWidget()) {
1111 QPoint receiverPos =
d->mapToReceiver(p, receiver).toPoint();
1112 if (receiver !=
d->dragDropWidget) {
1117 event->setAccepted(dragEnter.isAccepted());
1118 event->setDropAction(dragEnter.dropAction());
1124 d->lastDropAction =
event->dropAction();
1126 if (
d->dragDropWidget) {
1130 d->dragDropWidget = receiver;
1136 event->setAccepted(dragMove.isAccepted());
1137 event->setDropAction(dragMove.dropAction());
1140 eventDelivered =
true;
1144 if (!eventDelivered) {
1145 if (
d->dragDropWidget) {
1149 d->dragDropWidget = 0;
1162 #ifdef QT_NO_DRAGANDDROP 1166 if (
d->widget &&
d->dragDropWidget) {
1167 QPoint widgetPos =
d->mapToReceiver(event->
pos(),
d->dragDropWidget).toPoint();
1170 event->setAccepted(
dropEvent.isAccepted());
1171 d->dragDropWidget = 0;
1193 if (
d->lastWidgetUnderMouse) {
1195 d->lastWidgetUnderMouse = 0;
1205 #ifdef GRAPHICSPROXYWIDGET_DEBUG 1206 qDebug() <<
"QGraphicsProxyWidget::hoverMoveEvent";
1210 if (
d->lastWidgetUnderMouse) {
1212 d->lastWidgetUnderMouse = 0;
1217 d->embeddedMouseGrabber = 0;
1218 d->sendWidgetMouseEvent(event);
1236 d->embeddedMouseGrabber = 0;
1245 #ifdef GRAPHICSPROXYWIDGET_DEBUG 1246 qDebug() <<
"QGraphicsProxyWidget::mouseMoveEvent";
1248 d->sendWidgetMouseEvent(event);
1257 #ifdef GRAPHICSPROXYWIDGET_DEBUG 1258 qDebug() <<
"QGraphicsProxyWidget::mousePressEvent";
1260 d->sendWidgetMouseEvent(event);
1269 #ifdef GRAPHICSPROXYWIDGET_DEBUG 1270 qDebug() <<
"QGraphicsProxyWidget::mouseDoubleClickEvent";
1272 d->sendWidgetMouseEvent(event);
1278 #ifndef QT_NO_WHEELEVENT 1282 #ifdef GRAPHICSPROXYWIDGET_DEBUG 1283 qDebug() <<
"QGraphicsProxyWidget::wheelEvent";
1291 receiver =
d->widget;
1294 pos =
d->mapToReceiver(pos, receiver);
1298 event->buttons(),
event->modifiers(),
event->orientation());
1305 if (focusWidget && !focusWidget->hasFocus()) {
1306 focusWidget->update();
1307 focusWidget =
d->widget->focusWidget();
1308 if (focusWidget && focusWidget->hasFocus())
1309 focusWidget->update();
1320 #ifdef GRAPHICSPROXYWIDGET_DEBUG 1321 qDebug() <<
"QGraphicsProxyWidget::mouseReleaseEvent";
1323 d->sendWidgetMouseEvent(event);
1332 #ifdef GRAPHICSPROXYWIDGET_DEBUG 1333 qDebug() <<
"QGraphicsProxyWidget::keyPressEvent";
1335 d->sendWidgetKeyEvent(event);
1344 #ifdef GRAPHICSPROXYWIDGET_DEBUG 1345 qDebug() <<
"QGraphicsProxyWidget::keyReleaseEvent";
1347 d->sendWidgetKeyEvent(event);
1355 #ifdef GRAPHICSPROXYWIDGET_DEBUG 1356 qDebug() <<
"QGraphicsProxyWidget::focusInEvent";
1360 if (
d->focusFromWidgetToProxy) {
1367 d->proxyIsGivingFocus =
true;
1369 switch (event->
reason()) {
1371 if (
QWidget *focusChild =
d->findFocusChild(0,
true))
1372 focusChild->setFocus(event->
reason());
1376 if (
QWidget *focusChild =
d->findFocusChild(0,
false))
1377 focusChild->setFocus(event->
reason());
1380 if (
d->widget &&
d->widget->focusWidget()) {
1381 d->widget->focusWidget()->setFocus(event->
reason());
1386 d->proxyIsGivingFocus =
false;
1394 #ifdef GRAPHICSPROXYWIDGET_DEBUG 1395 qDebug() <<
"QGraphicsProxyWidget::focusOutEvent";
1412 if (!
d->widget || !
d->scene)
1416 QWidget *lastFocusChild =
d->widget->focusWidget();
1417 if (
QWidget *newFocusChild =
d->findFocusChild(lastFocusChild, next)) {
1418 newFocusChild->setFocus(reason);
1440 sh =
d->widget->sizeHint();
1444 sh =
l->minimumSize();
1446 sh =
d->widget->minimumSizeHint();
1450 sh =
l->maximumSize();
1483 if (!
d->widget || !
d->widget->isVisible())
1488 if (exposedWidgetRect.
isEmpty())
1497 d->widget->render(painter, exposedWidgetRect.
topLeft(), exposedWidgetRect);
1535 qWarning(
"QGraphicsProxyWidget::createProxyForChildWidget: top-level widget not in a QGraphicsScene");
1578 #include "moc_qgraphicsproxywidget.cpp" 1580 #endif //QT_NO_GRAPHICSVIEW The QVariant class acts like a union for the most common Qt data types.
Qt::DropAction dropAction() const
Returns the action that was performed in this drag and drop.
The QPainter class performs low-level painting on widgets and other paint devices.
QPointF scenePos() const
Returns the position of the mouse cursor in scene coordinates at the moment the help event was sent...
bool hasFocus() const
Returns true if this item is active, and it or its focus proxy has keyboard input focus; otherwise...
The QKeyEvent class describes a key event.
#define QT_END_NAMESPACE
This macro expands to.
QPointF toPointF() const
Returns the variant as a QPointF if the variant has type() Point or PointF ; otherwise returns a null...
void setModifiers(Qt::KeyboardModifiers modifiers)
bool isWindow() const
Returns true if the item is a QGraphicsWidget window, otherwise returns false.
QList< QGraphicsItem * > childItems() const
Returns a list of this item's children.
QScopedPointer< QGraphicsItemPrivate > d_ptr
static QMouseEvent * createExtendedMouseEvent(Type type, const QPointF &pos, const QPoint &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
QSize toSize() const
Returns an integer based copy of this size.
The QWheelEvent class contains parameters that describe a wheel event.
void setScreenPos(const QPoint &pos)
QPoint screenPos() const
Returns the position of the mouse cursor in screen coordinates at the moment the hover event was sent...
void setAccepted(bool accepted)
void setToolTip(const QString &toolTip)
Sets the item's tool tip to toolTip.
The QPointF class defines a point in the plane using floating point precision.
The QGraphicsItem class is the base class for all graphical items in a QGraphicsScene.
The QGraphicsSceneMouseEvent class provides mouse events in the graphics view framework.
void removeEventFilter(QObject *)
Removes an event filter object obj from this object.
bool isVisible() const
Returns true if the item is visible; otherwise, false is returned.
void setDropAction(Qt::DropAction action)
Sets the action to be performed on the data by the target.
Qt::MouseButton button() const
Returns the mouse button (if any) that caused the event.
QPointF topLeft() const
Returns the position of the rectangle's top-left corner.
QRect translated(int dx, int dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
#define Q_ARG(type, data)
The QGraphicsSceneResizeEvent class provides events for widget resizing in the graphics view framewor...
QPointF pos() const
Returns the position of the item in parent coordinates.
GraphicsItemChange
This enum describes the state changes that are notified by QGraphicsItem::itemChange().
void setButtons(Qt::MouseButtons buttons)
QRectF toRectF() const
Returns the variant as a QRectF if the variant has type() Rect or RectF ; otherwise returns an invali...
The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress...
bool isEnabled() const
Returns true if the item is enabled; otherwise, false is returned.
The QObject class is the base class of all Qt objects.
The QSizeF class defines the size of a two-dimensional object using floating point precision...
void setVisible(bool visible)
If visible is true, the item is made visible.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
void setParent(QObject *)
Makes the object a child of parent.
Q_CORE_EXPORT void qDebug(const char *,...)
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
int key() const
Returns the code of the key that was pressed or released.
#define QT_BEGIN_NAMESPACE
This macro expands to.
The QRectF class defines a rectangle in the plane using floating point precision. ...
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifiers at the moment the hover event was sent.
virtual bool isProxyWidget() const
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
void setDropAction(Qt::DropAction action)
This function lets the receiver of the drop set the drop action that was performed to action...
void removeItem(QGraphicsItem *item)
Removes the item item and all its children from the scene.
The QLayout class is the base class of geometry managers.
The QHideEvent class provides an event which is sent after a widget is hidden.
bool spontaneous() const
Returns true if the event originated outside the application (a system event); otherwise returns fals...
void setPos(const QPointF &pos)
Q_CORE_EXPORT void qWarning(const char *,...)
#define Q_RETURN_ARG(type, data)
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leav...
The QShowEvent class provides an event that is sent when a widget is shown.
QVariant extra(Extra type) const
QPoint screenPos() const
Returns the position of the mouse cursor in screen coordinates at the moment the help event was sent...
void setSize(const QSizeF &s)
Sets the size of the rectangle to the given size.
static QWidget * parentWidget(const QWidget *w)
virtual bool eventFilter(QObject *, QEvent *)
Filters events if this object has been installed as an event filter for the watched object...
QPointF mapFromScene(const QPointF &point) const
Maps the point point, which is in this item's scene's coordinate system, to this item's coordinate sy...
The QMouseEvent class contains parameters that describe a mouse event.
Qt::DropAction proposedAction() const
Returns the drop action that is proposed, i.e., preferred.
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
void setRenderHints(RenderHints hints, bool on=true)
Sets the given render hints on the painter if on is true; otherwise clears the render hints...
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
Disconnects signal in object sender from method in object receiver.
Qt::DropActions possibleActions() const
Returns the possible drop actions that the drag and drop can result in.
#define Q_ASSERT_X(cond, where, what)
The QGraphicsSceneHelpEvent class provides events when a tooltip is requested.
The QDropEvent class provides an event which is sent when a drag and drop action is completed...
QSizeF newSize() const
Returns the new size (i.e., the current size).
The QGraphicsSceneDragDropEvent class provides events for drag and drop in the graphics view framewor...
Type
This enum type defines the valid event types in Qt.
QRect toRect() const
Returns the variant as a QRect if the variant has type() Rect ; otherwise returns an invalid QRect...
QPoint toPoint() const
Rounds the coordinates of this point to the nearest integer, and returns a QPoint object with the rou...
QString toolTip() const
Returns the item's tool tip, or an empty QString if no tool tip has been set.
Type type() const
Returns the storage type of the value stored in the variant.
QObject * parent() const
Returns a pointer to the parent object.
The QDragEnterEvent class provides an event which is sent to a widget when a drag and drop action ent...
The QPoint class defines a point in the plane using integer precision.
void installEventFilter(QObject *)
Installs an event filter filterObj on this object.
QPointF pos() const
Returns the position of the mouse cursor in item coordinates at the moment the hover event was sent...
The QRect class defines a rectangle in the plane using integer precision.
bool isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false...
bool isWidget() const
Returns true if this item is a widget (i.
virtual bool contains(const QPointF &point) const
Returns true if this item contains point, which is in local coordinates; otherwise, false is returned.
static void mouseEvent(MouseAction action, QWidget *widget, Qt::MouseButton button, Qt::KeyboardModifiers stateKey, QPoint pos, int delay=-1)
static void dispatchEnterLeave(QWidget *enter, QWidget *leave)
void moveTo(qreal x, qreal t)
Moves the rectangle, leaving the top-left corner at the given position (x, y).
QPointF pos() const
Returns the mouse cursor position in item coordinates.
bool isNull() const
Returns true if both the width and height is 0; otherwise returns false.
The QSize class defines the size of a two-dimensional object using integer point precision.
void setEnabled(bool enabled)
If enabled is true, the item is enabled; otherwise, it is disabled.
RenderHints renderHints() const
Returns a flag that specifies the rendering hints that are set for this painter.
The QGraphicsSceneWheelEvent class provides wheel events in the graphics view framework.
QList< QGraphicsItem * > children
QRectF translated(qreal dx, qreal dy) const
Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis...
QRectF exposedRect
the exposed rectangle, in item coordinates
void setButton(Qt::MouseButton button)
static bool sendMouseEvent(QWidget *receiver, QMouseEvent *event, QWidget *alienWidget, QWidget *native, QWidget **buttonDown, QPointer< QWidget > &lastMouseReceiver, bool spontaneous=true)
The QEvent class is the base class of all event classes.
Type type() const
Returns the event type.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
The QStyleOptionGraphicsItem class is used to describe the parameters needed to draw a QGraphicsItem...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
The QFocusEvent class contains event parameters for widget focus events.
QPoint toPoint() const
Returns the variant as a QPoint if the variant has type() Point or PointF ; otherwise returns a null ...
Qt::MouseButtons buttons() const
Returns the combination of mouse buttons that were pressed at the time the event was sent...
QPointF pos() const
Returns the mouse position of the event relative to the view that sent the event. ...
The QGraphicsSceneHoverEvent class provides hover events in the graphics view framework.
QPoint topLeft() const
Returns the position of the rectangle's top-left corner.
The QHelpEvent class provides an event that is used to request helpful information about a particular...