title: QFileSystemModel drop items issue
body: <p>I have reimplemented <code>QFileSystemModel</code> class to add the drag and drop feature between <code>QTreeView</code> and <code>QListView</code> but it still does not work. It displays the following dialog:</p>
  <p><a href="https://i.stack.imgur.com/rA158.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rA158.gif" alt="https://ddgobkiprc33d.cloudfront.net/8f3a20b4-83fe-46bc-be2b-7454bea9b269.gif" /></a></p>
  <p><strong>ExplorerModel.h</strong></p>
  <pre><code>#ifndef EXPLORERMODEL_H
  #define EXPLORERMODEL_H
  
  #include &lt;QObject&gt;
  #include &lt;QFileSystemModel&gt;
  #include &lt;QMimeData&gt;
  #include &lt;QBrush&gt;
  #include &lt;QDebug&gt;
  
  class ExplorerModel : public QFileSystemModel
  {
      Q_OBJECT
  public:
      using QFileSystemModel::QFileSystemModel;
      Qt::DropActions supportedDragActions() const;
      Qt::DropActions supportedDropActions() const;
      QStringList mimeTypes() const;
      Qt::ItemFlags flags(const QModelIndex &amp;index) const;
      QMimeData *mimeData(const QModelIndexList &amp;indexes) const;
      bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &amp;parent);
  
  private:
      bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &amp;parent);
  };
  
  #endif // EXPLORERMODEL_H
  </code></pre>
  <p><strong>ExplorerModel.cpp:</strong></p>
  <pre><code>#include &quot;explorermodel.h&quot;
  
  Qt::DropActions ExplorerModel::supportedDragActions() const
  {
     return Qt::CopyAction | Qt::MoveAction;
  }
  
  Qt::DropActions ExplorerModel::supportedDropActions() const
  {
      return Qt::CopyAction | Qt::MoveAction;
  }
  
  Qt::ItemFlags ExplorerModel::flags(const QModelIndex &amp;index) const
  {
      Qt::ItemFlags defaultFlags = QFileSystemModel::flags(index);
  
      if (index.isValid()) {
          return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags;
      } else {
          return Qt::ItemIsDropEnabled | defaultFlags;
      }
  }
  
  QStringList ExplorerModel::mimeTypes() const
  {
      QStringList types;
      types &lt;&lt; &quot;application/octet-stream&quot;;
      return types;
  }
  
  QMimeData *ExplorerModel::mimeData(const QModelIndexList &amp;indexes) const
  {
      QMimeData *mimeData = new QMimeData;
      QByteArray encodedData;
      QDataStream stream(&amp;encodedData, QIODevice::WriteOnly);
  
      if (indexes.first().isValid()) {
          QString fileName = data(indexes.first(), Qt::DisplayRole).toString();
          qDebug() &lt;&lt; fileName;
          stream &lt;&lt; fileName;
      }
  
      mimeData-&gt;setData(&quot;application/octet-stream&quot;, encodedData);
      return mimeData;
  }
  
  bool ExplorerModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &amp;parent)
  {
      Q_UNUSED(action);
      Q_UNUSED(row);
      Q_UNUSED(parent);
  
      if (!data-&gt;hasFormat(&quot;application/octet-stream&quot;)) {
          return false;
      }
  
      if (column &gt; 0) {
          return false;
      }
  
      return true;
  }
  
  bool ExplorerModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &amp;parent)
  {
      if (!canDropMimeData(data, action, row, column, parent)) {
          return false;
      }
  
      if (action == Qt::IgnoreAction) {
          return true;
      }
  
      int beginRow;
  
      if (row != -1) {
          beginRow = row;
      } else if (parent.isValid()) {
          beginRow = parent.row();
      } else {
          beginRow = rowCount(QModelIndex());
      }
  
      QByteArray encodedData = data-&gt;data(&quot;application/octet-stream&quot;);
      QDataStream stream(&amp;encodedData, QIODevice::ReadOnly);
      QString fileName;
  
      while (!stream.atEnd()) {
          stream &gt;&gt; fileName;
      }
  
      //removeRow(row, parent);
      insertRow(beginRow, parent);
      QModelIndex idx = index(beginRow, 0, QModelIndex());
      qDebug() &lt;&lt; &quot;Filename: &quot; &lt;&lt; fileName;
      setData(idx, fileName, Qt::UserRole);
      return true;
  }
  </code></pre>
  <p>It does not copy or move items. Any ideas how to fix it? Thanks in advance.</p>