Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-30534

canDropMimeData() not called

    XMLWordPrintable

Details

    • b13aa15e1007a1b5ed61049bbd9ef8f95b6d12a5

    Description

      A virtual function canDropMimeData() never get called, because there is no code that calls it.

      Full search over Qt sources gives only three entries for 'canDropMimeData'.
      Two of them are function definition and declaration in qabstractitemview.h/.cpp files.
      The third is a part of a comment.

      Some more code:

      1. Drag enter event handler. Qt decides to allow or to forbid a drop operation via canDecode() function result.

      void QAbstractItemView::dragEnterEvent(QDragEnterEvent *event)
      {
          if (dragDropMode() == InternalMove
              && (event->source() != this|| !(event->possibleActions() & Qt::MoveAction)))
              return;
      
          if (d_func()->canDecode(event)) {
              event->accept();
              setState(DraggingState);
          } else {
              event->ignore();
          }
      }
      

      2. canDecode() source code. No canDropMimeData() call here.

          inline bool canDecode(QDropEvent *e) const {
              QStringList modelTypes = model->mimeTypes();
              const QMimeData *mime = e->mimeData();
              for (int i = 0; i < modelTypes.count(); ++i)
                  if (mime->hasFormat(modelTypes.at(i))
                      && (e->dropAction() & model->supportedDropActions()))
                      return true;
              return false;
          }
      

      As a result, there is no way to customize drop/non-drop logic on per-node basis.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            dfaure_kdab David Faure
            lostman Lost Guadelenn
            Votes:
            8 Vote for this issue
            Watchers:
            16 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes