Changeset 447 for trunk

Timestamp:
Jan 12, 2010, 12:00:10 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

gui: DnD: Implemented support for painting in widgets during drag and draw.

Location:
trunk/src/gui/kernel
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gui/kernel/qapplication_pm.cpp

    r438 r447  
    6464#include "qkeymapper_p.h"
    6565#include "qcursor_p.h"
     66
    6667
    6768#define WM_KBDLAYERCHANGED   0x0BD4 // defined in OS2TK45/h/pmbidi.h
     
    702703#define SV_WORKAREA_XLEFT   54
    703704
    704 #ifndef QT_NO_DRAGANDDROP
    705 extern MRESULT qt_dispatchDragAndDrop(QWidget *, const QMSG &); // qdnd_pm.cpp
    706 #endif
    707 
    708705/*!
    709706    \internal
     
    921918#ifndef QT_NO_DRAGANDDROP
    922919        } else if (msg >= WM_DRAGFIRST && msg <= WM_DRAGLAST) {
    923             return qt_dispatchDragAndDrop(widget, qmsg);
     920            return dispatchDragAndDrop(widget, qmsg);
    924921#endif
    925922        } else {
     
    21422139    if (rc == RGN_ERROR) { // The update bounding rect is invalid
    21432140        GpiDestroyRegion(displayPS, hrgn);
    2144         d_func()->hd = NULLHANDLE;
    21452141        setAttribute(Qt::WA_PendingUpdate, false);
    21462142        return false;
     
    21662162    if (rcl.xRight <= rcl.xLeft || rcl.yTop <= rcl.yBottom) {
    21672163        WinEndPaint(d_func()->hd);
     2164
    21682165        GpiDestroyRegion(displayPS, hrgn);
    2169         d_func()->hd = NULLHANDLE;
    21702166        setAttribute(Qt::WA_PendingUpdate, false);
    21712167        return true;
     
    21732169
    21742170    // flip y coordinate
    2175     rcl.yBottom = height() - (rcl.yBottom + 1);
    2176     rcl.yTop = height() - (rcl.yTop + 1);
    2177 
    21782171    // note: right top point is exlusive in rcl
    2179     QRect updRect(QPoint(rcl.xLeft, rcl.yTop + 1),
    2180                   QPoint(rcl.xRight - 1, rcl.yBottom));
     2172    QRect updRect(QPoint(rcl.xLeft, ),
     2173                  QPoint(rcl.xRight - 1, ));
    21812174
    21822175    // Mapping region from system to qt (32 bit) coordinate system.
  • trunk/src/gui/kernel/qdnd.cpp

    r438 r447  
    358358    xdndMimeTransferedPixmapIndex = 0;
    359359#endif
     360
     361
     362
    360363}
    361364
     
    363366QDragManager::~QDragManager()
    364367{
     368
     369
     370
    365371#ifndef QT_NO_CURSOR
    366372    if (restoreCursor)
  • trunk/src/gui/kernel/qdnd_p.h

    r438 r447  
    6363#ifdef Q_WS_MAC
    6464# include "private/qt_mac_p.h"
     65
     66
     67
     68
    6569#endif
    6670
     
    205209    LPDATAOBJECT currentDataObject;
    206210#elif defined(Q_WS_PM)
    207     friend class QPMDragData;
     211    friend class Q;
    208212    QPMDragData *d;
    209213#endif
     
    267271#endif
    268272
     273
     274
     275
     276
     277
     278
     279
     280
    269281private:
    270282    QPixmap *pm_cursor;
     
    272284#ifdef Q_WS_QWS
    273285    Qt::DropAction currentActionForOverrideCursor;
     286
     287
     288
    274289#endif
    275290
  • trunk/src/gui/kernel/qdnd_pm.cpp

    r444 r447  
    9393
    9494private:
     95
    9596
    9697    void initWorkers();
     
    102103    DRAGINFO *di;
    103104    QList<QPMMime::DropWorker*> workers;
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
    104117};
    105118
     
    107120    : initialized(false), dropped(false)
    108121    , gotWorkers(false), di(NULL)
    109 {
    110     QDragManager *manager = QDragManager::self();
    111     Q_ASSERT(!manager->dropData->d);
    112     manager->dropData->d = this;
     122    , lastDragOverWidget(0), lastDragOverOp(0)
     123    , supportedOps(0), sourceAllowsOp(false)
     124    , lastDropReply(DOR_NEVERDROP), lastOpRequest(DO_UNKNOWN)
     125    , lastProposedAction(Qt::CopyAction)
     126{
    113127}
    114128
     
    116130{
    117131    reset();
    118 
    119     QDragManager *manager = QDragManager::self();
    120     if (manager) {
    121         Q_ASSERT(manager->dropData->d == this);
    122         manager->dropData->d = 0;
    123     }
    124132}
    125133
     
    265273}
    266274
     275
     276
     277
     278
     279
     280
     281
     282
     283
     284
     285
     286
     287
     288
     289
     290
     291
     292
     293
     294
     295
     296
     297
     298
     299
     300
     301
     302
     303
     304
    267305/*!
    268306 *  \internal
    269307 *  Direct manipulation (Drag & Drop) event handler
    270308 */
    271 MRESULT qt_dispatchDragAndDrop(QWidget *widget, const QMSG &qmsg)
    272 {
    273     static QWidget *lastDragOverWidget = 0; // last target widget
    274     static USHORT lastDragOverOp = 0; // last DM_DRAGOVER operation
    275 
    276     static USHORT supportedOps = 0; // operations supported by all items
    277     static bool sourceAllowsOp = false; // does source allow requested operation
    278 
    279     static USHORT lastDropReply = DOR_NEVERDROP; // last reply to DM_DRAGOVER
    280     static USHORT lastOpRequest = DO_UNKNOWN; // last op requested in DM_DRAGOVER
    281 
    282     static Qt::DropAction lastProposedAction = Qt::CopyAction; // last proposed action
    283     static QRect lastAnswerRect; // last accepted rectangle from the target
    284     // @todo use lastAnswerRect to compress DM_DRAGOVER events
    285 
    286     static QPMDragData dragData;
    287 
     309MRESULT QDragManager::dispatchDragAndDrop(QWidget *widget, const QMSG &qmsg)
     310{
    288311    Q_ASSERT(widget);
    289312
     
    291314
    292315    QDragManager *manager = QDragManager::self();
     316
     317
     318
     319
    293320
    294321    switch (qmsg.msg) {
     
    312339                dragOverWidget = widget;
    313340
    314             bool first = lastDragOverWidget != dragOverWidget;
     341            bool first = lastDragOverWidget != dragOverWidget;
    315342            if (first) {
    316343                // the first DM_DRAGOVER message
    317                 if (lastDragOverWidget != 0) {
     344                if (lastDragOverWidget != 0) {
    318345                    // send drag leave to the old widget
    319                     dragData.reset();
     346                    dragDatareset();
    320347                    QPointer<QWidget> dragOverWidgetGuard(dragOverWidget);
    321348                    QDragLeaveEvent dle;
    322                     QApplication::sendEvent(lastDragOverWidget, &dle);
     349                    lastDragOverWidget, &dle);
    323350                    if (!dragOverWidgetGuard) {
    324351                        dragOverWidget = widget->childAt(pnt);
     
    327354                    }
    328355                }
    329                 lastDragOverWidget = dragOverWidget;
    330                 lastDragOverOp = 0;
    331                 supportedOps = DO_COPYABLE | DO_MOVEABLE | DO_LINKABLE;
    332                 sourceAllowsOp = false;
    333                 lastDropReply = DOR_NEVERDROP;
    334                 lastOpRequest = DO_UNKNOWN;
    335                 lastProposedAction = manager->defaultAction(toQDragDropActions(supportedOps),
    336                                                             Qt::NoModifier);
    337                 lastAnswerRect = QRect();
     356                dragData->lastDragOverWidget = dragOverWidget;
     357                dragData->lastDragOverOp = 0;
     358                dragData->supportedOps = DO_COPYABLE | DO_MOVEABLE | DO_LINKABLE;
     359                dragData->sourceAllowsOp = false;
     360                dragData->lastDropReply = DOR_NEVERDROP;
     361                dragData->lastOpRequest = DO_UNKNOWN;
     362                dragData->lastProposedAction =
     363                    manager->defaultAction(toQDragDropActions(dragData->supportedOps),
     364                                           Qt::NoModifier);
     365                dragData->lastAnswerRect = QRect();
    338366                // ensure drag data is reset (just in case of a wrong msg flow...)
    339                 dragData.reset();
     367                dragDatareset();
    340368            }
    341369
     
    362390                        break;
    363391                    }
    364                     supportedOps &= item->fsSupportedOps;
     392                    supportedOps &= item->fsSupportedOps;
    365393                }
    366394                if (dropReply != DOR_NEVERDROP) {
    367395                    Q_ASSERT(itemCount);
    368                     if (!itemCount || !supportedOps) {
     396                    if (!itemCount || !supportedOps) {
    369397                        // items don't have even a single common operation...
    370398                        dropReply = DOR_NEVERDROP;