Ticket #292: dnd_ignoreaction.diff

File dnd_ignoreaction.diff, 3.6 KB (added by KO Myung-Hun, 10 years ago)

Patch for Qt::IgnoreAction?

  • src/gui/kernel/qdnd_pm.cpp

     
    110110    friend class QDragManager;
    111111
    112112    void initWorkers();
     113    bool allowedOp(USHORT realOp);
    113114
    114115    bool initialized : 1;
    115116    bool fakeDrop : 1;
     
    123124    USHORT lastDragOverOp; // last DM_DRAGOVER operation
    124125
    125126    USHORT supportedOps; // operations supported by all items
    126     bool sourceAllowsOp : 1; // does source allow requested operation
    127127
    128128    USHORT lastDropReply; // last reply to DM_DRAGOVER
    129129
     
    135135    : initialized(false), fakeDrop(false)
    136136    , gotWorkers(false), canSyncRndr(false), di(NULL)
    137137    , lastDragOverWidget(0), lastDragOverOp(0)
    138     , supportedOps(0), sourceAllowsOp(false)
     138    , supportedOps(0) 
    139139    , lastDropReply(DOR_NEVERDROP)
    140140    , lastAction(Qt::CopyAction)
    141141{
     
    246246    }
    247247}
    248248
     249// does source allow requested operation
     250bool QPMDragData::allowedOp(USHORT realOp)
     251{
     252    return ((supportedOps & DO_MOVEABLE) && realOp == DO_MOVE) ||
     253           ((supportedOps & DO_COPYABLE) && realOp == DO_COPY) ||
     254           ((supportedOps & DO_LINKABLE) && realOp == DO_LINK);
     255}
     256
    249257void QPMDragData::reset(bool isAccepted)
    250258{
    251259    if (!initialized)
     
    505513                dragData->lastDragOverWidget = dragOverWidget;
    506514                dragData->lastDragOverOp = 0;
    507515                dragData->supportedOps = DO_COPYABLE | DO_MOVEABLE | DO_LINKABLE;
    508                 dragData->sourceAllowsOp = false;
    509516                dragData->lastDropReply = DOR_NEVERDROP;
    510517                dragData->lastAction =
    511518                    manager->defaultAction(toQDragDropActions(dragData->supportedOps),
     
    547554
    548555            if (dropReply != DOR_NEVERDROP) {
    549556
     557#if 0
    550558                if (first || dragData->lastDragOverOp != info->usOperation) {
    551559                    // the current drop operation was changed by a modifier key
    552560                    USHORT realOp = info->usOperation;
     
    571579                // events anyway (stealing them from Qt would be confusing), but
    572580                // we will silently ignore any accept commands and always reject
    573581                // the drop. Other platforms seem to do the same.
    574 
     582#endif
    575583                QMimeData *data = manager->source() ? manager->dragPrivate()->data : manager->dropData;
    576584
    577585                if (first) {
     
    583591                    sendDropEvent(dragOverWidget, &dee);
    584592                    // if not allowed or not accepted, always reply DOR_NODROP
    585593                    // to have DM_DRAGOVER delivered to us again for a new test
    586                     if (dragData->sourceAllowsOp && dee.isAccepted()) {
     594                    if (dragData->allowedOp(toPmDragDropOp(dee.dropAction())) && dee.isAccepted()) {
    587595                        dropReply = DOR_DROP;
    588596                        dragData->lastAction = dee.dropAction();
    589597                        dragData->lastAnswerRect = dee.answerRect();
     
    605613                    if (dropReply == DOR_DROP)
    606614                        dme.accept();
    607615                    sendDropEvent(dragOverWidget, &dme);
    608                     if (dragData->sourceAllowsOp && dme.isAccepted()) {
     616                    if (dragData->allowedOp(toPmDragDropOp(dme.dropAction())) && dme.isAccepted()) {
    609617                        dropReply = DOR_DROP;
    610618                        dragData->lastAction = dme.dropAction();
    611619                        dragData->lastAnswerRect = dme.answerRect();