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

QFileSystemModel folders Drag'n'Drop

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 5.0.2
    • GUI: Drag and Drop
    • None
    • All

    Description

      QFileSystemModel::dropMimeData(...) has no support for folders. Drag'n'Drop works for files only.

      Code snippet:

      bool QFileSystemModel::dropMimeData(const QMimeData *data, Qt::DropAction action,
                                   int row, int column, const QModelIndex &parent)
      {
          Q_UNUSED(row);
          Q_UNUSED(column);
          if (!parent.isValid() || isReadOnly())
              return false;
          bool success = true;
          QString to = filePath(parent) + QDir::separator();
          QList<QUrl> urls = data->urls();
          QList<QUrl>::const_iterator it = urls.constBegin();
          switch (action) {
          case Qt::CopyAction:
              for (; it != urls.constEnd(); ++it) {
                  QString path = (*it).toLocalFile();
                  success = QFile::copy(path, to + QFileInfo(path).fileName()) && success;
              }
              break;
          case Qt::LinkAction:
              for (; it != urls.constEnd(); ++it) {
                  QString path = (*it).toLocalFile();
                  success = QFile::link(path, to + QFileInfo(path).fileName()) && success;
              }
              break;
          case Qt::MoveAction:
              for (; it != urls.constEnd(); ++it) {
                  QString path = (*it).toLocalFile();
                  success = QFile::copy(path, to + QFileInfo(path).fileName())
                            && QFile::remove(path) && success;
              }
              break;
          default:
              return false;
          }
          return success;
      }

      The suggestion is to add such functionality to API

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            damkrat Anton
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes