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

QListView in IconMode does not call dropMimeData, when draggin item from itself.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.6.2
    • 4.6.0
    • Widgets: Itemviews
    • None
    • c6f1e91c114eaf331fd40c909553b173136ffe99

    Description

      Steps to reproduce.
      1. Create model with d'n'd support, and 3 rows.
      2. Create QListView in IconMode.
      3. Drag last item to the first place, drop it, last item will be deleted, but not inserted, dropMimeData is not called.

      This is because QIconModeViewBase::filterDropEvent(QDropEvent *e) returns false, only if draggin from another widget.

      QListView.cpp
      bool QIconModeViewBase::filterDropEvent(QDropEvent *e)
      {
          if (e->source() != qq)
              return false;
      
          const QSize contents = contentsSize;
          QPoint offset(horizontalOffset(), verticalOffset());
          QPoint end = e->pos() + offset;
          QPoint start = dd->pressedPosition;
          QPoint delta = (dd->movement == QListView::Snap ? snapToGrid(end) - snapToGrid(start) : end - start);
          QList<QModelIndex> indexes = dd->selectionModel->selectedIndexes();
          for (int i = 0; i < indexes.count(); ++i) {
              QModelIndex index = indexes.at(i);
              QRect rect = dd->rectForIndex(index);
              viewport()->update(dd->mapToViewport(rect, false));
              QPoint dest = rect.topLeft() + delta;
              if (qq->isRightToLeft())
                  dest.setX(dd->flipX(dest.x()) - rect.width());
              moveItem(index.row(), dest);
              qq->update(index);
          }
          dd->stopAutoScroll();
          draggedItems.clear();
          dd->emitIndexesMoved(indexes);
          e->accept(); // we have handled the event
          // if the size has not grown, we need to check if it has shrinked
          if (contentsSize != contents) {
              if ((contentsSize.width() <= contents.width()
                  || contentsSize.height() <= contents.height())) {
                      updateContentsSize();
              }
              dd->viewUpdateGeometries();
          }
          return true;
      }
      

      Attachments

        1. example1.7z
          0.6 kB
        2. example2.7z
          0.6 kB
        3. example3.7z
          1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            dedietri Gabriel de Dietrich (drgvond)
            pete Petr Krasnoshchekov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes