OSDN Git Service

use foreach() for iteration in QFileSystemModel::dropMimeData()
authorIvailo Monev <xakepa10@gmail.com>
Thu, 24 Dec 2020 01:07:47 +0000 (01:07 +0000)
committerIvailo Monev <xakepa10@gmail.com>
Thu, 24 Dec 2020 01:07:47 +0000 (01:07 +0000)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/gui/dialogs/qfilesystemmodel.cpp

index 8f37290..96a301e 100644 (file)
@@ -1101,25 +1101,22 @@ bool QFileSystemModel::dropMimeData(const QMimeData *data, Qt::DropAction action
     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();
+        foreach (const QUrl &it, data->urls()) {
+            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();
+        foreach (const QUrl &it, data->urls()) {
+            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();
+        foreach (const QUrl &it, data->urls()) {
+            QString path = it.toLocalFile();
             success = QFile::rename(path, to + QFileInfo(path).fileName()) && success;
         }
         break;