Changeset 450 for trunk/src


Ignore:
Timestamp:
Jan 19, 2010, 11:30:46 PM (16 years ago)
Author:
Dmitry A. Kuminov
Message:

kernel: DnD: Made Copy operation work. Fixed several small bugs.

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

Legend:

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

    r449 r450  
    119119
    120120    USHORT lastDropReply; // last reply to DM_DRAGOVER
    121     USHORT lastOpRequest; // last op requested in DM_DRAGOVER
    122 
    123     Qt::DropAction lastProposedAction; // last proposed action
     121
     122    Qt::DropAction lastAction; // last target-accepted action
    124123    QRect lastAnswerRect; // last accepted rectangle from the target
    125124};
     
    130129    , lastDragOverWidget(0), lastDragOverOp(0)
    131130    , supportedOps(0), sourceAllowsOp(false)
    132     , lastDropReply(DOR_NEVERDROP), lastOpRequest(DO_UNKNOWN)
    133     , lastProposedAction(Qt::CopyAction)
     131    , lastDropReply(DOR_NEVERDROP)
     132    , lastAction(Qt::CopyAction)
    134133{
    135134}
     
    379378                dragData->sourceAllowsOp = false;
    380379                dragData->lastDropReply = DOR_NEVERDROP;
    381                 dragData->lastOpRequest = DO_UNKNOWN;
    382                 dragData->lastProposedAction =
     380                dragData->lastAction =
    383381                    manager->defaultAction(toQDragDropActions(dragData->supportedOps),
    384382                                           Qt::NoModifier);
     
    425423                if (first || dragData->lastDragOverOp != info->usOperation) {
    426424                    // the current drop operation was changed by a modifier key
    427                     dragData->lastDragOverOp = info->usOperation;
    428425                    USHORT realOp = info->usOperation;
    429426                    if (realOp == DO_DEFAULT || realOp == DO_UNKNOWN) {
    430427                        // the default operation is requested
    431                         realOp = toPmDragDropOp(dragData->lastProposedAction);
     428                        realOp = toPmDragDropOp(dragData->lastAction);
     429                    } else {
     430                        dragData->lastAction = toQDragDropAction(realOp);
    432431                    }
    433432                    dragData->sourceAllowsOp =
     
    435434                        ((dragData->supportedOps & DO_COPYABLE) && realOp == DO_COPY) ||
    436435                        ((dragData->supportedOps & DO_LINKABLE) && realOp == DO_LINK);
     436                    dragData->lastDragOverOp = realOp;
    437437                }
    438438
     
    443443
    444444                QMimeData *data = manager->source() ? manager->dragPrivate()->data : manager->dropData;
    445 
    446                 Qt::DropAction action = toQDragDropAction(dragData->lastOpRequest);
    447445
    448446                if (first) {
     
    452450                                        data, QApplication::mouseButtons(),
    453451                                        QApplication::keyboardModifiers());
     452                    dee.setDropAction(dragData->lastAction);
    454453                    sendDropEvent(dragOverWidget, &dee);
    455454                    // if not allowed or not accepted, always reply DOR_NODROP
     
    457456                    if (dragData->sourceAllowsOp && dee.isAccepted()) {
    458457                        dropReply = DOR_DROP;
    459                         action = dee.dropAction();
    460                         dragData->lastProposedAction = dee.proposedAction();
     458                        dragData->lastAction = dee.dropAction();
    461459                        dragData->lastAnswerRect = dee.answerRect();
    462460                    } else {
     
    474472                                       QApplication::keyboardModifiers());
    475473                    // accept by default, since enter event was accepted.
    476                     dme.setDropAction(action);
     474                    dme.setDropAction(dragData->lastAction);
    477475                    dme.accept();
    478476                    sendDropEvent(dragOverWidget, &dme);
    479477                    if (dragData->sourceAllowsOp && dme.isAccepted()) {
    480478                        dropReply = DOR_DROP;
    481                         action = dme.dropAction();
    482                         dragData->lastProposedAction = dme.proposedAction();
     479                        dragData->lastAction = dme.dropAction();
    483480                        dragData->lastAnswerRect = dme.answerRect();
    484481                    } else {
     
    488485
    489486                dragData->lastDropReply = dropReply;
    490                 dragData->lastOpRequest = toPmDragDropOp(action);
    491487            }
    492488
    493489            DrgFreeDraginfo(info);
    494490
    495             return MRFROM2SHORT(dropReply, dragData->lastOpRequest);
     491            return MRFROM2SHORT(dropReply, toPmDragDropOp(dragData->lastAction));
    496492        }
    497493        case DM_DRAGLEAVE: {
     
    540536            pnt = widget->mapFromGlobal(pnt);
    541537
    542             Q_ASSERT(dragData->lastOpRequest == info->usOperation);
     538            Q_ASSERT(dragData->lastDragOverOp == info->usOperation);
    543539
    544540            Q_ASSERT(dragData->lastDragOverWidget->acceptDrops());
     
    551547            QMimeData *data = manager->source() ? manager->dragPrivate()->data : manager->dropData;
    552548
    553             Qt::DropAction action = toQDragDropAction(dragData->lastOpRequest);
    554 
    555549            dragData->setDropped(true);
    556550
    557             QDropEvent de(pnt, action, data, QApplication::mouseButtons(),
     551            QDropEvent de(pnt, dragData->lastAction, data, QApplication::mouseButtons(),
    558552                          QApplication::keyboardModifiers());
    559553            if (dragData->lastDropReply == DOR_DROP)
    560                 de.setDropAction(action);
     554                de.setDropAction(dragData->lastAction);
    561555
    562556            sendDropEvent(dragData->lastDragOverWidget, &de);
     
    686680                continue;
    687681            DEBUG(() << "QPMCoopDragWorker: Got worker" << wrk
    688                      << "(isExclusive" << wrk->isExclusive() << ", "
     682                     << "( isExclusive" << wrk->isExclusive()
    689683                     << "itemCount" << wrk->itemCount() << ") from convertor"
    690                      << mime << " (gotExclForMime"
    691                      << gotExclForMime << ", " << "gotExcl" << gotExcl
    692                      << ", skipExcl" << skipExcl << ", coopLevel"
     684                     << mime << "( gotExclForMime" << gotExclForMime
     685                     << "gotExcl" << gotExcl
     686                     << "skipExcl" << skipExcl << "coopLevel"
    693687                     << coopLevel << ")");
    694688            if (wrk->isExclusive()) {
     
    748742            if (w->isExclusive() || w->itemCount() > 1) {
    749743                DEBUG(() << "QPMCoopDragWorker: DragWorker" << w
    750                          << "for" << fmt << "(isExclusive" << w->isExclusive()
    751                          << ", itemCount" << w->itemCount()
     744                         << "for" << fmt << "( isExclusive" << w->isExclusive()
     745                         << "itemCount" << w->itemCount()
    752746                         <<") has no fall-back cooperative 1-item worker!");
    753747                workers.removeLast();
     
    763757    // (depending on skipExcl) and remove duplicates
    764758    for (QList<DragWorker*>::iterator it = workers.begin();
    765          it <= workers.end();) {
     759         it < workers.end();) {
    766760        DragWorker *wrk = *it;
    767761        bool excl = wrk->isExclusive() || wrk->itemCount() > 1;
     
    776770    foreach (DragWorker *wrk, workers) {
    777771        DEBUG(() << "QPMCoopDragWorker: Will use worker" << wrk
    778                  << "(isExclusive" << wrk->isExclusive()
    779                  << ", itemCount" << wrk->itemCount() << ")");
     772                 << "( isExclusive" << wrk->isExclusive()
     773                 << "itemCount" << wrk->itemCount() << ")");
    780774    }
    781775#endif
     
    934928    if (msg == DM_RENDERPREPARE) {
    935929        if (!info) {
    936             qWarning("Drop target sent DM_RENDERPREPARE after the DnD session "
    937                      "is over!");
     930            DEBUG(() << "Drop target sent DM_RENDERPREPARE after the DnD "
     931                        "session is over!");
    938932            // free the given DRAGTRANSFER structure to avoud memory leak
    939933            DRAGTRANSFER *xfer = (DRAGTRANSFER *)mp1;
     
    961955        DEBUG(() << "QPMCoopDragWorker: Got DM_RENDERPREPARE to"
    962956                 << QPMMime::queryHSTR(xfer->hstrSelectedRMF) << "for item"
    963                  << index << "(id" << xfer->pditem->ulItemID << ")");
     957                 << index << "( id" << xfer->pditem->ulItemID << ")");
    964958       
    965959        QByteArray drm, drf;
     
    984978   
    985979    if (msg == DM_RENDER || msg == DM_ENDCONVERSATION) {
    986         qWarning("Drop target sent DM_RENDER or DM_ENDCONVERSATION to the "
    987                  "drag source window instead of the drag item window!");
     980        DEBUG(() << "Drop target sent DM_RENDER or DM_ENDCONVERSATION to the "
     981                    "drag source window instead of the drag item window!");
    988982        if (msg == DM_RENDER) {
    989983            // free the given DRAGTRANSFER structure to avoud memory leak
     
    10451039    }
    10461040
    1047     USHORT supportedOps = toPmDragDropOps(dragPrivate()->possible_actions);
     1041    USHORT supportedOps = toPmDragDropOps(o->d_func()->possible_actions);
    10481042
    10491043    static QPMCoopDragWorker dragWorker;
  • trunk/src/gui/kernel/qmime_pm.cpp

    r444 r450  
    309309    bool moveDisallowed = false;
    310310
    311     DEBUG(() << "DefaultDragWorker: Session ended (cancelled" << isCancelled
     311    DEBUG(() << "DefaultDragWorker: Session ended ( cancelled" << isCancelled
    312312             << "requests.left" << d->requests.count() << ")");
    313313
     
    392392        return false;
    393393
    394     DEBUG(() << "DefaultDragWorker: Preparing item" <<  itemIndex << "(id "
     394    DEBUG(() << "DefaultDragWorker: Preparing item" <<  itemIndex << "( id "
    395395             << item->ulItemID << ") for <" << drm << "," << drf << ">");
    396396
     
    460460        DEBUG(() << "DefaultDragWorker: Got DM_RENDER to"
    461461                 << queryHSTR(xfer->hstrSelectedRMF) << "for item" << req->index
    462                  << "(id " << xfer->pditem->ulItemID << ")");
     462                 << "( id " << xfer->pditem->ulItemID << ")");
    463463
    464464        QByteArray drm, drf;
     
    513513
    514514        DEBUG(() << "DefaultDragWorker: Got DO_RENDER for item " << req->index
    515                  << "(id " << req->xfer->pditem->ulItemID << ")"
     515                 << "( id " << req->xfer->pditem->ulItemID << ")"
    516516                 << "provider"<< req->provider << "drm" << req->drm.data()
    517517                 << "drf" << req->drf.data());
Note: See TracChangeset for help on using the changeset viewer.