From 9e9b3ed25e08b0803646ea73efa7d67078deb6b5 Mon Sep 17 00:00:00 2001 From: lordmulder Date: Mon, 5 Sep 2011 15:36:58 +0200 Subject: [PATCH] When a folder that does NOT contain any files is dropped, descent into its sub-folders (if any). --- src/Config.h | 2 +- src/Dialog_MainWindow.cpp | 29 +++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Config.h b/src/Config.h index 794d708f..81e6a610 100644 --- a/src/Config.h +++ b/src/Config.h @@ -30,7 +30,7 @@ #define VER_LAMEXP_MINOR_LO 3 #define VER_LAMEXP_TYPE Beta #define VER_LAMEXP_PATCH 1 -#define VER_LAMEXP_BUILD 680 +#define VER_LAMEXP_BUILD 681 /////////////////////////////////////////////////////////////////////////////// // Tools versions diff --git a/src/Dialog_MainWindow.cpp b/src/Dialog_MainWindow.cpp index 5eb29915..d492d184 100644 --- a/src/Dialog_MainWindow.cpp +++ b/src/Dialog_MainWindow.cpp @@ -534,7 +534,7 @@ void MainWindow::addFolder(const QString &path, bool recursive, bool delayed) } QDir currentDir(folderInfoList.takeFirst().canonicalFilePath()); - QFileInfoList fileInfoList = currentDir.entryInfoList(QDir::Files); + QFileInfoList fileInfoList = currentDir.entryInfoList(QDir::Files | QDir::NoSymLinks); while(!fileInfoList.isEmpty()) { @@ -732,11 +732,12 @@ void MainWindow::dropEvent(QDropEvent *event) ABORT_IF_BUSY; QStringList droppedFiles; - const QList urls = event->mimeData()->urls(); + QList urls = event->mimeData()->urls(); - for(int i = 0; i < urls.count(); i++) + while(!urls.isEmpty()) { - QFileInfo file(urls.at(i).toLocalFile()); + QUrl currentUrl = urls.takeFirst(); + QFileInfo file(currentUrl.toLocalFile()); if(!file.exists()) { continue; @@ -747,13 +748,25 @@ void MainWindow::dropEvent(QDropEvent *event) droppedFiles << file.canonicalFilePath(); continue; } - else if(file.isDir()) + if(file.isDir()) { qDebug64("Dropped Folder: %1", file.canonicalFilePath()); - QList list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Files); - for(int j = 0; j < list.count(); j++) + QList list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Files | QDir::NoSymLinks); + if(list.count() > 0) { - droppedFiles << list.at(j).canonicalFilePath(); + for(int j = 0; j < list.count(); j++) + { + droppedFiles << list.at(j).canonicalFilePath(); + } + } + else + { + list = QDir(file.canonicalFilePath()).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks); + for(int j = 0; j < list.count(); j++) + { + qDebug64("Descending to Folder: %1", list.at(j).canonicalFilePath()); + urls.prepend(QUrl::fromLocalFile(list.at(j).canonicalFilePath())); + } } } }