Changeset 561 for trunk/src/gui/graphicsview/qgraphicsproxywidget.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/graphicsview/qgraphicsproxywidget.cpp
r2 r561 2 2 ** 3 3 ** 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) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 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. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** 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. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 58 58 #include <QtGui/qstyleoption.h> 59 59 #include <QtGui/qgraphicsview.h> 60 #include <QtGui/qlistview.h> 61 #include <QtGui/qlineedit.h> 62 #include <QtGui/qtextedit.h> 60 63 61 64 QT_BEGIN_NAMESPACE … … 68 71 a QWidget in a QGraphicsScene. 69 72 \since 4.4 70 \ingroup multimedia71 73 \ingroup graphicsview-api 72 74 … … 88 90 means that when an embedded QComboBox shows its popup list, a new 89 91 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). 91 95 92 96 \section1 Embedding a Widget with QGraphicsProxyWidget … … 178 182 in behavior from when it is not embedded. 179 183 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 180 188 \sa QGraphicsScene::addWidget(), QGraphicsWidget 181 189 */ 182 190 183 191 extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); 192 extern bool qt_tab_all_widgets; 184 193 185 194 /*! … … 272 281 QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber; 273 282 QApplicationPrivate::sendMouseEvent(receiver, mouseEvent, alienWidget, widget, 274 &embeddedMouseGrabberPtr, lastWidgetUnderMouse );283 &embeddedMouseGrabberPtr, lastWidgetUnderMouse, event->spontaneous()); 275 284 embeddedMouseGrabber = embeddedMouseGrabberPtr; 276 285 … … 367 376 /*! 368 377 \internal 378 Some of the logic is shared with QApplicationPrivate::focusNextPrevChild_helper 369 379 */ 370 380 QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) const … … 380 390 if ((next && child == widget) || (!next && child == widget->d_func()->focus_prev)) { 381 391 return 0; 382 392 } 383 393 } 384 394 385 395 QWidget *oldChild = child; 396 uint focus_flag = qt_tab_all_widgets ? Qt::TabFocus : Qt::StrongFocus; 386 397 do { 387 398 if (child->isEnabled() 388 399 && 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; 391 403 } 392 404 child = next ? child->d_func()->focus_next : child->d_func()->focus_prev; … … 448 460 /*! 449 461 \internal 462 */ 463 void 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 450 478 451 479 Embeds \a subWin as a subwindow of this proxy widget. \a subWin must be a top-level … … 457 485 QWExtra *extra; 458 486 if (!((extra = subWin->d_func()->extra) && extra->proxyWidget)) { 459 QGraphicsProxyWidget *subProxy = new QGraphicsProxyWidget(q_func() );487 QGraphicsProxyWidget *subProxy = new QGraphicsProxyWidget(q_func(), subWin->windowFlags()); 460 488 subProxy->d_func()->setWidget_helper(subWin, false); 461 489 } … … 540 568 hidden or disabled after embedding is complete. The class documentation 541 569 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. 542 573 543 574 After this function returns, QGraphicsProxyWidget will keep its state … … 658 689 q->setCursor(widget->cursor()); 659 690 #endif 660 Qt::WFlags flags = newWidget->windowFlags();661 if (newWidget->windowType() == Qt::Window)662 flags &= ~Qt::Window;663 q->setWindowFlags(flags);664 691 q->setEnabled(newWidget->isEnabled()); 665 692 q->setVisible(newWidget->isVisible()); … … 687 714 688 715 updateProxyGeometryFromWidget(); 716 717 updateProxyInputMethodAcceptanceFromWidget(); 689 718 690 719 // Hook up the event filter to keep the state up to date. … … 837 866 // of inputMethodEvent(). 838 867 QWidget *focusWidget = d->widget->focusWidget(); 839 if (focusWidget ->testAttribute(Qt::WA_InputMethodEnabled))868 if (focusWidget && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) 840 869 QApplication::sendEvent(focusWidget, event); 841 870 break; … … 954 983 { 955 984 Q_D(QGraphicsProxyWidget); 956 if (!event || !d->widget || !d->widget->isVisible() )985 if (!event || !d->widget || !d->widget->isVisible() || !hasFocus()) 957 986 return; 958 987 … … 974 1003 #endif // QT_NO_CONTEXTMENU 975 1004 1005 #ifndef QT_NO_DRAGANDDROP 976 1006 /*! 977 1007 \reimp … … 1034 1064 // Try to enter before we leave 1035 1065 QDragEnterEvent dragEnter(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers()); 1036 dragEnter.setDropAction(event->proposedAction()); 1066 dragEnter.setDropAction(event->proposedAction()); 1037 1067 QApplication::sendEvent(receiver, &dragEnter); 1038 1068 event->setAccepted(dragEnter.isAccepted()); … … 1094 1124 #endif 1095 1125 } 1126 #endif 1096 1127 1097 1128 /*! … … 1299 1330 d->widget->focusWidget()->setFocus(event->reason()); 1300 1331 return; 1301 1302 1332 } 1333 break; 1303 1334 } 1304 1335 } … … 1432 1463 Creates a proxy widget for the given \a child of the widget 1433 1464 contained in this proxy. 1434 1465 1435 1466 This function makes it possible to aquire proxies for 1436 1467 non top-level widgets. For instance, you can embed a dialog,
Note:
See TracChangeset
for help on using the changeset viewer.